PHP Classes

File: plugins/EagerImageLoader/eager-image-loader.min.js

Recommend this page to a friend!
  Classes of Laudir Bispo   PHP Real Estate Website   plugins/EagerImageLoader/eager-image-loader.min.js   Download  
File: plugins/EagerImageLoader/eager-image-loader.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Real Estate Website
Manage the properties of a real estate business
Author: By
Last change:
Date: 3 years ago
Size: 3,913 bytes
 

Contents

Class file image Download
!function(t,e){"use strict";function n(n,a){function o(){function e(e,n){var a;if(e){if("string"==typeof e)return s(document.querySelectorAll(e));if("object"==typeof e||"function"==typeof e){if(a=Object.prototype.toString.call(e),"[object NodeList]"===a||"[object HTMLCollection]"===a||"[object Elements]"===a)return s(e);if(e instanceof HTMLElement||!n&&e.element)return[e]}}return t.console.warn("Couldn't get element."),t.console.warn(e),[]}function a(e){function n(t){var e=Object.getPrototypeOf(t);return e.hasOwnProperty("src")||t.hasOwnProperty("src")?"src":e.hasOwnProperty("data")||t.hasOwnProperty("data")?"data":"background"}var a=e.element,o=n(a),r=e[o]||(a.dataset?a.dataset[o]:a.getAttribute("data-"+o));return r?(e._attrName=o,e._url=r,!0):(t.console.warn("Couldn't get URL."),t.console.warn(e),!1)}function o(e){return c.indexOf(e)>-1?(t.console.warn("Element was specified in duplicate."),t.console.warn(e),!1):(c.push(e),!0)}var s=Function.prototype.call.bind(Array.prototype.slice),c=[];r.targets=[],(Array.isArray(n)?n:e(n||"[data-src],[data-data],[data-background]")).forEach(function(n){var s=[];(Array.isArray(n)?n:[n]).forEach(function(t){var n,r=t;t&&"object"==typeof t&&t.element&&(r=t.element,n=t),e(r,!0).forEach(function(t){var e={element:t};n&&(e=["src","data","background","start","load","error","abort","stopLoading"].reduce(function(t,e){return t[e]=n[e],t},e)),a(e)&&o(e.element)&&s.push(e)})}),s.length?r.targets.push({imageTargets:s}):(t.console.warn("Couldn't get any element in a step."),t.console.warn(n))}),r.targets.length?(r.stepIndex=0,r.options.autoStart&&r.start()):r.done=!0}var r=this;r.options=Object.keys(i).reduce(function(t,n){return t[n]===e&&(t[n]=i[n]),t},a||{}),r.stepIndex=-1,r.done=r.stopped=!1,"complete"===document.readyState?o():document.addEventListener("DOMContentLoaded",o,!1)}function a(t){return null!=t?(t+"").replace(d,""):""}function o(t,e){var n=t.className,o=n?(" "+n+" ").replace(u," "):" ";return((e||"").match(l)||[]).forEach(function(t){o.indexOf(" "+t+" ")<0&&(o+=t+" ")}),o=a(o),o!==n&&(t.className=o),t}function r(t,e){var n=t.className,o=n?(" "+n+" ").replace(u," "):"";return o&&(e?((e.match(l)||[]).forEach(function(t){for(;o.indexOf(" "+t+" ")>=0;)o=o.replace(" "+t+" "," ")}),o=a(o)):o="",o!==n&&(t.className=o)),t}function s(t){var e=t.targets[t.stepIndex];t.done||t.stopped||e.started||(e.started=!0,e.imageTargets.forEach(function(n){function a(a){"load"===a.type&&("src"===n._attrName||"data"===n._attrName?n.element[n._attrName]=i.src:n.element.style.backgroundImage='url("'+i.src+'")'),i=null,t.options.loadingClass&&r(n.element,t.options.loadingClass),n.endTime=Date.now(),n[a.type]&&(a.imageTarget=n,a.eagerImageLoader=t,n[a.type](a)),e.imageTargets.every(function(t){return!!t.endTime})&&(t.stepIndex>=t.targets.length-1?(t.done=!0,t.options.complete&&t.options.complete.call(t)):(t.stepIndex++,setTimeout(function(){s(t)},0)))}var i=new Image;n.stopLoading&&t.stop(),t.options.loadingClass&&o(n.element,t.options.loadingClass),n.startTime=Date.now(),n.start&&n.start(c("start",{imageTarget:n,eagerImageLoader:t})),["load","error","abort"].forEach(function(t){i.addEventListener(t,a,!1)}),i.src=n._url}))}function c(t,e){var n,a=[function(){n=new Event(t,{bubbles:!1,cancelable:!1})},function(){n=new CustomEvent(t)},function(){n=document.createEvent("Event"),n.initEvent(t,!1,!1)},function(){n=document.createEvent("CustomEvent"),n.initCustomEvent(t,!1,!1,null)}];return a.some(function(t){try{return t(),!0}catch(e){}})||(n={type:t}),Object.keys(e).forEach(function(t){n[t]=e[t]}),n}var i={autoStart:!0,loadingClass:"loading"},u=/[\t\r\n\f]/g,l=/\S+/g,d=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;n.prototype.start=function(){return this.done||(this.stopped=!1,this.stepIndex>=0?s(this):this.options.autoStart=!0),this},n.prototype.stop=function(){return this.stopped=!0,this},t.EagerImageLoader=n}(Function("return this")());