Be modular when loading the various JS modules
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 15 Feb 2009 20:27:09 +0000
changeset 1358 6be502a1bcc6
parent 1357 3dd1507aa723
child 1359 582661519e5d
Be modular when loading the various JS modules Patch by: Sverre Rabbelier
app/soc/templates/soc/base.html
app/soc/templates/soc/models/admin.html
app/soc/templates/soc/models/edit.html
app/soc/templates/soc/org_app/review_overview.html
app/soc/templates/soc/presence/home.html
app/soc/templates/soc/request/create.html
app/soc/templates/soc/role/edit.html
app/soc/templates/soc/timeline/edit.html
--- a/app/soc/templates/soc/base.html	Sun Feb 15 20:26:15 2009 +0000
+++ b/app/soc/templates/soc/base.html	Sun Feb 15 20:27:09 2009 +0000
@@ -17,8 +17,15 @@
   <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
 	{% block stylesheet %}
   <link rel="stylesheet" href="/soc/content/css/soc-090120.css" type="text/css"/>
+  {% if uses_jq_autocomplete %}
   <link rel="stylesheet" href="/soc/content/css/jquery-autocomplete.css" type="text/css"/>
+  {% endif %}
+  {% if uses_jq_thickbox %}
   <link rel="stylesheet" href="/soc/content/css/jquery-thickbox.css" type="text/css"/>
+  {% endif %}
+  {% if uses_jq_datetimepicker %}
+  <link rel="stylesheet" type="text/css" media="screen" href="/soc/content/css/ui.datetimepicker.css">
+  {% endif %}
 	{% endblock %}
   <title>
     {% block page_title %}
@@ -29,16 +36,51 @@
       {% endif %}
     {% endblock %}
   </title>
-	<script src="/jquery/jquery-1.2.6.js"></script>
-	<script src="/jquery/jquery-bt-0.7.js"></script>
-	<script src="/soc/content/js/menu-081108.js"></script>
-	<script src="/soc/content/js/tips-081027.js"></script>
-	<script type='text/javascript' src='/jquery/jquery-bgiframe.js'></script>
-	<script type='text/javascript' src='/jquery/jquery-ajaxQueue.js'></script>
-	<script type='text/javascript' src='/jquery/jquery-autocomplete.js'></script>
-	<script type='text/javascript' src='/jquery/jquery-thickbox.js'></script>
-	{% block scripts %}{% endblock %}
+
+{% block scripts %}
+  {% if uses_jq %}
+  <script type='text/javascript' src="/jquery/jquery-1.2.6.js"></script>
+  {% endif %}
+  {% if uses_jq_bt %}
+  <script type='text/javascript' src="/jquery/jquery-bt-0.7.js"></script>
+  {% endif %}
+  {% if uses_menu %}
+  <script type='text/javascript' src="/soc/content/js/menu-081108.js"></script>
+  {% endif %}
+  {% if uses_jq_bt %}
+  <script type='text/javascript' src="/soc/content/js/tips-081027.js"></script>
+  {% endif %}
+  {% if uses_jq_bgiframe %}
+  <script type='text/javascript' src='/jquery/jquery-bgiframe.js'></script>
+  {% endif %}
+  {% if uses_jq_ajaqQueue %}
+  <script type='text/javascript' src='/jquery/jquery-ajaxQueue.js'></script>
+  {% endif %}
+  {% if uses_jq_autocomplete %}
+  <script type='text/javascript' src='/jquery/jquery-autocomplete.js'></script>
+  {% endif %}
+  {% if uses_jq_thickbox %}
+  <script type='text/javascript' src='/jquery/jquery-thickbox.js'></script>
+  {% endif %}
+  {% if uses_tinymce %}
+  <script type="text/javascript" src="/tiny_mce/tiny_mce_src.js"></script>
+  {% endif %}
+  {% if uses_jq_progressbar %}
+  <script type="text/javascript" src="/jquery/jquery-progressbar.js"></script>
+  {% endif %}
+  {% if uses_orgaccept %}
+  <script type="text/javascript" src="/soc/content/js/org-accept.js"></script>
+  {% endif %}
+  {% if uses_jq_ui_core %}
+  <script type="text/javascript" src="/jquery/jquery-ui.core.js"></script>
+  {% endif %}
+  {% if uses_jq_datetimepicker %}
+  <script type="text/javascript" src="/jquery/jquery-ui.datetimepicker.js"></script>
+  <script type="text/javascript" src="/soc/content/js/datetime-loader.js"></script>
+  {% endif %}
  </head>
+{% endblock %}
+
 {% block body_tag %}
  <body>
 {% endblock %}
--- a/app/soc/templates/soc/models/admin.html	Sun Feb 15 20:26:15 2009 +0000
+++ b/app/soc/templates/soc/models/admin.html	Sun Feb 15 20:27:09 2009 +0000
@@ -14,8 +14,6 @@
 {% endcomment %}
 {% load forms_helpers %}
 
-{% block scripts %}{% endblock %}
-
 {% block body %}
 <p>
 <table>
--- a/app/soc/templates/soc/models/edit.html	Sun Feb 15 20:26:15 2009 +0000
+++ b/app/soc/templates/soc/models/edit.html	Sun Feb 15 20:27:09 2009 +0000
@@ -14,9 +14,6 @@
 {% endcomment %}
 {% load forms_helpers %}
 
-{% block scripts %}
-	<script type="text/javascript" src="/tiny_mce/tiny_mce_src.js"></script>
-{% endblock %}
 {% block header_title %}
 {{ page_name }}
  {% if entity %}
