From 4b7612772345a2e6c9365f904aa6eac71cd0ddca Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 4 Mar 2014 09:04:30 +0200 Subject: [PATCH] Update JSHint rules. Enabled: * `immed` * `newcap` * `latedef` Removed: * `boss` * `laxbreak` * `validthis` Also move `bitwise` to fingerblast.js since that's where it's only needed. --- docs/assets/js/docs.js | 7 ++++--- docs/assets/js/fingerblast.js | 3 ++- js/.jshintrc | 9 +++++---- js/modals.js | 4 ++-- js/popovers.js | 8 ++++---- js/push.js | 28 +++++++++++++--------------- js/segmented-controllers.js | 4 ++-- js/sliders.js | 4 ++-- js/toggles.js | 8 ++++---- 9 files changed, 38 insertions(+), 37 deletions(-) diff --git a/docs/assets/js/docs.js b/docs/assets/js/docs.js index a8b8005..902385c 100644 --- a/docs/assets/js/docs.js +++ b/docs/assets/js/docs.js @@ -137,6 +137,10 @@ $(function() { device[0].setAttribute('style',''); } + function updateContent(content) { + $('#iwindow').html(content); + } + // Injection of components into device for (var l = contentSection.length; l--;) { if ((topCache[l] - currentTop) < windowHeight) { @@ -159,9 +163,6 @@ $(function() { } } - function updateContent(content) { - $('#iwindow').html(content); - } }; // Toolbar toggle diff --git a/docs/assets/js/fingerblast.js b/docs/assets/js/fingerblast.js index a7cd3fd..eb882bb 100644 --- a/docs/assets/js/fingerblast.js +++ b/docs/assets/js/fingerblast.js @@ -2,6 +2,7 @@ // -------------- // Adapted from phantom limb by Brian Cartensen +/* jshint bitwise: false */ /* global GLOBAL: true */ function FingerBlast(element) { @@ -33,7 +34,7 @@ FingerBlast.prototype = { } else if ('contains' in ancestor) { return ancestor !== element && ancestor.contains(element); } else { - for (descendants = ancestor.getElementsByTagName('*'), index = 0; descendant = descendants[index++];) { + for ((descendants = ancestor.getElementsByTagName('*')), index = 0; (descendant = descendants[index++]);) { if (descendant === element) { return true; } diff --git a/js/.jshintrc b/js/.jshintrc index e4afdcf..b81ecc1 100644 --- a/js/.jshintrc +++ b/js/.jshintrc @@ -1,5 +1,5 @@ { - "boss" : true, + "bitwise" : true, "browser" : true, "camelcase" : true, "curly" : true, @@ -9,13 +9,14 @@ "expr" : true, "forin" : true, "freeze" : true, + "immed" : true, "indent" : 2, - "laxbreak" : true, + "latedef" : true, + "newcap" : true, "nonbsp" : true, "quotmark" : "single", "strict" : true, "trailing" : true, "undef" : true, - "unused" : true, - "validthis" : true + "unused" : true } diff --git a/js/modals.js b/js/modals.js index 3c36dc6..0fc3bf6 100644 --- a/js/modals.js +++ b/js/modals.js @@ -4,7 +4,7 @@ * http://opensource.org/licenses/MIT * ---------------------------------- */ -!function () { +!(function () { 'use strict'; var findModals = function (target) { @@ -34,4 +34,4 @@ event.preventDefault(); // prevents rewriting url (apps can still use hash values in url) } }); -}(); +}()); diff --git a/js/popovers.js b/js/popovers.js index 4b6954e..5551b41 100644 --- a/js/popovers.js +++ b/js/popovers.js @@ -4,7 +4,7 @@ * http://opensource.org/licenses/MIT * ---------------------------------- */ -!function () { +!(function () { 'use strict'; var popover; @@ -25,7 +25,7 @@ popover.removeEventListener('webkitTransitionEnd', onPopoverHidden); }; - var backdrop = function () { + var backdrop = (function () { var element = document.createElement('div'); element.classList.add('backdrop'); @@ -37,7 +37,7 @@ }); return element; - }(); + }()); var getPopover = function (e) { var anchor = findPopovers(e.target); @@ -81,4 +81,4 @@ window.addEventListener('touchend', showHidePopover); window.addEventListener('click', showHidePopover); -}(); +}()); diff --git a/js/push.js b/js/push.js index 30b5c99..da45507 100644 --- a/js/push.js +++ b/js/push.js @@ -7,7 +7,7 @@ /* global _gaq: true */ -!function () { +!(function () { 'use strict'; var noop = function () {}; @@ -87,18 +87,16 @@ var getTarget = function (e) { var target = findTarget(e.target); - if ( - ! target - || e.which > 1 - || e.metaKey - || e.ctrlKey - || isScrolling - || location.protocol !== target.protocol - || location.host !== target.host - || !target.hash && /#/.test(target.href) - || target.hash && target.href.replace(target.hash, '') === location.href.replace(location.hash, '') - || target.getAttribute('data-ignore') === 'push' - ) { return; } + if (!target || + e.which > 1 || + e.metaKey || + e.ctrlKey || + isScrolling || + location.protocol !== target.protocol || + location.host !== target.host || + !target.hash && /#/.test(target.href) || + target.hash && target.href.replace(target.hash, '') === location.href.replace(location.hash, '') || + target.getAttribute('data-ignore') === 'push') { return; } return target; }; @@ -158,7 +156,7 @@ } if (direction === 'back' && !transitionFromObj.id) { - return PUSH.id = id; + return (PUSH.id = id); } transition = direction === 'back' ? transitionMap[transitionFromObj.transition] : transitionFromObj.transition; @@ -477,4 +475,4 @@ window.addEventListener('popstate', popstate); window.PUSH = PUSH; -}(); +}()); diff --git a/js/segmented-controllers.js b/js/segmented-controllers.js index bac1c0c..006c13d 100644 --- a/js/segmented-controllers.js +++ b/js/segmented-controllers.js @@ -4,7 +4,7 @@ * http://opensource.org/licenses/MIT * ---------------------------------- */ -!function () { +!(function () { 'use strict'; var getTarget = function (target) { @@ -58,4 +58,4 @@ }); window.addEventListener('click', function (e) { if (getTarget(e.target)) {e.preventDefault();} }); -}(); \ No newline at end of file +}()); \ No newline at end of file diff --git a/js/sliders.js b/js/sliders.js index 6d6aa2c..43dc248 100644 --- a/js/sliders.js +++ b/js/sliders.js @@ -5,7 +5,7 @@ * http://opensource.org/licenses/MIT * ---------------------------------- */ -!function () { +!(function () { 'use strict'; var pageX; @@ -127,4 +127,4 @@ window.addEventListener('touchmove', onTouchMove); window.addEventListener('touchend', onTouchEnd); -}(); +}()); diff --git a/js/toggles.js b/js/toggles.js index beff5bf..e8e9f7c 100644 --- a/js/toggles.js +++ b/js/toggles.js @@ -4,7 +4,7 @@ * http://opensource.org/licenses/MIT * ---------------------------------- */ -!function () { +!(function () { 'use strict'; var start = {}; @@ -68,10 +68,10 @@ e.preventDefault(); if (distanceX < 0) { - return handle.style.webkitTransform = 'translate3d(0,0,0)'; + return (handle.style.webkitTransform = 'translate3d(0,0,0)'); } if (distanceX > offset) { - return handle.style.webkitTransform = 'translate3d(' + offset + 'px,0,0)'; + return (handle.style.webkitTransform = 'translate3d(' + offset + 'px,0,0)'); } handle.style.webkitTransform = 'translate3d(' + distanceX + 'px,0,0)'; @@ -110,4 +110,4 @@ toggle = false; }); -}(); +}());