1(function(){if(!window.CrossPageLoadBar)window.CrossPageLoadBar={} 2function supported(){var isOpera=!!(window.opera&&window.opera.version)||navigator.userAgent.indexOf(' OPR/')>=0;var isFirefox=typeof InstallTrigger!=='undefined';var isSafari=Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor')>0;var isChrome=!!window.chrome&&!isOpera;var isIE=false||!!document.documentMode;if(!isChrome&&!isFirefox&&!isOpera&&!isIE)return false;if(!window.sessionStorage||!window.sessionStorage.setItem)return false;return true;} 3window.CrossPageLoadBar.init=function(options){$('body').append('<div id="crosspageloadbar-container"><div id="crosspageloadbar-percentage"></div></div>');var timer=null;var el_window=$(window);var el_container=$('#crosspageloadbar-container');var el_percentage=$('#crosspageloadbar-percentage');var settings={container_opacity:1,fadeto_opacity:0.1,enable_crossload:true,enable_ajax:false,enable_pjax:false,enable_filedownload:false,filedownload_anchor_selector:null,idle_msec:1500,fadeout_msec:1000,inc_msec:6000,downloadfile_msec:1500,};if(options){for(key in options){settings[key]=options[key];}} 4function __timeout(fcall){if(timer)clearTimeout(timer);timer=setTimeout(fcall,settings.idle_msec);} 5window.CrossPageLoadBar._perc=function(offset){return Math.max(0,Math.min(100,(offset||0)+(el_percentage.width()*100)/el_window.width()));} 6window.CrossPageLoadBar.show=function(percentage){el_container.stop(true,false).css({opacity:settings.container_opacity}).show();el_percentage.stop(true,false).css({width:percentage+'%'});return this;};window.CrossPageLoadBar.inc=function(perc,complete,speed_msec){el_percentage.stop(true,false).animate({width:Math.max(window.CrossPageLoadBar._perc(),perc)+'%'},speed_msec||settings.inc_msec,function(){complete&&complete(perc);});return this;};window.CrossPageLoadBar.hide=function(complete,speed_msec){if(timer){clearTimeout(timer);timer;} 7if(!el_container.is(':visible'))return;el_percentage.stop(true,false).animate({width:'100%'});el_container.fadeTo(speed_msec||settings.fadeout_msec,settings.fadeto_opacity,function(){el_container.hide();complete&&complete();});return this;};if(supported()){var skip_on_beforeunload=false;if(settings.enable_crossload){var oldbeforeunload=window.onbeforeunload;window.onbeforeunload=function(){if(oldbeforeunload){var ret=oldbeforeunload();if(ret)return ret;} 8if(skip_on_beforeunload){skip_on_beforeunload=false;return;} 9__timeout(function(){window.CrossPageLoadBar.show(0).inc(35);});} 10var oldunload=window.onpagehide;window.onpagehide=function(){if(oldunload)oldunload();el_percentage.stop(true,false);try{window.sessionStorage.setItem('crosspageloadbar-state',window.CrossPageLoadBar._perc());} 11catch(err){}} 12try{var previous_state=window.sessionStorage.getItem('crosspageloadbar-state')||0;if(previous_state>0){window.sessionStorage.setItem('crosspageloadbar-state',0);window.CrossPageLoadBar.show(previous_state).inc(60);var oldonload=window.onload;window.onload=function(){if(oldonload)oldonload();window.CrossPageLoadBar.hide();}}} 13catch(err){}} 14if(settings.enable_ajax){$(document).ajaxStart(function(){__timeout(function(){window.CrossPageLoadBar.show(0).inc(50);});});$(document).ajaxComplete(function(){window.CrossPageLoadBar.hide();});} 15if(settings.enable_pjax){$(document).on('pjax:start',function(){__timeout(function(){window.CrossPageLoadBar.show(0).inc(50);});});$(document).on('pjax:end',function(){window.CrossPageLoadBar.hide();});} 16if(settings.enable_filedownload&&settings.filedownload_anchor_selector){$(document).ready(function(){$(document).delegate(settings.filedownload_anchor_selector,'click',function(event){var url=$(this).attr('href');if(!url||(url&&!url.length)){skip_on_beforeunload=true;return;} 17event&&event.preventDefault();var hidden_iframe_id='crosspageloadbar-hidden-iframe';$('#'+hidden_iframe_id).remove();var iframe=document.createElement('iframe');iframe.id=hidden_iframe_id;iframe.style.display='none';window.CrossPageLoadBar.show(0).inc(25,function(){window.CrossPageLoadBar.hide();},settings.downloadfile_msec);iframe.src=url;document.body.appendChild(iframe);});});}} 18return this;}})();;(function(){var root=this;var previousUnderscore=root._;var ArrayProto=Array.prototype,ObjProto=Object.prototype,FuncProto=Function.prototype;var 19push=ArrayProto.push,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty;var 20nativeIsArray=Array.isArray,nativeKeys=Object.keys,nativeBind=FuncProto.bind,nativeCreate=Object.create;var Ctor=function(){};
vendor: 25,514 bytes, lines 20-81
20var _=function(obj){if(obj instanceof _)return obj;if(!(this instanceof _))return new _(obj);this._wrapped=obj;};if(typeof exports!=='undefined'){if(typeof module!=='undefined'&&module.exports){exports=module.exports=_;} 21exports._=_;}else{root._=_;} 22_.VERSION='1.8.3';var optimizeCb=function(func,context,argCount){if(context===void 0)return func;switch(argCount==null?3:argCount){case 1:return function(value){return func.call(context,value);};case 2:return function(value,other){return func.call(context,value,other);};case 3:return function(value,index,collection){return func.call(context,value,index,collection);};case 4:return function(accumulator,value,index,collection){return func.call(context,accumulator,value,index,collection);};} 23return function(){return func.apply(context,arguments);};};var cb=function(value,context,argCount){if(value==null)return _.identity;if(_.isFunction(value))return optimizeCb(value,context,argCount);if(_.isObject(value))return _.matcher(value);return _.property(value);};_.iteratee=function(value,context){return cb(value,context,Infinity);};var createAssigner=function(keysFunc,undefinedOnly){return function(obj){var length=arguments.length;if(length<2||obj==null)return obj;for(var index=1;index<length;index++){var source=arguments[index],keys=keysFunc(source),l=keys.length;for(var i=0;i<l;i++){var key=keys[i];if(!undefinedOnly||obj[key]===void 0)obj[key]=source[key];}} 24return obj;};};var baseCreate=function(prototype){if(!_.isObject(prototype))return{};if(nativeCreate)return nativeCreate(prototype);Ctor.prototype=prototype;var result=new Ctor;Ctor.prototype=null;return result;};var property=function(key){return function(obj){return obj==null?void 0:obj[key];};};var MAX_ARRAY_INDEX=Math.pow(2,53)-1;var getLength=property('length');var isArrayLike=function(collection){var length=getLength(collection);return typeof length=='number'&&length>=0&&length<=MAX_ARRAY_INDEX;};_.each=_.forEach=function(obj,iteratee,context){iteratee=optimizeCb(iteratee,context);var i,length;if(isArrayLike(obj)){for(i=0,length=obj.length;i<length;i++){iteratee(obj[i],i,obj);}}else{var keys=_.keys(obj);for(i=0,length=keys.length;i<length;i++){iteratee(obj[keys[i]],keys[i],obj);}} 25return obj;};_.map=_.collect=function(obj,iteratee,context){iteratee=cb(iteratee,context);var keys=!isArrayLike(obj)&&_.keys(obj),length=(keys||obj).length,results=Array(length);for(var index=0;index<length;index++){var currentKey=keys?keys[index]:index;results[index]=iteratee(obj[currentKey],currentKey,obj);} 26return results;};function createReduce(dir){function iterator(obj,iteratee,memo,keys,index,length){for(;index>=0&&index<length;index+=dir){var currentKey=keys?keys[index]:index;memo=iteratee(memo,obj[currentKey],currentKey,obj);} 27return memo;} 28return function(obj,iteratee,memo,context){iteratee=optimizeCb(iteratee,context,4);var keys=!isArrayLike(obj)&&_.keys(obj),length=(keys||obj).length,index=dir>0?0:length-1;if(arguments.length<3){memo=obj[keys?keys[index]:index];index+=dir;} 29return iterator(obj,iteratee,memo,keys,index,length);};} 30_.reduce=_.foldl=_.inject=createReduce(1);_.reduceRight=_.foldr=createReduce(-1);_.find=_.detect=function(obj,predicate,context){var key;if(isArrayLike(obj)){key=_.findIndex(obj,predicate,context);}else{key=_.findKey(obj,predicate,context);} 31if(key!==void 0&&key!==-1)return obj[key];};_.filter=_.select=function(obj,predicate,context){var results=[];predicate=cb(predicate,context);_.each(obj,function(value,index,list){if(predicate(value,index,list))results.push(value);});return results;};_.reject=function(obj,predicate,context){return _.filter(obj,_.negate(cb(predicate)),context);};_.every=_.all=function(obj,predicate,context){predicate=cb(predicate,context);var keys=!isArrayLike(obj)&&_.keys(obj),length=(keys||obj).length;for(var index=0;index<length;index++){var currentKey=keys?keys[index]:index;if(!predicate(obj[currentKey],currentKey,obj))return false;} 32return true;};_.some=_.any=function(obj,predicate,context){predicate=cb(predicate,context);var keys=!isArrayLike(obj)&&_.keys(obj),length=(keys||obj).length;for(var index=0;index<length;index++){var currentKey=keys?keys[index]:index;if(predicate(obj[currentKey],currentKey,obj))return true;} 33return false;};_.contains=_.includes=_.include=function(obj,item,fromIndex,guard){if(!isArrayLike(obj))obj=_.values(obj);if(typeof fromIndex!='number'||guard)fromIndex=0;return _.indexOf(obj,item,fromIndex)>=0;};_.invoke=function(obj,method){var args=slice.call(arguments,2);var isFunc=_.isFunction(method);return _.map(obj,function(value){var func=isFunc?method:value[method];return func==null?func:func.apply(value,args);});};_.pluck=function(obj,key){return _.map(obj,_.property(key));};_.where=function(obj,attrs){return _.filter(obj,_.matcher(attrs));};_.findWhere=function(obj,attrs){return _.find(obj,_.matcher(attrs));};_.max=function(obj,iteratee,context){var result=-Infinity,lastComputed=-Infinity,value,computed;if(iteratee==null&&obj!=null){obj=isArrayLike(obj)?obj:_.values(obj);for(var i=0,length=obj.length;i<length;i++){value=obj[i];if(value>result){result=value;}}}else{iteratee=cb(iteratee,context);_.each(obj,function(value,index,list){computed=iteratee(value,index,list);if(computed>lastComputed||computed===-Infinity&&result===-Infinity){result=value;lastComputed=computed;}});} 34return result;};_.min=function(obj,iteratee,context){var result=Infinity,lastComputed=Infinity,value,computed;if(iteratee==null&&obj!=null){obj=isArrayLike(obj)?obj:_.values(obj);for(var i=0,length=obj.length;i<length;i++){value=obj[i];if(value<result){result=value;}}}else{iteratee=cb(iteratee,context);_.each(obj,function(value,index,list){computed=iteratee(value,index,list);if(computed<lastComputed||computed===Infinity&&result===Infinity){result=value;lastComputed=computed;}});} 35return result;};_.shuffle=function(obj){var set=isArrayLike(obj)?obj:_.values(obj);var length=set.length;var shuffled=Array(length);for(var index=0,rand;index<length;index++){rand=_.random(0,index);if(rand!==index)shuffled[index]=shuffled[rand];shuffled[rand]=set[index];} 36return shuffled;};_.sample=function(obj,n,guard){if(n==null||guard){if(!isArrayLike(obj))obj=_.values(obj);return obj[_.random(obj.length-1)];} 37return _.shuffle(obj).slice(0,Math.max(0,n));};_.sortBy=function(obj,iteratee,context){iteratee=cb(iteratee,context);return _.pluck(_.map(obj,function(value,index,list){return{value:value,index:index,criteria:iteratee(value,index,list)};}).sort(function(left,right){var a=left.criteria;var b=right.criteria;if(a!==b){if(a>b||a===void 0)return 1;if(a<b||b===void 0)return-1;} 38return left.index-right.index;}),'value');};var group=function(behavior){return function(obj,iteratee,context){var result={};iteratee=cb(iteratee,context);_.each(obj,function(value,index){var key=iteratee(value,index,obj);behavior(result,value,key);});return result;};};_.groupBy=group(function(result,value,key){if(_.has(result,key))result[key].push(value);else result[key]=[value];});_.indexBy=group(function(result,value,key){result[key]=value;});_.countBy=group(function(result,value,key){if(_.has(result,key))result[key]++;else result[key]=1;});_.toArray=function(obj){if(!obj)return[];if(_.isArray(obj))return slice.call(obj);if(isArrayLike(obj))return _.map(obj,_.identity);return _.values(obj);};_.size=function(obj){if(obj==null)return 0;return isArrayLike(obj)?obj.length:_.keys(obj).length;};_.partition=function(obj,predicate,context){predicate=cb(predicate,context);var pass=[],fail=[];_.each(obj,function(value,key,obj){(predicate(value,key,obj)?pass:fail).push(value);});return[pass,fail];};_.first=_.head=_.take=function(array,n,guard){if(array==null)return void 0;if(n==null||guard)return array[0];return _.initial(array,array.length-n);};_.initial=function(array,n,guard){return slice.call(array,0,Math.max(0,array.length-(n==null||guard?1:n)));};_.last=function(array,n,guard){if(array==null)return void 0;if(n==null||guard)return array[array.length-1];return _.rest(array,Math.max(0,array.length-n));};_.rest=_.tail=_.drop=function(array,n,guard){return slice.call(array,n==null||guard?1:n);};_.compact=function(array){return _.filter(array,_.identity);};var flatten=function(input,shallow,strict,startIndex){var output=[],idx=0;for(var i=startIndex||0,length=getLength(input);i<length;i++){var value=input[i];if(isArrayLike(value)&&(_.isArray(value)||_.isArguments(value))){if(!shallow)value=flatten(value,shallow,strict);var j=0,len=value.length;output.length+=len;while(j<len){output[idx++]=value[j++];}}else if(!strict){output[idx++]=value;}} 39return output;};_.flatten=function(array,shallow){return flatten(array,shallow,false);};_.without=function(array){return _.difference(array,slice.call(arguments,1));};_.uniq=_.unique=function(array,isSorted,iteratee,context){if(!_.isBoolean(isSorted)){context=iteratee;iteratee=isSorted;isSorted=false;} 40if(iteratee!=null)iteratee=cb(iteratee,context);var result=[];var seen=[];for(var i=0,length=getLength(array);i<length;i++){var value=array[i],computed=iteratee?iteratee(value,i,array):value;if(isSorted){if(!i||seen!==computed)result.push(value);seen=computed;}else if(iteratee){if(!_.contains(seen,computed)){seen.push(computed);result.push(value);}}else if(!_.contains(result,value)){result.push(value);}} 41return result;};_.union=function(){return _.uniq(flatten(arguments,true,true));};_.intersection=function(array){var result=[];var argsLength=arguments.length;for(var i=0,length=getLength(array);i<length;i++){var item=array[i];if(_.contains(result,item))continue;for(var j=1;j<argsLength;j++){if(!_.contains(arguments[j],item))break;} 42if(j===argsLength)result.push(item);} 43return result;};_.difference=function(array){var rest=flatten(arguments,true,true,1);return _.filter(array,function(value){return!_.contains(rest,value);});};_.zip=function(){return _.unzip(arguments);};_.unzip=function(array){var length=array&&_.max(array,getLength).length||0;var result=Array(length);for(var index=0;index<length;index++){result[index]=_.pluck(array,index);} 44return result;};_.object=function(list,values){var result={};for(var i=0,length=getLength(list);i<length;i++){if(values){result[list[i]]=values[i];}else{result[list[i][0]]=list[i][1];}} 45return result;};function createPredicateIndexFinder(dir){return function(array,predicate,context){predicate=cb(predicate,context);var length=getLength(array);var index=dir>0?0:length-1;for(;index>=0&&index<length;index+=dir){if(predicate(array[index],index,array))return index;} 46return-1;};} 47_.findIndex=createPredicateIndexFinder(1);_.findLastIndex=createPredicateIndexFinder(-1);_.sortedIndex=function(array,obj,iteratee,context){iteratee=cb(iteratee,context,1);var value=iteratee(obj);var low=0,high=getLength(array);while(low<high){var mid=Math.floor((low+high)/2);if(iteratee(array[mid])<value)low=mid+1;else high=mid;} 48return low;};function createIndexFinder(dir,predicateFind,sortedIndex){return function(array,item,idx){var i=0,length=getLength(array);if(typeof idx=='number'){if(dir>0){i=idx>=0?idx:Math.max(idx+length,i);}else{length=idx>=0?Math.min(idx+1,length):idx+length+1;}}else if(sortedIndex&&idx&&length){idx=sortedIndex(array,item);return array[idx]===item?idx:-1;} 49if(item!==item){idx=predicateFind(slice.call(array,i,length),_.isNaN);return idx>=0?idx+i:-1;} 50for(idx=dir>0?i:length-1;idx>=0&&idx<length;idx+=dir){if(array[idx]===item)return idx;} 51return-1;};} 52_.indexOf=createIndexFinder(1,_.findIndex,_.sortedIndex);_.lastIndexOf=createIndexFinder(-1,_.findLastIndex);_.range=function(start,stop,step){if(stop==null){stop=start||0;start=0;} 53step=step||1;var length=Math.max(Math.ceil((stop-start)/step),0);var range=Array(length);for(var idx=0;idx<length;idx++,start+=step){range[idx]=start;} 54return range;};var executeBound=function(sourceFunc,boundFunc,context,callingContext,args){if(!(callingContext instanceof boundFunc))return sourceFunc.apply(context,args);var self=baseCreate(sourceFunc.prototype);var result=sourceFunc.apply(self,args);if(_.isObject(result))return result;return self;};_.bind=function(func,context){if(nativeBind&&func.bind===nativeBind)return nativeBind.apply(func,slice.call(arguments,1));if(!_.isFunction(func))throw new TypeError('Bind must be called on a function');var args=slice.call(arguments,2);var bound=function(){return executeBound(func,bound,context,this,args.concat(slice.call(arguments)));};return bound;};_.partial=function(func){var boundArgs=slice.call(arguments,1);var bound=function(){var position=0,length=boundArgs.length;var args=Array(length);for(var i=0;i<length;i++){args[i]=boundArgs[i]===_?arguments[position++]:boundArgs[i];} 55while(position<arguments.length)args.push(arguments[position++]);return executeBound(func,bound,this,this,args);};return bound;};_.bindAll=function(obj){var i,length=arguments.length,key;if(length<=1)throw new Error('bindAll must be passed function names');for(i=1;i<length;i++){key=arguments[i];obj[key]=_.bind(obj[key],obj);} 56return obj;};_.memoize=function(func,hasher){var memoize=function(key){var cache=memoize.cache;var address=''+(hasher?hasher.apply(this,arguments):key);if(!_.has(cache,address))cache[address]=func.apply(this,arguments);return cache[address];};memoize.cache={};return memoize;};_.delay=function(func,wait){var args=slice.call(arguments,2);return setTimeout(function(){return func.apply(null,args);},wait);};_.defer=_.partial(_.delay,_,1);_.throttle=function(func,wait,options){var context,args,result;var timeout=null;var previous=0;if(!options)options={};var later=function(){previous=options.leading===false?0:_.now();timeout=null;result=func.apply(context,args);if(!timeout)context=args=null;};return function(){var now=_.now();if(!previous&&options.leading===false)previous=now;var remaining=wait-(now-previous);context=this;args=arguments;if(remaining<=0||remaining>wait){if(timeout){clearTimeout(timeout);timeout=null;} 57previous=now;result=func.apply(context,args);if(!timeout)context=args=null;}else if(!timeout&&options.trailing!==false){timeout=setTimeout(later,remaining);} 58return result;};};_.debounce=function(func,wait,immediate){var timeout,args,context,timestamp,result;var later=function(){var last=_.now()-timestamp;if(last<wait&&last>=0){timeout=setTimeout(later,wait-last);}else{timeout=null;if(!immediate){result=func.apply(context,args);if(!timeout)context=args=null;}}};return function(){context=this;args=arguments;timestamp=_.now();var callNow=immediate&&!timeout;if(!timeout)timeout=setTimeout(later,wait);if(callNow){result=func.apply(context,args);context=args=null;} 59return result;};};_.wrap=function(func,wrapper){return _.partial(wrapper,func);};_.negate=function(predicate){return function(){return!predicate.apply(this,arguments);};};_.compose=function(){var args=arguments;var start=args.length-1;return function(){var i=start;var result=args[start].apply(this,arguments);while(i--)result=args[i].call(this,result);return result;};};_.after=function(times,func){return function(){if(--times<1){return func.apply(this,arguments);}};};_.before=function(times,func){var memo;return function(){if(--times>0){memo=func.apply(this,arguments);} 60if(times<=1)func=null;return memo;};};_.once=_.partial(_.before,2);var hasEnumBug=!{toString:null}.propertyIsEnumerable('toString');var nonEnumerableProps=['valueOf','isPrototypeOf','toString','propertyIsEnumerable','hasOwnProperty','toLocaleString'];function collectNonEnumProps(obj,keys){var nonEnumIdx=nonEnumerableProps.length;var constructor=obj.constructor;var proto=(_.isFunction(constructor)&&constructor.prototype)||ObjProto;var prop='constructor';if(_.has(obj,prop)&&!_.contains(keys,prop))keys.push(prop);while(nonEnumIdx--){prop=nonEnumerableProps[nonEnumIdx];if(prop in obj&&obj[prop]!==proto[prop]&&!_.contains(keys,prop)){keys.push(prop);}}} 61_.keys=function(obj){if(!_.isObject(obj))return[];if(nativeKeys)return nativeKeys(obj);var keys=[];for(var key in obj)if(_.has(obj,key))keys.push(key);if(hasEnumBug)collectNonEnumProps(obj,keys);return keys;};_.allKeys=function(obj){if(!_.isObject(obj))return[];var keys=[];for(var key in obj)keys.push(key);if(hasEnumBug)collectNonEnumProps(obj,keys);return keys;};_.values=function(obj){var keys=_.keys(obj);var length=keys.length;var values=Array(length);for(var i=0;i<length;i++){values[i]=obj[keys[i]];} 62return values;};_.mapObject=function(obj,iteratee,context){iteratee=cb(iteratee,context);var keys=_.keys(obj),length=keys.length,results={},currentKey;for(var index=0;index<length;index++){currentKey=keys[index];results[currentKey]=iteratee(obj[currentKey],currentKey,obj);} 63return results;};_.pairs=function(obj){var keys=_.keys(obj);var length=keys.length;var pairs=Array(length);for(var i=0;i<length;i++){pairs[i]=[keys[i],obj[keys[i]]];} 64return pairs;};_.invert=function(obj){var result={};var keys=_.keys(obj);for(var i=0,length=keys.length;i<length;i++){result[obj[keys[i]]]=keys[i];} 65return result;};_.functions=_.methods=function(obj){var names=[];for(var key in obj){if(_.isFunction(obj[key]))names.push(key);} 66return names.sort();};_.extend=createAssigner(_.allKeys);_.extendOwn=_.assign=createAssigner(_.keys);_.findKey=function(obj,predicate,context){predicate=cb(predicate,context);var keys=_.keys(obj),key;for(var i=0,length=keys.length;i<length;i++){key=keys[i];if(predicate(obj[key],key,obj))return key;}};_.pick=function(object,oiteratee,context){var result={},obj=object,iteratee,keys;if(obj==null)return result;if(_.isFunction(oiteratee)){keys=_.allKeys(obj);iteratee=optimizeCb(oiteratee,context);}else{keys=flatten(arguments,false,false,1);iteratee=function(value,key,obj){return key in obj;};obj=Object(obj);} 67for(var i=0,length=keys.length;i<length;i++){var key=keys[i];var value=obj[key];if(iteratee(value,key,obj))result[key]=value;} 68return result;};_.omit=function(obj,iteratee,context){if(_.isFunction(iteratee)){iteratee=_.negate(iteratee);}else{var keys=_.map(flatten(arguments,false,false,1),String);iteratee=function(value,key){return!_.contains(keys,key);};} 69return _.pick(obj,iteratee,context);};_.defaults=createAssigner(_.allKeys,true);_.create=function(prototype,props){var result=baseCreate(prototype);if(props)_.extendOwn(result,props);return result;};_.clone=function(obj){if(!_.isObject(obj))return obj;return _.isArray(obj)?obj.slice():_.extend({},obj);};_.tap=function(obj,interceptor){interceptor(obj);return obj;};_.isMatch=function(object,attrs){var keys=_.keys(attrs),length=keys.length;if(object==null)return!length;var obj=Object(object);for(var i=0;i<length;i++){var key=keys[i];if(attrs[key]!==obj[key]||!(key in obj))return false;} 70return true;};var eq=function(a,b,aStack,bStack){if(a===b)return a!==0||1/a===1/b;if(a==null||b==null)return a===b;if(a instanceof _)a=a._wrapped;if(b instanceof _)b=b._wrapped;var className=toString.call(a);if(className!==toString.call(b))return false;switch(className){case'[object RegExp]':case'[object String]':return''+a===''+b;case'[object Number]':if(+a!==+a)return+b!==+b;return+a===0?1/+a===1/b:+a===+b;case'[object Date]':case'[object Boolean]':return+a===+b;} 71var areArrays=className==='[object Array]';if(!areArrays){if(typeof a!='object'||typeof b!='object')return false;var aCtor=a.constructor,bCtor=b.constructor;if(aCtor!==bCtor&&!(_.isFunction(aCtor)&&aCtor instanceof aCtor&&_.isFunction(bCtor)&&bCtor instanceof bCtor)&&('constructor'in a&&'constructor'in b)){return false;}} 72aStack=aStack||[];bStack=bStack||[];var length=aStack.length;while(length--){if(aStack[length]===a)return bStack[length]===b;} 73aStack.push(a);bStack.push(b);if(areArrays){length=a.length;if(length!==b.length)return false;while(length--){if(!eq(a[length],b[length],aStack,bStack))return false;}}else{var keys=_.keys(a),key;length=keys.length;if(_.keys(b).length!==length)return false;while(length--){key=keys[length];if(!(_.has(b,key)&&eq(a[key],b[key],aStack,bStack)))return false;}} 74aStack.pop();bStack.pop();return true;};_.isEqual=function(a,b){return eq(a,b);};_.isEmpty=function(obj){if(obj==null)return true;if(isArrayLike(obj)&&(_.isArray(obj)||_.isString(obj)||_.isArguments(obj)))return obj.length===0;return _.keys(obj).length===0;};_.isElement=function(obj){return!!(obj&&obj.nodeType===1);};_.isArray=nativeIsArray||function(obj){return toString.call(obj)==='[object Array]';};_.isObject=function(obj){var type=typeof obj;return type==='function'||type==='object'&&!!obj;};_.each(['Arguments','Function','String','Number','Date','RegExp','Error'],function(name){_['is'+name]=function(obj){return toString.call(obj)==='[object '+name+']';};});if(!_.isArguments(arguments)){_.isArguments=function(obj){return _.has(obj,'callee');};} 75if(typeof/./!='function'&&typeof Int8Array!='object'){_.isFunction=function(obj){return typeof obj=='function'||false;};} 76_.isFinite=function(obj){return isFinite(obj)&&!isNaN(parseFloat(obj));};_.isNaN=function(obj){return _.isNumber(obj)&&obj!==+obj;};_.isBoolean=function(obj){return obj===true||obj===false||toString.call(obj)==='[object Boolean]';};_.isNull=function(obj){return obj===null;};_.isUndefined=function(obj){return obj===void 0;};_.has=function(obj,key){return obj!=null&&hasOwnProperty.call(obj,key);};_.noConflict=function(){root._=previousUnderscore;return this;};_.identity=function(value){return value;};_.constant=function(value){return function(){return value;};};_.noop=function(){};_.property=property;_.propertyOf=function(obj){return obj==null?function(){}:function(key){return obj[key];};};_.matcher=_.matches=function(attrs){attrs=_.extendOwn({},attrs);return function(obj){return _.isMatch(obj,attrs);};};_.times=function(n,iteratee,context){var accum=Array(Math.max(0,n));iteratee=optimizeCb(iteratee,context,1);for(var i=0;i<n;i++)accum[i]=iteratee(i);return accum;};_.random=function(min,max){if(max==null){max=min;min=0;} 77return min+Math.floor(Math.random()*(max-min+1));};_.now=Date.now||function(){return new Date().getTime();};var escapeMap={'&':'&','<':'<','>':'>','"':'"',"'":''','`':'`'};var unescapeMap=_.invert(escapeMap);var createEscaper=function(map){var escaper=function(match){return map[match];};var source='(?:'+_.keys(map).join('|')+')';var testRegexp=RegExp(source);var replaceRegexp=RegExp(source,'g');return function(string){string=string==null?'':''+string;return testRegexp.test(string)?string.replace(replaceRegexp,escaper):string;};};_.escape=createEscaper(escapeMap);_.unescape=createEscaper(unescapeMap);_.result=function(object,property,fallback){var value=object==null?void 0:object[property];if(value===void 0){value=fallback;} 78return _.isFunction(value)?value.call(object):value;};var idCounter=0;_.uniqueId=function(prefix){var id=++idCounter+'';return prefix?prefix+id:id;};_.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var noMatch=/(.)^/;var escapes={"'":"'",'\\':'\\','\r':'r','\n':'n','\u2028':'u2028','\u2029':'u2029'};var escaper=/\\|'|\r|\n|\u2028|\u2029/g;var escapeChar=function(match){return'\\'+escapes[match];};_.template=function(text,settings,oldSettings){if(!settings&&oldSettings)settings=oldSettings;settings=_.defaults({},settings,_.templateSettings);var matcher=RegExp([(settings.escape||noMatch).source,(settings.interpolate||noMatch).source,(settings.evaluate||noMatch).source].join('|')+'|$','g');var index=0;var source="__p+='";text.replace(matcher,function(match,escape,interpolate,evaluate,offset){source+=text.slice(index,offset).replace(escaper,escapeChar);index=offset+match.length;if(escape){source+="'+\n((__t=("+escape+"))==null?'':_.escape(__t))+\n'";}else if(interpolate){source+="'+\n((__t=("+interpolate+"))==null?'':__t)+\n'";}else if(evaluate){source+="';\n"+evaluate+"\n__p+='";} 79return match;});source+="';\n";if(!settings.variable)source='with(obj||{}){\n'+source+'}\n';source="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+ 80source+'return __p;\n';try{var render=new Function(settings.variable||'obj','_',source);}catch(e){e.source=source;throw e;} 81var template=function(data){return render.call(this,data,_);};var argument=settings.variable||'obj';template.source='function('+argument+'){\n'+source+'}';return template;};_.chain=function(obj){var instance=_(obj);instance._chain=true;return instance;};var result=function(instance,obj){return instance._chain?_(obj).chain():obj;};_.mixin=function(obj){_.each(_.functions(obj),function(name){var func=_[name]=obj[name];_.prototype[name]=function(){var args=[this._wrapped];push.apply(args,arguments);return result(this,func.apply(_,args));};});};_.mixin(_);_.each(['pop','push','reverse','shift','sort','splice','unshift'],function(name){var method=ArrayProto[name];_.prototype[name]=function(){var obj=this._wrapped;method.apply(obj,arguments);if((name==='shift'||name==='splice')&&obj.length===0)delete obj[0];return result(this,obj);};});_.each(['concat','join','slice'],function(name){var method=ArrayProto[name];_.prototype[name]=function(){return result(this,method.apply(this._wrapped,arguments));};});_.prototype.value=function(){return this._wrapped;};_.prototype.valueOf=_.prototype.toJSON=_.prototype.value;_.prototype.toString=function(){return''+this._wrapped;};if(typeof define==='function'&&define.amd){define('underscore',[],function(){return _;});}}.call(this));;(function(factory){var root=(typeof self=='object'&&self.self===self&&self)||(typeof global=='object'&&global.global===global&&global);if(typeof define==='function'&&define.amd){define(['underscore','jquery','exports'],function(_,$,exp
vendor: 5,726 bytes, lines 81-92
81orts){root.Backbone=factory(root,exports,_,$);});}else if(typeof exports!=='undefined'){var _=require('underscore'),$;try{$=require('jquery');}catch(e){} 82factory(root,exports,_,$);}else{root.Backbone=factory(root,{},root._,(root.jQuery||root.Zepto||root.ender||root.$));}})(function(root,Backbone,_,$){var previousBackbone=root.Backbone;var slice=Array.prototype.slice;Backbone.VERSION='1.3.3';Backbone.$=$;Backbone.noConflict=function(){root.Backbone=previousBackbone;return this;};Backbone.emulateHTTP=false;Backbone.emulateJSON=false;var addMethod=function(length,method,attribute){switch(length){case 1:return function(){return _[method](this[attribute]);};case 2:return function(value){return _[method](this[attribute],value);};case 3:return function(iteratee,context){return _[method](this[attribute],cb(iteratee,this),context);};case 4:return function(iteratee,defaultVal,context){return _[method](this[attribute],cb(iteratee,this),defaultVal,context);};default:return function(){var args=slice.call(arguments);args.unshift(this[attribute]);return _[method].apply(_,args);};}};var addUnderscoreMethods=function(Class,methods,attribute){_.each(methods,function(length,method){if(_[method])Class.prototype[method]=addMethod(length,method,attribute);});};var cb=function(iteratee,instance){if(_.isFunction(iteratee))return iteratee;if(_.isObject(iteratee)&&!instance._isModel(iteratee))return modelMatcher(iteratee);if(_.isString(iteratee))return function(model){return model.get(iteratee);};return iteratee;};var modelMatcher=function(attrs){var matcher=_.matches(attrs);return function(model){return matcher(model.attributes);};};var Events=Backbone.Events={};var eventSplitter=/\s+/;var eventsApi=function(iteratee,events,name,callback,opts){var i=0,names;if(name&&typeof name==='object'){if(callback!==void 0&&'context'in opts&&opts.context===void 0)opts.context=callback;for(names=_.keys(name);i<names.length;i++){events=eventsApi(iteratee,events,names[i],name[names[i]],opts);}}else if(name&&eventSplitter.test(name)){for(names=name.split(eventSplitter);i<names.length;i++){events=iteratee(events,names[i],callback,opts);}}else{events=iteratee(events,name,callback,opts);} 83return events;};Events.on=function(name,callback,context){return internalOn(this,name,callback,context);};var internalOn=function(obj,name,callback,context,listening){obj._events=eventsApi(onApi,obj._events||{},name,callback,{context:context,ctx:obj,listening:listening});if(listening){var listeners=obj._listeners||(obj._listeners={});listeners[listening.id]=listening;} 84return obj;};Events.listenTo=function(obj,name,callback){if(!obj)return this;var id=obj._listenId||(obj._listenId=_.uniqueId('l'));var listeningTo=this._listeningTo||(this._listeningTo={});var listening=listeningTo[id];if(!listening){var thisId=this._listenId||(this._listenId=_.uniqueId('l'));listening=listeningTo[id]={obj:obj,objId:id,id:thisId,listeningTo:listeningTo,count:0};} 85internalOn(obj,name,callback,this,listening);return this;};var onApi=function(events,name,callback,options){if(callback){var handlers=events[name]||(events[name]=[]);var context=options.context,ctx=options.ctx,listening=options.listening;if(listening)listening.count++;handlers.push({callback:callback,context:context,ctx:context||ctx,listening:listening});} 86return events;};Events.off=function(name,callback,context){if(!this._events)return this;this._events=eventsApi(offApi,this._events,name,callback,{context:context,listeners:this._listeners});return this;};Events.stopListening=function(obj,name,callback){var listeningTo=this._listeningTo;if(!listeningTo)return this;var ids=obj?[obj._listenId]:_.keys(listeningTo);for(var i=0;i<ids.length;i++){var listening=listeningTo[ids[i]];if(!listening)break;listening.obj.off(name,callback,this);} 87return this;};var offApi=function(events,name,callback,options){if(!events)return;var i=0,listening;var context=options.context,listeners=options.listeners;if(!name&&!callback&&!context){var ids=_.keys(listeners);for(;i<ids.length;i++){listening=listeners[ids[i]];delete listeners[listening.id];delete listening.listeningTo[listening.objId];} 88return;} 89var names=name?[name]:_.keys(events);for(;i<names.length;i++){name=names[i];var handlers=events[name];if(!handlers)break;var remaining=[];for(var j=0;j<handlers.length;j++){var handler=handlers[j];if(callback&&callback!==handler.callback&&callback!==handler.callback._callback||context&&context!==handler.context){remaining.push(handler);}else{listening=handler.listening;if(listening&&--listening.count===0){delete listeners[listening.id];delete listening.listeningTo[listening.objId];}}} 90if(remaining.length){events[name]=remaining;}else{delete events[name];}} 91return events;};Events.once=function(name,callback,context){var events=eventsApi(onceMap,{},name,callback,_.bind(this.off,this));if(typeof name==='string'&&context==null)callback=void 0;return this.on(events,callback,context);};Events.listenToOnce=function(obj,name,callback){var events=eventsApi(onceMap,{},name,callback,_.bind(this.stopListening,this,obj));return this.listenTo(obj,events);};var onceMap=function(map,name,callback,offer){if(callback){var once=map[name]=_.once(function(){offer(name,once);callback.apply(this,arguments);});once._callback=callback;} 92return map;};Events.trigger=function(name){if(!this._events)return this;var length=Math.max(0,arguments.length-1);var args=Array(length);for(var i=0;i<length;i++)args[i]=arguments[i+1];eventsApi(triggerApi,this._events,name,void 0,args);return this;};var triggerApi=function(objEvents,name,callback,args){if(objEvents){var events=objEvents[name];var allEvents=objEvents.all;if(events&&allEvents)allEvents=allEvents.slice();if(events)triggerEvents(events,args);
vendor: 4,169 bytes, lines 92-101
92if(allEvents)triggerEvents(allEvents,[name].concat(args));} 93return objEvents;};var triggerEvents=function(events,args){var ev,i=-1,l=events.length,a1=args[0],a2=args[1],a3=args[2];switch(args.length){case 0:while(++i<l)(ev=events[i]).callback.call(ev.ctx);return;case 1:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1);return;case 2:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2);return;case 3:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2,a3);return;default:while(++i<l)(ev=events[i]).callback.apply(ev.ctx,args);return;}};Events.bind=Events.on;Events.unbind=Events.off;_.extend(Backbone,Events);var Model=Backbone.Model=function(attributes,options){var attrs=attributes||{};options||(options={});this.cid=_.uniqueId(this.cidPrefix);this.attributes={};if(options.collection)this.collection=options.collection;if(options.parse)attrs=this.parse(attrs,options)||{};var defaults=_.result(this,'defaults');attrs=_.defaults(_.extend({},defaults,attrs),defaults);this.set(attrs,options);this.changed={};this.initialize.apply(this,arguments);};_.extend(Model.prototype,Events,{changed:null,validationError:null,idAttribute:'id',cidPrefix:'c',initialize:function(){},toJSON:function(options){return _.clone(this.attributes);},sync:function(){return Backbone.sync.apply(this,arguments);},get:function(attr){return this.attributes[attr];},escape:function(attr){return _.escape(this.get(attr));},has:function(attr){return this.get(attr)!=null;},matches:function(attrs){return!!_.iteratee(attrs,this)(this.attributes);},set:function(key,val,options){if(key==null)return this;var attrs;if(typeof key==='object'){attrs=key;options=val;}else{(attrs={})[key]=val;} 94options||(options={});if(!this._validate(attrs,options))return false;var unset=options.unset;var silent=options.silent;var changes=[];var changing=this._changing;this._changing=true;if(!changing){this._previousAttributes=_.clone(this.attributes);this.changed={};} 95var current=this.attributes;var changed=this.changed;var prev=this._previousAttributes;for(var attr in attrs){val=attrs[attr];if(!_.isEqual(current[attr],val))changes.push(attr);if(!_.isEqual(prev[attr],val)){changed[attr]=val;}else{delete changed[attr];} 96unset?delete current[attr]:current[attr]=val;} 97if(this.idAttribute in attrs)this.id=this.get(this.idAttribute);if(!silent){if(changes.length)this._pending=options;for(var i=0;i<changes.length;i++){this.trigger('change:'+changes[i],this,current[changes[i]],options);}} 98if(changing)return this;if(!silent){while(this._pending){options=this._pending;this._pending=false;this.trigger('change',this,options);}} 99this._pending=false;this._changing=false;return this;},unset:function(attr,options){return this.set(attr,void 0,_.extend({},options,{unset:true}));},clear:function(options){var attrs={};for(var key in this.attributes)attrs[key]=void 0;return this.set(attrs,_.extend({},options,{unset:true}));},hasChanged:function(attr){if(attr==null)return!_.isEmpty(this.changed);return _.has(this.changed,attr);},changedAttributes:function(diff){if(!diff)return this.hasChanged()?_.clone(this.changed):false;var old=this._changing?this._previousAttributes:this.attributes;var changed={};for(var attr in diff){var val=diff[attr];if(_.isEqual(old[attr],val))continue;changed[attr]=val;} 100return _.size(changed)?changed:false;},previous:function(attr){if(attr==null||!this._previousAttributes)return null;return this._previousAttributes[attr];},previousAttributes:function(){return _.clone(this._previousAttributes);},fetch:function(options){options=_.extend({parse:true},options);var model=this;var success=options.success;options.success=function(resp){var serverAttrs=options.parse?model.parse(resp,options):resp;if(!model.set(serverAttrs,options))return false;if(success)success.call(options.context,model,resp,options);model.trigger('sync',model,resp,options);};wrapError(this,options);return this.sync('read',this,options);},save:function(key,val,options){var attrs;if(key==null||typeof key==='object'){attrs=key;options=val;}else{(attrs={})[key]=val;} 101options=_.extend({validate:true,parse:true},options);var wait=options.wait;if(attrs&&!wait){if(!this.set(attrs,options))return false;}
vendor: 4,900 bytes, lines 101-108
101else if(!this._validate(attrs,options)){return false;} 102var model=this;var success=options.success;var attributes=this.attributes;options.success=function(resp){model.attributes=attributes;var serverAttrs=options.parse?model.parse(resp,options):resp;if(wait)serverAttrs=_.extend({},attrs,serverAttrs);if(serverAttrs&&!model.set(serverAttrs,options))return false;if(success)success.call(options.context,model,resp,options);model.trigger('sync',model,resp,options);};wrapError(this,options);if(attrs&&wait)this.attributes=_.extend({},attributes,attrs);var method=this.isNew()?'create':(options.patch?'patch':'update');if(method==='patch'&&!options.attrs)options.attrs=attrs;var xhr=this.sync(method,this,options);this.attributes=attributes;return xhr;},destroy:function(options){options=options?_.clone(options):{};var model=this;var success=options.success;var wait=options.wait;var destroy=function(){model.stopListening();model.trigger('destroy',model,model.collection,options);};options.success=function(resp){if(wait)destroy();if(success)success.call(options.context,model,resp,options);if(!model.isNew())model.trigger('sync',model,resp,options);};var xhr=false;if(this.isNew()){_.defer(options.success);}else{wrapError(this,options);xhr=this.sync('delete',this,options);} 103if(!wait)destroy();return xhr;},url:function(){var base=_.result(this,'urlRoot')||_.result(this.collection,'url')||urlError();if(this.isNew())return base;var id=this.get(this.idAttribute);return base.replace(/[^\/]$/,'$&/')+encodeURIComponent(id);},parse:function(resp,options){return resp;},clone:function(){return new this.constructor(this.attributes);},isNew:function(){return!this.has(this.idAttribute);},isValid:function(options){return this._validate({},_.extend({},options,{validate:true}));},_validate:function(attrs,options){if(!options.validate||!this.validate)return true;attrs=_.extend({},this.attributes,attrs);var error=this.validationError=this.validate(attrs,options)||null;if(!error)return true;this.trigger('invalid',this,error,_.extend(options,{validationError:error}));return false;}});var modelMethods={keys:1,values:1,pairs:1,invert:1,pick:0,omit:0,chain:1,isEmpty:1};addUnderscoreMethods(Model,modelMethods,'attributes');var Collection=Backbone.Collection=function(models,options){options||(options={});if(options.model)this.model=options.model;if(options.comparator!==void 0)this.comparator=options.comparator;this._reset();this.initialize.apply(this,arguments);if(models)this.reset(models,_.extend({silent:true},options));};var setOptions={add:true,remove:true,merge:true};var addOptions={add:true,remove:false};var splice=function(array,insert,at){at=Math.min(Math.max(at,0),array.length);var tail=Array(array.length-at);var length=insert.length;var i;for(i=0;i<tail.length;i++)tail[i]=array[i+at];for(i=0;i<length;i++)array[i+at]=insert[i];for(i=0;i<tail.length;i++)array[i+length+at]=tail[i];};_.extend(Collection.prototype,Events,{model:Model,initialize:function(){},toJSON:function(options){return this.map(function(model){return model.toJSON(options);});},sync:function(){return Backbone.sync.apply(this,arguments);},add:function(models,options){return this.set(models,_.extend({merge:false},options,addOptions));},remove:function(models,options){options=_.extend({},options);var singular=!_.isArray(models);models=singular?[models]:models.slice();var removed=this._removeModels(models,options);if(!options.silent&&removed.length){options.changes={added:[],merged:[],removed:removed};this.trigger('update',this,options);} 104return singular?removed[0]:removed;},set:function(models,options){if(models==null)return;options=_.extend({},setOptions,options);if(options.parse&&!this._isModel(models)){models=this.parse(models,options)||[];} 105var singular=!_.isArray(models);models=singular?[models]:models.slice();var at=options.at;if(at!=null)at=+at;if(at>this.length)at=this.length;if(at<0)at+=this.length+1;var set=[];var toAdd=[];var toMerge=[];var toRemove=[];var modelMap={};var add=options.add;var merge=options.merge;var remove=options.remove;var sort=false;var sortable=this.comparator&&at==null&&options.sort!==false;var sortAttr=_.isString(this.comparator)?this.comparator:null;var model,i;for(i=0;i<models.length;i++){model=models[i];var existing=this.get(model);if(existing){if(merge&&model!==existing){var attrs=this._isModel(model)?model.attributes:model;if(options.parse)attrs=existing.parse(attrs,options);existing.set(attrs,options);toMerge.push(existing);if(sortable&&!sort)sort=existing.hasChanged(sortAttr);} 106if(!modelMap[existing.cid]){modelMap[existing.cid]=true;set.push(existing);} 107models[i]=existing;}else if(add){model=models[i]=this._prepareModel(model,options);if(model){toAdd.push(model);this._addReference(model,options);modelMap[model.cid]=true;set.push(model);}}} 108if(remove){for(i=0;i<this.length;i++){model=this.models[i];if(!modelMap[model.cid])toRemove.push(model);}
vendor: 6,809 bytes, lines 109-119
109if(toRemove.length)this._removeModels(toRemove,options);} 110var orderChanged=false;var replace=!sortable&&add&&remove;if(set.length&&replace){orderChanged=this.length!==set.length||_.some(this.models,function(m,index){return m!==set[index];});this.models.length=0;splice(this.models,set,0);this.length=this.models.length;}else if(toAdd.length){if(sortable)sort=true;splice(this.models,toAdd,at==null?this.length:at);this.length=this.models.length;} 111if(sort)this.sort({silent:true});if(!options.silent){for(i=0;i<toAdd.length;i++){if(at!=null)options.index=at+i;model=toAdd[i];model.trigger('add',model,this,options);} 112if(sort||orderChanged)this.trigger('sort',this,options);if(toAdd.length||toRemove.length||toMerge.length){options.changes={added:toAdd,removed:toRemove,merged:toMerge};this.trigger('update',this,options);}} 113return singular?models[0]:models;},reset:function(models,options){options=options?_.clone(options):{};for(var i=0;i<this.models.length;i++){this._removeReference(this.models[i],options);} 114options.previousModels=this.models;this._reset();models=this.add(models,_.extend({silent:true},options));if(!options.silent)this.trigger('reset',this,options);return models;},push:function(model,options){return this.add(model,_.extend({at:this.length},options));},pop:function(options){var model=this.at(this.length-1);return this.remove(model,options);},unshift:function(model,options){return this.add(model,_.extend({at:0},options));},shift:function(options){var model=this.at(0);return this.remove(model,options);},slice:function(){return slice.apply(this.models,arguments);},get:function(obj){if(obj==null)return void 0;return this._byId[obj]||this._byId[this.modelId(obj.attributes||obj)]||obj.cid&&this._byId[obj.cid];},has:function(obj){return this.get(obj)!=null;},at:function(index){if(index<0)index+=this.length;return this.models[index];},where:function(attrs,first){return this[first?'find':'filter'](attrs);},findWhere:function(attrs){return this.where(attrs,true);},sort:function(options){var comparator=this.comparator;if(!comparator)throw new Error('Cannot sort a set without a comparator');options||(options={});var length=comparator.length;if(_.isFunction(comparator))comparator=_.bind(comparator,this);if(length===1||_.isString(comparator)){this.models=this.sortBy(comparator);}else{this.models.sort(comparator);} 115if(!options.silent)this.trigger('sort',this,options);return this;},pluck:function(attr){return this.map(attr+'');},fetch:function(options){options=_.extend({parse:true},options);var success=options.success;var collection=this;options.success=function(resp){var method=options.reset?'reset':'set';collection[method](resp,options);if(success)success.call(options.context,collection,resp,options);collection.trigger('sync',collection,resp,options);};wrapError(this,options);return this.sync('read',this,options);},create:function(model,options){options=options?_.clone(options):{};var wait=options.wait;model=this._prepareModel(model,options);if(!model)return false;if(!wait)this.add(model,options);var collection=this;var success=options.success;options.success=function(m,resp,callbackOpts){if(wait)collection.add(m,callbackOpts);if(success)success.call(callbackOpts.context,m,resp,callbackOpts);};model.save(null,options);return model;},parse:function(resp,options){return resp;},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator});},modelId:function(attrs){return attrs[this.model.prototype.idAttribute||'id'];},_reset:function(){this.length=0;this.models=[];this._byId={};},_prepareModel:function(attrs,options){if(this._isModel(attrs)){if(!attrs.collection)attrs.collection=this;return attrs;} 116options=options?_.clone(options):{};options.collection=this;var model=new this.model(attrs,options);if(!model.validationError)return model;this.trigger('invalid',this,model.validationError,options);return false;},_removeModels:function(models,options){var removed=[];for(var i=0;i<models.length;i++){var model=this.get(models[i]);if(!model)continue;var index=this.indexOf(model);this.models.splice(index,1);this.length--;delete this._byId[model.cid];var id=this.modelId(model.attributes);if(id!=null)delete this._byId[id];if(!options.silent){options.index=index;model.trigger('remove',model,this,options);} 117removed.push(model);this._removeReference(model,options);} 118return removed;},_isModel:function(model){return model instanceof Model;},_addReference:function(model,options){this._byId[model.cid]=model;var id=this.modelId(model.attributes);if(id!=null)this._byId[id]=model;model.on('all',this._onModelEvent,this);},_removeReference:function(model,options){delete this._byId[model.cid];var id=this.modelId(model.attributes);if(id!=null)delete this._byId[id];if(this===model.collection)delete model.collection;model.off('all',this._onModelEvent,this);},_onModelEvent:function(event,model,collection,options){if(model){if((event==='add'||event==='remove')&&collection!==this)return;if(event==='destroy')this.remove(model,options);if(event==='change'){var prevId=this.modelId(model.previousAttributes());var id=this.modelId(model.attributes);if(prevId!==id){if(prevId!=null)delete this._byId[prevId];if(id!=null)this._byId[id]=model;}}} 119this.trigger.apply(this,arguments);}});var collectionMethods={forEach:3,each:3,map:3,collect:3,reduce:0,foldl:0,inject:0,reduceRight:0,foldr:0,find:3,detect:3,filter:3,select:3,reject:3,every:3,all:3,some:3,any:3,include:3,includes:3,contains:3,invoke:0,max:3,min:3,toArray:1,size:1,first:3,head:3,take:3,initial:3,rest:3,tail:3,drop:3,last:3,without:0,difference:0,indexOf:3,shuffle:1,lastIndexOf:3,isEmpty:1,chain:1,sample:3,partition:3,groupBy:3,countBy:3,sortBy:3,indexBy:3,findIndex:3,findLastIndex:3};addUnderscoreMethods(Collection,collectionMethods,'models');var View=Backbone.View=function(options){this.cid=_.uniqueId('view');_.extend(this,_.pick(options,viewOptions));this._ensureElement();this.initialize.apply(this,arguments);};var delegateEventSplitter=/^(\S+)\s*(.*)$/;var viewOptions=['model','collection','el','id','attributes','className','tagName','events'];_.extend(View.prototype,Events,{tagName:'div',$:function(selector){return this.$el.find(selector);},initialize:function(){},render:function(){return this;},remove:function(){this._removeElement();this.stopListening();return this;},_removeElement:function(){this.$el.remove();},setElement:function(element){this.undelegateEvents();this._setElement(element);this.delegateEvents();return this;},_setElement:function(el){this.$el=el instanceof Backbone.$?el:Backbone.$(el);this.el=this.$el[0];},delegateEvents:function(events){events||(events=_.result(this,'events'));if(!events)return this;this.undelegateEvents();for(var key in events){var method=events[key];if(!_.isFunction(method))method=this[method];
vendor: 8,246 bytes, lines 119-133
119if(!method)continue;var match=key.match(delegateEventSplitter);this.delegate(match[1],match[2],_.bind(method,this));} 120return this;},delegate:function(eventName,selector,listener){this.$el.on(eventName+'.delegateEvents'+this.cid,selector,listener);return this;},undelegateEvents:function(){if(this.$el)this.$el.off('.delegateEvents'+this.cid);return this;},undelegate:function(eventName,selector,listener){this.$el.off(eventName+'.delegateEvents'+this.cid,selector,listener);return this;},_createElement:function(tagName){return document.createElement(tagName);},_ensureElement:function(){if(!this.el){var attrs=_.extend({},_.result(this,'attributes'));if(this.id)attrs.id=_.result(this,'id');if(this.className)attrs['class']=_.result(this,'className');this.setElement(this._createElement(_.result(this,'tagName')));this._setAttributes(attrs);}else{this.setElement(_.result(this,'el'));}},_setAttributes:function(attributes){this.$el.attr(attributes);}});Backbone.sync=function(method,model,options){var type=methodMap[method];_.defaults(options||(options={}),{emulateHTTP:Backbone.emulateHTTP,emulateJSON:Backbone.emulateJSON});var params={type:type,dataType:'json'};if(!options.url){params.url=_.result(model,'url')||urlError();} 121if(options.data==null&&model&&(method==='create'||method==='update'||method==='patch')){params.contentType='application/json';params.data=JSON.stringify(options.attrs||model.toJSON(options));} 122if(options.emulateJSON){params.contentType='application/x-www-form-urlencoded';params.data=params.data?{model:params.data}:{};} 123if(options.emulateHTTP&&(type==='PUT'||type==='DELETE'||type==='PATCH')){params.type='POST';if(options.emulateJSON)params.data._method=type;var beforeSend=options.beforeSend;options.beforeSend=function(xhr){xhr.setRequestHeader('X-HTTP-Method-Override',type);if(beforeSend)return beforeSend.apply(this,arguments);};} 124if(params.type!=='GET'&&!options.emulateJSON){params.processData=false;} 125var error=options.error;options.error=function(xhr,textStatus,errorThrown){options.textStatus=textStatus;options.errorThrown=errorThrown;if(error)error.call(options.context,xhr,textStatus,errorThrown);};var xhr=options.xhr=Backbone.ajax(_.extend(params,options));model.trigger('request',model,xhr,options);return xhr;};var methodMap={'create':'POST','update':'PUT','patch':'PATCH','delete':'DELETE','read':'GET'};Backbone.ajax=function(){return Backbone.$.ajax.apply(Backbone.$,arguments);};var Router=Backbone.Router=function(options){options||(options={});if(options.routes)this.routes=options.routes;this._bindRoutes();this.initialize.apply(this,arguments);};var optionalParam=/\((.*?)\)/g;var namedParam=/(\(\?)?:\w+/g;var splatParam=/\*\w+/g;var escapeRegExp=/[\-{}\[\]+?.,\\\^$|#\s]/g;_.extend(Router.prototype,Events,{initialize:function(){},route:function(route,name,callback){if(!_.isRegExp(route))route=this._routeToRegExp(route);if(_.isFunction(name)){callback=name;name='';} 126if(!callback)callback=this[name];var router=this;Backbone.history.route(route,function(fragment){var args=router._extractParameters(route,fragment);if(router.execute(callback,args,name)!==false){router.trigger.apply(router,['route:'+name].concat(args));router.trigger('route',name,args);Backbone.history.trigger('route',router,name,args);}});return this;},execute:function(callback,args,name){if(callback)callback.apply(this,args);},navigate:function(fragment,options){Backbone.history.navigate(fragment,options);return this;},_bindRoutes:function(){if(!this.routes)return;this.routes=_.result(this,'routes');var route,routes=_.keys(this.routes);while((route=routes.pop())!=null){this.route(route,this.routes[route]);}},_routeToRegExp:function(route){route=route.replace(escapeRegExp,'\\$&').replace(optionalParam,'(?:$1)?').replace(namedParam,function(match,optional){return optional?match:'([^/?]+)';}).replace(splatParam,'([^?]*?)');return new RegExp('^'+route+'(?:\\?([\\s\\S]*))?$');},_extractParameters:function(route,fragment){var params=route.exec(fragment).slice(1);return _.map(params,function(param,i){if(i===params.length-1)return param||null;return param?decodeURIComponent(param):null;});}});var History=Backbone.History=function(){this.handlers=[];this.checkUrl=_.bind(this.checkUrl,this);if(typeof window!=='undefined'){this.location=window.location;this.history=window.history;}};var routeStripper=/^[#\/]|\s+$/g;var rootStripper=/^\/+|\/+$/g;var pathStripper=/#.*$/;History.started=false;_.extend(History.prototype,Events,{interval:50,atRoot:function(){var path=this.location.pathname.replace(/[^\/]$/,'$&/');return path===this.root&&!this.getSearch();},matchRoot:function(){var path=this.decodeFragment(this.location.pathname);var rootPath=path.slice(0,this.root.length-1)+'/';return rootPath===this.root;},decodeFragment:function(fragment){return decodeURI(fragment.replace(/%25/g,'%2525'));},getSearch:function(){var match=this.location.href.replace(/#.*/,'').match(/\?.+/);return match?match[0]:'';},getHash:function(window){var match=(window||this).location.href.match(/#(.*)$/);return match?match[1]:'';},getPath:function(){var path=this.decodeFragment(this.location.pathname+this.getSearch()).slice(this.root.length-1);return path.charAt(0)==='/'?path.slice(1):path;},getFragment:function(fragment){if(fragment==null){if(this._usePushState||!this._wantsHashChange){fragment=this.getPath();}else{fragment=this.getHash();}} 127return fragment.replace(routeStripper,'');},start:function(options){if(History.started)throw new Error('Backbone.history has already been started');History.started=true;this.options=_.extend({root:'/'},this.options,options);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._hasHashChange='onhashchange'in window&&(document.documentMode===void 0||document.documentMode>7);this._useHashChange=this._wantsHashChange&&this._hasHashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.history&&this.history.pushState);this._usePushState=this._wantsPushState&&this._hasPushState;this.fragment=this.getFragment();this.root=('/'+this.root+'/').replace(rootStripper,'/');if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var rootPath=this.root.slice(0,-1)||'/';this.location.replace(rootPath+'#'+this.getPath());return true;}else if(this._hasPushState&&this.atRoot()){this.navigate(this.getHash(),{replace:true});}} 128if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement('iframe');this.iframe.src='javascript:0';this.iframe.style.display='none';this.iframe.tabIndex=-1;var body=document.body;var iWindow=body.insertBefore(this.iframe,body.firstChild).contentWindow;iWindow.document.open();iWindow.document.close();iWindow.location.hash='#'+this.fragment;} 129var addEventListener=window.addEventListener||function(eventName,listener){return attachEvent('on'+eventName,listener);};if(this._usePushState){addEventListener('popstate',this.checkUrl,false);}else if(this._useHashChange&&!this.iframe){addEventListener('hashchange',this.checkUrl,false);}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval);} 130if(!this.options.silent)return this.loadUrl();},stop:function(){var removeEventListener=window.removeEventListener||function(eventName,listener){return detachEvent('on'+eventName,listener);};if(this._usePushState){removeEventListener('popstate',this.checkUrl,false);}else if(this._useHashChange&&!this.iframe){removeEventListener('hashchange',this.checkUrl,false);} 131if(this.iframe){document.body.removeChild(this.iframe);this.iframe=null;} 132if(this._checkUrlInterval)clearInterval(this._checkUrlInterval);History.started=false;},route:function(route,callback){this.handlers.unshift({route:route,callback:callback});},checkUrl:function(e){var current=this.getFragment();if(current===this.fragment&&this.iframe){current=this.getHash(this.iframe.contentWindow);} 133if(current===this.fragment)return false;if(this.iframe)this.navigate(current);this.loadUrl();},loadUrl:function(fragment){if(!this.matchRoot())return false;fragment=this.fragment=this.getFragment(fragment);return _.some(this.handlers,function(handler){if(handler.route.test(fragment)){handler.callback(fragment);return true;}}
133);},navigate:function(fragment,options){if(!History.started)return false;if(!options||options===true)options={trigger:!!options};fragment=this.getFragment(fragment||'');var rootPath=this.root;if(fragment===''||fragment.charAt(0)==='?'){rootPath=rootPath.slice(0,-1)||'/';} 134var url=rootPath+fragment;fragment=this.decodeFragment(fragment.replace(pathStripper,''));if(this.fragment===fragment)return;this.fragment=fragment;if(this._usePushState){this.history[options.replace?'replaceState':'pushState']({},document.title,url);}else if(this._wantsHashChange){this._updateHash(this.location,fragment,options.replace);if(this.iframe&&fragment!==this.getHash(this.iframe.contentWindow)){var iWindow=this.iframe.contentWindow;if(!options.replace){iWindow.document.open();iWindow.document.close();} 135this._updateHash(iWindow.location,fragment,options.replace);}}else{return this.location.assign(url);} 136if(options.trigger)return this.loadUrl(fragment);},_updateHash:function(location,fragment,replace){if(replace){var href=location.href.replace(/(javascript:|#).*$/,'');location.replace(href+'#'+fragment);}else{location.hash='#'+fragment;}}});Backbone.history=new History;var extend=function(protoProps,staticProps){var parent=this;var child;if(protoProps&&_.has(protoProps,'constructor')){child=protoProps.constructor;}else{child=function(){return parent.apply(this,arguments);};} 137_.extend(child,parent,staticProps);child.prototype=_.create(parent.prototype,protoProps);child.prototype.constructor=child;child.__super__=parent.prototype;return child;};Model.extend=Collection.extend=Router.extend=View.extend=History.extend=extend;var urlError=function(){throw new Error('A "url" property or function must be specified');};var wrapError=function(model,options){var error=options.error;options.error=function(resp){if(error)error.call(options.context,model,resp,options);model.trigger('error',model,resp,options);};};return Backbone;});;(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?factory(exports,require('backbone'),require('underscore'),require('backbone.radio')):typeof define==='function'&&define.amd?define(['exports','backbone','underscore','backbone.radio'],factory):(global=global||self,(function(){var current=global.Marionette;var exports=global.Marionette={};factory(exports,global.Backbone,global._,global.Backbone.Radio);exports.noConflict=function(){global.Marionette=current;return exports;};}()));}(this,function(exports,Backbone,_,Radio){'use strict';Backbone=Backbone&&Backbone.hasOwnProperty('default')?Backbone['default']:Backbone;_=_&&_.hasOwnProperty('default')?_['default']:_;Radio=Radio&&Radio.hasOwnProperty('default')?Radio['default']:Radio;var version="4.1.2";var proxy=function proxy(method){return function(context){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];} 138return method.apply(context,args);};};var extend=Backbone.Model.extend;var normalizeMethods=function normalizeMethods(hash){var _this=this;if(!hash){return;} 139return _.reduce(hash,function(normalizedHash,method,name){if(!_.isFunction(method)){method=_this[method];} 140if(method){normalizedHash[name]=method;} 141return normalizedHash;},{});};var errorProps=['description','fileName','lineNumber','name','message','number','url'];var MarionetteError=extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v".concat(version,"/"),url:'',constructor:function constructor(options){var error=Error.call(this,options.message);_.extend(this,_.pick(error,errorProps),_.pick(options,errorProps));if(Error.captureStackTrace){this.captureStackTrace();} 142this.url=this.urlRoot+this.url;},captureStackTrace:function captureStackTrace(){Error.captureStackTrace(this,MarionetteError);},toString:function toString(){return"".concat(this.name,": ").concat(this.message," See: ").concat(this.url);}});function normalizeBindings(context,bindings){if(!_.isObject(bindings)){throw new MarionetteError({message:'Bindings must be an object.',url:'common.html#bindevents'});} 143return normalizeMethods.call(context,bindings);} 144function bindEvents(entity,bindings){if(!entity||!bindings){return this;} 145this.listenTo(entity,normalizeBindings(this,bindings));return this;} 146function unbindEvents(entity,bindings){if(!entity){return this;} 147if(!bindings){this.stopListening(entity);return this;} 148this.stopListening(entity,normalizeBindings(this,bindings));return this;} 149function normalizeBindings$1(context,bindings){if(!_.isObject(bindings)){throw new MarionetteError({message:'Bindings must be an object.',url:'common.html#bindrequests'});} 150return normalizeMethods.call(context,bindings);} 151function bindRequests(channel,bindings){if(!channel||!bindings){return this;}
152channel.reply(normalizeBindings$1(this,bindings),this);return this;} 153function unbindRequests(channel,bindings){if(!channel){return this;} 154if(!bindings){channel.stopReplying(null,null,this);return this;} 155channel.stopReplying(normalizeBindings$1(this,bindings));return this;} 156var getOption=function getOption(optionName){if(!optionName){return;} 157if(this.options&&this.options[optionName]!==undefined){return this.options[optionName];}else{return this[optionName];}};var mergeOptions=function mergeOptions(options,keys){var _this=this;if(!options){return;} 158_.each(keys,function(key){var option=options[key];if(option!==undefined){_this[key]=option;}});};function triggerMethodChildren(view,event,shouldTrigger){if(!view._getImmediateChildren){return;} 159_.each(view._getImmediateChildren(),function(child){if(!shouldTrigger(child)){return;} 160child.triggerMethod(event,child);});} 161function shouldTriggerAttach(view){return!view._isAttached;} 162function shouldAttach(view){if(!shouldTriggerAttach(view)){return false;} 163view._isAttached=true;return true;} 164function shouldTriggerDetach(view){return view._isAttached;} 165function shouldDetach(view){view._isAttached=false;return true;} 166function triggerDOMRefresh(view){if(view._isAttached&&view._isRendered){view.triggerMethod('dom:refresh',view);}} 167function triggerDOMRemove(view){if(view._isAttached&&view._isRendered){view.triggerMethod('dom:remove',view);}} 168function handleBeforeAttach(){triggerMethodChildren(this,'before:attach',shouldTriggerAttach);} 169function handleAttach(){triggerMethodChildren(this,'attach',shouldAttach);triggerDOMRefresh(this);} 170function handleBeforeDetach(){triggerMethodChildren(this,'before:detach',shouldTriggerDetach);triggerDOMRemove(this);} 171function handleDetach(){triggerMethodChildren(this,'detach',shouldDetach);} 172function handleBeforeRender(){triggerDOMRemove(this);} 173function handleRender(){triggerDOMRefresh(this);} 174function monitorViewEvents(view){if(view._areViewEventsMonitored||view.monitorViewEvents===false){return;} 175view._areViewEventsMonitored=true;view.on({'before:attach':handleBeforeAttach,'attach':handleAttach,'before:detach':handleBeforeDetach,'detach':handleDetach,'before:render':handleBeforeRender,'render':handleRender});} 176var splitter=/(^|:)(\w)/gi;var methodCache={};function getEventName(match,prefix,eventName){return eventName.toUpperCase();} 177var getOnMethodName=function getOnMethodName(event){if(!methodCache[event]){methodCache[event]='on'+event.replace(splitter,getEventName);} 178return methodCache[event];};function triggerMethod(event){var methodName=getOnMethodName(event);var method=getOption.call(this,methodName);var result;if(_.isFunction(method)){result=method.apply(this,_.drop(arguments));} 179this.trigger.apply(this,arguments);return result;} 180var Events={triggerMethod:triggerMethod};var CommonMixin={normalizeMethods:normalizeMethods,_setOptions:function _setOptions(options,classOptions){this.options=_.extend({},_.result(this,'options'),options);this.mergeOptions(options,classOptions);},mergeOptions:mergeOptions,getOption:getOption,bindEvents:bindEvents,unbindEvents:unbindEvents,bindRequests:bindRequests,unbindRequests:unbindRequests,triggerMethod:triggerMethod};_.extend(CommonMixin,Backbone.Events);var DestroyMixin={_isDestroyed:false,isDestroyed:function isDestroyed(){return this._isDestroyed;},destroy:function destroy(options){if(this._isDestroyed){return this;} 181this.triggerMethod('before:destroy',this,options);this._isDestroyed=true;this.triggerMethod('destroy',this,options);this.stopListening();return this;}};var RadioMixin={_initRadio:function _initRadio(){var channelName=_.result(this,'channelName');if(!channelName){return;} 182if(!Radio){throw new MarionetteError({message:'The dependency "backbone.radio" is missing.',url:'backbone.radio.html#marionette-integration'});} 183var channel=this._channel=Radio.channel(channelName);var radioEvents=_.result(this,'radioEvents');this.bindEvents(channel,radioEvents);var radioRequests=_.result(this,'radioRequests');this.bindRequests(channel,radioRequests);this.on('destroy',this._destroyRadio);},_destroyRadio:function _destroyRadio(){this._channel.stopReplying(null,null,this);},getChannel:function getChannel(){return this._channel;}};var ClassOptions=['channelName','radioEvents','radioRequests'];var MarionetteObject=function MarionetteObject(options){this._setOptions(options,ClassOptions);this.cid=_.uniqueId(this.cidPrefix);this._initRadio();this.initialize.apply(this,arguments);};MarionetteObject.extend=extend;_.extend(MarionetteObject.prototype,CommonMixin,DestroyMixin,RadioMixin,{cidPrefix:'mno',initialize:function initialize(){}});var _invoke=_.invokeMap||_.invoke;function getBehaviorClass(options){if(options.behaviorClass){return{BehaviorClass:options.behaviorClass,options:options};} 184if(_.isFunction(options)){return{BehaviorClass:options,options:{}};} 185throw new MarionetteError({message:'Unable to get behavior class. A Behavior constructor should be passed directly or as behaviorClass property of options',url:'marionette.behavior.html#defining-and-attaching-behaviors'});} 186function parseBehaviors(view,behaviors,allBehaviors){return _.reduce(behaviors,function(reducedBehaviors,behaviorDefiniton){var _getBehaviorClass=getBehaviorClass(behaviorDefiniton),BehaviorClass=_getBehaviorClass.BehaviorClass,options=_getBehaviorClass.options;var behavior=new BehaviorClass(options,view);reducedBehaviors.push(behavior);return parseBehaviors(view,_.result(behavior,'behaviors'),reducedBehaviors);},allBehaviors);} 187var BehaviorsMixin={_initBehaviors:function _initBehaviors(){this._behaviors=parseBehaviors(this,_.result(this,'behaviors'),[]);},_getBehaviorTriggers:function _getBehaviorTriggers(){var triggers=_invoke(this._behaviors,'_getTriggers');return _.reduce(triggers,function(memo,_triggers){return _.extend(memo,_triggers);},{});},_getBehaviorEvents:function _getBehaviorEvents(){var events=_invoke(this._behaviors,'_getEvents');return _.reduce(events,function(memo,_events){return _.extend(memo,_events);},{});},_proxyBehaviorViewProperties:function _proxyBehaviorViewProperties(){_invoke(this._behaviors,'proxyViewProperties');},_delegateBehaviorEntityEvents:function _delegateBehaviorEntityEvents(){_invoke(this._behaviors,'delegateEntityEvents');},_undelegateBehaviorEntityEvents:function _undelegateBehaviorEntityEvents(){_invoke(this._behaviors,'undelegateEntityEvents');},_destroyBehaviors:function _destroyBehaviors(options){_invoke(this._behaviors,'destroy',options);},_removeBehavior:function _removeBehavior(behavior){if(this._isDestroyed){return;} 188this.undelegate(".trig".concat(behavior.cid," .").concat(behavior.cid));this._behaviors=_.without(this._behaviors,behavior);},_bindBehaviorUIElements:function _bindBehaviorUIElements(){_invoke(this._behaviors,'bindUIElements');},_unbindBehaviorUIElements:function _unbindBehaviorUIElements(){_invoke(this._behaviors,'unbindUIElements');},_triggerEventOnBehaviors:function _triggerEventOnBehaviors(eventName,view,options){_invoke(this._behaviors,'triggerMethod',eventName,view,options);}};var DelegateEntityEventsMixin={_delegateEntityEvents:function _delegateEntityEvents(model,collection){if(model){this._modelEvents=_.result(this,'modelEvents');this.bindEvents(model,this._modelEvents);} 189if(collection){this._collectionEvents=_.result(this,'collectionEvents');this.bindEvents(collection,this._collectionEvents);}},_undelegateEntityEvents:function _undelegateEntityEvents(model,collection){if(this._modelEvents){this.unbindEvents(model,this._modelEvents);delete this._modelEvents;} 190if(this._collectionEvents){this.unbindEvents(collection,this._collectionEvents);delete this._collectionEvents;}},_deleteEntityEventHandlers:function _deleteEntityEventHandlers(){delete this._modelEvents;delete this._collectionEvents;}};var TemplateRenderMixin={_renderTemplate:function _renderTemplate(template){var data=this.mixinTemplateContext(this.serializeData())||{};var html=this._renderHtml(template,data);if(typeof html!=='undefined'){this.attachElContent(html);}},getTemplate:function getTemplate(){return this.template;},mixinTemplateContext:function mixinTemplateContext(serializedData){var templateContext=_.result(this,'templateContext');if(!templateContext){return serializedData;} 191if(!serializedData){return templateContext;} 192return _.extend({},serializedData,templateContext);},serializeData:function serializeData(){if(this.model){return this.serializeModel();} 193if(this.collection){return{items:this.serializeCollection()};}},serializeModel:function serializeModel(){return this.model.attributes;},serializeCollection:function serializeCollection(){return _.map(this.collection.models,function(model){return model.attributes;});},_renderHtml:function _renderHtml(template,data){return template(data);},attachElContent:function attachElContent(html){this.Dom.setContents(this.el,html,this.$el);}};var delegateEventSplitter=/^(\S+)\s*(.*)$/;var getNamespacedEventName=function getNamespacedEventName(eventName,namespace){var match=eventName.match(delegateEventSplitter);return"".concat(match[1],".").concat(namespace," ").concat(match[2]);};var FEATURES={childViewEventPrefix:false,triggersStopPropagation:true,triggersPreventDefault:true,DEV_MODE:false};function isEnabled(name){return!!FEATURES[name];} 194function setEnabled(name,state){return FEATURES[name]=state;} 195function buildViewTrigger(view,triggerDef){if(_.isString(triggerDef)){triggerDef={event:triggerDef};} 196var eventName=triggerDef.event;var shouldPreventDefault=!!triggerDef.preventDefault;if(isEnabled('triggersPreventDefault')){shouldPreventDefault=triggerDef.preventDefault!==false;} 197var shouldStopPropagation=!!triggerDef.stopPropagation;if(isEnabled('triggersStopPropagation')){shouldStopPropagation=triggerDef.stopPropagation!==false;} 198return function(event){if(shouldPreventDefault){event.preventDefault();} 199if(shouldStopPropagation){event.stopPropagation();} 200for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];} 201view.triggerMethod.apply(view,[eventName,view,event].concat(args));};} 202var TriggersMixin={_getViewTriggers:function _getViewTriggers(view,triggers){var _this=this;return _.reduce(triggers,function(events,value,key){key=getNamespacedEventName(key,"trig".concat(_this.cid));events[key]=buildViewTrigger(view,value);return events;},{});}};var _normalizeUIKeys=function normalizeUIKeys(hash,ui){return _.reduce(hash,function(memo,val,key){var normalizedKey=_normalizeUIString(key,ui);memo[normalizedKey]=val;return memo;},{});};var uiRegEx=/@ui\.[a-zA-Z-_$0-9]*/g;var _normalizeUIString=function normalizeUIString(uiString,ui){return uiString.replace(uiRegEx,function(r){return ui[r.slice(4)];});};var _normalizeUIValues=function normalizeUIValues(hash,ui,property){_.each(hash,function(val,key){if(_.isString(val)){hash[key]=_normalizeUIString(val,ui);}else if(val){var propertyVal=val[property];if(_.isString(propertyVal)){val[property]=_normalizeUIString(propertyVal,ui);}}});return hash;};var UIMixin={normalizeUIKeys:function normalizeUIKeys(hash){var uiBindings=this._getUIBindings();return _normalizeUIKeys(hash,uiBindings);},normalizeUIString:function normalizeUIString(uiString){var uiBindings=this._getUIBindings();return _normalizeUIString(uiString,uiBindings);},normalizeUIValues:function normalizeUIValues(hash,property){var uiBindings=this._getUIBindings();return _normalizeUIValues(hash,uiBindings,property);},_getUIBindings:function _getUIBindings(){var uiBindings=_.result(this,'_uiBindings');return uiBindings||_.result(this,'ui');},_bindUIElements:function _bindUIElements(){var _this=this;if(!this.ui){return;} 203if(!this._uiBindings){this._uiBindings=this.ui;} 204var bindings=_.result(this,'_uiBindings');this._ui={};_.each(bindings,function(selector,key){_this._ui[key]=_this.$(selector);});this.ui=this._ui;},_unbindUIElements:function _unbindUIElements(){var _this2=this;if(!this.ui||!this._uiBindings){return;} 205_.each(this.ui,function($el,name){delete _this2.ui[name];});this.ui=this._uiBindings;delete this._uiBindings;delete this._ui;},_getUI:function _getUI(name){return this._ui[name];}};function _getEl(el){return el instanceof Backbone.$?el:Backbone.$(el);} 206function setDomApi(mixin){this.prototype.Dom=_.extend({},this.prototype.Dom,mixin);return this;} 207var DomApi={createBuffer:function createBuffer(){return document.createDocumentFragment();},getDocumentEl:function getDocumentEl(el){return el.ownerDocument.documentElement;},getEl:function getEl(selector){return _getEl(selector);},findEl:function findEl(el,selector){return _getEl(el).find(selector);},hasEl:function hasEl(el,childEl){return el.contains(childEl&&childEl.parentNode);},detachEl:function detachEl(el){var _$el=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_getEl(el);_$el.detach();},replaceEl:function replaceEl(newEl,oldEl){if(newEl===oldEl){return;} 208var parent=oldEl.parentNode;if(!parent){return;} 209parent.replaceChild(newEl,oldEl);},swapEl:function swapEl(el1,el2){if(el1===el2){return;} 210var parent1=el1.parentNode;var parent2=el2.parentNode;if(!parent1||!parent2){return;} 211var next1=el1.nextSibling;var next2=el2.nextSibling;parent1.insertBefore(el2,next1);parent2.insertBefore(el1,next2);},setContents:function setContents(el,html){var _$el=arguments.length>2&&arguments[2]!==undefined?arguments[2]:_getEl(el);_$el.html(html);},appendContents:function appendContents(el,contents){var _ref=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref$_$el=_ref._$el,_$el=_ref$_$el===void 0?_getEl(el):_ref$_$el,_ref$_$contents=_ref._$contents,_$contents=_ref$_$contents===void 0?_getEl(contents):_ref$_$contents;_$el.append(_$contents);},hasContents:function hasContents(el){return!!el&&el.hasChildNodes();},detachContents:function detachContents(el){var _$el=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_getEl(el);_$el.contents().detach();}};var ViewMixin={Dom:DomApi,_isElAttached:function _isElAttached(){return!!this.el&&this.Dom.hasEl(this.Dom.getDocumentEl(this.el),this.el);},supportsRenderLifecycle:true,supportsDestroyLifecycle:true,_isDestroyed:false,isDestroyed:function isDestroyed(){return!!this._isDestroyed;},_isRendered:false,isRendered:function isRendered(){return!!this._isRendered;},_isAttached:false,isAttached:function isAttached(){return!!this._isAttached;},delegateEvents:function delegateEvents(events){this._proxyBehaviorViewProperties();this._buildEventProxies();var combinedEvents=_.extend({},this._getBehaviorEvents(),this._getEvents(events),this._getBehaviorTriggers(),this._getTriggers());Backbone.View.prototype.delegateEvents.call(this,combinedEvents);return this;},_getEvents:function _getEvents(events){if(events){return this.normalizeUIKeys(events);} 212if(!this.events){return;} 213return this.normalizeUIKeys(_.result(this,'events'));},_getTriggers:function _getTriggers(){if(!this.triggers){return;} 214var triggers=this.normalizeUIKeys(_.result(this,'triggers'));return this._getViewTriggers(this,triggers);},delegateEntityEvents:function delegateEntityEvents(){this._delegateEntityEvents(this.model,this.collection);this._delegateBehaviorEntityEvents();return this;},undelegateEntityEvents:function undelegateEntityEvents(){this._undelegateEntityEvents(this.model,this.collection);this._undelegateBehaviorEntityEvents();return this;},destroy:function destroy(options){if(this._isDestroyed||this._isDestroying){return this;} 215this._isDestroying=true;var shouldTriggerDetach=this._isAttached&&!this._disableDetachEvents;this.triggerMethod('before:destroy',this,options);if(shouldTriggerDetach){this.triggerMethod('before:detach',this);} 216this.unbindUIElements();this._removeElement();if(shouldTriggerDetach){this._isAttached=false;this.triggerMethod('detach',this);} 217this._removeChildren();this._isDestroyed=true;this._isRendered=false;this._destroyBehaviors(options);this._deleteEntityEventHandlers();this.triggerMethod('destroy',this,options);this._triggerEventOnBehaviors('destroy',this,options);this.stopListening();return this;},_removeElement:function _removeElement(){this.$el.off().removeData();this.Dom.detachEl(this.el,this.$el);},bindUIElements:function bindUIElements(){this._bindUIElements();this._bindBehaviorUIElements();return this;},unbindUIElements:function unbindUIElements(){this._unbindUIElements();this._unbindBehaviorUIElements();return this;},getUI:function getUI(name){return this._getUI(name);},_b
217uildEventProxies:function _buildEventProxies(){this._childViewEvents=this.normalizeMethods(_.result(this,'childViewEvents'));this._childViewTriggers=_.result(this,'childViewTriggers');this._eventPrefix=this._getEventPrefix();},_getEventPrefix:function _getEventPrefix(){var defaultPrefix=isEnabled('childViewEventPrefix')?'childview':false;var prefix=_.result(this,'childViewEventPrefix',defaultPrefix);return prefix===false?prefix:prefix+':';},_proxyChildViewEvents:function _proxyChildViewEvents(view){if(this._childViewEvents||this._childViewTriggers||this._eventPrefix){this.listenTo(view,'all',this._childViewEventHandler);}},_childViewEventHandler:function _childViewEventHandler(eventName){var childViewEvents=this._childViewEvents;for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];} 218if(childViewEvents&&childViewEvents[eventName]){childViewEvents[eventName].apply(this,args);} 219var childViewTriggers=this._childViewTriggers;if(childViewTriggers&&childViewTriggers[eventName]){this.triggerMethod.apply(this,[childViewTriggers[eventName]].concat(args));} 220if(this._eventPrefix){this.triggerMethod.apply(this,[this._eventPrefix+eventName].concat(args));}}};_.extend(ViewMixin,BehaviorsMixin,CommonMixin,DelegateEntityEventsMixin,TemplateRenderMixin,TriggersMixin,UIMixin);function renderView(view){if(view._isRendered){return;} 221if(!view.supportsRenderLifecycle){view.triggerMethod('before:render',view);} 222view.render();view._isRendered=true;if(!view.supportsRenderLifecycle){view.triggerMethod('render',view);}} 223function destroyView(view,disableDetachEvents){if(view.destroy){view._disableDetachEvents=disableDetachEvents;view.destroy();return;} 224if(!view.supportsDestroyLifecycle){view.triggerMethod('before:destroy',view);} 225var shouldTriggerDetach=view._isAttached&&!disableDetachEvents;if(shouldTriggerDetach){view.triggerMethod('before:detach',view);} 226view.remove();if(shouldTriggerDetach){view._isAttached=false;view.triggerMethod('detach',view);} 227view._isDestroyed=true;if(!view.supportsDestroyLifecycle){view.triggerMethod('destroy',view);}} 228var classErrorName='RegionError';var ClassOptions$1=['allowMissingEl','parentEl','replaceElement'];var Region=function Region(options){this._setOptions(options,ClassOptions$1);this.cid=_.uniqueId(this.cidPrefix);this._initEl=this.el=this.getOption('el');this.el=this.el instanceof Backbone.$?this.el[0]:this.el;this.$el=this._getEl(this.el);this.initialize.apply(this,arguments);};Region.extend=extend;Region.setDomApi=setDomApi;_.extend(Region.prototype,CommonMixin,{Dom:DomApi,cidPrefix:'mnr',replaceElement:false,_isReplaced:false,_isSwappingView:false,initialize:function initialize(){},show:function show(view,options){if(!this._ensureElement(options)){return;} 229view=this._getView(view,options);if(view===this.currentView){return this;} 230if(view._isShown){throw new MarionetteError({name:classErrorName,message:'View is already shown in a Region or CollectionView',url:'marionette.region.html#showing-a-view'});} 231this._isSwappingView=!!this.currentView;this.triggerMethod('before:show',this,view,options);if(this.currentView||!view._isAttached){this.empty(options);} 232this._setupChildView(view);this.currentView=view;renderView(view);this._attachView(view,options);this.triggerMethod('show',this,view,options);this._isSwappingView=false;return this;},_getEl:function _getEl(el){if(!el){throw new MarionetteError({name:classErrorName,message:'An "el" must be specified for a region.',url:'marionette.region.html#additional-options'});} 233return this.getEl(el);},_setEl:function _setEl(){this.$el=this._getEl(this.el);if(this.$el.length){this.el=this.$el[0];} 234if(this.$el.length>1){this.$el=this.Dom.getEl(this.el);}},_setElement:function _setElement(el){if(el===this.el){return this;} 235var shouldReplace=this._isReplaced;this._restoreEl();this.el=el;this._setEl();if(this.currentView){var view=this.currentView;if(shouldReplace){this._replaceEl(view);}else{this.attachHtml(view);}} 236return this;},_setupChildView:function _setupChildView(view){monitorViewEvents(view);this._proxyChildViewEvents(view);view.on('destroy',this._empty,this);},_proxyChildViewEvents:function _proxyChildViewEvents(view){var parentView=this._parentView;if(!parentView){return;} 237parentView._proxyChildViewEvents(view);},_shouldDisableMonitoring:function _shouldDisableMonitoring(){return this._parentView&&this._parentView.monitorViewEvents===false;},_isElAttached:function _isElAttached(){return this.Dom.hasEl(this.Dom.getDocumentEl(this.el),this.el);},_attachView:function _attachView(view){var _ref=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},replaceElement=_ref.replaceElement;var shouldTriggerAttach=!view._isAttached&&this._isElAttached()&&!this._shouldDisableMonitoring();var shouldReplaceEl=typeof replaceElement==='undefined'?!!_.result(this,'replaceElement'):!!replaceElement;if(shouldTriggerAttach){view.triggerMethod('before:attach',view);} 238if(shouldReplaceEl){this._replaceEl(view);}else{this.attachHtml(view);} 239if(shouldTriggerAttach){view._isAttached=true;view.triggerMethod('attach',view);} 240view._isShown=true;},_ensureElement:function _ensureElement(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(!_.isObject(this.el)){this._setEl();} 241if(!this.$el||this.$el.length===0){var allowMissingEl=typeof options.allowMissingEl==='undefined'?!!_.result(this,'allowMissingEl'):!!options.allowMissingEl;if(allowMissingEl){return false;}else{throw new MarionetteError({name:classErrorName,message:"An \"el\" must exist in DOM for this region ".concat(this.cid),url:'marionette.region.html#additional-options'});}} 242return true;},_getView:function _getView(view){if(!view){throw new MarionetteError({name:classErrorName,message:'The view passed is undefined and therefore invalid. You must pass a view instance to show.',url:'marionette.region.html#showing-a-v
242iew'});} 243if(view._isDestroyed){throw new MarionetteError({name:classErrorName,message:"View (cid: \"".concat(view.cid,"\") has already been destroyed and cannot be used."),url:'marionette.region.html#showing-a-view'});} 244if(view instanceof Backbone.View){return view;} 245var viewOptions=this._getViewOptions(view);return new View(viewOptions);},_getViewOptions:function _getViewOptions(viewOptions){if(_.isFunction(viewOptions)){return{template:viewOptions};} 246if(_.isObject(viewOptions)){return viewOptions;} 247var template=function template(){return viewOptions;};return{template:template};},getEl:function getEl(el){var context=_.result(this,'parentEl');if(context&&_.isString(el)){return this.Dom.findEl(context,el);} 248return this.Dom.getEl(el);},_replaceEl:function _replaceEl(view){this._restoreEl();view.on('before:destroy',this._restoreEl,this);this.Dom.replaceEl(view.el,this.el);this._isReplaced=true;},_restoreEl:function _restoreEl(){if(!this._isReplaced){return;} 249var view=this.currentView;if(!view){return;} 250this._detachView(view);this._isReplaced=false;},isReplaced:function isReplaced(){return!!this._isReplaced;},isSwappingView:function isSwappingView(){return!!this._isSwappingView;},attachHtml:function attachHtml(view){this.Dom.appendContents(this.el,view.el,{_$el:this.$el,_$contents:view.$el});},empty:function empty(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{allowMissingEl:true};var view=this.currentView;if(!view){if(this._ensureElement(options)){this.detachHtml();} 251return this;} 252this._empty(view,true);return this;},_empty:function _empty(view,shouldDestroy){view.off('destroy',this._empty,this);this.triggerMethod('before:empty',this,view);this._restoreEl();delete this.currentView;if(!view._isDestroyed){if(shouldDestroy){this.removeView(view);}else{this._detachView(view);} 253view._isShown=false;this._stopChildViewEvents(view);} 254this.triggerMethod('empty',this,view);},_stopChildViewEvents:function _stopChildViewEvents(view){var parentView=this._parentView;if(!parentView){return;} 255this._parentView.stopListening(view);},destroyView:function destroyView$1(view){if(view._isDestroyed){return view;} 256destroyView(view,this._shouldDisableMonitoring());return view;},removeView:function removeView(view){this.destroyView(view);},detachView:function detachView(){var view=this.currentView;if(!view){return;} 257this._empty(view);return view;},_detachView:function _detachView(view){var shouldTriggerDetach=view._isAttached&&!this._shouldDisableMonitoring();var shouldRestoreEl=this._isReplaced;if(shouldTriggerDetach){view.triggerMethod('before:detach',view);} 258if(shouldRestoreEl){this.Dom.replaceEl(this.el,view.el);}else{this.detachHtml();} 259if(shouldTriggerDetach){view._isAttached=false;view.triggerMethod('detach',view);}},detachHtml:function detachHtml(){this.Dom.detachContents(this.el,this.$el);},hasView:function hasView(){return!!this.currentView;},reset:function reset(options){this.empty(options);this.el=this._initEl;delete this.$el;return this;},_isDestroyed:false,isDestroyed:function isDestroyed(){return this._isDestroyed;},destroy:function destroy(options){if(this._isDestroyed){return this;} 260this.triggerMethod('before:destroy',this,options);this._isDestroyed=true;this.reset(options);if(this._name){this._parentView._removeReferences(this._name);} 261delete this._parentView;delete this._name;this.triggerMethod('destroy',this,options);this.stopListening();return this;}});function buildRegion(definition,defaults){if(definition instanceof Region){return definition;} 262if(_.isString(definition)){return buildRegionFromObject(defaults,{el:definition});} 263if(_.isFunction(definition)){return buildRegionFromObject(defaults,{regionClass:definition});} 264if(_.isObject(definition)){return buildRegionFromObject(defaults,definition);} 265throw new MarionetteError({message:'Improper region configuration type.',url:'marionette.region.html#defining-regions'});} 266function buildRegionFromObject(defaults,definition){var options=_.extend({},defaults,definition);var RegionClass=options.regionClass;delete options.regionClass;return new RegionClass(options);} 267var RegionsMixin={regionClass:Region,_initRegions:function _initRegions(){this.regions=this.regions||{};this._regions={};this.addRegions(_.result(this,'regions'));},_reInitRegions:function _reInitRegions(){_invoke(this._regions,'reset');},addRegion:function addRegion(name,definition){var regions={};regions[name]=definition;return this.addRegions(regions)[name];},addRegions:function addRegions(regions){if(_.isEmpty(regions)){return;} 268regions=this.normalizeUIValues(regions,'el');this.regions=_.extend({},this.regions,regions);return this._addRegions(regions);},_addRegions:function _addRegions(regionDefinitions){var _this=this;var defaults={regionClass:this.regionClass,parentEl:_.partial(_.result,this,'el')};return _.reduce(regionDefinitions,function(regions,definition,name){regions[name]=buildRegion(definition,defaults);_this._addRegion(regions[name],name);return regions;},{});},_addRegion:function _addRegion(region,name){this.triggerMethod('before:add:region',this,name,region);region._parentView=this;region._name=name;this._regions[name]=region;this.triggerMethod('add:region',this,name,region);},removeRegion:function removeRegion(name){var region=this._regions[name];this._removeRegion(region,name);return region;},removeRegions:function removeRegions(){var regions=this._getRegions();_.each(this._regions,this._removeRegion.bind(this));return regions;},_removeRegion:function _removeRegion(region,name){this.triggerMethod('before:remove:region',this,name,region);region.destroy();this.triggerMethod('remove:region',this,name,region);},_removeReferences:function _removeReferences(name){delete this.regions[name];delete this._regions[name];},emptyRegions:function emptyRegions(){var regions=this.getRegions();_invoke(regions,'empty');return regions;},hasRegion:function hasRegion(name){return!!this.getRegion(name);},getRegion:function getRegion(name){if(!this._isRendered){this.render();} 269return this._regions[name];},_getRegions:function _getRegions(){return _.clone(this._regions);},getRegions:function getRegions(){if(!this._isRendered){this.render();} 270return this._getRegions();},showChildView:function showChildView(name,view,options){var region=this.getRegion(name);region.show(view,options);return view;},detachChildView:function detachChildView(name){return this.getRegion(name).detachView();},getChildView:function getChildView(name){return this.getRegion(name).currentView;}};function setRenderer(renderer){this.prototype._renderHtml=renderer;return this;} 271var ClassOptions$2=['behaviors','childViewEventPrefix','childViewEvents','childViewTriggers','collectionEvents','events','modelEvents','regionClass','regi
271ons','template','templateContext','triggers','ui'];function childReducer(children,region){if(region.currentView){children.push(region.currentView);} 272return children;} 273var View=Backbone.View.extend({constructor:function constructor(options){this._setOptions(options,ClassOptions$2);monitorViewEvents(this);this._initBehaviors();this._initRegions();Backbone.View.prototype.constructor.apply(this,arguments);this.delegateEntityEvents();this._triggerEventOnBehaviors('initialize',this,options);},setElement:function setElement(){Backbone.View.prototype.setElement.apply(this,arguments);this._isRendered=this.Dom.hasContents(this.el);this._isAttached=this._isElAttached();if(this._isRendered){this.bindUIElements();} 274return this;},render:function render(){var template=this.getTemplate();if(template===false||this._isDestroyed){return this;} 275this.triggerMethod('before:render',this);if(this._isRendered){this._reInitRegions();} 276this._renderTemplate(template);this.bindUIElements();this._isRendered=true;this.triggerMethod('render',this);return this;},_removeChildren:function _removeChildren(){this.removeRegions();},_getImmediateChildren:function _getImmediateChildren(){return _.reduce(this._regions,childReducer,[]);}},{setRenderer:setRenderer,setDomApi:setDomApi});_.extend(View.prototype,ViewMixin,RegionsMixin);var Container=function Container(){this._init();};var methods=['forEach','each','map','find','detect','filter','select','reject','every','all','some','any','include','contains','invoke','toArray','first','initial','rest','last','without','isEmpty','pluck','reduce','partition'];_.each(methods,function(method){Container.prototype[method]=function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];} 277return _[method].apply(_,[this._views].concat(args));};});function stringComparator(comparator,view){return view.model&&view.model.get(comparator);} 278_.extend(Container.prototype,{_init:function _init(){this._views=[];this._viewsByCid={};this._indexByModel={};this._updateLength();},_add:function _add(view){var index=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this._views.length;this._addViewIndexes(view);this._views.splice(index,0,view);this._updateLength();},_addViewIndexes:function _addViewIndexes(view){this._viewsByCid[view.cid]=view;if(view.model){this._indexByModel[view.model.cid]=view;}},_sort:function _sort(comparator,context){if(typeof comparator==='string'){comparator=_.partial(stringComparator,comparator);return this._sortBy(comparator);} 279if(comparator.length===1){return this._sortBy(comparator.bind(context));} 280return this._views.sort(comparator.bind(context));},_sortBy:function _sortBy(comparator){var sortedViews=_.sortBy(this._views,comparator);this._set(sortedViews);return sortedViews;},_set:function _set(views,shouldReset){this._views.length=0;this._views.push.apply(this._views,views.slice(0));if(shouldReset){this._viewsByCid={};this._indexByModel={};_.each(views,this._addViewIndexes.bind(this));this._updateLength();}},_swap:function _swap(view1,view2){var view1Index=this.findIndexByView(view1);var view2Index=this.findIndexByView(view2);if(view1Index===-1||view2Index===-1){return;} 281var swapView=this._views[view1Index];this._views[view1Index]=this._views[view2Index];this._views[view2Index]=swapView;},findByModel:function findByModel(model){return this.findByModelCid(model.cid);},findByModelCid:function findByModelCid(modelCid){return this._indexByModel[modelCid];},findByIndex:function findByIndex(index){return this._views[index];},findIndexByView:function findIndexByView(view){return this._views.indexOf(view);},findByCid:function findByCid(cid){return this._viewsByCid[cid];},hasView:function hasView(view){return!!this.findByCid(view.cid);},_remove:function _remove(view){if(!this._viewsByCid[view.cid]){return;} 282if(view.model){delete this._indexByModel[view.model.cid];} 283delete this._viewsByCid[view.cid];var index=this.findIndexByView(view);this._views.splice(index,1);this._updateLength();},_updateLength:function _updateLength(){this.length=this._views.length;}});var classErrorName$1='CollectionViewError';var ClassOptions$3=['behaviors','childView','childViewContainer','childViewEventPrefix','childViewEvents','childViewOptions','childViewTriggers','collectionEvents','emptyView','emptyViewOptions','events','modelEvents','sortWithCollection','template','templateContext','triggers','ui','viewComparator','viewFilter'];var CollectionView=Backbone.View.extend({sortWithCollection:true,constructor:function constructor(options){this._setOptions(options,ClassOptions$3);monitorViewEvents(this);this._initChildViewStorage();this._initBehaviors();Backbone.View.prototype.constructor.apply(this,arguments);this.getEmptyRegion();this.delegateEntityEvents();this._triggerEventOnBehaviors('initialize',this,options);},_initChildViewStorage:function _initChildViewStorage(){this._children=new Container();this.children=new Container();},getEmptyRegion:function getEmptyRegion(){var $emptyEl=this.$container||this.$el;if(this._emptyRegion&&!this._emptyRegion.isDestroyed()){this._emptyRegion._setElement($emptyEl[0]);return this._emptyRegion;} 284this._emptyRegion=new Region({el:$emptyEl[0],replaceElement:false});this._emptyRegion._parentView=this;return this._emptyRegion;},_initialEvents:function _initialEvents(){if(this._isRendered){return;}
285this.listenTo(this.collection,{'sort':this._onCollectionSort,'reset':this._onCollectionReset,'update':this._onCollectionUpdate});},_onCollectionSort:function _onCollectionSort(collection,_ref){var add=_ref.add,merge=_ref.merge,remove=_ref.remove;if(!this.sortWithCollection||this.viewComparator===false){return;} 286if(add||remove||merge){return;} 287this.sort();},_onCollectionReset:function _onCollectionReset(){this._destroyChildren();this._addChildModels(this.collection.models);this.sort();},_onCollectionUpdate:function _onCollectionUpdate(collection,options){var changes=options.changes;var removedViews=changes.removed.length&&this._removeChildModels(changes.removed);this._addedViews=changes.added.length&&this._addChildModels(changes.added);this._detachChildren(removedViews);this.sort();this._removeChildViews(removedViews);},_removeChildModels:function _removeChildModels(models){var _this=this;return _.reduce(models,function(views,model){var removeView=_this._removeChildModel(model);if(removeView){views.push(removeView);} 288return views;},[]);},_removeChildModel:function _removeChildModel(model){var view=this._children.findByModel(model);if(view){this._removeChild(view);} 289return view;},_removeChild:function _removeChild(view){this.triggerMethod('before:remove:child',this,view);this.children._remove(view);this._children._remove(view);this.triggerMethod('remove:child',this,view);},_addChildModels:function _addChildModels(models){return _.map(models,this._addChildModel.bind(this));},_addChildModel:function _addChildModel(model){var view=this._createChildView(model);this._addChild(view);return view;},_createChildView:function _createChildView(model){var ChildView=this._getChildView(model);var childViewOptions=this._getChildViewOptions(model);var view=this.buildChildView(model,ChildView,childViewOptions);return view;},_addChild:function _addChild(view,index){this.triggerMethod('before:add:child',this,view);this._setupChildView(view);this._children._add(view,index);this.children._add(view,index);this.triggerMethod('add:child',this,view);},_getChildView:function _getChildView(child){var childView=this.childView;if(!childView){throw new MarionetteError({name:classErrorName$1,message:'A "childView" must be specified',url:'marionette.collectionview.html#collectionviews-childview'});} 290childView=this._getView(childView,child);if(!childView){throw new MarionetteError({name:classErrorName$1,message:'"childView" must be a view class or a function that returns a view class',url:'marionette.collectionview.html#collectionviews-childview'});} 291return childView;},_getView:function _getView(view,child){if(view.prototype instanceof Backbone.View||view===Backbone.View){return view;}else if(_.isFunction(view)){return view.call(this,child);}},_getChildViewOptions:function _getChildViewOptions(child){if(_.isFunction(this.childViewOptions)){return this.childViewOptions(child);} 292return this.childViewOptions;},buildChildView:function buildChildView(child,ChildViewClass,childViewOptions){var options=_.extend({model:child},childViewOptions);return new ChildViewClass(options);},_setupChildView:function _setupChildView(view){monitorViewEvents(view);view.on('destroy',this.removeChildView,this);this._proxyChildViewEvents(view);},_getImmediateChildren:function _getImmediateChildren(){return this.children._views;},setElement:function setElement(){Backbone.View.prototype.setElement.apply(this,arguments);this._isAttached=this._isElAttached();return this;},render:function render(){if(this._isDestroyed){return this;} 293this.triggerMethod('before:render',this);this._destroyChildren();if(this.collection){this._addChildModels(this.collection.models);this._initialEvents();} 294var template=this.getTemplate();if(template){this._renderTemplate(template);this.bindUIElements();} 295this._getChildViewContainer();this.sort();this._isRendered=true;this.triggerMethod('render',this);return this;},_getChildViewContainer:function _getChildViewContainer(){var childViewContainer=_.result(this,'childViewContainer');this.$container=childViewContainer?this.$(childViewContainer):this.$el;if(!this.$container.length){throw new MarionetteError({name:classErrorName$1,message:"The specified \"childViewContainer\" was not found: ".concat(childViewContainer),url:'marionette.collectionview.html#defining-the-childviewcontainer'});}},sort:function sort(){this._sortChildren();this.filter();return this;},_sortChildren:function _sortChildren(){if(!this._children.length){return;} 296var viewComparator=this.getComparator();if(!viewComparator){return;} 297delete this._addedViews;this.triggerMethod('before:sort',this);this._children._sort(viewComparator,this);this.triggerMethod('sort',this);},setComparator:function setComparator(comparator){var _ref2=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},preventRender=_ref2.preventRender;var comparatorChanged=this.viewComparator!==comparator;var shouldSort=comparatorChanged&&!preventRender;this.viewComparator=comparator;if(shouldSort){this.sort();} 298return this;},removeComparator:function removeComparator(options){return this.setComparator(null,options);},getComparator:function getComparator(){if(this.viewComparator){return this.viewComparator;} 299if(!this.sortWithCollection||this.viewComparator===false||!this.collection){return false;} 300return this._viewComparator;},_viewComparator:function _viewComparator(view){return this.collection.indexOf(view.model);},filter:function filter(){if(this._isDestroyed){return this;} 301this._filterChildren();this._renderChildren();return this;},_filterChildren:function _filterChildren(){var _this2=this;if(!this._children.length){return;} 302var viewFilter=this._getFilter();if(!viewFilter){var shouldReset=this.children.length!==this._children.length;this.children._set(this._children._views,shouldReset);return;} 303delete this._addedViews;this.triggerMethod('before:filter',this);var attachViews=[];var detachViews=[];_.each(this._children._views,function(view,key,children){(viewFilter.call(_this2,view,key,children)?attachViews:detachViews).push(view);});this._detachChildren(detachViews);this.children._set(attachViews,true);this.triggerMethod('filter',this,attachViews,detachViews);},_getFilter:function _getFilter(){var viewFilter=this.getFilter();if(!viewFilter){return false;} 304if(_.isFunction(viewFilter)){return viewFilter;} 305if(_.isObject(viewFilter)){var matcher=_.matches(viewFilter);return function(view){return matcher(view.model&&view.model.attributes);};} 306if(_.isString(viewFilter)){return function(view){return view.model&&view.model.get(viewFilter);};} 307throw new MarionetteError({name:classErrorName$1,message:'"viewFilter" must be a function, predicate object literal, a string indicating a model attribute, or falsy',url:'marionette.collectionview.html#defining-the-viewfilter'});},getFilter:function getFilter(){return this.viewFilter;},setFilter:function setFilter(filter){var _ref3=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},preventRender=_ref3.preventRender;var filterChanged=this.viewFilter!==filter;var shouldRender=filterChanged&&!preventRender;this.viewFilter=filter;if(shouldRender){this.filter();} 308return this;},removeFilter:function removeFilter(options){return this.setFilter(null,options);},_detachChildren:function _detachChildren(detachingViews){_.each(detachingViews,this._detachChildView.bind(this));},_detachChildView:function _detachChildView(view){var shouldTriggerDetach=view._isAttached&&this.monitorViewEvents!==false;if(shouldTriggerDetach){view.triggerMethod('before:detach',view);} 309this.detachHtml(view);if(shouldTriggerDetach){view._isAttached=false;view.triggerMethod('detach',view);} 310view._isShown=false;},detachHtml:function detachHtml(view){this.Dom.detachEl(view.el,view.$el);},_renderChildren:function _renderChildren(){if(this._hasUnrenderedViews){delete this._addedViews;delete this._hasUnrenderedViews;} 311var views=this._addedViews||this.children._views;this.triggerMethod('before:render:children',this,views);if(this.isEmpty()){this._showEmptyView();}else{this._destroyEmptyView();var els=this._getBuffer(views);this._attachChildren(els,views);} 312delete this._addedViews;this.triggerMethod('render:children',this,views);},_getBuffer:function _getBuffer(views){var _this3=this;var elBuffer=this.Dom.createBuffer();_.each(views,function(view){renderView(view);view._isShown=true;
312_this3.Dom.appendContents(elBuffer,view.el,{_$contents:view.$el});});return elBuffer;},_attachChildren:function _attachChildren(els,views){var shouldTriggerAttach=this._isAttached&&this.monitorViewEvents!==false;views=shouldTriggerAttach?views:[];_.each(views,function(view){if(view._isAttached){return;} 313view.triggerMethod('before:attach',view);});this.attachHtml(els,this.$container);_.each(views,function(view){if(view._isAttached){return;} 314view._isAttached=true;view.triggerMethod('attach',view);});},attachHtml:function attachHtml(els,$container){this.Dom.appendContents($container[0],els,{_$el:$container});},isEmpty:function isEmpty(){return!this.children.length;},_showEmptyView:function _showEmptyView(){var EmptyView=this._getEmptyView();if(!EmptyView){return;} 315var options=this._getEmptyViewOptions();var emptyRegion=this.getEmptyRegion();emptyRegion.show(new EmptyView(options));},_getEmptyView:function _getEmptyView(){var emptyView=this.emptyView;if(!emptyView){return;} 316return this._getView(emptyView);},_destroyEmptyView:function _destroyEmptyView(){var emptyRegion=this.getEmptyRegion();if(emptyRegion.hasView()){emptyRegion.empty();}},_getEmptyViewOptions:function _getEmptyViewOptions(){var emptyViewOptions=this.emptyViewOptions||this.childViewOptions;if(_.isFunction(emptyViewOptions)){return emptyViewOptions.call(this);} 317return emptyViewOptions;},swapChildViews:function swapChildViews(view1,view2){if(!this._children.hasView(view1)||!this._children.hasView(view2)){throw new MarionetteError({name:classErrorName$1,message:'Both views must be children of the collection view to swap.',url:'marionette.collectionview.html#swapping-child-views'});} 318this._children._swap(view1,view2);this.Dom.swapEl(view1.el,view2.el);if(this.children.hasView(view1)!==this.children.hasView(view2)){this.filter();}else{this.children._swap(view1,view2);} 319return this;},addChildView:function addChildView(view,index){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(!view||view._isDestroyed){return view;} 320if(view._isShown){throw new MarionetteError({name:classErrorName$1,message:'View is already shown in a Region or CollectionView',url:'marionette.region.html#showing-a-view'});} 321if(_.isObject(index)){options=index;} 322if(options.index!=null){index=options.index;} 323if(!this._isRendered){this.render();} 324this._addChild(view,index);if(options.preventRender){this._hasUnrenderedViews=true;return view;} 325var hasIndex=typeof index!=='undefined';var isAddedToEnd=!hasIndex||index>=this._children.length;if(isAddedToEnd&&!this._hasUnrenderedViews){this._addedViews=[view];} 326if(hasIndex){this._renderChildren();}else{this.sort();} 327return view;},detachChildView:function detachChildView(view){this.removeChildView(view,{shouldDetach:true});return view;},removeChildView:function removeChildView(view,options){if(!view){return view;} 328this._removeChildView(view,options);this._removeChild(view);if(this.isEmpty()){this._showEmptyView();} 329return view;},_removeChildViews:function _removeChildViews(views){_.each(views,this._removeChildView.bind(this));},_removeChildView:function _removeChildView(view){var _ref4=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},shouldDetach=_ref4.shouldDetach;view.off('destroy',this.removeChildView,this);if(shouldDetach){this._detachChildView(view);}else{this._destroyChildView(view);} 330this.stopListening(view);},_destroyChildView:function _destroyChildView(view){if(view._isDestroyed){return;} 331var shouldDisableEvents=this.monitorViewEvents===false;destroyView(view,shouldDisableEvents);},_removeChildren:function _removeChildren(){this._destroyChildren();var emptyRegion=this.getEmptyRegion();emptyRegion.destroy();delete this._addedViews;},_destroyChildren:function _destroyChildren(){if(!this._children.length){return;} 332this.triggerMethod('before:destroy:children',this);if(this.monitorViewEvents===false){this.Dom.detachContents(this.el,this.$el);} 333this._removeChildViews(this._children._views);this._children._init();this.children._init();this.triggerMethod('destroy:children',this);}},{setDomApi:setDomApi,setRenderer:setRenderer});_.extend(CollectionView.prototype,ViewMixin);
333var ClassOptions$4=['collectionEvents','events','modelEvents','triggers','ui'];var Behavior=function Behavior(options,view){this.view=view;this._setOptions(options,ClassOptions$4);this.cid=_.uniqueId(this.cidPrefix);this.ui=_.extend({},_.result(this,'ui'),_.result(view,'ui'));this.listenTo(view,'all',this.triggerMethod);this.initialize.apply(this,arguments);};Behavior.extend=extend;_.extend(Behavior.prototype,CommonMixin,DelegateEntityEventsMixin,TriggersMixin,UIMixin,{cidPrefix:'mnb',initialize:function initialize(){},$:function $(){return this.view.$.apply(this.view,arguments);},destroy:function destroy(){this.stopListening();this.view._removeBehavior(this);this._deleteEntityEventHandlers();return this;},proxyViewProperties:function proxyViewProperties(){this.$el=this.view.$el;this.el=this.view.el;return this;},bindUIElements:function bindUIElements(){this._bindUIElements();return this;},unbindUIElements:function unbindUIElements(){this._unbindUIElements();return this;},getUI:function getUI(name){return this._getUI(name);},delegateEntityEvents:function delegateEntityEvents(){this._delegateEntityEvents(this.view.model,this.view.collection);return this;},undelegateEntityEvents:function undelegateEntityEvents(){this._undelegateEntityEvents(this.view.model,this.view.collection);return this;},_getEvents:function _getEvents(){var _this=this;if(!this.events){return;} 334var behaviorEvents=this.normalizeUIKeys(_.result(this,'events'));return _.reduce(behaviorEvents,function(events,behaviorHandler,key){if(!_.isFunction(behaviorHandler)){behaviorHandler=_this[behaviorHandler];} 335if(!behaviorHandler){return events;} 336key=getNamespacedEventName(key,_this.cid);events[key]=behaviorHandler.bind(_this);return events;},{});},_getTriggers:function _getTriggers(){if(!this.triggers){return;} 337var behaviorTriggers=this.normalizeUIKeys(_.result(this,'triggers'));return this._getViewTriggers(this.view,behaviorTriggers);}});var ClassOptions$5=['channelName','radioEvents','radioRequests','region','regionClass'];var Application=function Application(options){this._setOptions(options,ClassOptions$5);this.cid=_.uniqueId(this.cidPrefix);this._initRegion();this._initRadio();this.initialize.apply(this,arguments);};Application.extend=extend;_.extend(Application.prototype,CommonMixin,DestroyMixin,RadioMixin,{cidPrefix:'mna',initialize:function initialize(){},start:function start(options){this.triggerMethod('before:start',this,options);this.triggerMethod('start',this,options);return this;},regionClass:Region,_initRegion:function _initRegion(){var region=this.region;if(!region){return;} 338var defaults={regionClass:this.regionClass};this._region=buildRegion(region,defaults);},getRegion:function getRegion(){return this._region;},showView:function showView(view){var region=this.getRegion();for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];} 339region.show.apply(region,[view].concat(args));return view;},getView:function getView(){return this.getRegion().currentView;}});var bindEvents$1=proxy(bindEvents);var unbindEvents$1=proxy(unbindEvents);var bindRequests$1=proxy(bindRequests);var unbindRequests$1=proxy(unbindRequests);var mergeOptions$1=proxy(mergeOptions);var getOption$1=proxy(getOption);var normalizeMethods$1=proxy(normalizeMethods);var triggerMethod$1=proxy(triggerMethod);var setDomApi$1=function setDomApi(mixin){CollectionView.setDomApi(mixin);Region.setDomApi(mixin);View.setDomApi(mixin);};var setRenderer$1=function setRenderer(renderer){CollectionView.setRenderer(renderer);View.setRenderer(renderer);};var backbone_marionette={View:View,CollectionView:CollectionView,MnObject:MarionetteObject,Object:MarionetteObject,Region:Region,Behavior:Behavior,Application:Application,isEnabled:isEnabled,setEnabled:setEnabled,monitorViewEvents:monitorViewEvents,Events:Events,extend:extend,DomApi:DomApi,VERSION:version};exports.Application=Application;exports.Behavior=Behavior;exports.CollectionView=CollectionView;exports.DomApi=DomApi;exports.Events=Events;exports.MnObject=MarionetteObject;exports.Region=Region;exports.VERSION=version;exports.View=View;exports.bindEvents=bindEvents$1;exports.bindRequests=bindRequests$1;exports.default=backbone_marionette;exports.extend=extend;
339exports.getOption=getOption$1;exports.isEnabled=isEnabled;exports.mergeOptions=mergeOptions$1;exports.monitorViewEvents=monitorViewEvents;exports.normalizeMethods=normalizeMethods$1;exports.setDomApi=setDomApi$1;exports.setEnabled=setEnabled;exports.setRenderer=setRenderer$1;exports.triggerMethod=triggerMethod$1;exports.unbindEvents=unbindEvents$1;exports.unbindRequests=unbindRequests$1;Object.defineProperty(exports,'__esModule',{value:true});}));this&&this.Marionette&&(this.Mn=this.Marionette);;(function(root,factory){if(typeof define==='function'&&define.amd){define(['backbone','underscore'],function(Backbone,_){return factory(Backbone,_);});} 340else if(typeof exports!=='undefined'){var Backbone=require('backbone');var _=require('underscore');module.exports=factory(Backbone,_);} 341else{factory(root.Backbone,root._);}}(this,function(Backbone,_){'use strict';var previousRadio=Backbone.Radio;var Radio=Backbone.Radio={};Radio.VERSION='0.9.0';Radio.noConflict=function(){Backbone.Radio=previousRadio;return this;};Radio.DEBUG=false;Radio._debugText=function(warning,eventName,channelName){return warning+(channelName?' on the '+channelName+' channel':'')+': "'+eventName+'"';};Radio.debugLog=function(warning,eventName,channelName){if(Radio.DEBUG&&console&&console.warn){console.warn(Radio._debugText(warning,eventName,channelName));}};var eventSplitter=/\s+/;Radio._eventsApi=function(obj,action,name,rest){if(!name){return false;} 342var results={};if(typeof name==='object'){for(var key in name){var result=obj[action].apply(obj,[key,name[key]].concat(rest));eventSplitter.test(key)?_.extend(results,result):results[key]=result;} 343return results;} 344if(eventSplitter.test(name)){var names=name.split(eventSplitter);for(var i=0,l=names.length;i<l;i++){results[names[i]]=obj[action].apply(obj,[names[i]].concat(rest));} 345return results;} 346return false;};Radio._callHandler=function(callback,context,args){var a1=args[0],a2=args[1],a3=args[2];switch(args.length){case 0:return callback.call(context);case 1:return callback.call(context,a1);case 2:return callback.call(context,a1,a2);case 3:return callback.call(context,a1,a2,a3);default:return callback.apply(context,args);}};function removeHandler(store,name,callback,context){var event=store[name];if((!callback||(callback===event.callback||callback===event.callback._callback))&&(!context||(context===event.context))){delete store[name];return true;}} 347function removeHandlers(store,name,callback,context){store||(store={});var names=name?[name]:_.keys(store);var matched=false;for(var i=0,length=names.length;i<length;i++){name=names[i];if(!store[name]){continue;} 348if(removeHandler(store,name,callback,context)){matched=true;}} 349return matched;} 350var _logs={};function _partial(channelName){return _logs[channelName]||(_logs[channelName]=_.partial(Radio.log,channelName));} 351_.extend(Radio,{log:function(channelName,eventName){var args=_.rest(arguments,2);console.log('['+channelName+'] "'+eventName+'"',args);},tuneIn:function(channelName){var channel=Radio.channel(channelName);channel._tunedIn=true;channel.on('all',_partial(channelName));return this;},tuneOut:function(channelName){var channel=Radio.channel(channelName);channel._tunedIn=false;channel.off('all',_partial(channelName));delete _logs[channelName];return this;}});Radio.Commands={command:function(name){var args=_.rest(arguments);if(Radio._eventsApi(this,'command',name,args)){return this;} 352var channelName=this.channelName;var commands=this._commands;if(channelName&&this._tunedIn){Radio.log.apply(this,[channelName,name].concat(args));} 353if(commands&&(commands[name]||commands['default'])){var handler=commands[name]||commands['default'];args=commands[name]?args:arguments;Radio._callHandler(handler.callback,handler.context,args);}else{Radio.debugLog('An unhandled command was fired',name,channelName);} 354return this;},comply:function(name,callback,context){if(Radio._eventsApi(this,'comply',name,[callback,context])){return this;} 355this._commands||(this._commands={});if(this._commands[name]){Radio.debugLog('A command was overwritten',name,this.channelName);} 356this._commands[name]={callback:callback,context:context||this};return this;},complyOnce:function(name,callback,context){if(Radio._eventsApi(this,'complyOnce',name,[callback,context])){return this;} 357var self=this;var once=_.once(function(){self.stopComplying(name);return callback.apply(this,arguments);});return this.comply(name,once,context);},stopComplying:function(name,callback,context){if(Radio._eventsApi(this,'stopComplying',name)){return this;} 358if(!name&&!callback&&!context){delete this._commands;}else if(!removeHandlers(this._commands,name,callback,context)){Radio.debugLog('Attempted to remove the unregistered command',name,this.channelName);} 359return this;}};function makeCallback(callback){return _.isFunction(callback)?callback:function(){return callback;};} 360Radio.Requests={request:function(name){var args=_.rest(arguments);var results=Radio._eventsApi(this,'request',name,args);if(results){return results;} 361var channelName=this.channelName;var requests=this._requests;if(channelName&&this._tunedIn){Radio.log.apply(this,[channelName,name].concat(args));} 362if(requests&&(requests[name]||requests['default'])){var handler=requests[name]||requests['default'];args=requests[name]?args:arguments;return Radio._callHandler(handler.callback,handler.context,args);}else{Radio.debugLog('An unhandled request was fired',name,channelName);}},reply:function(name,callback,context){if(Radio._eventsApi(this,'reply',name,[callback,context])){return this;} 363this._requests||(this._requests={});if(this._requests[name]){Radio.debugLog('A request was overwritten',name,this.channelName);} 364this._requests[name]={callback:makeCallback(callback),context:context||this};return this;},replyOnce:function(name,callback,context){if(Radio._eventsApi(this,'replyOnce',name,[callback,context])){return this;} 365var self=this;var once=_.once(function(){self.stopReplying(name);return makeCallback(callback).apply(this,arguments);});return this.reply(name,once,context);},stopReplying:function(name,callback,context){if(Radio._eventsApi(this,'stopReplying',name)){return this;} 366if(!name&&!callback&&!context){delete this._requests;}else if(!removeHandlers(this._requests,name,callback,context)){Radio.debugLog('Attempted to remove the unregistered request',name,this.channelName);} 367return this;}};Radio._channels={};
367Radio.channel=function(channelName){if(!channelName){throw new Error('You must provide a name for the channel.');} 368if(Radio._channels[channelName]){return Radio._channels[channelName];}else{return(Radio._channels[channelName]=new Radio.Channel(channelName));}};Radio.Channel=function(channelName){this.channelName=channelName;};_.extend(Radio.Channel.prototype,Backbone.Events,Radio.Commands,Radio.Requests,{reset:function(){this.off();this.stopListening();this.stopComplying();this.stopReplying();return this;}});var channel,args,systems=[Backbone.Events,Radio.Commands,Radio.Requests];_.each(systems,function(system){_.each(system,function(method,methodName){Radio[methodName]=function(channelName){args=_.rest(arguments);channel=this.channel(channelName);return channel[methodName].apply(channel,args);};});});Radio.reset=function(channelName){var channels=!channelName?this._channels:[this._channels[channelName]];_.invoke(channels,'reset');};return Radio;}));;(function(){var Transifex=window.Transifex||(window.Transifex={}),global_channel=Backbone.Radio.channel('global');if(typeof Marionette!=='undefined'&&Marionette.View&&Marionette.View.prototype){var originalRender=Marionette.View.prototype.render;Marionette.View.prototype.render=function(){try{this.getTemplate();}catch(e){return this;} 369return originalRender.apply(this,arguments);};} 370_.extend(Backbone.Router.prototype,{refresh:function(location){var tmp=Backbone.history.fragment;if(location){tmp=location;} 371this.navigate(tmp+(new Date()).getTime());this.navigate(tmp,{trigger:true});},});Transifex.namespace=function(structure){if(typeof structure=='string'){return Transifex.namespace._return.apply(this,arguments);}else{Transifex.namespace._extend.apply(this,arguments);}};Transifex.namespace._extend=function(structure){if(!structure){structure={};} 372for(var key in structure){if(!(key in this)){this[key]={};} 373var value=structure[key];if(_.isString(value)||_.isArray(value)||_.isNumber(value)||_.isBoolean(value)||_.isNull(value)||_.isUndefined(value)||_.isFunction(value)||_.isDate(value)||_.isRegExp(value)){this[key]=value;}else{Transifex.namespace._extend.call(this[key],structure[key]);}}};Transifex.namespace._return=function(path){var keys=path.split('.');var previous=this;for(var i=0;i<keys.length;i++){var key=keys[i];if(!(key in previous)){previous[key]={};} 374previous=previous[key];} 375return previous;};var TxBase=Transifex.namespace('base');var Urls=Transifex.namespace('urls');TxBase.humanize_int=function(number){number=parseFloat(number);if(isNaN(number))return'0';var thousands_array=[];var remainder=number;var thousands;var negative=(remainder<0);if(negative)remainder=-remainder;if(remainder==0)return'0';while(remainder!=0){thousands=remainder%1000;remainder=parseInt(remainder/1000);if(thousands<10){thousands='00'+thousands;}else if(thousands<100){thousands='0'+thousands;}else{thousands=''+thousands;} 376thousands_array.push(thousands);} 377var humanized='';for(var i=thousands_array.length-1;i>=0;
377i--){thousands=thousands_array[i];humanized+=','+thousands;} 378humanized=humanized.substr(1);while(true){if(humanized[0]=='0'){humanized=humanized.substr(1);}else{break;}} 379if(humanized[0]=='.'){humanized='0'+humanized;} 380return(negative?'-'+humanized:humanized);};TxBase.dollarize=function(price,options){options=options||{};options=_.extend({show_dollar:true,show_decimals:true},options);var price_text=TxBase.humanize_int(price);var parts=price_text.split('.');if(parts.length==1){parts[1]='00';} 381var integer=parts[0],decimal=parts[1];decimal=decimal.substr(0,2);if(decimal.length==1){decimal+='0';} 382var return_value=integer;if(options.show_dollar){return_value='$'+return_value;} 383if(options.show_decimal){return_value+='.'+decimal;} 384return return_value;};TxBase.humanize_num=function(input,options){options=options||{};var precision,scaling_factor,symbol,new_value,max_decimals=options.max_decimals,number=parseInt(input);if(typeof max_decimals==='undefined'){max_decimals=1;} 385if(isNaN(number)||number<Math.pow(10,3)||number>=Math.pow(10,12)){return input;} 386if(number<Math.pow(10,6)){scaling_factor=Math.pow(10,3);symbol='K';}else if(number<Math.pow(10,9)){scaling_factor=Math.pow(10,6);symbol='M';}else{scaling_factor=Math.pow(10,9);symbol='B';} 387new_value=number/scaling_factor;if(new_value>=100||(new_value%1===0)){precision=0;}else{precision=2;} 388if(max_decimals!=null&&max_decimals<precision){precision=max_decimals;} 389var text=new_value.toFixed(precision);if(max_decimals!=null&&text.indexOf('.')!==-1){text=text.replace(/\.?0+$/,'');} 390return text+symbol;};TxBase.downloadCSVData=function(filename,rows,headers){function escapeCsv(value){var str=value==null?'':String(value);if(/^[=+\-@\t\r]/.test(str)){str='\''+str;} 391if(/[",\n\r]/.test(str)){return'"'+str.replace(/"/g,'""')+'"';} 392return str;} 393headers=headers||(rows.length?Object.keys(rows[0]):[]);var csvString=[headers.map(escapeCsv).join(',')].concat(rows.map(function(row){return headers.map(function(key){return escapeCsv(row[key]);}).join(',');})).join('\r\n');var blob=new Blob(['\ufeff'+csvString],{type:'text/csv;charset=utf-8'});if(window.navigator&&window.navigator.msSaveOrOpenBlob){window.navigator.msSaveOrOpenBlob(blob,filename);}else{var e=document.createEvent('MouseEvents'),a=document.createElement('a'),url=window.URL.createObjectURL(blob);a.download=filename;a.href=url;a.dataset.downloadurl=['text/csv',a.download,a.href].join(':');e.initEvent('click',true,false,window,0,0,0,0,0,false,false,false,false,0,null);a.dispatchEvent(e);setTimeout(function(){window.URL.revokeObjectURL(url);},0);}};TxBase.Set=(function(){function TxBaseSet(iterable){if(!iterable){(iterable=[]);} 394this._set_dict={};for(var i=0;i<iterable.length;i++){this.add(iterable[i]);}} 395var _to_set=function(iterable){if('_set_dict'in iterable){return iterable;}else{return new TxBaseSet(iterable);}};var _to_array=function(iterable){return Array.prototype.slice.call(iterable,0);};TxBaseSet.prototype.add=function(value){this._set_dict[value]=true;return this;};TxBaseSet.prototype.remove=function(value){delete this._set_dict[value];return this;};TxBaseSet.prototype.toggle=function(value){var already_had=this.has(value);if(already_had){this.remove(value);}else{this.add(value);} 396return!already_had;};TxBaseSet.prototype.values=function(){var return_value=[];this.each(function(value){return_value.push(value);});return return_value;};TxBaseSet.prototype.has=function(value){return value in this._set_dict;};TxBaseSet.prototype.each=function(callback,context){if(!context){context=this;} 397for(var value in this._set_dict){callback.call(context,value);}};TxBaseSet.prototype.count=function(){var count=0;this.each(function(){count++;});return count;};var _union=function(){var return_value=new TxBaseSet();var each_func=function(value){return_value.add(value);};for(var i=0;i<arguments.length;i++){var set=_to_set(arguments[i]);set.each(each_func);} 398return return_value;};TxBaseSet.prototype.union=function(){return _union.apply(null,[this].concat(_to_array(arguments)));};TxBaseSet.prototype.union_update=function(){var updated=_union.apply(null,[this].concat(_to_array(arguments)));this._set_dict=updated._set_dict;return this;};TxBaseSet.prototype.update=TxBaseSet.prototype.union_update;var _intersection=function(){if(arguments.length==2){var return_value=new TxBaseSet();var a=_to_set(arguments[0]),b=_to_set(arguments[1]);a.each(function(value){if(b.has(value)){return_value.add(value);}});return return_value;}else{return _intersection(arguments[0],_intersection.apply(null,_to_array(arguments).slice(1)));}};TxBaseSet.prototype.intersection=function(){return _intersection.apply(null,[this].concat(_to_array(arguments)));};TxBaseSet.prototype.intersection_update=function(){var intersected=_intersection.apply(null,[this].concat(_to_array(arguments)));this._set_dict=intersected._set_dict;return this;};var _diff=function(a,b){var return_value=new TxBaseSet();
398_to_set(a).each(function(value){if(!_to_set(b).has(value)){return_value.add(value);}});return return_value;};TxBaseSet.prototype.diff=function(other){return _diff(this,other);};TxBaseSet.prototype.diff_update=function(other){var diffed=_diff(this,other);this._set_dict=diffed._set_dict;return this;};return TxBaseSet;})();TxBase.get_params=function(options){var strict=!!((options||{}).strict);if(strict){var params=new URLSearchParams(window.location.search);var result={};params.forEach(function(value,key){result[key]=value;});return result;}else{var search_string=window.location.search.substr(1);var params_array=search_string.split('&');var return_value={};for(var i=0;i<params_array.length;i++){var param_string=params_array[i];if(param_string.indexOf('=')!=-1){var param_string_split=param_string.split('=');var key=param_string_split[0],value=param_string_split[1];return_value[key]=value;}else{return_value[param_string]=null;}} 399return return_value;}};TxBase.change_get_variable=function(key,value){var params=TxBase.get_params();if(value){params[key]=value;}else{delete params[key];} 400if(!_.isEmpty(params)){window.location.replace(window.location.pathname+'?'+$.param(params));}else{window.location.replace(window.location.pathname);}};TxBase.is_array=Array.isArray||function(obj){return Object.prototype.toString.call(obj)=='[object Array]';};TxBase.param=function(params){return $.param(params);};TxBase.deparam=function(params){if(!params)return params;var obj={};_.each(params.replace(/\+/g,' ').split('&'),function(v,j){var param=v.split('='),key=decodeURIComponent(param[0]),val,cur=obj,i=0,keys=key.split(']['),keys_last=keys.length-1;if(/\[/.test(keys[0])&&/\]$/.test(keys[keys_last])){keys[keys_last]=keys[keys_last].replace(/\]$/,'');keys=keys.shift().split('[').concat(keys);keys_last=keys.length-1;}else{keys_last=0;} 401if(param.length===2){val=decodeURIComponent(param[1]);if(keys_last){for(;i<=keys_last;i++){key=keys[i]===''?cur.length:keys[i];cur=cur[key]=i<keys_last?cur[key]||(keys[i+1]&&isNaN(keys[i+1])?{}:[]):val;}}else{if(TxBase.is_array(obj[key])){obj[key].push(val);}else if(obj[key]!==undefined){obj[key]=[obj[key],val];}else{obj[key]=val;}}}else if(key){obj[key]='';}});return obj;};TxBase.escape_regex=function(string){return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1");};TxBase.validate_email_address=function(email_address){var re=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return re.test(email_address);};TxBase.refresh=function(){window.location.reload();};TxBase.toUpperCaseFirst=function(str){if(str){return str[0].toUpperCase()+str.substr(1);} 402return str;};TxBase.FaceboxView=Backbone.View.extend({afterShow:function(){return;},show:function(){var _this=this;var afterClose=function(){_this.afterClose();_this.undelegateEvents();};$(document).one('afterClose.facebox',afterClose);var render_result=this.render.apply(this,arguments);if(render_result!==false){$.facebox(render_result);this.setElement('#facebox');this.delegateEvents();this.afterShow.apply(this,arguments);}else{$.facebox(function(){});}},async_render:function(content){$.facebox(content);this.setElement('#facebox');this.delegateEvents();this.afterShow.apply(this,arguments);},afterClose:function(){},hide:function(callback){if(callback){var _this=this;var afterClose=function(){callback.apply(_this);};$(document).one('afterClose.facebox',afterClose);} 403$(document).trigger('close.facebox');},});TxBase.FaceboxView.show=(function(){this._singleton=null;return function(show_options,init_options){if(!this._singleton){this._singleton=new this(init_options);} 404this._singleton.show(show_options);};})();var mnO=Marionette.Object||Marionette.MnObject;var FaceboxPro=mnO.extend({initialize:function(options){var view;if(!options||!options.view){throw new Error('view needs to be defined');} 405view=this.view=options.view;this.listenTo(view,'destroy',function(){$(document).trigger('close.facebox');});$(document).one('afterClose.facebox',function(){view.destroy();});},show:function(settings){this.view.render();$.facebox(this.view.$el);},});
405var ModalView=Marionette.ModalView=Marionette.View.extend({template:false,master_template:'<div id="js-txmodal-outer" style="position: relative;z-index: 9999;">'+' <div class="o-overlay u-backgroundColor-fadedBlack js-close">'+' <div id="js-txmodal-inner" class="c-modal c-modal--default">'+' </div>'+' </div>'+'</div>',initialize:function(options){var that=this;options=options||{};this.el_outer=options.el_outer||'#js-txmodal-outer';this.el_inner=options.el_inner||'#js-txmodal-inner';this.events=this.events||{};this.events['click .js-close']='_onClose';if(ModalView._singleton){ModalView._singleton.destroy();} 406ModalView._singleton=this;$('body').append(options.master_template||this.master_template);$(this.el_outer).find('.js-close').click(function(event){if(!that.prevent_close&&$(event.target).hasClass('js-close')){that.hide(event);}});this.setElement(this.el_inner);this.onInitialize&&this.onInitialize(options);this.listenTo(this,'before:render',function(){$(this.el_outer).css('opacity',this.__is_rerender?1:0);});this.listenTo(this,'render',function(){if(!this.__is_rerender){$(this.el_outer).animate({opacity:1},150);this.__is_rerender=true;if($.fn&&$.fn.tooltip){$('[data-toggle="tooltip"]').not($(this.el_outer).find('[data-toggle="tooltip"]')).tooltip('disable');}}});this.listenTo(this,'destroy',function(){if($.fn&&$.fn.tooltip){$('[data-toggle="tooltip"]').tooltip('enable');} 407$(this.el_outer).remove();});this.render();},enableClose:function(enable){this.prevent_close=!enable;},_onClose:function(){if(!this.prevent_close)this.hide();},hide:function(event){if(event){event.preventDefault();event.stopPropagation();} 408if(ModalView._singleton!=this)return;this.trigger('modal:beforeclose');var that=this;$(this.el_outer).animate({opacity:0,},function(){ModalView._singleton=null;that.trigger('modal:afterclose');that.destroy();});},});ModalView.show=function(options){return new this(options);};Marionette.FileInputMixin=function(view){var source=view.prototype||view;var proto=source.onRender;source.onRender=function(){this.$('input[type=file]').filestyle();this.$('input[type=file]').on('change',function(event){var $container=$(event.target).closest('.customfileinputbtn').parent();$container.find('.clear-file').unbind('click').remove();if($(event.target).val()){$container.find('.customfileinputbtn').addClass('has-value');$container.find('.customfileinput.file').show();$container.find('.customfileinputbtn').append('<span class="clear-file"><svg style="width: 8px;height:8px;fill:currentColor;" viewbox="0 0 16 16"><path class="path1" d="M8 5.905l-5.905-5.714-2.095 2.095 5.714 5.905-5.333 5.333 2.095 2.286 5.524-5.524 5.524 5.524 2.095-2.286-5.524-5.333 5.905-5.905-2.286-2.095-5.714 5.714z"></path></svg></span>');$container.find('.clear-file').click(function(){$container.find('input[type=file]').val('').change();});}else{$container.find('.customfileinputbtn').removeClass('has-value');$container.find('.customfileinput.file').hide();}});if(proto){proto.apply(this,arguments);}};return view;};global_channel.comply('show_dialog',function(view,settings){var dialog=new FaceboxPro({view:view,});dialog.show(settings);});function getCookie(cname){var name=cname+'=';var decodedCookie=decodeURIComponent(document.cookie);var ca=decodedCookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1);} 409if(c.indexOf(name)==0){return c.substring(name.length,c.length);}} 410return'';} 411Urls.set_past_action='/_/txcommon/past_actions/set/';Urls.get_past_action='/_/txcommon/past_actions/get/';TxBase.set_past_action=function(label,callback,error){var ajax_args={type:'POST',url:Urls.set_past_action,data:{label:label,},};if(callback){ajax_args.success=callback;} 412if(error){ajax_args.error=error;} 413$.ajax(ajax_args);};TxBase.get_past_action=function(label,callback,error){var value=getCookie('sess_pa_'+label);if(value){callback(value==='1');}else{var ajax_args={type:'GET',url:Urls.get_past_action,data:{label:label,},success:callback,};if(error){ajax_args.error=error;} 414$.ajax(ajax_args);}};TxBase.PastActionLink=Backbone.View.extend({events:{'click':'handle_click'},initialize:function(options){this.label=options.label;this.callback=options.callback;this.error=options.error;this.next=options.next;},handle_click:function(event){event.preventDefault();var _this=this;TxBase.set_past_action(_this.label,function(){if(_this.callback){_this.callback();} 415if(_this.next){window.document.location.replace(_this.next);}},_this.error);},});TxBase.SearchView=Backbone.View.extend({events:{'keyup':'handle_keyup','focus':'handle_focus',},initialize:function(options){_.bindAll(this,'search','_process');this.search_timer=null;this.search_index=0;this.search_list=[];this.stats_total=0;this.stats_results_count=0;this.list_selector=options.list_selector;this.search_attribute=options.search_attribute||'data-search';this.match_func=options.match_func||this.match;this.show_func=options.show_func||this.show;this.hide_func=options.hide_func||this.hide;this.start_func=options.start_func;this.finish_func=options.finish_func;this.abort_func=options.abort_func;this.search_batch_size=options.search_batch_size||20;},handle_keyup:function(){if(this.search_timer)clearTimeout(this.search_timer);this.search_timer=setTimeout(this.search,250);},handle_focus:function(event){_.defer(function(){$(event.target).select();});},abort:function(){this.search_index=-1;this.abort_func&&this.abort_func(this);},search:function(){this.search_value=$.trim((this.$el.val()||'').toLowerCase());this.search_timer=null;this.search_index=0;this.stats_total=0;this.stats_results_count=0;this.search_list=$(this.list_selector);this.start_func&&this.start_func(this);this._process();},match:function(el,search_value){var list_value=(el.attr(this.search_attribute)||'').toLowerCase();return list_value.indexOf(search_value)>=0;},show:function(el){el.removeClass('is-hidden');},hide:function(el){el.addClass('is-hidden');},getStatistics:function(){return{total:this.stats_total,results_count:this.stats_results_count,};},_process:function(){if(this.search_index<0)return;this.stats_total=this.search_list.length;var len=Math.min(this.stats_total,this.search_index+this.search_batch_size);while(this.search_index<len){var el=this.search_list.eq(this.search_index);if(this.match_func(el,this.search_value)){this.stats_results_count++;this.show_func(el);}else{this.hide_func(el);} 416this.search_index++;} 417if(this.search_index<this.stats_total){_.defer(this._process);}else{this.finish_func&&this.finish_func(this);}},});TxBase.LanguagesSearch=function(value,object,model,search_attribute){var was_found=false;model.set('priority',100);was_found=(model.get(search_attribute)||'').toLowerCase().indexOf(value)==0;if(was_found&&!(object.hide_selection&&model.get('selected'))){model.set('priority',1);} 418if(!was_found&&!(object.hide_selection&&model.get('selected'))){was_found=(model.get('code')||'').toLowerCase().indexOf(value)>=0;if(was_found){model.set('priority',2);}else if(!(object.hide_selection&&model.get('selected'))){was_found=(model.get(search_attribute)||'').toLowerCase().indexOf(value)>0;if(was_found){model.set('priority',3);}} 419if(!model.get('code'))was_found=false;} 420return was_found;};TxBase.DropdownView=Backbone.View.extend({initialize:function(options){var that=this;_.bindAll(this,'_search');options=options||{};this.search_attribute=options.search_attribute||'search';this.fuzzy_search=options.fuzzy_search&&!options.special_search;this.special_search=options.special_search;this.collection_default_comparator=options.collection_default_comparator;this.collection_priority_comparator=options.collection_priority_comparator;this.collection_reset_sorting_cb=options.collection_reset_sorting_cb;this.collection=options.collection;this.template=options.template;this.selected_template=options.selected_template;this.empty_template=options.empty_template;this.on_select=options.on_select;this.on_beforeselect=options.on_beforeselect;this.single_select=options.single_select;this.multi_select=options.multi_select;this.hide_selection=options.hide_selection;this.highlight_class=options.highlight_class;this.multi_select_toggle=options.multi_select_toggle;this.keep_open=options.keep_open;this.placeholder=options.placeholder;this.has_highlight=options.has_highlight;this.on_search=options.on_search;if(this.single_select&&!this.highlight_class){this.highlight_class='is-active';} 421this.state=new Backbone.Model({search:'',});this.selectors={list:'.js-dropdown-list',item:'.js-dropdown-item',search_input:'.js-dropdown-search-input',selection:'.js-dropdown-selection',placeholder:'.js-dropdown-placeholder',scrollable:'.js-scrollable-content',};var _events={};_events['click '+this.selectors.item]='handle_select';_events['click '+this.selectors.search_input]='ignore_input';_events['keyup '+this.selectors.search_input]='handle_input';_events['click '+this.selectors.selection]='focus_search';this.events=_.extend(this.events||{},_events);this.delegateEvents();this.setPlaceholder();if(this.collection&&this.template){this.listenTo(this.collection,'reset add remove',this.render);this.render();} 422this.listenTo(this.collection,'change:selected',function(){this._search();this.setPlaceholder();});if(this.has_highlight){this.listenTo(this.state,'change:search',this.render);} 423this.$el.on('dropdown.open',function(){that.handle_dropdown_open();});this.$el.on('dropdown.close',function(){that.handle_dropdown_close();});},render:function(){var html='';this.collection.each(function(model){html+=this.template({model:model.toJSON(),search:this.state.get('search'),});},this);this.$(this.selectors.list).html(html);if(this.empty_template){this.$(this.selectors.list).append(this.empty_template());if(this.collection.length){this.$('[data-id="0"]').addClass('is-hidden');}} 424this._search();},setPlaceholder:function(){if(this.single_select){if(this.collection.findWhere({selected:true})){this.$(this.selectors.placeholder).addClass('is-hidden');}else{this.$(this.selectors.placeholder).removeClass('is-hidden');if(this.placeholder){this.$(this.selectors.selection).addClass('has-placeholder').text(this.placeholder);}}}},setSelectedDisplay:function(value){return this.$(this.selectors.selection).text(value);},resetSelection:function(){_.each(this.collection.where({selected:true}),function(entry){entry.set('selected',false);});},_scrollToCollectionTop:function(){var col=this.collection.toJSON(),model=col&&col.length?col[0]:null;if(model){var $el=this.$('[data-id="'+model.id+'"]'),$scrollable=this.$(this.selectors.scrollable);if($el.length&&$scrollable.length){$scrollable.scrollTop($scrollable.scrollTop()- 425$scrollable.offset().top+ 426$el.offset().top);}}},_resetSorting:function(){if(this.collection_reset_sorting_cb){this.collection_reset_sorting_cb();} 427if(this.collection_default_comparator){this.collection.comparator=this.collection_default_comparator;} 428this.collection.sort();},_prioritySorting:function(){if(this.collection_priority_comparator){this.collection.comparator=this.collection_priority_comparator;}else{this.collection.comparator='priority';} 429this.collection.sort();},_search:function(){this.timer=null;if(!this.collection)return;var value=$.trim((this.$(this.selectors.search_input).val()||'').toLowerCase());if(this.state.get('search')===value&&this.on_search)return;this.state.set('search',value);if(!value&&!this.on_search){this.$('[data-id]').removeClass('is-hidden');if(this.collection.length){this.$('[data-id="0"]').addClass('is-hidden');}else{this.$('[data-id="0"]').removeClass('is-hidden');} 430this.collection.trigger('results',this.collection.length);this._updateUI();return;} 431var has_results=false;var search_attribute=this.search_attribute;if(this.special_search)this._resetSorting();if(this.on_search){this.on_search(this.state.get('search'),this.collection);} 432this.collection.each(function(model){var el=this.$('[data-id="'+model.id+'"]'),was_found=false;if(this.special_search){was_found=this.special_search(value,this,model,search_attribute);}else if(this.fuzzy_search){was_found=(model.get(search_attribute)||'').toLowerCase().indexOf(value)>-1;}else{was_found=(model.get(search_attribute)||'').toLowerCase().indexOf(value)==0;} 433if(was_found&&!(this.hide_selection&&model.get('selected'))){el.removeClass('is-hidden');has_results=true;}else{el.addClass('is-hidden');}},this);if(this.special_search)this._prioritySorting();if(has_results){this._scrollToCollectionTop();this.$('[data-id="0"]').addClass('is-hidden');}else{this.$('[data-id="0"]').removeClass('is-hidden');} 434this.collection.trigger('results',has_results);this._updateUI();},_updateUI:function(){if(this.single_select){var selection=this.collection.findWhere({selected:true});if(selection){var text=this.$('[data-id="'+selection.id+'"]').text();if(!this.selected_template){this.setSelectedDisplay(text).removeClass('has-placeholder');}else{this.$(this.selectors.selection).html(this.selected_template({model:selection.toJSON(),}));this.$(this.selectors.selection).removeClass('has-placeholder');} 435this.$(this.selectors.placeholder).addClass('is-hidden');}} 436if(this.highlight_class){this.$('[data-id]').removeClass(this.highlight_class);_.each(this.collection.where({selected:true}),function(entry){this.$('[data-id="'+entry.id+'"]').addClass(this.highlight_class);},this);} 437if(this.hide_selection){_.each(this.collection.where({selected:true}),function(entry){this.$('[data-id="'+entry.id+'"]').addClass('is-hidden');},this);}}
437,handle_input:function(event){if(this.on_search){if(this.timer)clearTimeout(this.timer);this.timer=setTimeout(this._search,250);}else{if(this.special_search){if(!event.target.value){this._resetSorting();this.collection.trigger('handle_input','');}else{this._prioritySorting();this.collection.trigger('handle_input',this.state.get('search'));}} 438this.collection.trigger('handle_input',this.state.get('search'));if(this.timer)clearTimeout(this.timer);this.timer=setTimeout(this._search,250);}},ignore_input:function(event){event&&event.stopPropagation();},handle_select:function(event){event&&event.preventDefault();if(this.keep_open){event&&event.stopPropagation();} 439var el=$(event.target).closest('[data-id]');var id=el.data('id');var model=this.collection.get(id);if(model){if(model.get('disabled'))return;var payload={collection:this.collection,model:model,el:el,};if(this.on_beforeselect&&this.on_beforeselect(payload)===false){this.$(this.selectors.search_input).val('');if(this.special_search){this.state.set('search','');this._resetSorting();this.collection.trigger('handle_input',this.state.get('search'));}else{this._search();} 440return;} 441if(this.single_select&&!model.get('selected')){_.each(this.collection.where({selected:true}),function(entry){entry.set('selected',false);});model.set('selected',true);} 442if(this.multi_select){if(this.multi_select_toggle){model.set('selected',!model.get('selected'));}else{model.set('selected',true);}} 443this.on_select&&this.on_select(payload);if(!this.keep_open){this.$(this.selectors.search_input).val('');this._search();}}},focus_search:function(){var $searchbox=this.$(this.selectors.search_input);if($searchbox.length){_.defer(function(){$searchbox.trigger('focus');});}},handle_dropdown_open:function(){this.$(this.selectors.search_input).focus();var model=this.collection.findWhere({selected:true});if(model){var $el=this.$('[data-id="'+model.id+'"]'),$scrollable=this.$(this.selectors.scrollable);if($el.length&&$scrollable.length){$scrollable.scrollTop($scrollable.scrollTop()- 444$scrollable.offset().top+ 445$el.offset().top);}}},handle_dropdown_close:function(){var val=this.$(this.selectors.search_input).val();if(val||this.state.get('search')){this.$(this.selectors.search_input).val('');this._search();this.state.set('search','');} 446if(this.special_search){this._resetSorting();this.collection.trigger('handle_input',this.state.get('search'));}},});TxBase.LanguagesDropdownView=Backbone.View.extend({events:{'click .js-secondary-languages':'handle_toggle','click .js-simplified-languages':'handle_simplified_toggle',},initialize:function(options){options.fuzzy_search=false;options.special_search=TxBase.LanguagesSearch;if(!options.collection_default_comparator){options.collection_default_comparator='name';} 447options.collection_reset_sorting_cb=function(){this.collection.each(function(model){model.set('priority',100);});};this.simplify_toggling=options.simplify_toggling||false;this.all_langs=false;this.show_secondary=false;this.collection=options.collection;this.on_select=options.on_select;this.on_beforeselect=options.on_beforeselect;this.display_collection=new Backbone.Collection();options.collection=this.display_collection;this.dropdown=new TxBase.DropdownView(options);this.listenTo(this.collection,'add remove reset',this.refresh);this.listenTo(this.display_collection,'results',this.onSearchResult);this.listenTo(this.display_collection,'handle_input',function(value){this.refresh();});this.refresh();},onSearchResult:function(has_results){if(!has_results){this.$('[data-helptext="standard"]').addClass('is-hidden');this.$('[data-helptext="secondary"]').addClass('is-hidden');}else{if(this.show_secondary){this.$('[data-helptext="standard"]').addClass('is-hidden');this.$('[data-helptext="secondary"]').removeClass('is-hidden');}else{this.$('[data-helptext="standard"]').removeClass('is-hidden');this.$('[data-helptext="secondary"]').addClass('is-hidden');}} 448if(this.simplify_toggling){if(!has_results){this.$('[data-helptext="in_organization"]').addClass('is-hidden');this.$('[data-helptext="all_langs"]').addClass('is-hidden');}else{if(this.all_langs){this.$('[data-helptext="in_organization"]').addClass('is-hidden');this.$('[data-helptext="all_langs"]').removeClass('is-hidden');}else{this.$('[data-helptext="in_organization"]').removeClass('is-hidden');this.$('[data-helptext="all_langs"]').addClass('is-hidden');}}}},render:function(){this.dropdown.render();},remove:function(){this.dropdown.remove();Backbone.View.prototype.remove.call(this);},refresh:function(){if(this.show_secondary){this.display_collection.reset(this.collection.models);this.$('[data-helptext="standard"]').addClass('is-hidden');this.$('[data-helptext="secondary"]').removeClass('is-hidden');}else{this.display_collection.reset(this.collection.where({standard:true}));this.$('[data-helptext="standard"]').removeClass('is-hidden');this.$('[data-helptext="secondary"]').addClass('is-hidden');} 449if(this.simplify_toggling){if(this.all_langs){this.display_collection.reset(this.collection.models);this.$('[data-helptext="in_organization"]').addClass('is-hidden');this.$('[data-helptext="all_langs"]').removeClass('is-hidden');}else{this.display_collection.reset(this.collection.where({is_in_org:true}));this.$('[data-helptext="in_organization"]').removeClass('is-hidden');this.$('[data-helptext="all_langs"]').addClass('is-hidden');}}},handle_toggle:function(event){event.preventDefault();event.stopPropagation();this.show_secondary=!this.show_secondary;this.refresh();},handle_simplified_toggle:function(event){event.preventDefault();event.stopPropagation();this.all_langs=!this.all_langs;this.refresh();},});TxBase.download_file=function(response,jqXHR,filename,isBlob){if(!filename){var disposition=jqXHR.getResponseHeader('Content-Disposition');if(disposition&&disposition.indexOf('attachment')!==-1){var filenameRegex=/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;var matches=filenameRegex.exec(disposition);if(matches!=null&&matches[1]){filename=matches[1].replace(/['"]/g,'');}}} 450var type=jqXHR.getResponseHeader('Content-Type');var blob=!isBlob?new Blob([response],{type:type}):response;if(typeof window.navigator.msSaveBlob!=='undefined'){window.navigator.msSaveBlob(blob,filename);}else{var URL=window.URL||window.webkitURL;var downloadUrl=URL.createObjectURL(blob);if(filename){var link=document.createElement('a');if(typeof link.download==='undefined'){window.location=downloadUrl;}else{link.href=downloadUrl;link.target='_blank';link.download=filename;document.body.appendChild(link);link.click();}}else{window.location=downloadUrl;} 451setTimeout(function(){URL.revokeObjectURL(downloadUrl);},100);}};var MessageContainer=Backbone.View.extend({send_message:function(message,type,options){var cls='message';if(type){cls+='_'+type;} 452var $div=$('<div class="'+cls+'">');$div.append($('<p class="icon i'+cls+'">').html(message));$div.append($('<span class="close-message">'));$div.prependTo(this.$el);if(options&&options.scroll){$('html, body').animate({scrollTop:0,},'fast');}},});var message_container;TxBase.send_message=function(message,type,options){if(!type){type='info';} 453if(!message_container){message_container=new MessageContainer({el:'#js-messages'});} 454message_container.send_message(message,type,options);};TxBase.something_went_wrong=(function(){var template=null;return function(message,title){if(!template){var jq=$('#something-went-wrong-template');if(jq.length){template=_.template(jq.html());}else{template=_.template('Something went wrong, please try again later');}} 455$.facebox(template({title:title,message:message}));};})();TxBase.bindAll=function(obj){var funcs=_.functions(obj);_.each(funcs,function(f){obj[f]=_.bind(obj[f],obj);});return obj;};TxBase.preload_images=function(image_array){if(!image_array)return;var images=[];_.each(image_array,function(url){var img=new Image();img.src=url;images.push(img);},this);};TxBase.generateUUID=function(){var d=new Date().getTime();if(window.performance&&typeof window.performance.now==='function'){d+=performance.now();} 456var uuid='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(c){var r=(d+Math.random()*16)%16|0;d=Math.floor(d/16);return(c=='x'?r:(r&0x3|0x8)).toString(16);});return uuid;};TxBase.slugify=function(text){return text.toString().toLowerCase().trim().replace(/\s+/g,'-').replace(/&/g,'-and-').replace(/[^\w\-]+/g,'').replace(/\-\-+/g,'-');};TxBase.template=_.memoize(function(selector){var $el=$(selector);if($el.length){return _.template($el.html());}});TxBase.unwrappedView=function(view){return view.extend({onRender:function(){this.$el=this.$el.children();this.$el.unwrap();this.setElement(this.$el);this._onRender&&this._onRender();},});};TxBase.stoplight=function(name){var promises=Transifex.namespace('stoplight.promises');if(promises[name]===undefined){promises[name]=$.Deferred();} 457return promises[name];};TxBase.pjaxSafeMnApplication=function(app){$(document).one('pjax:start',function(){if(app&&app.rootView&&app.rootView.setElement){app.rootView.setElement($('<div></div>'));}});return app;};TxBase.tabs=function(el){if(!el)el='body';var tabs=$(el).find('[role="tablist"]');$.each(tabs,function(){var $togglers=$(this).find('[role="tab"]');$togglers.on('click',function(event){event.preventDefault();var $this=$(this);if($this.hasClass('is-active'))return;$this.addClass('is-active').attr('aria-selected',true).siblings().attr('aria-selected',false).removeClass('is-active');var new_active_tab=$this.attr('href');$(new_active_tab).addClass('is-active').attr('aria-hidden',false).siblings().attr('aria-hidden',true).removeClass('is-active');});});};TxBase.getAvatarLetters=function(str){if(!str)return'';var words=str.split(/[_\- ]/g);if(words.length==1)return str.slice(0,1)+str.slice(-1);if(words.length>1)return str.slice(0,2);};TxBase.parseLinkHeader=function(header){if(!header)return{};var parts=header.split(',');var links={};for(var i=0;i<parts.length;i++){var section=parts[i].split(';');
457if(section.length!==2){return{};} 458var url=section[0].replace(/<(.*)>/,'$1').trim();var name=section[1].replace(/rel="(.*)"/,'$1').trim();links[name]=url;} 459return links;};TxBase.setDateLocale=function(){if(typeof moment==='undefined')return;var app_locale=$('html').attr('lang')||'en';if(app_locale=='bg-bg'){app_locale='bg';}else if(app_locale=='es-es'){app_locale='es';}else if(app_locale=='fr-fr'){app_locale='fr';}else if(app_locale=='eu-es'){app_locale='eu';} 460moment.locale(app_locale);};TxBase.preciseDateDiffWrapper=function(config){if(!config||_.isEmpty(config))return;var Dates=Transifex.namespace('txcommon.dates_i18n')||{};var result='',options={momentObject:config.momentObject,precision:config.precision||7,abbreviations:config.abbreviations,hide_context:config.hide_context,i18n:{nodiff:'',delimiter:' ',future:Dates.i18n.in+' %(diff)s',past:'%(diff)s '+Dates.i18n.ago,full:{year:Dates.i18n.year||'year',years:Dates.i18n.years||'years',month:Dates.i18n.month||'month',months:Dates.i18n.months||'months',day:Dates.i18n.day||'day',days:Dates.i18n.days||'days',hour:Dates.i18n.hour||'hour',hours:Dates.i18n.hours||'hours',minute:Dates.i18n.minute||'minute',minutes:Dates.i18n.minutes||'minutes',second:Dates.i18n.second||'second',seconds:Dates.i18n.seconds||'seconds',},abbreviations:{year:Dates.i18n.yr||'yr',month:Dates.i18n.mo||'mo',day:Dates.i18n.d||'d',hour:Dates.i18n.hr||'hr',minute:Dates.i18n.min||'min',second:Dates.i18n.sec||'sec',},},};function pluralize(num,word){var str='';if(options.abbreviations){str=options.i18n.abbreviations[word];}else{str=options.i18n.full[word+(num===1?'':'s')];} 461return num+((!options.abbreviations)?' ':'')+str;} 462function buildDiffString(yDiff,mDiff,dDiff,hourDiff,minDiff,secDiff){var result=[];if(yDiff&&result.length<options.precision){result.push(pluralize(yDiff,'year'));} 463if(mDiff&&result.length<options.precision){result.push(pluralize(mDiff,'month'));} 464if(dDiff&&result.length<options.precision){result.push(pluralize(dDiff,'day'));} 465if(hourDiff&&result.length<options.precision){result.push(pluralize(hourDiff,'hour'));} 466if(minDiff&&result.length<options.precision){result.push(pluralize(minDiff,'minute'));} 467if(secDiff&&result.length<options.precision){result.push(pluralize(secDiff,'second'));} 468if(!result.length)result.push(pluralize(0,'second'));return result.join(options.i18n.delimiter);} 469function getRelativeString(strDiff){var replaceString=(options.momentObject.firstDateWasLater)?options.i18n.future:options.i18n.past;return replaceString.replace('%(diff)s',strDiff);} 470result=buildDiffString(options.momentObject['years'],options.momentObject['months'],options.momentObject['days'],options.momentObject['hours'],options.momentObject['minutes'],options.momentObject['seconds']);if(!options.hide_context)result=getRelativeString(result);return result;};TxBase.removeFromArray=function(list,value){var index=list.indexOf(value);if(index!=-1){list.splice(index,1);} 471return list;} 472TxBase.highlightToken=function(token,search){token=_.escape(token);if(!search)return token;search=_.escape(search);var regex=new RegExp(TxBase.escape_regex(search),'gi');return token.replace(regex,function(match){return'<span class="s-mark">'+match+'</span>';});};TxBase.is_deactivated_username=function(username){return/[0-9a-f]{32}/i.test(username);} 473TxBase.Tunnel=function(){this.__stack=[];this.__on=[];};TxBase.Tunnel.prototype.receive=function(events,fn,context){if(_.isString(events)&&_.isFunction(fn)){_.each(_.compact(events.split(' ')),function(event){this.__on[event]=this.__on[event]||[];this.__on[event].push({context:context,fn:fn,});},this);}else{throw new Error('Invalid arguments');}};TxBase.Tunnel.prototype.use=function(p1,p2,p3){if(_.isFunction(p1)){this.__stack.push({fn:p1,context:p2,});}else if(_.isString(p1)&&_.isFunction(p2)){_.each(_.compact(p1.split(' ')),function(event){this.__stack.push({event:event,fn:p2,context:p3,});},this);}else{throw new Error('Invalid arguments');}};TxBase.Tunnel.prototype.send=function(event,params){var that=this;function done(){_.each(that.__on[event],function(entry){entry.fn.call(entry.context||that,params);});} 474if(!this.__stack.length)return done();var stack=_.filter(this.__stack,function(entry){return!entry.event||entry.event==event;});function next(){var consumer=stack.shift();if(consumer){consumer.fn.call(consumer.context||that,event,params,next);}else{done();}} 475next();};TxBase.getCaretCoordinates=function(element,position,options){var properties=['direction','boxSizing','width','height','overflowX','overflowY','borderTopWidth','borderRightWidth','borderBottomWidth','borderLeftWidth','borderStyle','paddingTop','paddingRight','paddingBottom','paddingLeft','fontStyle','fontVariant','fontWeight','fontStretch','fontSize','fontSizeAdjust','lineHeight','fontFamily','textAlign','textTransform','textIndent','textDecoration','letterSpacing','wordSpacing','tabSize','MozTabSize'];var isFirefox=(window.mozInnerScreenX!=null);var debug=options&&options.debug||false;
475if(debug){var el=document.querySelector('#input-textarea-caret-position-mirror-div');if(el)el.parentNode.removeChild(el);} 476var div=document.createElement('div');div.id='input-textarea-caret-position-mirror-div';document.body.appendChild(div);var style=div.style;var computed=window.getComputedStyle?window.getComputedStyle(element):element.currentStyle;var isInput=element.nodeName==='INPUT';style.whiteSpace='pre-wrap';if(!isInput) 477style.wordWrap='break-word';style.position='absolute';if(!debug) 478style.visibility='hidden';properties.forEach(function(prop){if(isInput&&prop==='lineHeight'){if(computed.boxSizing==="border-box"){var height=parseInt(computed.height);var outerHeight=parseInt(computed.paddingTop)+ 479parseInt(computed.paddingBottom)+ 480parseInt(computed.borderTopWidth)+ 481parseInt(computed.borderBottomWidth);var targetHeight=outerHeight+parseInt(computed.lineHeight);if(height>targetHeight){style.lineHeight=height-outerHeight+"px";}else if(height===targetHeight){style.lineHeight=computed.lineHeight;}else{style.lineHeight=0;}}else{style.lineHeight=computed.height;}}else{style[prop]=computed[prop];}});if(isFirefox){if(element.scrollHeight>parseInt(computed.height)) 482style.overflowY='scroll';}else{style.overflow='hidden';} 483div.textContent=element.value.substring(0,position);if(isInput) 484div.textContent=div.textContent.replace(/\s/g,'\u00a0');var span=document.createElement('span');span.textContent=element.value.substring(position)||'.';div.appendChild(span);var top=span.offsetTop;if(options.no_scroll)top=(span.offsetTop-element.scrollTop);var coordinates={top:top+parseInt(computed['borderTopWidth']),left:span.offsetLeft+parseInt(computed['borderLeftWidth']),height:parseInt(computed['lineHeight'])};if(debug){span.style.backgroundColor='#aaa';}else{document.body.removeChild(div);} 485return coordinates;};TxBase.normalizeStringEOL=function(str){return str?str.replace(/\n/g,"\r\n"):str;} 486TxBase.getHostname=function(){var url=new URL(window.location.href);var port=url.port&&url.port!=''?':'+url.port:'';return url.protocol+'//'+url.hostname+port+'/';};TxBase.urlExists=function(url){var defer=$.Deferred();jQuery.ajax({url:url,type:'GET',complete:function(xhr){defer.resolve(xhr.status==200);}});return defer.promise();} 487TxBase.convertUnicodeToChar=function(text){return text.replace(/\\u[\dA-F]{4}/gi,function(match){return String.fromCharCode(parseInt(match.replace(/\\u/g,''),16));});} 488TxBase.fetchJSONFile=function(path,callback){var httpRequest=new XMLHttpRequest();httpRequest.onreadystatechange=function(){if(httpRequest.readyState===4){if(httpRequest.status===200){var data=JSON.parse(httpRequest.responseText);if(callback)callback(data);}}};httpRequest.open('GET',path);httpRequest.send();} 489TxBase.makePasswordFieldsReadonly=function(form_id){function disableAutofill(input){$(input).attr('readonly',true);$(input).on('focus',function(){this.removeAttribute('readonly');});} 490var form_password_inputs=document.querySelectorAll(form_id+' input[type=password]');for(var i=0;i<form_password_inputs.length;i++){var input=form_password_inputs[i];if(input.type==='password'&&input.id){disableAutofill('#'+input.id);};}} 491TxBase.toUTC=function(date){return Date.UTC(date.getUTCFullYear(),date.getUTCMonth(),date.getUTCDate(),date.getUTCHours(),date.getUTCMinutes());} 492TxBase.toUTCDate=function(date){return Date.UTC(date.getUTCFullYear(),date.getUTCMonth(),date.getUTCDate());} 493TxBase.dropImagePixel=function(url,callback){if(url){try{var imgtag=document.createElement('img');imgtag.height='1';imgtag.width='1';imgtag.style='border-style:none;';imgtag.alt='';imgtag.src=url;imgtag.referrerPolicy='origin';document.body.appendChild(imgtag);}catch(e){}} 494if(callback)callback();} 495TxBase.swapArrayElementPosition=function(arr,old_index,new_index){if(new_index>=arr.length){var k=new_index-arr.length+1;while(k--){arr.push(undefined);}} 496arr.splice(new_index,0,arr.splice(old_index,1)[0]);return arr;};TxBase.get_hutk=function(){return document.cookie.replace(/(?:(?:^|.*;\s*)hubspotutk\s*\=\s*([^;]*).*$)|^.*$/,"$1");} 497TxBase.get_project_type=function(ptype){switch(ptype){case 1:return"file";case 2:return"live";case 3:return"native";case 4:return"glossary";default:return"";}};TxBase.printElement=function(title,elem){var printWnd=window.open('','PRINT','height=600,width=800');
497printWnd.document.write('<html><head><title>'+title+'</title>');printWnd.document.write('<style>.js-backup-code{ width: 50%; float: left;}</style>');printWnd.document.write('</head><body >');printWnd.document.write('<h1>'+title+'</h1>');printWnd.document.write(document.getElementById(elem).innerHTML);printWnd.document.write('</body></html>');printWnd.document.close();printWnd.focus();printWnd.print();return true;};TxBase.downloadData=function(filename,data){var blob=new Blob(data,{type:'text/plain'});if(window.navigator&&window.navigator.msSaveOrOpenBlob){window.navigator.msSaveOrOpenBlob(blob,filename);}else{var e=document.createEvent('MouseEvents'),a=document.createElement('a');a.download=filename;a.href=window.URL.createObjectURL(blob);a.dataset.downloadurl=['text/plain',a.download,a.href].join(':');e.initEvent('click',true,false,window,0,0,0,0,0,false,false,false,false,0,null);a.dispatchEvent(e);}};TxBase.clearQueryString=function(){try{var currentUrl=window.location.href;var newUrl=currentUrl.split('?')[0];window.history.replaceState(null,null,newUrl);}catch(e){}} 498TxBase.closeEditorSidemenu=function(){try{var evt=document.createEvent('Event');evt.initEvent('clickedOutsideSidemenu',true,true);document.dispatchEvent(evt);}catch(e){}} 499TxBase.saveSelection=function(containerEl){var selection=window.getSelection();if(selection.rangeCount===0)return null;var range=selection.getRangeAt(0);var preSelectionRange=range.cloneRange();preSelectionRange.selectNodeContents(containerEl);preSelectionRange.setEnd(range.startContainer,range.startOffset);var start=preSelectionRange.toString().length;return{start:start,end:start+range.toString().length,};};TxBase.restoreSelection=function(containerEl,savedSel){if(!savedSel)return;var charIndex={current:0};var range=document.createRange();range.setStart(containerEl,0);range.collapse(true);var nodeStack=[containerEl];var node;var foundStart=false;var stop=false;while(!stop&&(node=nodeStack.pop())){if(node.nodeType===3){var nextCharIndex=charIndex.current+node.length;if(!foundStart&&savedSel.start>=charIndex.current&&savedSel.start<=nextCharIndex){range.setStart(node,savedSel.start-charIndex.current);foundStart=true;} 500if(foundStart&&savedSel.end>=charIndex.current&&savedSel.end<=nextCharIndex){range.setEnd(node,savedSel.end-charIndex.current);stop=true;} 501charIndex.current=nextCharIndex;}else if(node.nodeType===1){for(var i=node.childNodes.length-1;i>=0;i--){nodeStack.push(node.childNodes[i]);}}} 502var sel=window.getSelection();sel.removeAllRanges();sel.addRange(range);};TxBase.isOverlapping=function(el1,el2){var el1Offset=el1.offset();var el2Offset=el2.offset();var el1Left=el1Offset.left;var el1Top=el1Offset.top;var el1Right=el1Left+el1.outerWidth();var el1Bottom=el1Top+el1.outerHeight();var el2Left=el2Offset.left;var el2Top=el2Offset.top;var el2Right=el2Left+el2.outerWidth();var el2Bottom=el2Top+el2.outerHeight();return!(el1Right<el2Left||el1Left>el2Right||el1Bottom<el2Top||el1Top>el2Bottom);};})();;function html_escape(html){return html.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');} 503function html_unescape(html){return html.replace(/\</g,'<').replace(/\>/g,'>').replace(/\&/g,'&').replace(/\"/g,'"');} 504function typeOf(value){var s=typeof value;if(s==='object'){if(value){if(value instanceof Array){s='array';}}else{s='null';}} 505return s;} 506function array_escape(tab){var key;for(key in tab){if(typeOf(tab[key])=='array'){array_escape(tab[key]);}else if(typeOf(tab[key])=='string'){tab[key]=html_escape(tab[key]);}} 507return tab;} 508function stripToTwoDecDigits(number){return parseFloat(number.toFixed(2));} 509var url_check_re=new RegExp('^'+'(?:(?:https?|ftp)://)'+'(?:\\S+(?::\\S*)?@)?'+'(?:'+'(?!(?:10|127)(?:\\.\\d{1,3}){3})'+'(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})'+'(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})'+'(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])'+'(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}'+'(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))'+'|'+'(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)'+'(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*'+'(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))'+'\\.?'+')'+'(?::\\d{2,5})?'+'(?:[/?#]\\S*)?'+'$','i');function isValidUrl(url){return url_check_re.test(url);} 510function addSpinner(el){el.addClass('is-disabled has-spinner');el.append('<span class="o-spinner o-spinner--light o-button__spinner"></span>');} 511function removeSpinner(el){el.removeClass('is-disabled has-spinner');el.find('.o-spinner').remove();} 512function get_url_vars(){var vars={};var parts=window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(m,key,value){vars[key]=value;});return vars;} 513function injectXML(url){$.get(url,function(data){var div=document.createElement('div');div.className='no-display';div.innerHTML=new XMLSerializer().serializeToString(data.documentElement);function appendXML(){if(!document.body){setTimeout(appendXML,150);}else{document.body.insertBefore(div,document.body.childNodes[0]);}} 514appendXML();});} 515function resolveTemplate(selector){return function(data){var htmlSelector=document.querySelector(selector)||{};var html=htmlSelector.innerHTML||'';return _.template(html)(data||{});};};
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.