aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-08-15 11:43:10 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-08-16 17:31:07 +0100
commit945ce43e9e5c3d872d3b22219e2c3b9d03ab4cfd (patch)
treefacb8affb9f19c8581873fb9573ad4998d4e6f7a /web
parentfa6b57a3664bc6a23b09d60a0abcaa75b170f8f9 (diff)
Do HTML class and JS variable setting ASAP.
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js6
-rw-r--r--web/cobrands/fixmystreet/header.js17
-rw-r--r--web/js/map-OpenLayers.js2
3 files changed, 19 insertions, 6 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 490057135..09d387506 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -182,9 +182,6 @@ fixmystreet.resize_to = {
fixmystreet.set_up = fixmystreet.set_up || {};
$.extend(fixmystreet.set_up, {
basics: function() {
- // Add a class to the whole page saying JavaScript is enabled (for CSS and so on)
- $('html').removeClass('no-js').addClass('js');
-
// Preload the new report pin
if ( typeof fixmystreet !== 'undefined' && typeof fixmystreet.pin_prefix !== 'undefined' ) {
document.createElement('img').src = fixmystreet.pin_prefix + 'pin-green.png';
@@ -547,7 +544,7 @@ $.extend(fixmystreet.set_up, {
map_controls: function() {
//add permalink on desktop, force hide on mobile
//add links container (if its not there)
- if (window.cobrand != 'zurich') {
+ if (fixmystreet.cobrand != 'zurich') {
if ($('#sub_map_links').length === 0) {
$('<p id="sub_map_links" />').insertAfter($('#map'));
}
@@ -1017,7 +1014,6 @@ fixmystreet.display = {
$(function() {
- window.cobrand = $('meta[name="cobrand"]').attr('content');
fixmystreet.original = {
'title': document.title,
'page': fixmystreet.page
diff --git a/web/cobrands/fixmystreet/header.js b/web/cobrands/fixmystreet/header.js
new file mode 100644
index 000000000..493facc7d
--- /dev/null
+++ b/web/cobrands/fixmystreet/header.js
@@ -0,0 +1,17 @@
+var fixmystreet = fixmystreet || {};
+
+(function(D){
+ var E = D.documentElement;
+ E.className = E.className.replace(/\bno-js\b/, 'js');
+ var iel8 = E.className.indexOf('iel8') > -1;
+ var type = Modernizr.mq('(min-width: 48em)') || iel8 ? 'desktop' : 'mobile';
+ var meta = D.getElementById('js-meta-data');
+ fixmystreet.page = meta.getAttribute('data-page');
+ fixmystreet.cobrand = meta.getAttribute('data-cobrand');
+ if (type == 'mobile') {
+ E.className += ' mobile';
+ if (fixmystreet.page == 'around') {
+ E.className += ' mobile-reporting-map only-map';
+ }
+ }
+})(document);
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 992037a2f..f110dec26 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -744,7 +744,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
var lonlat = fixmystreet.map.getLonLatFromViewPortPx(e.xy);
fixmystreet.display.begin_report(lonlat);
- if ( typeof ga !== 'undefined' && window.cobrand == 'fixmystreet' ) {
+ if ( typeof ga !== 'undefined' && fixmystreet.cobrand == 'fixmystreet' ) {
ga('send', 'pageview', { 'page': '/map_click' } );
}
}