From 1fdef4fc5bb4424846a5be005b26bb9b839c15d1 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:11:45 +0400 Subject: [PATCH 01/11] simplified shower._isNumber --- shower.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shower.js b/shower.js index 7589533..4fdc956 100755 --- a/shower.js +++ b/shower.js @@ -75,11 +75,7 @@ window.shower = (function(window, document, undefined) { * @returns {Boolean} */ shower._isNumber = function(arg) { - if ( ! ( ! isNaN(parseFloat(arg)) && isFinite(arg))) { - return false; - } - - return true; + return ( ! isNaN(parseFloat(arg)) && isFinite(arg)); }; /** From f140afabd247db3a07b52326487d9ce2e504b79c Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:15:29 +0400 Subject: [PATCH 02/11] simplified shower._isNumber() --- shower.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shower.js b/shower.js index 4fdc956..b7ba143 100755 --- a/shower.js +++ b/shower.js @@ -75,7 +75,7 @@ window.shower = (function(window, document, undefined) { * @returns {Boolean} */ shower._isNumber = function(arg) { - return ( ! isNaN(parseFloat(arg)) && isFinite(arg)); + return ! isNaN(parseFloat(arg)) && isFinite(arg); }; /** From 5fa3a4ce4760334b1a6e2df2255616e1cecbb76f Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:15:53 +0400 Subject: [PATCH 03/11] simplified shower._checkInteractiveElement() --- shower.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shower.js b/shower.js index b7ba143..3a10a41 100755 --- a/shower.js +++ b/shower.js @@ -128,11 +128,7 @@ window.shower = (function(window, document, undefined) { * @returns {Boolean} */ shower._checkInteractiveElement = function(e) { - if ('A' === e.target.nodeName) { - return true; - } else { - return false; - } + return 'A' === e.target.nodeName; }; /** From b87fc92cda2e61d38636116ca79519c6af2387bb Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:20:58 +0400 Subject: [PATCH 04/11] shower.getSlideNumber JSDoc: slideId is String instead of Number --- shower.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shower.js b/shower.js index 3a10a41..12984ff 100755 --- a/shower.js +++ b/shower.js @@ -133,7 +133,7 @@ window.shower = (function(window, document, undefined) { /** * Get slide number by slideId - * @param {Number} slideId (HTML id or position in slideList) + * @param {String} slideId (HTML id or position in slideList) * @returns {Number} */ shower.getSlideNumber = function(slideId) { From 0dac96b4deb952c4b8e1f611b8d9ee377e7a6733 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:24:58 +0400 Subject: [PATCH 05/11] JSDoc: All callbacks are optional --- shower.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shower.js b/shower.js index 12984ff..c71888b 100755 --- a/shower.js +++ b/shower.js @@ -160,7 +160,7 @@ window.shower = (function(window, document, undefined) { /** * Show next slide. If slide is last returns false, otherwise return slide * number which been shown. - * @param {Function} callback runs only if shower.next() complete successfully + * @param {Function} [callback] runs only if shower.next() complete successfully * @returns {Number|Boolean} */ shower.next = function(callback) { @@ -192,7 +192,7 @@ window.shower = (function(window, document, undefined) { /** * Show previous slide. If slide is first returns false, otherwise return slide * number which been shown. - * @param {Function} callback runs only if shower.previous() complete successfully + * @param {Function} [callback] runs only if shower.previous() complete successfully * @returns {Number|Boolean} */ shower.previous = function(callback) { @@ -216,7 +216,7 @@ window.shower = (function(window, document, undefined) { /** * Show first slide. - * @param {Function} callback + * @param {Function} [callback] * @returns {Number} */ shower.first = function(callback) { @@ -229,7 +229,7 @@ window.shower = (function(window, document, undefined) { /** * Show last slide. - * @param {Function} callback + * @param {Function} [callback] * @returns {Number} */ shower.last = function(callback) { @@ -241,7 +241,7 @@ window.shower = (function(window, document, undefined) { /** * Switch to slide view. - * @param {Function} callback runs only if shower.enterSlideMode() complete successfully + * @param {Function} [callback] runs only if shower.enterSlideMode() complete successfully * @returns {Number|Boolean} */ shower.enterSlideMode = function(callback) { @@ -278,7 +278,7 @@ window.shower = (function(window, document, undefined) { /** * Switch to list view. - * @param {Function} callback runs only if shower.enterListMode() complete successfully + * @param {Function} [callback] runs only if shower.enterListMode() complete successfully * @returns {Number} */ shower.enterListMode = function(callback) { @@ -302,7 +302,7 @@ window.shower = (function(window, document, undefined) { /** * Toggle Mode: Slide and List - * @param {Function} callback + * @param {Function} [callback] */ shower.toggleMode = function(callback) { if (shower.isListMode()) { @@ -487,7 +487,7 @@ window.shower = (function(window, document, undefined) { /** * Go to slide number... * @param {Number} slideNumber slide number (sic!). Attention: starts from zero. - * @param {Function} callback runs only if you not in List mode + * @param {Function} [callback] runs only if you not in List mode * @returns {Number} */ shower.go = function(slideNumber, callback) { From 75686e010bd7d35cc6bfdec554a8d1b83a7a42eb Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:30:11 +0400 Subject: [PATCH 06/11] JSDoc: shower.enterListMode return Boolean --- shower.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shower.js b/shower.js index c71888b..5badbfe 100755 --- a/shower.js +++ b/shower.js @@ -279,7 +279,7 @@ window.shower = (function(window, document, undefined) { /** * Switch to list view. * @param {Function} [callback] runs only if shower.enterListMode() complete successfully - * @returns {Number} + * @returns {Boolean} */ shower.enterListMode = function(callback) { var currentSlideNumber = shower.getCurrentSlideNumber(); From 4c8ecdfcdf6c229fff6acacce5865369e67dc5f1 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:31:34 +0400 Subject: [PATCH 07/11] JSDOc: shower.scrollToSlide return only Boolean --- shower.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shower.js b/shower.js index 5badbfe..f7caf6e 100755 --- a/shower.js +++ b/shower.js @@ -342,11 +342,11 @@ window.shower = (function(window, document, undefined) { /** * Scroll to slide. * @param {Number} slideNumber slide number (sic!) - * @returns {Undefined|Boolean} + * @returns {Boolean} */ shower.scrollToSlide = function(slideNumber) { var currentSlide, - ret; + ret = false; if ( ! shower._isNumber(slideNumber)) { throw new Error('Gimme slide number as Number, baby!'); @@ -358,7 +358,7 @@ window.shower = (function(window, document, undefined) { // @TODO: WTF? if (-1 === slideNumber) { - return; + return ret; } if (slideList[slideNumber]) { From 850e2dd15b5382e2135aa3e770d3e0597eb9fe71 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:32:53 +0400 Subject: [PATCH 08/11] JSDoc: shower.getSlideHash return String --- shower.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shower.js b/shower.js index f7caf6e..bf56b9a 100755 --- a/shower.js +++ b/shower.js @@ -472,7 +472,7 @@ window.shower = (function(window, document, undefined) { /** * Get slide hash. * @param {Number} slideNumber slide number (sic!). Attention: starts from zero. - * @returns {Boolean} + * @returns {String} */ shower.getSlideHash = function(slideNumber) { if ( ! shower._isNumber(slideNumber)) { From 9e5035c5d4a05ed84db367c4744cfe41ac681716 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:40:59 +0400 Subject: [PATCH 09/11] JSDoc: domElem -> HTMLElement --- shower.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shower.js b/shower.js index bf56b9a..b013371 100755 --- a/shower.js +++ b/shower.js @@ -17,7 +17,7 @@ window.shower = (function(window, document, undefined) { /** * Get value at named data store for the DOM element. * @private - * @param {domElem} element + * @param {HTMLElement} element * @param {String} name * @returns {String} */ @@ -103,7 +103,7 @@ window.shower = (function(window, document, undefined) { /** * Get slide id from HTML element. * @private - * @param {domElem} el + * @param {HTMLElement} el * @returns {String} */ shower._getSlideIdByEl = function(el) { @@ -124,7 +124,7 @@ window.shower = (function(window, document, undefined) { * @TODO: add support for textareas/inputs/... * * @private - * @param {domElem} e + * @param {HTMLElement} e * @returns {Boolean} */ shower._checkInteractiveElement = function(e) { From ef5fba3cd38bf5d6fb570a8ae27cb84eb19471cb Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:45:04 +0400 Subject: [PATCH 10/11] shower.runSlideshowIfPresented return Boolean --- shower.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shower.js b/shower.js index b013371..23ce92b 100755 --- a/shower.js +++ b/shower.js @@ -513,7 +513,7 @@ window.shower = (function(window, document, undefined) { /** * Run slide show if presented. * @param {Number} slideNumber - * @returns {Undefined} + * @returns {Boolean} */ shower.runSlideshowIfPresented = function(slideNumber) { if ( ! shower._isNumber(slideNumber)) { @@ -536,6 +536,8 @@ window.shower = (function(window, document, undefined) { }, timing); } + + return true; }; /** From 890d312e6d96392c0e504334c65ac0c186e9e1e4 Mon Sep 17 00:00:00 2001 From: miripiruni Date: Sun, 20 Jan 2013 03:45:45 +0400 Subject: [PATCH 11/11] Removed unused arguments --- shower.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shower.js b/shower.js index 23ce92b..e2e0d78 100755 --- a/shower.js +++ b/shower.js @@ -579,7 +579,7 @@ window.shower = (function(window, document, undefined) { } }, false); - window.addEventListener('popstate', function(e) { + window.addEventListener('popstate', function() { if (shower.isListMode()) { shower.enterListMode(); } else { @@ -587,7 +587,7 @@ window.shower = (function(window, document, undefined) { } }, false); - window.addEventListener('resize', function(e) { + window.addEventListener('resize', function() { if (shower.isSlideMode()) { shower._applyTransform(shower._getTransform()); }