From 215d8777d9ff12490387958c11a19e0ea2f03f23 Mon Sep 17 00:00:00 2001 From: Syl Date: Tue, 3 Dec 2013 21:43:17 +0100 Subject: [PATCH] fixed undefined + released 1.2.3.1 --- README.md | 4 ++++ assets/less/desoslide/jquery.desoslide.less | 2 +- desoslide.jquery.json | 2 +- dist/css/jquery.desoslide.css | 4 ++-- dist/js/jquery.desoslide.js | 26 +++++++++++++-------- dist/js/jquery.desoslide.min.js | 4 ++-- index.html | 2 +- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5dc8cf6..34af5d7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ ## Changelog +03/12/2013 - **1.2.3.1** + +* fixed undefined if no overlay + 03/12/2013 - **1.2.3** * added 5 callbacks in the new 'events' option: 'thumbClick', 'prev', 'pause', 'play' and 'next' diff --git a/assets/less/desoslide/jquery.desoslide.less b/assets/less/desoslide/jquery.desoslide.less index 166f88f..f91a689 100644 --- a/assets/less/desoslide/jquery.desoslide.less +++ b/assets/less/desoslide/jquery.desoslide.less @@ -1,5 +1,5 @@ /*! -* Version 1.2.3 +* Version 1.2.3.1 * jQuery: desoSlide plugin - jquery.desoslide.less * Copyright - 2013 - https://github.com/sylouuu/desoslide * This source code is under the MIT License diff --git a/desoslide.jquery.json b/desoslide.jquery.json index 77f1f66..b43205d 100644 --- a/desoslide.jquery.json +++ b/desoslide.jquery.json @@ -7,7 +7,7 @@ "slider", "thumbnail" ], - "version": "1.2.3", + "version": "1.2.3.1", "author": { "name": "sylouuu", "url": "https://github.com/sylouuu" diff --git a/dist/css/jquery.desoslide.css b/dist/css/jquery.desoslide.css index 068bc1d..7d55ee6 100644 --- a/dist/css/jquery.desoslide.css +++ b/dist/css/jquery.desoslide.css @@ -1,6 +1,6 @@ /*! -* Version 1.2.3 -* jQuery: desoSlide plugin - jquery.desoslide.css +* Version 1.2.3.1 +* jQuery: desoSlide plugin - jquery.desoslide.less * Copyright - 2013 - https://github.com/sylouuu/desoslide * This source code is under the MIT License */ diff --git a/dist/js/jquery.desoslide.js b/dist/js/jquery.desoslide.js index babe2c7..78c84a2 100644 --- a/dist/js/jquery.desoslide.js +++ b/dist/js/jquery.desoslide.js @@ -1,5 +1,5 @@ /*! -* Version 1.2.3 +* Version 1.2.3.1 * jQuery: desoSlide plugin - jquery.desoslide.js * Copyright - 2013 - https://github.com/sylouuu/desoslide * This source code is under the MIT License @@ -574,13 +574,15 @@ $controls_wrapper = $(p.main.container).find('.desoSlide-controls-wrapper'); - /** - * Triggering "play" if autostart - */ - if(p.auto.start) { - $controls_wrapper.find('a[href="#play"]').hide().parent().find('a[href="#pause"]').show(); - } else { - $controls_wrapper.find('a[href="#pause"]').hide().parent().find('a[href="#play"]').show(); + if($controls_wrapper.length) { + /** + * Triggering "play" if autostart + */ + if(p.auto.start) { + $controls_wrapper.find('a[href="#play"]').hide().parent().find('a[href="#pause"]').show(); + } else { + $controls_wrapper.find('a[href="#pause"]').hide().parent().find('a[href="#play"]').show(); + } } }, @@ -594,7 +596,9 @@ clearTimeout(timer); current_img--; - $controls_wrapper.find('a[href="#pause"]').hide().parent().find('a[href="#play"]').show(); + if($controls_wrapper) { + $controls_wrapper.find('a[href="#pause"]').hide().parent().find('a[href="#play"]').show(); + } } }, @@ -611,7 +615,9 @@ app.outEffect(); - $controls_wrapper.find('a[href="#play"]').hide().parent().find('a[href="#pause"]').show(); + if($controls_wrapper) { + $controls_wrapper.find('a[href="#play"]').hide().parent().find('a[href="#pause"]').show(); + } } }, diff --git a/dist/js/jquery.desoslide.min.js b/dist/js/jquery.desoslide.min.js index a824db3..9dfc7b5 100644 --- a/dist/js/jquery.desoslide.min.js +++ b/dist/js/jquery.desoslide.min.js @@ -1,7 +1,7 @@ /*! -* Version 1.2.3 +* Version 1.2.3.1 * jQuery: desoSlide plugin - jquery.desoslide.js * Copyright - 2013 - https://github.com/sylouuu/desoslide * This source code is under the MIT License */ -!function(e){"use strict";e.fn.desoSlide=function(n){var a,t,i,o,r,s,d,l={main:{container:!1,cssClass:"",insertion:"append"},auto:{load:!0,start:!1},first:0,interval:3e3,effect:"fade",overlay:"always",caption:!1,controls:{enable:!0,keys:!0},events:{thumbClick:!1,prev:!1,pause:!1,play:!1,next:!1,completed:!1}},c=e.extend(!0,{},l,n),p=function(){var e=0;return function(n,a){clearTimeout(e),e=setTimeout(n,a)}}(),f=this,u=f.find("li"),m=u.length,h=c.first,v=e(c.main.container).find(".desoSlide-overlay"),g=c.interval<1500?1500:c.interval,y=!1,w=!1,k={checks:function(){f.length||k.resultHandler("error",f.selector+" doesn't exist."),c.main.container?e(c.main.container).length||k.resultHandler("error",e(c.main.container).selector+" doesn't exist."):k.resultHandler("error",'You must specify the "main.container" option. Check out the documentation.');var n=["always","hover","none"];-1===n.indexOf(c.overlay)&&k.resultHandler("error",'Incorrect value for the "overlay" option. Check out the documentation.'),h>=m&&(0===m?k.resultHandler("error","You must have at least 1 thumbnail."):k.resultHandler("error",'The "first" option must be between 0 and '+(m-1)+"."))},checkData:function(){!c.caption||void 0!==i&&""!==i||k.resultHandler("warning","The captions are enabled and the data-desoslide-caption attribute is missing on a thumb. Add it or disable captions. Check out the documention."),(void 0===t||""===t)&&k.resultHandler("warning","The alt attribute is missing on a thumb, it's mandatory on tags.")},init:function(){k.checks(),k.loadImages(),k.effectHandler(),k.addWrapper(),k.displayImg(),k.events()},loadImages:function(){c.auto.load&&u.find("a").each(function(n,a){e("",{src:a.href,alt:""}).hide().appendTo("body")})},effectHandler:function(){s={fade:{"in":"fadeIn",out:"fadeOut"},sideFade:{"in":"fadeInLeft",out:"fadeOutRight"},sideFadeBig:{"in":"fadeInLeftBig",out:"fadeOutRightBig"},flip:{"in":"flipInX",out:"flipOutX"},light:{"in":"lightSpeedIn",out:"lightSpeedOut"},roll:{"in":"rollIn",out:"rollOut"},rotate:{"in":"rotateIn",out:"rotateOut"}},s.hasOwnProperty(c.effect)||(c.effect=l.effect,k.resultHandler("error",'Incorrect value for the "effect" option. Default value is used. Check out the documentation.'))},outEffect:function(){e(c.main.container).find("img").removeClass("animated "+s[c.effect].in).addClass("animated "+s[c.effect].out),setTimeout(function(){k.displayImg()},900)},addWrapper:function(){var n=e("
",{"class":"desoSlide-wrapper"}),a=e("").addClass(c.main.cssClass).css("opacity",0);switch(c.main.insertion){case"prepend":a.prependTo(e(c.main.container)).wrap(n);break;case"append":a.appendTo(e(c.main.container)).wrap(n);break;case"replace":e(c.main.container).html(a).wrapInner(n);break;default:k.resultHandler("error",'Incorrect value for the "insertion" option. Check out the documentation.')}},addSpinner:function(){d=e("
").addClass("desoSlide-spinner"),e(c.main.container).css("text-align","center").prepend(d)},removeSpinner:function(){d.length&&d.remove()},displayImg:function(){k.resultHandler(),a=0,0>h&&(h=m-1),h>=m&&(h=0),a=h;var n=u.find("a").eq(a).attr("href");t=u.find("img").eq(a).attr("alt"),i=u.find("img").eq(a).data("desoslide-caption"),o=u.find("img").eq(a).data("desoslide-href"),k.checkData(),e(c.main.container).find("img").attr({src:n,alt:t,"data-desoslide-caption":i}).one("load",function(){e(this).removeClass("animated "+s[c.effect].out).addClass("animated "+s[c.effect].in).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){k.addOverlay()}),c.auto.start&&(h++,y=setTimeout(function(){k.outEffect()},g))})},addOverlay:function(){if("none"!==c.overlay){if(c.caption||c.controls.enable){var n=e(c.main.container).find("img").position(),a=parseInt(e(c.main.container).find("img").css("border-left-width"),10),t=e(c.main.container).find("img").width()+a,i=e(c.main.container).find("img").height()+a;0===e(c.main.container).find(".desoSlide-overlay").length&&e("
",{"class":"desoSlide-overlay"}).appendTo(e(c.main.container).find(".desoSlide-wrapper")),v=e(c.main.container).find(".desoSlide-overlay");var o=parseInt(v.css("padding-top").replace("px",""),10),r=parseInt(v.css("padding-bottom").replace("px",""),10),s=parseInt(v.css("padding-left").replace("px",""),10),d=parseInt(v.css("padding-right").replace("px",""),10),l=parseInt(v.css("height").replace("px",""),10)-(s+d);l=parseInt(i,10)-l-(o+r);var p=n.top+l,f=n.left;v.css({left:f+"px",top:p+"px",width:t+"px"}),"always"===c.overlay&&v.animate({opacity:.7},500),c.caption&&(k.updateCaption(),k.addLink())}else k.addLink();c.controls.enable&&k.addControls()}},updateCaption:function(){v.html(i)},addLink:function(){var n=e(c.main.container).find("a.desoslide-link").length>0?!0:!1,a=void 0!==o&&""!==o?!0:!1,t=e("",{"class":"desoslide-link",href:o,target:"_blank"});n&&a?e(c.main.container).find("a.desoslide-link").attr("href",o):n&&!a?e(c.main.container).find("a.desoslide-link").replaceWith(t):!n&&a&&e(c.main.container).find(".desoSlide-wrapper").append(t)},addControls:function(){e(c.main.container).find(".desoSlide-controls-wrapper").remove();var n='',a='',t='',i='',o=e("
",{"class":"desoSlide-controls-wrapper"}).append(n+a+t+i);o.css({width:v.css("width"),left:v.css("left")}),e(c.main.container).find("a.desoslide-link").length>0?o.appendTo(e(c.main.container).find("a.desoslide-link")):o.appendTo(e(c.main.container).find(".desoSlide-wrapper")),r=e(c.main.container).find(".desoSlide-controls-wrapper"),c.auto.start?r.find('a[href="#play"]').hide().parent().find('a[href="#pause"]').show():r.find('a[href="#pause"]').hide().parent().find('a[href="#play"]').show()},pause:function(){c.auto.start&&y&&(c.auto.start=!1,clearTimeout(y),h--,r.find('a[href="#pause"]').hide().parent().find('a[href="#play"]').show())},play:function(){c.auto.start||(c.auto.start=!0,a===h&&h++,k.outEffect(),r.find('a[href="#play"]').hide().parent().find('a[href="#pause"]').show())},resultHandler:function(e,n){if(!w)switch(e){case"error":void 0!==console&&console.error("desoSlide: "+n),c.events.completed&&c.events.completed("error"),w=e;break;case"warning":void 0!==console&&console.warn("desoSlide: "+n),c.events.completed&&c.events.completed("warning");break;default:c.events.completed&&c.events.completed("success")}},events:function(){u.find("a").on("click",function(n){n.preventDefault();var a=e(this),t=a.parent("li").index();t!==h&&(v.animate({opacity:0}),h=t,k.outEffect(),k.pause()),c.events.thumbClick&&c.events.thumbClick()}),u.find("img").on({mouseover:function(){e(this).stop(!0,!0).animate({opacity:.7},"normal")},mouseout:function(){e(this).stop(!0,!0).animate({opacity:1},"fast")}}),"hover"===c.overlay&&e(c.main.container).on({mouseover:function(){v.stop().animate({opacity:.7},400)},mouseleave:function(){v.stop().animate({opacity:0},400)}}),c.controls.enable&&c.controls.keys&&e(document).on("keydown",function(n){switch(n.which){case 37:e(c.main.container).trigger("prev.desoslide");break;case 39:e(c.main.container).trigger("next.desoslide");break;case 32:n.preventDefault(),e(c.main.container).trigger(c.auto.start?"pause.desoslide":"play")}}),e(c.main.container).on("click",".desoSlide-controls-wrapper a",e(c.main.container),function(n){switch(n.preventDefault(),e(this).attr("href")){case"#prev":e(c.main.container).trigger("prev.desoslide");break;case"#pause":e(c.main.container).trigger("pause.desoslide");break;case"#play":e(c.main.container).trigger("play.desoslide");break;case"#next":e(c.main.container).trigger("next.desoslide")}}),e(c.main.container).on("prev.desoslide",function(){k.pause(),h--,k.outEffect(),c.events.prev&&c.events.prev()}),e(c.main.container).on("pause.desoslide",function(){k.pause(),c.events.pause&&c.events.pause()}),e(c.main.container).on("play.desoslide",function(){k.play(),c.events.play&&c.events.play()}),e(c.main.container).on("next.desoslide",function(){k.pause(),h++,k.outEffect(),c.events.next&&c.events.next()}),"none"!==c.overlay&&e(window).bind("resize",function(){p(function(){k.addOverlay()},100)})}};return k.addSpinner(),e(window).load(function(){k.removeSpinner(),k.init()}),this}}(jQuery); \ No newline at end of file +!function(e){"use strict";e.fn.desoSlide=function(n){var a,t,i,o,r,s,d,l={main:{container:!1,cssClass:"",insertion:"append"},auto:{load:!0,start:!1},first:0,interval:3e3,effect:"fade",overlay:"always",caption:!1,controls:{enable:!0,keys:!0},events:{thumbClick:!1,prev:!1,pause:!1,play:!1,next:!1,completed:!1}},c=e.extend(!0,{},l,n),p=function(){var e=0;return function(n,a){clearTimeout(e),e=setTimeout(n,a)}}(),f=this,u=f.find("li"),m=u.length,h=c.first,v=e(c.main.container).find(".desoSlide-overlay"),g=c.interval<1500?1500:c.interval,y=!1,w=!1,k={checks:function(){f.length||k.resultHandler("error",f.selector+" doesn't exist."),c.main.container?e(c.main.container).length||k.resultHandler("error",e(c.main.container).selector+" doesn't exist."):k.resultHandler("error",'You must specify the "main.container" option. Check out the documentation.');var n=["always","hover","none"];-1===n.indexOf(c.overlay)&&k.resultHandler("error",'Incorrect value for the "overlay" option. Check out the documentation.'),h>=m&&(0===m?k.resultHandler("error","You must have at least 1 thumbnail."):k.resultHandler("error",'The "first" option must be between 0 and '+(m-1)+"."))},checkData:function(){!c.caption||void 0!==i&&""!==i||k.resultHandler("warning","The captions are enabled and the data-desoslide-caption attribute is missing on a thumb. Add it or disable captions. Check out the documention."),(void 0===t||""===t)&&k.resultHandler("warning","The alt attribute is missing on a thumb, it's mandatory on tags.")},init:function(){k.checks(),k.loadImages(),k.effectHandler(),k.addWrapper(),k.displayImg(),k.events()},loadImages:function(){c.auto.load&&u.find("a").each(function(n,a){e("",{src:a.href,alt:""}).hide().appendTo("body")})},effectHandler:function(){s={fade:{"in":"fadeIn",out:"fadeOut"},sideFade:{"in":"fadeInLeft",out:"fadeOutRight"},sideFadeBig:{"in":"fadeInLeftBig",out:"fadeOutRightBig"},flip:{"in":"flipInX",out:"flipOutX"},light:{"in":"lightSpeedIn",out:"lightSpeedOut"},roll:{"in":"rollIn",out:"rollOut"},rotate:{"in":"rotateIn",out:"rotateOut"}},s.hasOwnProperty(c.effect)||(c.effect=l.effect,k.resultHandler("error",'Incorrect value for the "effect" option. Default value is used. Check out the documentation.'))},outEffect:function(){e(c.main.container).find("img").removeClass("animated "+s[c.effect].in).addClass("animated "+s[c.effect].out),setTimeout(function(){k.displayImg()},900)},addWrapper:function(){var n=e("
",{"class":"desoSlide-wrapper"}),a=e("").addClass(c.main.cssClass).css("opacity",0);switch(c.main.insertion){case"prepend":a.prependTo(e(c.main.container)).wrap(n);break;case"append":a.appendTo(e(c.main.container)).wrap(n);break;case"replace":e(c.main.container).html(a).wrapInner(n);break;default:k.resultHandler("error",'Incorrect value for the "insertion" option. Check out the documentation.')}},addSpinner:function(){d=e("
").addClass("desoSlide-spinner"),e(c.main.container).css("text-align","center").prepend(d)},removeSpinner:function(){d.length&&d.remove()},displayImg:function(){k.resultHandler(),a=0,0>h&&(h=m-1),h>=m&&(h=0),a=h;var n=u.find("a").eq(a).attr("href");t=u.find("img").eq(a).attr("alt"),i=u.find("img").eq(a).data("desoslide-caption"),o=u.find("img").eq(a).data("desoslide-href"),k.checkData(),e(c.main.container).find("img").attr({src:n,alt:t,"data-desoslide-caption":i}).one("load",function(){e(this).removeClass("animated "+s[c.effect].out).addClass("animated "+s[c.effect].in).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){k.addOverlay()}),c.auto.start&&(h++,y=setTimeout(function(){k.outEffect()},g))})},addOverlay:function(){if("none"!==c.overlay){if(c.caption||c.controls.enable){var n=e(c.main.container).find("img").position(),a=parseInt(e(c.main.container).find("img").css("border-left-width"),10),t=e(c.main.container).find("img").width()+a,i=e(c.main.container).find("img").height()+a;0===e(c.main.container).find(".desoSlide-overlay").length&&e("
",{"class":"desoSlide-overlay"}).appendTo(e(c.main.container).find(".desoSlide-wrapper")),v=e(c.main.container).find(".desoSlide-overlay");var o=parseInt(v.css("padding-top").replace("px",""),10),r=parseInt(v.css("padding-bottom").replace("px",""),10),s=parseInt(v.css("padding-left").replace("px",""),10),d=parseInt(v.css("padding-right").replace("px",""),10),l=parseInt(v.css("height").replace("px",""),10)-(s+d);l=parseInt(i,10)-l-(o+r);var p=n.top+l,f=n.left;v.css({left:f+"px",top:p+"px",width:t+"px"}),"always"===c.overlay&&v.animate({opacity:.7},500),c.caption&&(k.updateCaption(),k.addLink())}else k.addLink();c.controls.enable&&k.addControls()}},updateCaption:function(){v.html(i)},addLink:function(){var n=e(c.main.container).find("a.desoslide-link").length>0?!0:!1,a=void 0!==o&&""!==o?!0:!1,t=e("",{"class":"desoslide-link",href:o,target:"_blank"});n&&a?e(c.main.container).find("a.desoslide-link").attr("href",o):n&&!a?e(c.main.container).find("a.desoslide-link").replaceWith(t):!n&&a&&e(c.main.container).find(".desoSlide-wrapper").append(t)},addControls:function(){e(c.main.container).find(".desoSlide-controls-wrapper").remove();var n='',a='',t='',i='',o=e("
",{"class":"desoSlide-controls-wrapper"}).append(n+a+t+i);o.css({width:v.css("width"),left:v.css("left")}),e(c.main.container).find("a.desoslide-link").length>0?o.appendTo(e(c.main.container).find("a.desoslide-link")):o.appendTo(e(c.main.container).find(".desoSlide-wrapper")),r=e(c.main.container).find(".desoSlide-controls-wrapper"),r.length&&(c.auto.start?r.find('a[href="#play"]').hide().parent().find('a[href="#pause"]').show():r.find('a[href="#pause"]').hide().parent().find('a[href="#play"]').show())},pause:function(){c.auto.start&&y&&(c.auto.start=!1,clearTimeout(y),h--,r&&r.find('a[href="#pause"]').hide().parent().find('a[href="#play"]').show())},play:function(){c.auto.start||(c.auto.start=!0,a===h&&h++,k.outEffect(),r&&r.find('a[href="#play"]').hide().parent().find('a[href="#pause"]').show())},resultHandler:function(e,n){if(!w)switch(e){case"error":void 0!==console&&console.error("desoSlide: "+n),c.events.completed&&c.events.completed("error"),w=e;break;case"warning":void 0!==console&&console.warn("desoSlide: "+n),c.events.completed&&c.events.completed("warning");break;default:c.events.completed&&c.events.completed("success")}},events:function(){u.find("a").on("click",function(n){n.preventDefault();var a=e(this),t=a.parent("li").index();t!==h&&(v.animate({opacity:0}),h=t,k.outEffect(),k.pause()),c.events.thumbClick&&c.events.thumbClick()}),u.find("img").on({mouseover:function(){e(this).stop(!0,!0).animate({opacity:.7},"normal")},mouseout:function(){e(this).stop(!0,!0).animate({opacity:1},"fast")}}),"hover"===c.overlay&&e(c.main.container).on({mouseover:function(){v.stop().animate({opacity:.7},400)},mouseleave:function(){v.stop().animate({opacity:0},400)}}),c.controls.enable&&c.controls.keys&&e(document).on("keydown",function(n){switch(n.which){case 37:e(c.main.container).trigger("prev.desoslide");break;case 39:e(c.main.container).trigger("next.desoslide");break;case 32:n.preventDefault(),e(c.main.container).trigger(c.auto.start?"pause.desoslide":"play")}}),e(c.main.container).on("click",".desoSlide-controls-wrapper a",e(c.main.container),function(n){switch(n.preventDefault(),e(this).attr("href")){case"#prev":e(c.main.container).trigger("prev.desoslide");break;case"#pause":e(c.main.container).trigger("pause.desoslide");break;case"#play":e(c.main.container).trigger("play.desoslide");break;case"#next":e(c.main.container).trigger("next.desoslide")}}),e(c.main.container).on("prev.desoslide",function(){k.pause(),h--,k.outEffect(),c.events.prev&&c.events.prev()}),e(c.main.container).on("pause.desoslide",function(){k.pause(),c.events.pause&&c.events.pause()}),e(c.main.container).on("play.desoslide",function(){k.play(),c.events.play&&c.events.play()}),e(c.main.container).on("next.desoslide",function(){k.pause(),h++,k.outEffect(),c.events.next&&c.events.next()}),"none"!==c.overlay&&e(window).bind("resize",function(){p(function(){k.addOverlay()},100)})}};return k.addSpinner(),e(window).load(function(){k.removeSpinner(),k.init()}),this}}(jQuery); \ No newline at end of file diff --git a/index.html b/index.html index 5d4fea3..4204973 100644 --- a/index.html +++ b/index.html @@ -74,7 +74,7 @@

... with thumbnails!

Download -
  • Version 1.2.3
  • +
  • Version 1.2.3.1