1/** 2 * @preserve Create and manage a DOM event delegator. 3 * 4 * @version 0.1.3 5 * @codingstandard ftlabs-jsv2 6 * @copyright The Financial Times Limited [All Rights Reserved] 7 * @license MIT License (see LICENSE.txt) 8 */(function(){"use strict";function Delegate(root){var self=this;root&&this.root(root),this.listenerMap={},this.handle=function(event){Delegate.prototype.handle.call(self,event)}}Delegate.tagsCaseSensitive=null,Delegate.prototype.root=function(root){var listenerMap=this.listenerMap,eventType;if(typeof root=="string"&&(root=document.querySelector(root)),this.rootElement)for(eventType in listenerMap)listenerMap.hasOwnProperty(eventType)&&this.rootElement.removeEventListener(eventType,this.handle,this.captureForType(eventType));if(!root||!root.addEventListener){this.rootElement&&delete this.rootElement;return}this.rootElement=root;for(eventType in listenerMap)listenerMap.hasOwnProperty(eventType)&&this.rootElement.addEventListener(eventType,this.handle,this.captureForType(eventType))},Delegate.prototype.captureForType=function(eventType){return eventType==="error"},Delegate.prototype.on=function(eventType,selector,handler,eventData){var root,listenerMap,matcher,matcherParam,self=this,SEPARATOR=" ";if(!eventType)throw new TypeError("Invalid event type: "+eventType);if(!selector)throw new TypeError("Invalid selector: "+selector);if(eventType.indexOf(SEPARATOR)!==-1)return eventType.split(SEPARATOR).forEach(function(singleEventType){self.on(singleEventType,selector,handler,eventData)}),this;if(eventData===void 0&&(eventData=null),typeof handler!="function")throw new TypeError("Handler must be a type of Function");return root=this.rootElement,listenerMap=this.listenerMap,listenerMap[eventType]||(root&&root.addEventListener(eventType,this.handle,this.captureForType(eventType)),listenerMap[eventType]=[]),/^[a-z]+$/i.test(selector)?(Delegate.tagsCaseSensitive===null&&(Delegate.tagsCaseSensitive=document.createElement("i").tagName==="i"),Delegate.tagsCaseSensitive?matcherParam=selector:matcherParam=selector.toUpperCase(),matcher=this.matchesTag):/^#[a-z0-9\-_]+$/i.test(selector)?(matcherParam=selector.slice(1),matcher=this.matchesId):(matcherParam=selector,matcher=this.matches),listenerMap[eventType].push({selector:selector,eventData:eventData,handler:handler,matcher:matcher,matcherParam:matcherParam}),this},Delegate.prototype.off=function(eventType,selector,handler){var i,listener,listenerMap,listenerList,singleEventType,self=this,SEPARATOR=" ";if(listenerMap=this.listenerMap,!eventType){for(singleEventType in listenerMap)listenerMap.hasOwnProperty(singleEventType)&&this.off(singleEventType,selector,handler);return this}if(listenerList=listenerMap[eventType],!listenerList||!listenerList.length)return this;if(eventType.indexOf(SEPARATOR)!==-1)return eventType.split(SEPARATOR).forEach(function(singleEventType2){self.off(singleEventType2,selector,handler)}),this;for(i=listenerList.length-1;i>=0;i--)listener=listenerList[i],(!selector||selector===listener.selector)&&(!handler||handler===listener.handler)&&listenerList.splice(i,1);return listenerList.length||(delete listenerMap[eventType],this.rootElement&&this.rootElement.removeEventListener(eventType,this.handle,this.captureForType(eventType))),this},Delegate.prototype.handle=function(event){var i,l,root,listener,returned,listenerList,target,EVENTIGNORE="ftLabsDelegateIgnore";if(event[EVENTIGNORE]!==!0)for(target=event.target,target.nodeType===Node.TEXT_NODE&&(target=target.parentNode),root=this.rootElement,listenerList=this.listenerMap[event.type],l=listenerList.length;target&&l;){for(i=0;i<l&&(listener=listenerList[i],!!listener);i++)if(listener.matcher.call(target,listener.matcherParam,target)&&(returned=this.fire(event,target,listener)),returned===!1){event[EVENTIGNORE]=!0;return}if(target===root)break;l=listenerList.length,target=target.parentElement}},Delegate.prototype.fire=function(event,target,listener){var returned,oldData;return listener.eventData!==null?(oldData=event.data,event.data=listener.eventData,returned=listener.handler.call(target,event,target),event.data=oldData):returned=listener.handler.call(target,event,target),returned},Delegate.prototype.matches=(function(p){return p.matchesSelector||p.webkitMatchesSelector||p.mozMatchesSelector||p.msMatchesSelector||p.oMatchesSelector})(HTMLElement.prototype),Delegate.prototype.matchesTag=function(tagName,element){return tagName===element.tagName},Delegate.prototype.matchesId=function(id,element){return id===element.i
8d},Delegate.prototype.destroy=function(){this.off(),this.root()},typeof module=="object"?(module.exports=function(root){return new Delegate(root)},module.exports.Delegate=Delegate):typeof define=="function"&&define.amd?define(function(){return Delegate}):window.Delegate=Delegate})(); 9//# sourceMappingURL=/cdn/shop/t/10/assets/delegate.js.map?v=147957583492646605101738990135
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.