aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-12-13 13:34:49 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-12-13 13:34:49 +0000
commitc6dd57095435257b1a37e424c4170d37a1c82a37 (patch)
tree77adf034ba64559317f9617801a11fe94eef562c
parente4d48666edffceea3dcab032221d6211090803ca (diff)
parentec8ad12f3b1103b22cc2e7694387daa7294f1ed7 (diff)
Merge branch 'jquery-needed-some-places-it-is-not'
-rw-r--r--perllib/FixMyStreet/Map/Bristol.pm2
-rw-r--r--t/map/tests.t2
-rw-r--r--templates/web/base/common_footer_tags.html9
-rw-r--r--templates/web/base/common_scripts.html17
-rw-r--r--templates/web/bristol/footer_extra_js.html2
-rw-r--r--templates/web/bromley/footer_extra_js.html1
-rw-r--r--templates/web/zurich/footer.html3
-rw-r--r--templates/web/zurich/footer_extra_js.html6
-rw-r--r--web/cobrands/borsetshire/js.js4
-rw-r--r--web/cobrands/fixmystreet-uk-councils/js.js2
-rw-r--r--web/cobrands/oxfordshire/js.js8
11 files changed, 27 insertions, 29 deletions
diff --git a/perllib/FixMyStreet/Map/Bristol.pm b/perllib/FixMyStreet/Map/Bristol.pm
index a75bb5eb9..5d05fbd34 100644
--- a/perllib/FixMyStreet/Map/Bristol.pm
+++ b/perllib/FixMyStreet/Map/Bristol.pm
@@ -63,6 +63,8 @@ sub map_javascript { [
'/js/map-OpenLayers.js',
'/js/map-wmts-base.js',
'/js/map-wmts-bristol.js',
+ '/cobrands/fixmystreet/assets.js',
+ '/cobrands/bristol/js.js',
] }
# Reproject a WGS84 lat/lon into BNG easting/northing
diff --git a/t/map/tests.t b/t/map/tests.t
index f34ccfa6d..1123133e4 100644
--- a/t/map/tests.t
+++ b/t/map/tests.t
@@ -4,7 +4,7 @@ use Test::More;
my $requires = {
'Angus' => 'angus/js.js',
'Bing' => 'map-bing-ol.js',
- 'Bristol' => 'map-wmts-bristol.js',
+ 'Bristol' => 'bristol/js.js',
'Bromley' => 'bromley/map.js',
'FMS' => 'map-fms.js',
'Google' => 'map-google.js',
diff --git a/templates/web/base/common_footer_tags.html b/templates/web/base/common_footer_tags.html
index 915751802..a5be06df5 100644
--- a/templates/web/base/common_footer_tags.html
+++ b/templates/web/base/common_footer_tags.html
@@ -5,8 +5,13 @@
<!--[if lte IE 9]>
<script src="[% version('/vendor/history.polyfill.min.js') %]"></script>
<![endif]-->
-[% FOR script IN scripts ~%]
- [% script = script.0 ? script : [ script ] ~%]
+[%
+scripts_seen = {};
+FOR script IN scripts;
+ script = script.0 ? script : [ script ];
+ NEXT IF scripts_seen.${script.0};
+ scripts_seen.${script.0} = 1;
+ ~%]
<script src="[% script.0 %]"
[%~ FOR attr IN script.1 %] [% attr.key %]="[% attr.value %]"[% END ~%]
></script>
diff --git a/templates/web/base/common_scripts.html b/templates/web/base/common_scripts.html
index 4c8fcfe74..86e826b18 100644
--- a/templates/web/base/common_scripts.html
+++ b/templates/web/base/common_scripts.html
@@ -9,21 +9,16 @@ scripts.push(
start _ "/js/translation_strings." _ lang_code _ ".js?" _ Math.int( date.now / 3600 ),
);
-SET jquery_loaded = 0;
-SET geolocation_loaded = 0;
IF bodyclass.match('frontpage');
- SET geolocation_loaded = 1;
scripts.push(
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'),
@@ -38,17 +33,9 @@ FOR script IN extra_js;
END;
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('/js/geolocation.js'),
+ version('/jslib/jquery-1.7.2.min.js'),
version('/cobrands/fixmystreet/staff.js')
);
IF c.user.has_body_permission_to('planned_reports');
diff --git a/templates/web/bristol/footer_extra_js.html b/templates/web/bristol/footer_extra_js.html
index 2f54083a0..218607498 100644
--- a/templates/web/bristol/footer_extra_js.html
+++ b/templates/web/bristol/footer_extra_js.html
@@ -1,6 +1,4 @@
[% scripts.push(
version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js')
version('/cobrands/fixmystreet-uk-councils/js.js'),
- version('/cobrands/fixmystreet/assets.js'),
- version('/cobrands/bristol/js.js'),
) %]
diff --git a/templates/web/bromley/footer_extra_js.html b/templates/web/bromley/footer_extra_js.html
index ac03496a8..0b69cf5ad 100644
--- a/templates/web/bromley/footer_extra_js.html
+++ b/templates/web/bromley/footer_extra_js.html
@@ -1,3 +1,4 @@
[% scripts.push(
+ version('/jslib/jquery-1.7.2.min.js'),
version('/cobrands/bromley/a-z-nav.js'),
) %]
diff --git a/templates/web/zurich/footer.html b/templates/web/zurich/footer.html
index 0164dbcab..f68f80aea 100644
--- a/templates/web/zurich/footer.html
+++ b/templates/web/zurich/footer.html
@@ -34,10 +34,7 @@
</div>
</div>
- <script src="[% version('/cobrands/zurich/validation_rules.js') %]"></script>
[% INCLUDE 'common_footer_tags.html' %]
- <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" charset="utf-8"></script>
- <script src="[% version('/cobrands/zurich/js.js') %]"></script>
</body>
</html>
diff --git a/templates/web/zurich/footer_extra_js.html b/templates/web/zurich/footer_extra_js.html
new file mode 100644
index 000000000..a98457363
--- /dev/null
+++ b/templates/web/zurich/footer_extra_js.html
@@ -0,0 +1,6 @@
+[% scripts.push(
+ version('/jslib/jquery-1.7.2.min.js'),
+ version('/cobrands/zurich/validation_rules.js'),
+ '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js',
+ version('/cobrands/zurich/js.js'),
+) %]
diff --git a/web/cobrands/borsetshire/js.js b/web/cobrands/borsetshire/js.js
index 6799ff5e3..2888a9548 100644
--- a/web/cobrands/borsetshire/js.js
+++ b/web/cobrands/borsetshire/js.js
@@ -1,5 +1,9 @@
(function(){
+ if (typeof jQuery === 'undefined') {
+ return;
+ }
+
function set_redirect(form) {
var e = form.username.value;
if (e == 'inspector@example.org') {
diff --git a/web/cobrands/fixmystreet-uk-councils/js.js b/web/cobrands/fixmystreet-uk-councils/js.js
index 7c4f7a9ed..5c550f56f 100644
--- a/web/cobrands/fixmystreet-uk-councils/js.js
+++ b/web/cobrands/fixmystreet-uk-councils/js.js
@@ -1,5 +1,5 @@
(function(){
- if (!jQuery.validator) {
+ if (typeof jQuery === 'undefined' || !jQuery.validator) {
return;
}
var validNamePat = /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i;
diff --git a/web/cobrands/oxfordshire/js.js b/web/cobrands/oxfordshire/js.js
index 17cb0dd8f..ad9639383 100644
--- a/web/cobrands/oxfordshire/js.js
+++ b/web/cobrands/oxfordshire/js.js
@@ -1,7 +1,5 @@
fixmystreet.utils = fixmystreet.utils || {};
-$.extend(fixmystreet.utils, {
- defect_type_format: function(data) {
- return data.extra.defect_code + ' - ' + data.extra.activity_code + ' (' + data.name + ')';
- }
-});
+fixmystreet.utils.defect_type_format = function(data) {
+ return data.extra.defect_code + ' - ' + data.extra.activity_code + ' (' + data.name + ')';
+};