--- a/app/soc/templates/soc/org_app/review_overview.html	Sun Feb 15 20:26:15 2009 +0000
+++ b/app/soc/templates/soc/org_app/review_overview.html	Sun Feb 15 20:27:09 2009 +0000
@@ -12,56 +12,9 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 {% endcomment %}
-{% block scripts %}
-<script type="text/javascript" src="/jquery/jquery-progressbar.js"></script>
-<script type="text/javascript">
-	$(document).ready(function() {
-		$("#applications_progress_bar").progressBar({showText: false});
-	});
 
-	function acceptOrgInit() {
-		$("#acceptance_text").fadeOut("slow",
-			function() {
-				$("#applications_progress_bar").fadeIn("slow");
-			}
-		);
-		$.getJSON("{{ bulk_accept_link|safe }}",
-			function(data){
-				setTimeout(function(){acceptOrg(data)}, 0);
-			}
-		);
-	}
-
-	function acceptOrg(accepted_applications) {
-		var application_index = 0, max_applications=accepted_applications.applications.length;
-		for (application_index; application_index<max_applications; application_index++) {
-			// regular expression to find a valid scope path inside matching parenthesis
-			var re = /\((\w*)\)/;
-			var scope_path = accepted_applications.link.match(re)[1];
-			// the URL is obtained by using the scope path found in the matching parenthesis
-			var url_to_call = accepted_applications.link.replace(re,eval("accepted_applications.applications[application_index]."+scope_path));
-			// now we can call the URL found
-			$.ajax({
-				async: false,
-				url: url_to_call,
-				timeout: 10000,
-				complete: function(data) {
-					if (data) {
-						// update progress bar percentage and description
-						var percentage = Math.floor(100 * (application_index+1) / (accepted_applications.nr_applications));
-						$("#description_progressbar").html(" Processed application "+accepted_applications.applications[application_index].name+" ("+(application_index+1)+"/"+accepted_applications.nr_applications+")");
-						$("#applications_progress_bar").progressBar(percentage);
-					}
-				}
-			});
-		}
-		// tell the user we are done
-		$("#description_done").html(" <strong>Done!</strong>");
-
-	}
-</script>
-{% endblock %}
 {% block body %}
 <span id="acceptance_text">If you want to accept all pre-accepted organizations please <button id="button_accept" onclick="javascript:acceptOrgInit();">click here</button></span><span class="progressBar" style="display:none;" id="applications_progress_bar"></span><span id="description_progressbar"></span><span id="description_done"></span>
 {{ block.super}}
+
 {% endblock %}
--- a/app/soc/templates/soc/presence/home.html	Sun Feb 15 20:26:15 2009 +0000
+++ b/app/soc/templates/soc/presence/home.html	Sun Feb 15 20:27:09 2009 +0000
@@ -14,20 +14,11 @@
 {% endcomment %}
 
 {% block scripts %}
+{{ block.super }}
 {% if entity.feed_url %}
-    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
-    <script type="text/javascript" src="/soc/content/js/blog-081117.js"></script>
-    <script type="text/javascript">
-
-    google.load("feeds", "1");
-
-    function initialize() {
-      var blog = new BlogPreview(document.getElementById("blog"));
-      blog.show("{{ entity.feed_url }}", 3);
-    }
-    google.setOnLoadCallback(initialize);
-
-    </script>
+  <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+  <script type="text/javascript" src="/soc/content/js/blog-081117.js"></script>
+  <script type="text/javascript" src="/soc/content/js/feed-loader.js"></script>
 {% endif %}
 {% endblock %}
 
--- a/app/soc/templates/soc/request/create.html	Sun Feb 15 20:26:15 2009 +0000
+++ b/app/soc/templates/soc/request/create.html	Sun Feb 15 20:27:09 2009 +0000
@@ -14,9 +14,6 @@
 {% endcomment %}
 {% load forms_helpers %}
 
-{% block scripts %}
-	<script type="text/javascript" src="/tiny_mce/tiny_mce_src.js"></script>
-{% endblock %}
 {% block header_title %}
 {{ page_name }}
 {% endblock %}
--- a/app/soc/templates/soc/role/edit.html	Sun Feb 15 20:26:15 2009 +0000
+++ b/app/soc/templates/soc/role/edit.html	Sun Feb 15 20:27:09 2009 +0000
@@ -15,7 +15,7 @@
 {% load forms_helpers %}
 
 {% block scripts %}
-	<script type="text/javascript" src="/tiny_mce/tiny_mce_src.js"></script>
+{{ block.super }}
 {% if gmaps_api_key %}
 	<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={{ gmaps_api_key }}" type="text/javascript"></script>
 	<script type="text/javascript" src="/soc/content/js/map-090201.js"></script>
--- a/app/soc/templates/soc/timeline/edit.html	Sun Feb 15 20:26:15 2009 +0000
+++ b/app/soc/templates/soc/timeline/edit.html	Sun Feb 15 20:27:09 2009 +0000
@@ -12,17 +12,7 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 {% endcomment %}
-{% block scripts %}
-<script type="text/javascript" src="/jquery/jquery-ui.core.js"></script>
-<script type="text/javascript" src="/jquery/jquery-ui.datetimepicker.js"></script>
-<link rel="stylesheet" type="text/css" media="screen" href="/soc/content/css/ui.datetimepicker.css">
-<script type="text/javascript" charset="utf-8">
-    $(function()
-    {
-		$('.datetime-pick').datetimepicker();
-    });
-</script>
-{% endblock %}
+
 {% block instructions %}
 {{ block.super }} Note that all times are in UTC.
 {% endblock %}