diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 19 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/front.js | 12 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/map.js | 40 | ||||
-rw-r--r-- | web/js/map-OpenLayers.js | 10 |
4 files changed, 71 insertions, 10 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 09d387506..689ad2755 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -510,6 +510,25 @@ $.extend(fixmystreet.set_up, { } }, + fixed_thead: function() { + var thead = $('.nicetable thead'); + if (thead.fixedThead) { + thead.fixedThead(); + } + }, + + report_list_filters: function() { + // Hide the pin filter submit button. Not needed because we'll use JS + // to refresh the map when the filter inputs are changed. + $(".report-list-filters [type=submit]").hide(); + + if (fixmystreet.page == "my" || fixmystreet.page == "reports") { + $(".report-list-filters select").change(function() { + $(this).closest("form").submit(); + }); + } + }, + mobile_ui_tweaks: function() { //move 'skip this step' link on mobile $('.mobile #skip-this-step').addClass('chevron').wrap('<li>').parent().appendTo('#key-tools'); diff --git a/web/cobrands/fixmystreet/front.js b/web/cobrands/fixmystreet/front.js new file mode 100644 index 000000000..8fc5db214 --- /dev/null +++ b/web/cobrands/fixmystreet/front.js @@ -0,0 +1,12 @@ +yepnope.addPrefix( 'preload', function ( resource ) { + resource.noexec = true; + return resource; +}); + +$(function(){ + var scripts = document.getElementById('script_front').getAttribute('data-scripts').split(','); + for (var i=0; i<scripts.length; i++) { + scripts[i] = 'preload!' + scripts[i]; + } + yepnope({ load: scripts }); +}); diff --git a/web/cobrands/fixmystreet/map.js b/web/cobrands/fixmystreet/map.js new file mode 100644 index 000000000..b822864f7 --- /dev/null +++ b/web/cobrands/fixmystreet/map.js @@ -0,0 +1,40 @@ +var fixmystreet = fixmystreet || {}; + +(function(){ + + var map_data = document.getElementById('js-map-data'), + map_keys = [ 'area', 'all_pins', 'latitude', 'longitude', 'zoomToBounds', 'zoom', 'pin_prefix', 'numZoomLevels', 'zoomOffset', 'map_type', 'key' ], + numeric = { zoom: 1, numZoomLevels: 1, zoomOffset: 1 }, + pin_keys = [ 'lat', 'lon', 'colour', 'id', 'title', 'type' ]; + + if (!map_data) { + return; + } + + $.each(map_keys, function(i, v) { + fixmystreet[v] = map_data.getAttribute('data-' + v); + if (numeric[v]) { + fixmystreet[v] = +fixmystreet[v]; + } + }); + + fixmystreet.area = fixmystreet.area ? fixmystreet.area.split(',') : []; + if (fixmystreet.map_type) { + var s = fixmystreet.map_type.split('.'); + var obj = window; + for (var i=0; i<s.length; i++) { + obj = obj[s[i]]; + } + fixmystreet.map_type = obj; + } + + fixmystreet.pins = []; + $('.js-pin').each(function(i, pin) { + var arr = []; + $.each(pin_keys, function(i, v) { + arr.push(pin.getAttribute('data-' + v)); + }); + fixmystreet.pins.push(arr); + }); + +})(); diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index f110dec26..f202e1392 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -508,16 +508,6 @@ var fixmystreet = fixmystreet || {}; click.activate(); } - // Hide the pin filter submit button. Not needed because we'll use JS - // to refresh the map when the filter inputs are changed. - $(".report-list-filters [type=submit]").hide(); - - if (fixmystreet.page == "my" || fixmystreet.page == "reports") { - $(".report-list-filters select").change(function() { - $(this).closest("form").submit(); - }); - } - // Vector layers must be added onload as IE sucks if ($.browser.msie) { $(window).load(onload); |