mirror of
https://github.com/github/choosealicense.com
synced 2024-11-10 13:38:53 +01:00
7 lines
3.3 KiB
JavaScript
7 lines
3.3 KiB
JavaScript
/* qTip2 v2.2.0 tips modal viewport svg imagemap ie6 | qtip2.com | Licensed MIT, GPL | Mon Nov 25 2013 11:54:49 */
|
|
/*!
|
|
* imagesLoaded v3.0.4
|
|
* JavaScript is all like "You images are done yet or what?"
|
|
*/
|
|
(function(t){"use strict";function e(t,e){for(var i in e)t[i]=e[i];return t}function i(t){return"[object Array]"===h.call(t)}function s(t){var e=[];if(i(t))e=t;else if("number"==typeof t.length)for(var s=0,o=t.length;o>s;s++)e.push(t[s]);else e.push(t);return e}function o(t,i){function o(t,i,r){if(!(this instanceof o))return new o(t,i);"string"==typeof t&&(t=document.querySelectorAll(t)),this.elements=s(t),this.options=e({},this.options),"function"==typeof i?r=i:e(this.options,i),r&&this.on("always",r),this.getImages(),n&&(this.jqDeferred=new n.Deferred);var a=this;setTimeout(function(){a.check()})}function h(t){this.img=t}o.prototype=new t,o.prototype.options={},o.prototype.getImages=function(){this.images=[];for(var t=0,e=this.elements.length;e>t;t++){var i=this.elements[t];"IMG"===i.nodeName&&this.addImage(i);for(var s=i.querySelectorAll("img"),o=0,n=s.length;n>o;o++){var r=s[o];this.addImage(r)}}},o.prototype.addImage=function(t){var e=new h(t);this.images.push(e)},o.prototype.check=function(){function t(t,o){return e.options.debug&&a&&r.log("confirm",t,o),e.progress(t),i++,i===s&&e.complete(),!0}var e=this,i=0,s=this.images.length;if(this.hasAnyBroken=!1,!s)return this.complete(),void 0;for(var o=0;s>o;o++){var n=this.images[o];n.on("confirm",t),n.check()}},o.prototype.progress=function(t){this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded;var e=this;setTimeout(function(){e.emit("progress",e,t),e.jqDeferred&&e.jqDeferred.notify(e,t)})},o.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var e=this;setTimeout(function(){if(e.emit(t,e),e.emit("always",e),e.jqDeferred){var i=e.hasAnyBroken?"reject":"resolve";e.jqDeferred[i](e)}})},n&&(n.fn.imagesLoaded=function(t,e){var i=new o(this,t,e);return i.jqDeferred.promise(n(this))});var l={};return h.prototype=new t,h.prototype.check=function(){var t=l[this.img.src];if(t)return this.useCached(t),void 0;if(l[this.img.src]=this,this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var e=this.proxyImage=new Image;i.bind(e,"load",this),i.bind(e,"error",this),e.src=this.img.src},h.prototype.useCached=function(t){if(t.isConfirmed)this.confirm(t.isLoaded,"cached was confirmed");else{var e=this;t.on("confirm",function(t){return e.confirm(t.isLoaded,"cache emitted confirmed"),!0})}},h.prototype.confirm=function(t,e){this.isConfirmed=!0,this.isLoaded=t,this.emit("confirm",this,e)},h.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},h.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindProxyEvents()},h.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindProxyEvents()},h.prototype.unbindProxyEvents=function(){i.unbind(this.proxyImage,"load",this),i.unbind(this.proxyImage,"error",this)},o}var n=t.jQuery,r=t.console,a=r!==void 0,h=Object.prototype.toString;"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],o):t.imagesLoaded=o(t.EventEmitter,t.eventie)})(window);
|
|
//@ sourceMappingURL=http://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/imagesloaded.pkg.min.map
|