aboutsummaryrefslogtreecommitdiffstats
path: root/templates/web/base/common_scripts.html
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-11-15 17:35:29 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-11-15 17:35:29 +0000
commitdb75de1ca7268692215dc79f157d61ab7d66fa8e (patch)
treecb2095aa1f8466919b25674c35f7b8d1bbbabcde /templates/web/base/common_scripts.html
parent52ab72ad43b391b0f3b6f7385b5ba723cc1a4aba (diff)
parentf59e12ee3fa9c65f178a300954586f6ac91bba79 (diff)
Merge branch '1901-js-deferring'
Updated geolocation.js with concurrent changes.
Diffstat (limited to 'templates/web/base/common_scripts.html')
-rw-r--r--templates/web/base/common_scripts.html77
1 files changed, 60 insertions, 17 deletions
diff --git a/templates/web/base/common_scripts.html b/templates/web/base/common_scripts.html
index 057ecfd67..c6225e8fa 100644
--- a/templates/web/base/common_scripts.html
+++ b/templates/web/base/common_scripts.html
@@ -7,28 +7,75 @@ scripts = [];
scripts.push(
start _ "/js/translation_strings." _ lang_code _ ".js?" _ Math.int( date.now / 3600 ),
- version('/jslib/jquery-1.7.2.min.js'),
- version('/js/validation_rules.js'),
- version('/vendor/jquery.validate.min.js'),
- version('/vendor/dropzone.min.js'),
- version('/js/jquery.multi-select.js'),
- version('/cobrands/fixmystreet/fixmystreet.js'),
);
-IF c.user_exists AND (c.user.from_body OR c.user.is_superuser);
+SET jquery_loaded = 0;
+SET geolocation_loaded = 0;
+IF bodyclass.match('frontpage');
+ SET geolocation_loaded = 1;
scripts.push(
- version('/cobrands/fixmystreet/staff.js')
+ version('/js/front.js'),
+ version('/js/geolocation.js'),
+ );
+ELSIF bodyclass.match('alertpage');
+ SET geolocation_loaded = 1;
+ scripts.push(
+ version('/js/geolocation.js'),
+ );
+ELSE;
+ SET jquery_loaded = 1;
+ scripts.push(
+ version('/js/validation_rules.js'),
+ version('/jslib/jquery-1.7.2.min.js'),
+ version('/js/jquery.multi-select.js'),
+ version('/vendor/jquery.validate.min.js'),
+ version('/cobrands/fixmystreet/fixmystreet.js'),
);
END;
-FOR script IN map_js;
+FOR script IN extra_js;
scripts.push(script);
END;
-scripts.push(
- version('/cobrands/fixmystreet/map.js'),
- version('/cobrands/fixmystreet/offline.js'),
-);
+IF c.user_exists AND (c.user.from_body OR c.user.is_superuser);
+ IF NOT geolocation_loaded;
+ scripts.push(
+ version('/js/geolocation.js'),
+ );
+ END;
+ IF NOT jquery_loaded;
+ scripts.push(
+ version('/jslib/jquery-1.7.2.min.js'),
+ );
+ END;
+ scripts.push(
+ version('/cobrands/fixmystreet/staff.js')
+ );
+ IF c.user.has_body_permission_to('planned_reports');
+ scripts.push(
+ version('/cobrands/fixmystreet/offline.js'),
+ );
+ END;
+END;
+
+IF bodyclass.match('mappage');
+ FOR script IN map_js;
+ IF script.match('^/');
+ scripts.push(version(script));
+ ELSE;
+ scripts.push(script);
+ END;
+ END;
+ scripts.push(
+ version('/cobrands/fixmystreet/map.js'),
+ version('/vendor/dropzone.min.js'),
+ version('/vendor/fancybox/jquery.fancybox-1.3.4.pack.js'),
+ );
+ELSE;
+ scripts.push(
+ version('/cobrands/fixmystreet/prefetch-polyfill.js'),
+ );
+END;
IF admin;
scripts.push(
@@ -37,10 +84,6 @@ IF admin;
);
END;
-FOR script IN extra_js;
- scripts.push(script);
-END;
-
TRY;
PROCESS 'footer_extra_js.html';
CATCH file;