diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/bathnes/js.js | 38 | ||||
-rw-r--r-- | web/cobrands/fixmystreet-uk-councils/roadworks.js | 52 | ||||
-rw-r--r-- | web/cobrands/lincolnshire/roadworks.js | 28 | ||||
-rw-r--r-- | web/cobrands/sass/_base.scss | 2 | ||||
-rw-r--r-- | web/cobrands/zurich/base.scss | 15 |
5 files changed, 49 insertions, 86 deletions
diff --git a/web/cobrands/bathnes/js.js b/web/cobrands/bathnes/js.js index a478d71fc..418e0650c 100644 --- a/web/cobrands/bathnes/js.js +++ b/web/cobrands/bathnes/js.js @@ -4,37 +4,11 @@ if (!fixmystreet.maps) { return; } -fixmystreet.roadworks.display_message = function(feature) { - var attr = feature.attributes, - start = new Date(attr.start.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), - end = new Date(attr.end.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), - tooltip = attr.tooltip.replace(/\\n/g, '\n'), - desc = attr.works_desc.replace(/\\n/g, '\n'); - - var $msg = $('<div class="js-roadworks-message box-warning"><h3>Roadworks are scheduled near this location, so you may not need to report your issue.</h3></div>'); - var $dl = $("<dl></dl>").appendTo($msg); - $dl.append("<dt>Dates:</dt>"); - $dl.append($("<dd></dd>").text(start + " until " + end)); - $dl.append("<dt>Summary:</dt>"); - var $summary = $("<dd></dd>").appendTo($dl); - tooltip.split("\n").forEach(function(para) { - if (para.match(/^(\d{2}\s+\w{3}\s+(\d{2}:\d{2}\s+)?\d{4}( - )?){2}/)) { - // skip showing the date again - return; - } - if (para.match(/^delays/)) { - // skip showing traffic delay information - return; - } - $summary.append(para).append("<br />"); - }); - if (desc) { - $dl.append("<dt>Description:</dt>"); - $dl.append($("<dd></dd>").text(desc)); - } - $dl.append($("<p>If you think this issue needs immediate attention you can continue your report below</p>")); - - $('.change_location').after($msg); +fixmystreet.roadworks.config = { + tag_top: 'h3', + colon: true, + skip_delays: true, + text_after: "<p>If you think this issue needs immediate attention you can continue your report below</p>" }; fixmystreet.roadworks.filter = function(feature) { @@ -52,7 +26,7 @@ fixmystreet.roadworks.filter = function(feature) { fixmystreet.roadworks.category_change = function() { if (fixmystreet.map) { - fixmystreet.roadworks.show_nearby(null, fixmystreet.map.getCenter()); + fixmystreet.roadworks.show_nearby(null, fixmystreet.get_lonlat_from_dom()); } }; diff --git a/web/cobrands/fixmystreet-uk-councils/roadworks.js b/web/cobrands/fixmystreet-uk-councils/roadworks.js index 354dfaf77..57941082f 100644 --- a/web/cobrands/fixmystreet-uk-councils/roadworks.js +++ b/web/cobrands/fixmystreet-uk-councils/roadworks.js @@ -170,25 +170,57 @@ fixmystreet.roadworks.show_nearby = function(evt, lonlat) { // The click wasn't directly over a road, try and find one nearby feature = layer.getNearestFeature(point, 100); } - if (feature !== null && fixmystreet.roadworks.filter(feature)) { - fixmystreet.roadworks.display_message(feature); - return true; + if (feature !== null) { + if (!fixmystreet.roadworks.filter || fixmystreet.roadworks.filter(feature)) { + fixmystreet.roadworks.display_message(feature); + return true; + } } } }; -fixmystreet.roadworks.filter = function() { - return 1; -}; +fixmystreet.roadworks.config = {}; fixmystreet.roadworks.display_message = function(feature) { var attr = feature.attributes, - start = attr.start.replace(/{ts '([^ ]*).*/, '$1'), - end = attr.end.replace(/{ts '([^ ]*).*/, '$1'), - tooltip = attr.tooltip.replace(/\\n/g, '\n'); - $('.change_location').after('<div class="js-roadworks-message box-warning">Roadworks are scheduled near this location from ' + start + ' to ' + end + ', so you may not need to report your issue: “' + tooltip + '”</div>'); + start = new Date(attr.start.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), + end = new Date(attr.end.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), + tooltip = attr.tooltip.replace(/\\n/g, '\n'), + desc = attr.works_desc.replace(/\\n/g, '\n'); + + var config = this.config, + tag_top = config.tag_top || 'p', + colon = config.colon ? ':' : ''; + + var $msg = $('<div class="js-roadworks-message box-warning"><' + tag_top + '>Roadworks are scheduled near this location, so you may not need to report your issue.</' + tag_top + '></div>'); + var $dl = $("<dl></dl>").appendTo($msg); + $dl.append("<dt>Dates" + colon + "</dt>"); + $dl.append($("<dd></dd>").text(start + " until " + end)); + $dl.append("<dt>Summary" + colon + "</dt>"); + var $summary = $("<dd></dd>").appendTo($dl); + tooltip.split("\n").forEach(function(para) { + if (para.match(/^(\d{2}\s+\w{3}\s+(\d{2}:\d{2}\s+)?\d{4}( - )?){2}/)) { + // skip showing the date again + return; + } + if (config.skip_delays && para.match(/^delays/)) { + // skip showing traffic delay information + return; + } + $summary.append(para).append("<br />"); + }); + if (desc) { + $dl.append("<dt>Description" + colon + "</dt>"); + $dl.append($("<dd></dd>").text(desc)); + } + if (config.text_after) { + $dl.append(config.text_after); + } + + $('.change_location').after($msg); }; + $(fixmystreet).on('maps:update_pin', fixmystreet.roadworks.show_nearby); /* Stop sending a needless header so that no preflight CORS request */ diff --git a/web/cobrands/lincolnshire/roadworks.js b/web/cobrands/lincolnshire/roadworks.js index a9fa64bb6..7b42a12f2 100644 --- a/web/cobrands/lincolnshire/roadworks.js +++ b/web/cobrands/lincolnshire/roadworks.js @@ -4,34 +4,6 @@ if (!fixmystreet.maps) { return; } -fixmystreet.roadworks.display_message = function(feature) { - var attr = feature.attributes, - start = new Date(attr.start.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), - end = new Date(attr.end.replace(/{ts '([^ ]*).*/, '$1')).toDateString(), - tooltip = attr.tooltip.replace(/\\n/g, '\n'), - desc = attr.works_desc.replace(/\\n/g, '\n'); - - var $msg = $('<div class="js-roadworks-message box-warning"><p>Roadworks are scheduled near this location, so you may not need to report your issue.</p></div>'); - var $dl = $("<dl></dl>").appendTo($msg); - $dl.append("<dt>Dates</dt>"); - $dl.append($("<dd></dd>").text(start + " until " + end)); - $dl.append("<dt>Summary</dt>"); - var $summary = $("<dd></dd>").appendTo($dl); - tooltip.split("\n").forEach(function(para) { - if (para.match(/^(\d{2}\s+\w{3}\s+(\d{2}:\d{2}\s+)?\d{4}( - )?){2}/)) { - // skip showing the date again - return; - } - $summary.append(para).append("<br />"); - }); - if (desc) { - $dl.append("<dt>Description</dt>"); - $dl.append($("<dd></dd>").text(desc)); - } - - $('.change_location').after($msg); -}; - fixmystreet.assets.add($.extend(true, {}, fixmystreet.roadworks.layer_future, { http_options: { params: { organisation_id: '1070' } }, body: "Lincolnshire County Council" diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index ba4ecb732..2491c4c21 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -281,7 +281,7 @@ label{ &.inline { display: inline; - padding: flip(0 2em 0 1em, 0 1em 0 2em); + padding: flip(0 1em 0 5px, 0 5px 0 1em); font-weight: normal; } diff --git a/web/cobrands/zurich/base.scss b/web/cobrands/zurich/base.scss index e7d7cc7c1..741539e9d 100644 --- a/web/cobrands/zurich/base.scss +++ b/web/cobrands/zurich/base.scss @@ -200,25 +200,10 @@ h4.static-with-rule { } } -.admin { - label.inline { - padding: 0; - } - - input[type="checkbox"] + label.inline { - margin-right: 0.2em; - } - -} table#admin_bodies tr.is-deleted { background-color: transparent; } -.admin-label--inline { - display: inline; // rather than block - margin-right: 0.333em; // bit of space between this and the following input -} - .ui-spinner input { // stop jQuery UI spinner inputs from inheriting FMS input styles padding: 1px; |