%PDF- %PDF-
Direktori : /proc/self/root/home/infra/fusioninventory/lib/lazy.js-0.5.1/ |
Current File : //proc/self/root/home/infra/fusioninventory/lib/lazy.js-0.5.1/lazy.browser.min.js |
(function(Lazy){function DomSequence(source){this.source=source}DomSequence.prototype=new Lazy.ArrayLikeSequence;DomSequence.prototype.get=function(i){return this.source[i]};DomSequence.prototype.length=function(){return this.source.length};DomSequence.prototype.flatten=function(){return new FlattenedDomSequence(this.source)};function FlattenedDomSequence(source){this.source=source}FlattenedDomSequence.prototype=new Lazy.Sequence;FlattenedDomSequence.prototype.each=function(fn){var i=0,done=false;Lazy(this.source).each(function(child){if(fn(child,i++)===false){return false}Lazy(child.children).flatten().each(function(descendent){if(fn(descendent,i++)===false){done=true;return false}});if(done){return false}})};DomSequence.prototype.on=function(eventName){return new DomEventSequence(this.source,eventName)};function DomEventSequence(elements,eventName){this.elements=elements;this.eventName=eventName}DomEventSequence.prototype=new Lazy.Sequence;DomEventSequence.prototype.each=function(fn){var elements=this.elements,eventName=this.eventName;var listener=function(e){if(fn(e)===false){for(var i=0;i<elements.length;++i){elements[i].removeEventListener(eventName,listener)}}};for(var i=0;i<elements.length;++i){elements[i].addEventListener(this.eventName,listener)}};Lazy.events=Lazy.deprecate("Lazy.events is deprecated. Use Lazy(element[s]).on('event') instead",function(element,eventName){return new DomEventSequence(element,eventName)});function StreamingHttpSequence(url){this.url=url}StreamingHttpSequence.prototype=new Lazy.StreamLikeSequence;StreamingHttpSequence.prototype.each=function each(fn){var request=new XMLHttpRequest,index=0,aborted=false;request.open("GET",this.url);var handle=new Lazy.AsyncHandle;var listener=function listener(data){if(!aborted){data=request.responseText.substring(index);try{if(fn(data)===false){request.removeEventListener("progress",listener,false);request.abort();aborted=true;handle._resolve(false)}index+=data.length}catch(e){handle._reject(e)}}};request.addEventListener("progress",listener,false);request.addEventListener("load",function(){handle._resolve(true)});request.send();return handle};Lazy.makeHttpRequest=function(url){return new StreamingHttpSequence(url)};Lazy.extensions||(Lazy.extensions=[]);Lazy.extensions.push(function(source){if(source instanceof NodeList||source instanceof HTMLCollection){return new DomSequence(source)}else if(source instanceof Element){return new DomSequence([source])}})})(window.Lazy);