diff --git a/advagg.admin.js b/advagg.admin.js index c89578f..aa4a86c 100644 --- a/advagg.admin.js +++ b/advagg.admin.js @@ -29,38 +29,38 @@ Drupal.formatInterval = function (interval, granularity, langcode) { var value = 0; if (interval >= 31536000) { value = 31536000; - output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 year', '@count years', { langcode : langcode }); + output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 year', '@count years', {langcode: langcode}); } else if (interval >= 2592000) { value = 2592000; - output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 month', '@count months', { langcode : langcode }); + output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 month', '@count months', {langcode: langcode}); } else if (interval >= 604800) { value = 604800; - output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 week', '@count weeks', { langcode : langcode }); + output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 week', '@count weeks', {langcode: langcode}); } else if (interval >= 86400) { value = 86400; - output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 day', '@count days', { langcode : langcode }); + output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 day', '@count days', {langcode: langcode}); } else if (interval >= 3600) { value = 3600; - output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 hour', '@count hours', { langcode : langcode }); + output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 hour', '@count hours', {langcode: langcode}); } else if (interval >= 60) { value = 60; - output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 min', '@count min', { langcode : langcode }); + output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 min', '@count min', {langcode: langcode}); } else if (interval >= 1) { value = 1; - output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 sec', '@count sec', { langcode : langcode }); + output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 sec', '@count sec', {langcode: langcode}); } interval %= value; granularity--; } - return output.length ? output : Drupal.t('0 sec', {}, { langcode : langcode }); + return output.length ? output : Drupal.t('0 sec', {}, {langcode: langcode}); }; /** @@ -112,13 +112,14 @@ function advagg_toggle_cookie() { } // If the cookie does not exist then set it. else { - var bypass_length = document.getElementById('edit-timespan').value, expire_date = new Date(new Date().getTime() + bypass_length * 1000); + var bypass_length = document.getElementById('edit-timespan').value; + var expire_date = new Date(new Date().getTime() + bypass_length * 1000); document.cookie = cookie_name + '=' + Drupal.settings.advagg.key + ';' + ' expires=' + expire_date.toGMTString() + ';' + ' path=' + Drupal.settings.basePath + ';' + ' domain=.' + document.location.hostname + ';'; - alert(Drupal.t('AdvAgg Bypass Cookie Set for @time.', {'@time' : Drupal.formatInterval(bypass_length)})); + alert(Drupal.t('AdvAgg Bypass Cookie Set for @time.', {'@time': Drupal.formatInterval(bypass_length)})); } // Must return false, if returning true then form gets submitted. diff --git a/advagg_font/advagg_font.inline.js b/advagg_font/advagg_font.inline.js index 567c0d9..aa32cac 100644 --- a/advagg_font/advagg_font.inline.js +++ b/advagg_font/advagg_font.inline.js @@ -3,13 +3,24 @@ * Used to add a class to the top level element based off of cookies. */ -// Check cookies ASAP and set class. -var fonts = document.cookie.split('advagg'); -for (var key in fonts) { - var font = fonts[key].split('='); - var pos = font[0].indexOf('font_'); - if (pos !== -1) { - // Only allow alpha numeric class names. - window.document.documentElement.className += ' ' + font[0].substr(5).replace(/[^a-zA-Z0-9\-]/g, ''); +/** + * Check advagg cookie for fonts. + * + * Changes the top level class to include the font name found in the cookie. + */ +function advagg_font_inline() { + "use strict"; + var fonts = document.cookie.split('advagg'); + for (var i = 0; i < fonts.length; i++) { + var font = fonts[i].split('='); + var pos = font[0].indexOf('font_'); + if (pos !== -1) { + // Only allow alpha numeric class names. + window.document.documentElement.className += ' ' + font[0].substr(5).replace(/[^a-zA-Z0-9\-]/g, ''); + alert(font[0].substr(5).replace(/[^a-zA-Z0-9\-]/g, '')); + } } } + +// Check cookies ASAP and set class. +advagg_font_inline(); diff --git a/advagg_font/advagg_font.js b/advagg_font/advagg_font.js index 49f3b15..833250e 100644 --- a/advagg_font/advagg_font.js +++ b/advagg_font/advagg_font.js @@ -51,11 +51,13 @@ function advagg_run_check(key, value) { function advagg_font_add_font_classes_on_load() { "use strict"; for (var key in Drupal.settings.advagg_font) { - var html_class = (' ' + window.document.documentElement.className + ' ').indexOf(' ' + key + ' '); - // If the class already exists in the html element do nothing. - if (html_class === -1) { - // Wait till the font is downloaded, then set cookie & class. - advagg_run_check(key, Drupal.settings.advagg_font[key]); + if (Drupal.settings.advagg_font.hasOwnProperty(key)) { + var html_class = (' ' + window.document.documentElement.className + ' ').indexOf(' ' + key + ' '); + // If the class already exists in the html element do nothing. + if (html_class === -1) { + // Wait till the font is downloaded, then set cookie & class. + advagg_run_check(key, Drupal.settings.advagg_font[key]); + } } } } diff --git a/advagg_mod/cssrelpreload.js b/advagg_mod/cssrelpreload.js index 1a264a0..2959c85 100644 --- a/advagg_mod/cssrelpreload.js +++ b/advagg_mod/cssrelpreload.js @@ -4,6 +4,7 @@ */ /* @codingStandardsIgnoreFile */ +/* eslint-disable */ /*! CSS rel=preload polyfill. Depends on loadCSS function. [c]2016 @scottjehl, Filament Group, Inc. Licensed MIT */ (function( w ){ diff --git a/advagg_mod/loadCSS.js b/advagg_mod/loadCSS.js index bfa7ea8..63a2274 100644 --- a/advagg_mod/loadCSS.js +++ b/advagg_mod/loadCSS.js @@ -4,6 +4,7 @@ */ /* @codingStandardsIgnoreFile */ +/* eslint-disable */ /*! loadCSS: load a CSS file asynchronously. [c]2016 @scottjehl, Filament Group, Inc. Licensed MIT */ (function(w){