diff --git a/.phpcs.xml b/.phpcs.xml index 77a35e5..a0785b8 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -41,4 +41,15 @@ + + + + *.js + + + *.js + diff --git a/themes/default/js/pico.js b/themes/default/js/pico.js index 06e8e26..90c1a4c 100644 --- a/themes/default/js/pico.js +++ b/themes/default/js/pico.js @@ -9,7 +9,8 @@ * @version 1.1 */ -function main() { +function main() +{ // capability CSS classes document.documentElement.className = 'js'; @@ -39,7 +40,9 @@ function main() { if (menuToggle.getAttribute('aria-expanded') === 'false') { menuToggle.setAttribute('aria-expanded', 'true'); utils.slideDown(menu, null, function () { - if (event.type === 'keydown') menu.focus(); + if (event.type === 'keydown') { + menu.focus(); + } }); } else { menuToggle.setAttribute('aria-expanded', 'false'); diff --git a/themes/default/js/utils.js b/themes/default/js/utils.js index 7cbb50d..a67ea27 100644 --- a/themes/default/js/utils.js +++ b/themes/default/js/utils.js @@ -20,7 +20,8 @@ utils = {}; * to stop the iteration * @return void */ -utils.forEach = function (object, callback) { +utils.forEach = function (object, callback) +{ var i = 0, keys = Object.keys(object), length = keys.length; @@ -36,7 +37,8 @@ utils.forEach = function (object, callback) { * * @return boolean TRUE when the browser supports sliding, FALSE otherwise */ -utils.canSlide = function () { +utils.canSlide = function () +{ return (Modernizr.classlist && Modernizr.requestanimationframe && Modernizr.csstransitions); }; @@ -49,7 +51,8 @@ utils.canSlide = function () { * @param function startCallback function to call when the animation starts * @return void */ -utils.slideUp = function (element, finishCallback, startCallback) { +utils.slideUp = function (element, finishCallback, startCallback) +{ if (!utils.canSlide()) { if (startCallback) startCallback(); element.className += (element.className !== '') ? ' hidden' : 'hidden'; @@ -96,7 +99,8 @@ utils.slideUp = function (element, finishCallback, startCallback) { * @param function startCallback function to call when the animation starts * @return void */ -utils.slideDown = function (element, finishCallback, startCallback) { +utils.slideDown = function (element, finishCallback, startCallback) +{ if (!utils.canSlide()) { if (startCallback) startCallback(); element.className = element.className.replace(/\bhidden\b */g, ''); @@ -146,6 +150,7 @@ utils.slideDown = function (element, finishCallback, startCallback) { * @param HTMLElement element the element to check * @return boolean TRUE when the element is visible, FALSE otherwise */ -utils.isElementVisible = function (element) { +utils.isElementVisible = function (element) +{ return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length); };