diff --git a/Gruntfile.js b/Gruntfile.js index 3756442..6031338 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -78,6 +78,6 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-remove-logging"); //register the task - grunt.registerTask('default', ['concat', 'removelogging', 'uglify']); + grunt.registerTask('build', ['concat', 'removelogging', 'uglify']); grunt.registerTask('dev-watching', ['concat:dist']); }; \ No newline at end of file diff --git a/bower.json b/bower.json index 1ab1f3f..bbc32fc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "QueryLoader2", - "version": "2.8", + "version": "2.8.2", "homepage": "http://www.gayadesign.com/diy/queryloader2-preload-your-images-with-ease/", "authors": [ "Gaya " diff --git a/jquery.queryloader2.js b/jquery.queryloader2.js index 646981c..731dac6 100644 --- a/jquery.queryloader2.js +++ b/jquery.queryloader2.js @@ -9,8 +9,8 @@ * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Version: 2.8.1 - * Last update: 2013-11-21 + * Version: 2.8.2 + * Last update: 2013-12-05 */ (function($){function OverlayLoader(parent) { this.parent = parent; @@ -332,7 +332,7 @@ QueryLoader2.prototype.endLoader = function () { QueryLoader2.prototype.onLoadComplete = function() { if (this.options.completeAnimation == "grow") { - var animationTime = 500; + var animationTime = this.options.minimumTime; this.overlayLoader.loadbar[0].parent = this; //put object in DOM element this.overlayLoader.loadbar.stop().animate({ diff --git a/jquery.queryloader2.min.js b/jquery.queryloader2.min.js index 6ef4f0a..170156d 100644 --- a/jquery.queryloader2.min.js +++ b/jquery.queryloader2.min.js @@ -9,7 +9,7 @@ * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Version: 2.8.1 - * Last update: 2013-11-21 + * Version: 2.8.2 + * Last update: 2013-12-05 */ -!function(a){function b(a){this.parent=a,this.container,this.loadbar,this.percentageContainer}function c(a){this.toPreload=[],this.parent=a,this.container}function d(a){this.element,this.parent=a}function e(d,e){this.element=d,this.$element=a(d),this.options=e,this.foundUrls=[],this.destroyed=!1,this.imageCounter=0,this.imageDone=0,this.alreadyLoaded=!1,this.preloadContainer=new c(this),this.overlayLoader=new b(this),this.defaultOptions={onComplete:function(){},backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",barHeight:1,percentage:!1,deepSearch:!0,completeAnimation:"fade",minimumTime:500},this.init()}b.prototype.createOverlay=function(){var b="absolute";if("body"==this.parent.element.tagName.toLowerCase())b="fixed";else{var c=this.parent.$element.css("position");("fixed"!=c||"absolute"!=c)&&this.parent.$element.css("position","relative")}this.container=a("
").css({width:"100%",height:"100%",backgroundColor:this.parent.options.backgroundColor,backgroundPosition:"fixed",position:b,zIndex:666999,top:0,left:0}).appendTo(this.parent.$element),this.loadbar=a("
").css({height:this.parent.options.barHeight+"px",marginTop:"-"+this.parent.options.barHeight/2+"px",backgroundColor:this.parent.options.barColor,width:"0%",position:"absolute",top:"50%"}).appendTo(this.container),1==this.parent.options.percentage&&(this.percentageContainer=a("
").text("0%").css({height:"40px",width:"100px",position:"absolute",fontSize:"3em",top:"50%",left:"50%",marginTop:"-"+(59+this.parent.options.barHeight)+"px",textAlign:"center",marginLeft:"-50px",color:this.parent.options.barColor}).appendTo(this.container)),this.parent.preloadContainer.toPreload.length&&1!=this.parent.alreadyLoaded||this.parent.destroyContainers()},b.prototype.updatePercentage=function(a){this.loadbar.stop().animate({width:a+"%",minWidth:a+"%"},200),1==this.parent.options.percentage&&this.percentageContainer.text(Math.ceil(a)+"%")},c.prototype.create=function(){this.container=a("
").appendTo("body").css({display:"none",width:0,height:0,overflow:"hidden"}),this.processQueue()},c.prototype.processQueue=function(){for(var a=0;this.toPreload.length>a;a++)this.parent.destroyed||this.preloadImage(this.toPreload[a])},c.prototype.addImage=function(a){this.toPreload.push(a)},c.prototype.preloadImage=function(a){var b=new d;b.addToPreloader(this,a),b.bindLoadEvent()},d.prototype.addToPreloader=function(b,c){this.element=a("").attr("src",c),this.element.appendTo(b.container),this.parent=b.parent},d.prototype.bindLoadEvent=function(){this.parent.imageCounter++;var a=this.element.attr("src");this.element.removeAttr("src");var b=this;setTimeout(function(){b.element.on("load error",b,function(a){a.data.completeLoading()}),b.element.attr("src",a)},1)},d.prototype.completeLoading=function(){this.parent.imageDone++;var a=100*(this.parent.imageDone/this.parent.imageCounter);this.parent.overlayLoader.updatePercentage(a),this.parent.imageDone==this.parent.imageCounter&&this.parent.endLoader()},e.prototype.init=function(){if(this.options=a.extend({},this.defaultOptions,this.options),this.findImageInElement(this.element),1==this.options.deepSearch)for(var b=this.$element.find("*:not(script)"),c=0;c0&&!a.match(/^(data:)/i)?!0:!1},e.prototype.urlIsNew=function(a){return-1==this.foundUrls.indexOf(a)?!0:!1},e.prototype.destroyContainers=function(){this.destroyed=!0,this.preloadContainer.container.remove(),this.overlayLoader.container.remove()},e.prototype.endLoader=function(){this.destroyed=!0,this.onLoadComplete()},e.prototype.onLoadComplete=function(){if("grow"==this.options.completeAnimation){var b=500;this.overlayLoader.loadbar[0].parent=this,this.overlayLoader.loadbar.stop().animate({width:"100%"},b,function(){a(this).animate({top:"0%",width:"100%",height:"100%"},500,function(){this.parent.overlayLoader.container[0].parent=this.parent,this.parent.overlayLoader.container.fadeOut(500,function(){this.parent.destroyContainers(),this.parent.options.onComplete()})})})}else this.overlayLoader.container[0].parent=this,this.overlayLoader.container.fadeOut(500,function(){this.parent.destroyContainers(),this.parent.options.onComplete()})},Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length>>>0,c=Number(arguments[1])||0;for(c=0>c?Math.ceil(c):Math.floor(c),0>c&&(c+=b);b>c;c++)if(c in this&&this[c]===a)return c;return-1}),a.fn.queryLoader2=function(a){return this.each(function(){new e(this,a)})}}(jQuery); \ No newline at end of file +!function(a){function b(a){this.parent=a,this.container,this.loadbar,this.percentageContainer}function c(a){this.toPreload=[],this.parent=a,this.container}function d(a){this.element,this.parent=a}function e(d,e){this.element=d,this.$element=a(d),this.options=e,this.foundUrls=[],this.destroyed=!1,this.imageCounter=0,this.imageDone=0,this.alreadyLoaded=!1,this.preloadContainer=new c(this),this.overlayLoader=new b(this),this.defaultOptions={onComplete:function(){},backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",barHeight:1,percentage:!1,deepSearch:!0,completeAnimation:"fade",minimumTime:500},this.init()}b.prototype.createOverlay=function(){var b="absolute";if("body"==this.parent.element.tagName.toLowerCase())b="fixed";else{var c=this.parent.$element.css("position");("fixed"!=c||"absolute"!=c)&&this.parent.$element.css("position","relative")}this.container=a("
").css({width:"100%",height:"100%",backgroundColor:this.parent.options.backgroundColor,backgroundPosition:"fixed",position:b,zIndex:666999,top:0,left:0}).appendTo(this.parent.$element),this.loadbar=a("
").css({height:this.parent.options.barHeight+"px",marginTop:"-"+this.parent.options.barHeight/2+"px",backgroundColor:this.parent.options.barColor,width:"0%",position:"absolute",top:"50%"}).appendTo(this.container),1==this.parent.options.percentage&&(this.percentageContainer=a("
").text("0%").css({height:"40px",width:"100px",position:"absolute",fontSize:"3em",top:"50%",left:"50%",marginTop:"-"+(59+this.parent.options.barHeight)+"px",textAlign:"center",marginLeft:"-50px",color:this.parent.options.barColor}).appendTo(this.container)),this.parent.preloadContainer.toPreload.length&&1!=this.parent.alreadyLoaded||this.parent.destroyContainers()},b.prototype.updatePercentage=function(a){this.loadbar.stop().animate({width:a+"%",minWidth:a+"%"},200),1==this.parent.options.percentage&&this.percentageContainer.text(Math.ceil(a)+"%")},c.prototype.create=function(){this.container=a("
").appendTo("body").css({display:"none",width:0,height:0,overflow:"hidden"}),this.processQueue()},c.prototype.processQueue=function(){for(var a=0;this.toPreload.length>a;a++)this.parent.destroyed||this.preloadImage(this.toPreload[a])},c.prototype.addImage=function(a){this.toPreload.push(a)},c.prototype.preloadImage=function(a){var b=new d;b.addToPreloader(this,a),b.bindLoadEvent()},d.prototype.addToPreloader=function(b,c){this.element=a("").attr("src",c),this.element.appendTo(b.container),this.parent=b.parent},d.prototype.bindLoadEvent=function(){this.parent.imageCounter++;var a=this.element.attr("src");this.element.removeAttr("src");var b=this;setTimeout(function(){b.element.on("load error",b,function(a){a.data.completeLoading()}),b.element.attr("src",a)},1)},d.prototype.completeLoading=function(){this.parent.imageDone++;var a=100*(this.parent.imageDone/this.parent.imageCounter);this.parent.overlayLoader.updatePercentage(a),this.parent.imageDone==this.parent.imageCounter&&this.parent.endLoader()},e.prototype.init=function(){if(this.options=a.extend({},this.defaultOptions,this.options),this.findImageInElement(this.element),1==this.options.deepSearch)for(var b=this.$element.find("*:not(script)"),c=0;c0&&!a.match(/^(data:)/i)?!0:!1},e.prototype.urlIsNew=function(a){return-1==this.foundUrls.indexOf(a)?!0:!1},e.prototype.destroyContainers=function(){this.destroyed=!0,this.preloadContainer.container.remove(),this.overlayLoader.container.remove()},e.prototype.endLoader=function(){this.destroyed=!0,this.onLoadComplete()},e.prototype.onLoadComplete=function(){if("grow"==this.options.completeAnimation){var b=this.options.minimumTime;this.overlayLoader.loadbar[0].parent=this,this.overlayLoader.loadbar.stop().animate({width:"100%"},b,function(){a(this).animate({top:"0%",width:"100%",height:"100%"},500,function(){this.parent.overlayLoader.container[0].parent=this.parent,this.parent.overlayLoader.container.fadeOut(500,function(){this.parent.destroyContainers(),this.parent.options.onComplete()})})})}else this.overlayLoader.container[0].parent=this,this.overlayLoader.container.fadeOut(500,function(){this.parent.destroyContainers(),this.parent.options.onComplete()})},Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length>>>0,c=Number(arguments[1])||0;for(c=0>c?Math.ceil(c):Math.floor(c),0>c&&(c+=b);b>c;c++)if(c in this&&this[c]===a)return c;return-1}),a.fn.queryLoader2=function(a){return this.each(function(){new e(this,a)})}}(jQuery); \ No newline at end of file diff --git a/package.json b/package.json index 33fe258..31095cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery.queryloader2", - "version": "2.8.1", + "version": "2.8.2", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-uglify": "~0.2.2", diff --git a/src/QueryLoader.js b/src/QueryLoader.js index 94067e7..c96c5b8 100644 --- a/src/QueryLoader.js +++ b/src/QueryLoader.js @@ -157,7 +157,7 @@ QueryLoader2.prototype.endLoader = function () { QueryLoader2.prototype.onLoadComplete = function() { if (this.options.completeAnimation == "grow") { - var animationTime = 500; + var animationTime = this.options.minimumTime; this.overlayLoader.loadbar[0].parent = this; //put object in DOM element this.overlayLoader.loadbar.stop().animate({