Merge pull request #108 from miripiruni/master
Fixes for JSDoc & Clean-up
This commit is contained in:
commit
ddf7cc64ba
54
shower.js
54
shower.js
|
@ -17,7 +17,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* Get value at named data store for the DOM element.
|
* Get value at named data store for the DOM element.
|
||||||
* @private
|
* @private
|
||||||
* @param {domElem} element
|
* @param {HTMLElement} element
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
|
@ -75,11 +75,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
shower._isNumber = function(arg) {
|
shower._isNumber = function(arg) {
|
||||||
if ( ! ( ! isNaN(parseFloat(arg)) && isFinite(arg))) {
|
return ! isNaN(parseFloat(arg)) && isFinite(arg);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +103,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* Get slide id from HTML element.
|
* Get slide id from HTML element.
|
||||||
* @private
|
* @private
|
||||||
* @param {domElem} el
|
* @param {HTMLElement} el
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
shower._getSlideIdByEl = function(el) {
|
shower._getSlideIdByEl = function(el) {
|
||||||
|
@ -128,20 +124,16 @@ window.shower = (function(window, document, undefined) {
|
||||||
* @TODO: add support for textareas/inputs/...
|
* @TODO: add support for textareas/inputs/...
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {domElem} e
|
* @param {HTMLElement} e
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
shower._checkInteractiveElement = function(e) {
|
shower._checkInteractiveElement = function(e) {
|
||||||
if ('A' === e.target.nodeName) {
|
return 'A' === e.target.nodeName;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get slide number by slideId
|
* 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}
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
shower.getSlideNumber = function(slideId) {
|
shower.getSlideNumber = function(slideId) {
|
||||||
|
@ -168,7 +160,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* Show next slide. If slide is last returns false, otherwise return slide
|
* Show next slide. If slide is last returns false, otherwise return slide
|
||||||
* number which been shown.
|
* 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}
|
* @returns {Number|Boolean}
|
||||||
*/
|
*/
|
||||||
shower.next = function(callback) {
|
shower.next = function(callback) {
|
||||||
|
@ -200,7 +192,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* Show previous slide. If slide is first returns false, otherwise return slide
|
* Show previous slide. If slide is first returns false, otherwise return slide
|
||||||
* number which been shown.
|
* 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}
|
* @returns {Number|Boolean}
|
||||||
*/
|
*/
|
||||||
shower.previous = function(callback) {
|
shower.previous = function(callback) {
|
||||||
|
@ -224,7 +216,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show first slide.
|
* Show first slide.
|
||||||
* @param {Function} callback
|
* @param {Function} [callback]
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
shower.first = function(callback) {
|
shower.first = function(callback) {
|
||||||
|
@ -237,7 +229,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show last slide.
|
* Show last slide.
|
||||||
* @param {Function} callback
|
* @param {Function} [callback]
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
shower.last = function(callback) {
|
shower.last = function(callback) {
|
||||||
|
@ -249,7 +241,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch to slide view.
|
* 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}
|
* @returns {Number|Boolean}
|
||||||
*/
|
*/
|
||||||
shower.enterSlideMode = function(callback) {
|
shower.enterSlideMode = function(callback) {
|
||||||
|
@ -286,8 +278,8 @@ window.shower = (function(window, document, undefined) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch to list view.
|
* 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}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
shower.enterListMode = function(callback) {
|
shower.enterListMode = function(callback) {
|
||||||
var currentSlideNumber = shower.getCurrentSlideNumber();
|
var currentSlideNumber = shower.getCurrentSlideNumber();
|
||||||
|
@ -310,7 +302,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle Mode: Slide and List
|
* Toggle Mode: Slide and List
|
||||||
* @param {Function} callback
|
* @param {Function} [callback]
|
||||||
*/
|
*/
|
||||||
shower.toggleMode = function(callback) {
|
shower.toggleMode = function(callback) {
|
||||||
if (shower.isListMode()) {
|
if (shower.isListMode()) {
|
||||||
|
@ -350,11 +342,11 @@ window.shower = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* Scroll to slide.
|
* Scroll to slide.
|
||||||
* @param {Number} slideNumber slide number (sic!)
|
* @param {Number} slideNumber slide number (sic!)
|
||||||
* @returns {Undefined|Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
shower.scrollToSlide = function(slideNumber) {
|
shower.scrollToSlide = function(slideNumber) {
|
||||||
var currentSlide,
|
var currentSlide,
|
||||||
ret;
|
ret = false;
|
||||||
|
|
||||||
if ( ! shower._isNumber(slideNumber)) {
|
if ( ! shower._isNumber(slideNumber)) {
|
||||||
throw new Error('Gimme slide number as Number, baby!');
|
throw new Error('Gimme slide number as Number, baby!');
|
||||||
|
@ -366,7 +358,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
|
|
||||||
// @TODO: WTF?
|
// @TODO: WTF?
|
||||||
if (-1 === slideNumber) {
|
if (-1 === slideNumber) {
|
||||||
return;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slideList[slideNumber]) {
|
if (slideList[slideNumber]) {
|
||||||
|
@ -480,7 +472,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* Get slide hash.
|
* Get slide hash.
|
||||||
* @param {Number} slideNumber slide number (sic!). Attention: starts from zero.
|
* @param {Number} slideNumber slide number (sic!). Attention: starts from zero.
|
||||||
* @returns {Boolean}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
shower.getSlideHash = function(slideNumber) {
|
shower.getSlideHash = function(slideNumber) {
|
||||||
if ( ! shower._isNumber(slideNumber)) {
|
if ( ! shower._isNumber(slideNumber)) {
|
||||||
|
@ -495,7 +487,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* Go to slide number...
|
* Go to slide number...
|
||||||
* @param {Number} slideNumber slide number (sic!). Attention: starts from zero.
|
* @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}
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
shower.go = function(slideNumber, callback) {
|
shower.go = function(slideNumber, callback) {
|
||||||
|
@ -521,7 +513,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
/**
|
/**
|
||||||
* Run slide show if presented.
|
* Run slide show if presented.
|
||||||
* @param {Number} slideNumber
|
* @param {Number} slideNumber
|
||||||
* @returns {Undefined}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
shower.runSlideshowIfPresented = function(slideNumber) {
|
shower.runSlideshowIfPresented = function(slideNumber) {
|
||||||
if ( ! shower._isNumber(slideNumber)) {
|
if ( ! shower._isNumber(slideNumber)) {
|
||||||
|
@ -544,6 +536,8 @@ window.shower = (function(window, document, undefined) {
|
||||||
},
|
},
|
||||||
timing);
|
timing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -585,7 +579,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
window.addEventListener('popstate', function(e) {
|
window.addEventListener('popstate', function() {
|
||||||
if (shower.isListMode()) {
|
if (shower.isListMode()) {
|
||||||
shower.enterListMode();
|
shower.enterListMode();
|
||||||
} else {
|
} else {
|
||||||
|
@ -593,7 +587,7 @@ window.shower = (function(window, document, undefined) {
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
window.addEventListener('resize', function(e) {
|
window.addEventListener('resize', function() {
|
||||||
if (shower.isSlideMode()) {
|
if (shower.isSlideMode()) {
|
||||||
shower._applyTransform(shower._getTransform());
|
shower._applyTransform(shower._getTransform());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue