aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-12-06 15:38:40 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-12-12 21:27:39 +0000
commitec8ad12f3b1103b22cc2e7694387daa7294f1ed7 (patch)
treecfc44a522ef541d1d85f31e8b2bcf0f3910db6f1
parentd688eb43a99a3c7782343677cd7285f66cfb3c32 (diff)
[UK] Make sure jQuery is loaded where it is needed
Bromley uses jQuery for its A-Z on all pages; only load Bristol map JavaScript on map pages (same as Angus); drop Oxfordshire JS use of jQuery; fix Zurich load order; and improve jQuery checking in other JavaScript.
-rw-r--r--perllib/FixMyStreet/Map/Bristol.pm2
-rw-r--r--t/map/tests.t2
-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
9 files changed, 18 insertions, 12 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/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 9fdb3e31b..a9842ffdd 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 + ')';
+};