diff --git a/build/meemoo-iframework.min.js b/build/meemoo-iframework.min.js index c649686..63b9ce2 100644 --- a/build/meemoo-iframework.min.js +++ b/build/meemoo-iframework.min.js @@ -1,4 +1,4 @@ -/*! Meemoo Iframework http://meemoo.org/ - v0.3.4 - 2013-04-29 (4:04:46 PM GMT+0300) +/*! Meemoo Iframework http://meemoo.org/ - v0.3.4 - 2013-04-29 (4:06:13 PM GMT+0300) * Copyright (c) 2013 Forrest Oliphant; Licensed MIT, AGPL */ (function(){var e=this,t=e._,i={},n=Array.prototype,o=Object.prototype,r=Function.prototype,s=n.push,a=n.slice,l=n.concat,h=o.toString,d=o.hasOwnProperty,c=n.forEach,u=n.map,p=n.reduce,g=n.reduceRight,f=n.filter,m=n.every,v=n.some,w=n.indexOf,y=n.lastIndexOf,b=Array.isArray,k=Object.keys,I=r.bind,$=function(e){return e instanceof $?e:this instanceof $?(this._wrapped=e,void 0):new $(e)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=$),exports._=$):e._=$,$.VERSION="1.4.4";var _=$.each=$.forEach=function(e,t,n){if(null!=e)if(c&&e.forEach===c)e.forEach(t,n);else if(e.length===+e.length){for(var o=0,r=e.length;r>o;o++)if(t.call(n,e[o],o,e)===i)return}else for(var s in e)if($.has(e,s)&&t.call(n,e[s],s,e)===i)return};$.map=$.collect=function(e,t,i){var n=[];return null==e?n:u&&e.map===u?e.map(t,i):(_(e,function(e,o,r){n[n.length]=t.call(i,e,o,r)}),n)};var x="Reduce of empty array with no initial value";$.reduce=$.foldl=$.inject=function(e,t,i,n){var o=arguments.length>2;if(null==e&&(e=[]),p&&e.reduce===p)return n&&(t=$.bind(t,n)),o?e.reduce(t,i):e.reduce(t);if(_(e,function(e,r,s){o?i=t.call(n,i,e,r,s):(i=e,o=!0)}),!o)throw new TypeError(x);return i},$.reduceRight=$.foldr=function(e,t,i,n){var o=arguments.length>2;if(null==e&&(e=[]),g&&e.reduceRight===g)return n&&(t=$.bind(t,n)),o?e.reduceRight(t,i):e.reduceRight(t);var r=e.length;if(r!==+r){var s=$.keys(e);r=s.length}if(_(e,function(a,l,h){l=s?s[--r]:--r,o?i=t.call(n,i,e[l],l,h):(i=e[l],o=!0)}),!o)throw new TypeError(x);return i},$.find=$.detect=function(e,t,i){var n;return E(e,function(e,o,r){return t.call(i,e,o,r)?(n=e,!0):void 0}),n},$.filter=$.select=function(e,t,i){var n=[];return null==e?n:f&&e.filter===f?e.filter(t,i):(_(e,function(e,o,r){t.call(i,e,o,r)&&(n[n.length]=e)}),n)},$.reject=function(e,t,i){return $.filter(e,function(e,n,o){return!t.call(i,e,n,o)},i)},$.every=$.all=function(e,t,n){t||(t=$.identity);var o=!0;return null==e?o:m&&e.every===m?e.every(t,n):(_(e,function(e,r,s){return(o=o&&t.call(n,e,r,s))?void 0:i}),!!o)};var E=$.some=$.any=function(e,t,n){t||(t=$.identity);var o=!1;return null==e?o:v&&e.some===v?e.some(t,n):(_(e,function(e,r,s){return o||(o=t.call(n,e,r,s))?i:void 0}),!!o)};$.contains=$.include=function(e,t){return null==e?!1:w&&e.indexOf===w?-1!=e.indexOf(t):E(e,function(e){return e===t})},$.invoke=function(e,t){var i=a.call(arguments,2),n=$.isFunction(t);return $.map(e,function(e){return(n?t:e[t]).apply(e,i)})},$.pluck=function(e,t){return $.map(e,function(e){return e[t]})},$.where=function(e,t,i){return $.isEmpty(t)?i?null:[]:$[i?"find":"filter"](e,function(e){for(var i in t)if(t[i]!==e[i])return!1;return!0})},$.findWhere=function(e,t){return $.where(e,t,!0)},$.max=function(e,t,i){if(!t&&$.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.max.apply(Math,e);if(!t&&$.isEmpty(e))return-1/0;var n={computed:-1/0,value:-1/0};return _(e,function(e,o,r){var s=t?t.call(i,e,o,r):e;s>=n.computed&&(n={value:e,computed:s})}),n.value},$.min=function(e,t,i){if(!t&&$.isArray(e)&&e[0]===+e[0]&&65535>e.length)return Math.min.apply(Math,e);if(!t&&$.isEmpty(e))return 1/0;var n={computed:1/0,value:1/0};return _(e,function(e,o,r){var s=t?t.call(i,e,o,r):e;n.computed>s&&(n={value:e,computed:s})}),n.value},$.shuffle=function(e){var t,i=0,n=[];return _(e,function(e){t=$.random(i++),n[i-1]=n[t],n[t]=e}),n};var S=function(e){return $.isFunction(e)?e:function(t){return t[e]}};$.sortBy=function(e,t,i){var n=S(t);return $.pluck($.map(e,function(e,t,o){return{value:e,index:t,criteria:n.call(i,e,t,o)}}).sort(function(e,t){var i=e.criteria,n=t.criteria;if(i!==n){if(i>n||void 0===i)return 1;if(n>i||void 0===n)return-1}return e.indexr;){var a=r+s>>>1;o>i.call(n,e[a])?r=a+1:s=a}return r},$.toArray=function(e){return e?$.isArray(e)?a.call(e):e.length===+e.length?$.map(e,$.identity):$.values(e):[]},$.size=function(e){return null==e?0:e.length===+e.length?e.length:$.keys(e).length},$.first=$.head=$.take=function(e,t,i){return null==e?void 0:null==t||i?e[0]:a.call(e,0,t)},$.initial=function(e,t,i){return a.call(e,0,e.length-(null==t||i?1:t))},$.last=function(e,t,i){return null==e?void 0:null==t||i?e[e.length-1]:a.call(e,Math.max(e.length-t,0))},$.rest=$.tail=$.drop=function(e,t,i){return a.call(e,null==t||i?1:t)},$.compact=function(e){return $.filter(e,$.identity)};var C=function(e,t,i){return _(e,function(e){$.isArray(e)?t?s.apply(i,e):C(e,t,i):i.push(e)}),i};$.flatten=function(e,t){return C(e,t,[])},$.without=function(e){return $.difference(e,a.call(arguments,1))},$.uniq=$.unique=function(e,t,i,n){$.isFunction(t)&&(n=i,i=t,t=!1);var o=i?$.map(e,i,n):e,r=[],s=[];return _(o,function(i,n){(t?n&&s[s.length-1]===i:$.contains(s,i))||(s.push(i),r.push(e[n]))}),r},$.union=function(){return $.uniq(l.apply(n,arguments))},$.intersection=function(e){var t=a.call(arguments,1);return $.filter($.uniq(e),function(e){return $.every(t,function(t){return $.indexOf(t,e)>=0})})},$.difference=function(e){var t=l.apply(n,a.call(arguments,1));return $.filter(e,function(e){return!$.contains(t,e)})},$.zip=function(){for(var e=a.call(arguments),t=$.max($.pluck(e,"length")),i=Array(t),n=0;t>n;n++)i[n]=$.pluck(e,""+n);return i},$.object=function(e,t){if(null==e)return{};for(var i={},n=0,o=e.length;o>n;n++)t?i[e[n]]=t[n]:i[e[n][0]]=e[n][1];return i},$.indexOf=function(e,t,i){if(null==e)return-1;var n=0,o=e.length;if(i){if("number"!=typeof i)return n=$.sortedIndex(e,t),e[n]===t?n:-1;n=0>i?Math.max(0,o+i):i}if(w&&e.indexOf===w)return e.indexOf(t,i);for(;o>n;n++)if(e[n]===t)return n;return-1},$.lastIndexOf=function(e,t,i){if(null==e)return-1;var n=null!=i;if(y&&e.lastIndexOf===y)return n?e.lastIndexOf(t,i):e.lastIndexOf(t);for(var o=n?i:e.length;o--;)if(e[o]===t)return o;return-1},$.range=function(e,t,i){1>=arguments.length&&(t=e||0,e=0),i=arguments[2]||1;for(var n=Math.max(Math.ceil((t-e)/i),0),o=0,r=Array(n);n>o;)r[o++]=e,e+=i;return r},$.bind=function(e,t){if(e.bind===I&&I)return I.apply(e,a.call(arguments,1));var i=a.call(arguments,2);return function(){return e.apply(t,i.concat(a.call(arguments)))}},$.partial=function(e){var t=a.call(arguments,1);return function(){return e.apply(this,t.concat(a.call(arguments)))}},$.bindAll=function(e){var t=a.call(arguments,1);return 0===t.length&&(t=$.functions(e)),_(t,function(t){e[t]=$.bind(e[t],e)}),e},$.memoize=function(e,t){var i={};return t||(t=$.identity),function(){var n=t.apply(this,arguments);return $.has(i,n)?i[n]:i[n]=e.apply(this,arguments)}},$.delay=function(e,t){var i=a.call(arguments,2);return setTimeout(function(){return e.apply(null,i)},t)},$.defer=function(e){return $.delay.apply($,[e,1].concat(a.call(arguments,1)))},$.throttle=function(e,t){var i,n,o,r,s=0,a=function(){s=new Date,o=null,r=e.apply(i,n)};return function(){var l=new Date,h=t-(l-s);return i=this,n=arguments,0>=h?(clearTimeout(o),o=null,s=l,r=e.apply(i,n)):o||(o=setTimeout(a,h)),r}},$.debounce=function(e,t,i){var n,o;return function(){var r=this,s=arguments,a=function(){n=null,i||(o=e.apply(r,s))},l=i&&!n;return clearTimeout(n),n=setTimeout(a,t),l&&(o=e.apply(r,s)),o}},$.once=function(e){var t,i=!1;return function(){return i?t:(i=!0,t=e.apply(this,arguments),e=null,t)}},$.wrap=function(e,t){return function(){var i=[e];return s.apply(i,arguments),t.apply(this,i)}},$.compose=function(){var e=arguments;return function(){for(var t=arguments,i=e.length-1;i>=0;i--)t=[e[i].apply(this,t)];return t[0]}},$.after=function(e,t){return 0>=e?t():function(){return 1>--e?t.apply(this,arguments):void 0}},$.keys=k||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var i in e)$.has(e,i)&&(t[t.length]=i);return t},$.values=function(e){var t=[];for(var i in e)$.has(e,i)&&t.push(e[i]);return t},$.pairs=function(e){var t=[];for(var i in e)$.has(e,i)&&t.push([i,e[i]]);return t},$.invert=function(e){var t={};for(var i in e)$.has(e,i)&&(t[e[i]]=i);return t},$.functions=$.methods=function(e){var t=[];for(var i in e)$.isFunction(e[i])&&t.push(i);return t.sort()},$.extend=function(e){return _(a.call(arguments,1),function(t){if(t)for(var i in t)e[i]=t[i]}),e},$.pick=function(e){var t={},i=l.apply(n,a.call(arguments,1));return _(i,function(i){i in e&&(t[i]=e[i])}),t},$.omit=function(e){var t={},i=l.apply(n,a.call(arguments,1));for(var o in e)$.contains(i,o)||(t[o]=e[o]);return t},$.defaults=function(e){return _(a.call(arguments,1),function(t){if(t)for(var i in t)null==e[i]&&(e[i]=t[i])}),e},$.clone=function(e){return $.isObject(e)?$.isArray(e)?e.slice():$.extend({},e):e},$.tap=function(e,t){return t(e),e};var P=function(e,t,i,n){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;e instanceof $&&(e=e._wrapped),t instanceof $&&(t=t._wrapped);var o=h.call(e);if(o!=h.call(t))return!1;switch(o){case"[object String]":return e==t+"";case"[object Number]":return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return!1;for(var r=i.length;r--;)if(i[r]==e)return n[r]==t;i.push(e),n.push(t);var s=0,a=!0;if("[object Array]"==o){if(s=e.length,a=s==t.length)for(;s--&&(a=P(e[s],t[s],i,n)););}else{var l=e.constructor,d=t.constructor;if(l!==d&&!($.isFunction(l)&&l instanceof l&&$.isFunction(d)&&d instanceof d))return!1;for(var c in e)if($.has(e,c)&&(s++,!(a=$.has(t,c)&&P(e[c],t[c],i,n))))break;if(a){for(c in t)if($.has(t,c)&&!s--)break;a=!s}}return i.pop(),n.pop(),a};$.isEqual=function(e,t){return P(e,t,[],[])},$.isEmpty=function(e){if(null==e)return!0;if($.isArray(e)||$.isString(e))return 0===e.length;for(var t in e)if($.has(e,t))return!1;return!0},$.isElement=function(e){return!(!e||1!==e.nodeType)},$.isArray=b||function(e){return"[object Array]"==h.call(e)},$.isObject=function(e){return e===Object(e)},_(["Arguments","Function","String","Number","Date","RegExp"],function(e){$["is"+e]=function(t){return h.call(t)=="[object "+e+"]"}}),$.isArguments(arguments)||($.isArguments=function(e){return!(!e||!$.has(e,"callee"))}),true&&($.isFunction=function(e){return"function"==typeof e}),$.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},$.isNaN=function(e){return $.isNumber(e)&&e!=+e},$.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"==h.call(e)},$.isNull=function(e){return null===e},$.isUndefined=function(e){return void 0===e},$.has=function(e,t){return d.call(e,t)},$.noConflict=function(){return e._=t,this},$.identity=function(e){return e},$.times=function(e,t,i){for(var n=Array(e),o=0;e>o;o++)n[o]=t.call(i,o);return n},$.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=$.invert(T.escape);var O={escape:RegExp("["+$.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+$.keys(T.unescape).join("|")+")","g")};$.each(["escape","unescape"],function(e){$[e]=function(t){return null==t?"":(""+t).replace(O[e],function(t){return T[e][t]})}}),$.result=function(e,t){if(null==e)return null;var i=e[t];return $.isFunction(i)?i.call(e):i},$.mixin=function(e){_($.functions(e),function(t){var i=$[t]=e[t];$.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),B.call(this,i.apply($,e))}})};var G=0;$.uniqueId=function(e){var t=++G+"";return e?e+t:t},$.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var L=/(.)^/,A={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},z=/\\|'|\r|\n|\t|\u2028|\u2029/g;$.template=function(e,t,i){var n;i=$.defaults({},i,$.templateSettings);var o=RegExp([(i.escape||L).source,(i.interpolate||L).source,(i.evaluate||L).source].join("|")+"|$","g"),r=0,s="__p+='";e.replace(o,function(t,i,n,o,a){return s+=e.slice(r,a).replace(z,function(e){return"\\"+A[e]}),i&&(s+="'+\n((__t=("+i+"))==null?'':_.escape(__t))+\n'"),n&&(s+="'+\n((__t=("+n+"))==null?'':__t)+\n'"),o&&(s+="';\n"+o+"\n__p+='"),r=a+t.length,t}),s+="';\n",i.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n";try{n=Function(i.variable||"obj","_",s)}catch(a){throw a.source=s,a}if(t)return n(t,$);var l=function(e){return n.call(this,e,$)};return l.source="function("+(i.variable||"obj")+"){\n"+s+"}",l},$.chain=function(e){return $(e).chain()};var B=function(e){return this._chain?$(e).chain():e};$.mixin($),_(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=n[e];$.prototype[e]=function(){var i=this._wrapped;return t.apply(i,arguments),"shift"!=e&&"splice"!=e||0!==i.length||delete i[0],B.call(this,i)}}),_(["concat","join","slice"],function(e){var t=n[e];$.prototype[e]=function(){return B.call(this,t.apply(this._wrapped,arguments))}}),$.extend($.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this),function(){var e,t=this,i=t.Backbone,n=[],o=n.push,r=n.slice,s=n.splice;e="undefined"!=typeof exports?exports:t.Backbone={},e.VERSION="1.0.0";var a=t._;a||"undefined"==typeof require||(a=require("underscore")),e.$=t.jQuery||t.Zepto||t.ender||t.$,e.noConflict=function(){return t.Backbone=i,this},e.emulateHTTP=!1,e.emulateJSON=!1;var l=e.Events={on:function(e,t,i){if(!d(this,"on",e,[t,i])||!t)return this;this._events||(this._events={});var n=this._events[e]||(this._events[e]=[]);return n.push({callback:t,context:i,ctx:i||this}),this},once:function(e,t,i){if(!d(this,"once",e,[t,i])||!t)return this;var n=this,o=a.once(function(){n.off(e,o),t.apply(this,arguments)});return o._callback=t,this.on(e,o,i)},off:function(e,t,i){var n,o,r,s,l,h,c,u;if(!this._events||!d(this,"off",e,[t,i]))return this;if(!e&&!t&&!i)return this._events={},this;for(s=e?[e]:a.keys(this._events),l=0,h=s.length;h>l;l++)if(e=s[l],r=this._events[e]){if(this._events[e]=n=[],t||i)for(c=0,u=r.length;u>c;c++)o=r[c],(t&&t!==o.callback&&t!==o.callback._callback||i&&i!==o.context)&&n.push(o);n.length||delete this._events[e]}return this},trigger:function(e){if(!this._events)return this;var t=r.call(arguments,1);if(!d(this,"trigger",e,t))return this;var i=this._events[e],n=this._events.all;return i&&c(i,t),n&&c(n,arguments),this},stopListening:function(e,t,i){var n=this._listeners;if(!n)return this;var o=!t&&!i;"object"==typeof t&&(i=this),e&&((n={})[e._listenerId]=e);for(var r in n)n[r].off(t,i,this),o&&delete this._listeners[r];return this}},h=/\s+/,d=function(e,t,i,n){if(!i)return!0;if("object"==typeof i){for(var o in i)e[t].apply(e,[o,i[o]].concat(n));return!1}if(h.test(i)){for(var r=i.split(h),s=0,a=r.length;a>s;s++)e[t].apply(e,[r[s]].concat(n));return!1}return!0},c=function(e,t){var i,n=-1,o=e.length,r=t[0],s=t[1],a=t[2];switch(t.length){case 0:for(;o>++n;)(i=e[n]).callback.call(i.ctx);return;case 1:for(;o>++n;)(i=e[n]).callback.call(i.ctx,r);return;case 2:for(;o>++n;)(i=e[n]).callback.call(i.ctx,r,s);return;case 3:for(;o>++n;)(i=e[n]).callback.call(i.ctx,r,s,a);return;default:for(;o>++n;)(i=e[n]).callback.apply(i.ctx,t)}},u={listenTo:"on",listenToOnce:"once"};a.each(u,function(e,t){l[t]=function(t,i,n){var o=this._listeners||(this._listeners={}),r=t._listenerId||(t._listenerId=a.uniqueId("l"));return o[r]=t,"object"==typeof i&&(n=this),t[e](i,n,this),this}}),l.bind=l.on,l.unbind=l.off,a.extend(e,l);var p=e.Model=function(e,t){var i,n=e||{};t||(t={}),this.cid=a.uniqueId("c"),this.attributes={},a.extend(this,a.pick(t,g)),t.parse&&(n=this.parse(n,t)||{}),(i=a.result(this,"defaults"))&&(n=a.defaults({},n,i)),this.set(n,t),this.changed={},this.initialize.apply(this,arguments)},g=["url","urlRoot","collection"];a.extend(p.prototype,l,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(){return a.clone(this.attributes)},sync:function(){return e.sync.apply(this,arguments)},get:function(e){return this.attributes[e]},escape:function(e){return a.escape(this.get(e))},has:function(e){return null!=this.get(e)},set:function(e,t,i){var n,o,r,s,l,h,d,c;if(null==e)return this;if("object"==typeof e?(o=e,i=t):(o={})[e]=t,i||(i={}),!this._validate(o,i))return!1;r=i.unset,l=i.silent,s=[],h=this._changing,this._changing=!0,h||(this._previousAttributes=a.clone(this.attributes),this.changed={}),c=this.attributes,d=this._previousAttributes,this.idAttribute in o&&(this.id=o[this.idAttribute]);for(n in o)t=o[n],a.isEqual(c[n],t)||s.push(n),a.isEqual(d[n],t)?delete this.changed[n]:this.changed[n]=t,r?delete c[n]:c[n]=t;if(!l){s.length&&(this._pending=!0);for(var u=0,p=s.length;p>u;u++)this.trigger("change:"+s[u],this,c[s[u]],i)}if(h)return this;if(!l)for(;this._pending;)this._pending=!1,this.trigger("change",this,i);return this._pending=!1,this._changing=!1,this},unset:function(e,t){return this.set(e,void 0,a.extend({},t,{unset:!0}))},clear:function(e){var t={};for(var i in this.attributes)t[i]=void 0;return this.set(t,a.extend({},e,{unset:!0}))},hasChanged:function(e){return null==e?!a.isEmpty(this.changed):a.has(this.changed,e)},changedAttributes:function(e){if(!e)return this.hasChanged()?a.clone(this.changed):!1;var t,i=!1,n=this._changing?this._previousAttributes:this.attributes;for(var o in e)a.isEqual(n[o],t=e[o])||((i||(i={}))[o]=t);return i},previous:function(e){return null!=e&&this._previousAttributes?this._previousAttributes[e]:null},previousAttributes:function(){return a.clone(this._previousAttributes)},fetch:function(e){e=e?a.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=this,i=e.success;return e.success=function(n){return t.set(t.parse(n,e),e)?(i&&i(t,n,e),t.trigger("sync",t,n,e),void 0):!1},B(this,e),this.sync("read",this,e)},save:function(e,t,i){var n,o,r,s=this.attributes;if(null==e||"object"==typeof e?(n=e,i=t):(n={})[e]=t,!(!n||i&&i.wait||this.set(n,i)))return!1;if(i=a.extend({validate:!0},i),!this._validate(n,i))return!1;n&&i.wait&&(this.attributes=a.extend({},s,n)),void 0===i.parse&&(i.parse=!0);var l=this,h=i.success;return i.success=function(e){l.attributes=s;var t=l.parse(e,i);return i.wait&&(t=a.extend(n||{},t)),a.isObject(t)&&!l.set(t,i)?!1:(h&&h(l,e,i),l.trigger("sync",l,e,i),void 0)},B(this,i),o=this.isNew()?"create":i.patch?"patch":"update","patch"===o&&(i.attrs=n),r=this.sync(o,this,i),n&&i.wait&&(this.attributes=s),r},destroy:function(e){e=e?a.clone(e):{};var t=this,i=e.success,n=function(){t.trigger("destroy",t,t.collection,e)};if(e.success=function(o){(e.wait||t.isNew())&&n(),i&&i(t,o,e),t.isNew()||t.trigger("sync",t,o,e)},this.isNew())return e.success(),!1;B(this,e);var o=this.sync("delete",this,e);return e.wait||n(),o},url:function(){var e=a.result(this,"urlRoot")||a.result(this.collection,"url")||z();return this.isNew()?e:e+("/"===e.charAt(e.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(e){return e},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},isValid:function(e){return this._validate({},a.extend(e||{},{validate:!0}))},_validate:function(e,t){if(!t.validate||!this.validate)return!0;e=a.extend({},this.attributes,e);var i=this.validationError=this.validate(e,t)||null;return i?(this.trigger("invalid",this,i,a.extend(t||{},{validationError:i})),!1):!0}});var f=["keys","values","pairs","invert","pick","omit"];a.each(f,function(e){p.prototype[e]=function(){var t=r.call(arguments);return t.unshift(this.attributes),a[e].apply(a,t)}});var m=e.Collection=function(e,t){t||(t={}),t.url&&(this.url=t.url),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,a.extend({silent:!0},t))},v={add:!0,remove:!0,merge:!0},w={add:!0,merge:!1,remove:!1};a.extend(m.prototype,l,{model:p,initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},sync:function(){return e.sync.apply(this,arguments)},add:function(e,t){return this.set(e,a.defaults(t||{},w))},remove:function(e,t){e=a.isArray(e)?e.slice():[e],t||(t={});var i,n,o,r;for(i=0,n=e.length;n>i;i++)r=this.get(e[i]),r&&(delete this._byId[r.id],delete this._byId[r.cid],o=this.indexOf(r),this.models.splice(o,1),this.length--,t.silent||(t.index=o,r.trigger("remove",r,this,t)),this._removeReference(r));return this},set:function(e,t){t=a.defaults(t||{},v),t.parse&&(e=this.parse(e,t)),a.isArray(e)||(e=e?[e]:[]);var i,n,r,l,h,d=t.at,c=this.comparator&&null==d&&t.sort!==!1,u=a.isString(this.comparator)?this.comparator:null,p=[],g=[],f={};for(i=0,n=e.length;n>i;i++)(r=this._prepareModel(e[i],t))&&((l=this.get(r))?(t.remove&&(f[l.cid]=!0),t.merge&&(l.set(r.attributes,t),c&&!h&&l.hasChanged(u)&&(h=!0))):t.add&&(p.push(r),r.on("all",this._onModelEvent,this),this._byId[r.cid]=r,null!=r.id&&(this._byId[r.id]=r)));if(t.remove){for(i=0,n=this.length;n>i;++i)f[(r=this.models[i]).cid]||g.push(r);g.length&&this.remove(g,t)}if(p.length&&(c&&(h=!0),this.length+=p.length,null!=d?s.apply(this.models,[d,0].concat(p)):o.apply(this.models,p)),h&&this.sort({silent:!0}),t.silent)return this;for(i=0,n=p.length;n>i;i++)(r=p[i]).trigger("add",r,this,t);return h&&this.trigger("sort",this,t),this},reset:function(e,t){t||(t={});for(var i=0,n=this.models.length;n>i;i++)this._removeReference(this.models[i]);return t.previousModels=this.models,this._reset(),this.add(e,a.extend({silent:!0},t)),t.silent||this.trigger("reset",this,t),this},push:function(e,t){return e=this._prepareModel(e,t),this.add(e,a.extend({at:this.length},t)),e},pop:function(e){var t=this.at(this.length-1);return this.remove(t,e),t},unshift:function(e,t){return e=this._prepareModel(e,t),this.add(e,a.extend({at:0},t)),e},shift:function(e){var t=this.at(0);return this.remove(t,e),t},slice:function(e,t){return this.models.slice(e,t)},get:function(e){return null==e?void 0:this._byId[null!=e.id?e.id:e.cid||e]},at:function(e){return this.models[e]},where:function(e,t){return a.isEmpty(e)?t?void 0:[]:this[t?"find":"filter"](function(t){for(var i in e)if(e[i]!==t.get(i))return!1;return!0})},findWhere:function(e){return this.where(e,!0)},sort:function(e){if(!this.comparator)throw Error("Cannot sort a set without a comparator");return e||(e={}),a.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(a.bind(this.comparator,this)),e.silent||this.trigger("sort",this,e),this},sortedIndex:function(e,t,i){t||(t=this.comparator);var n=a.isFunction(t)?t:function(e){return e.get(t)};return a.sortedIndex(this.models,e,n,i)},pluck:function(e){return a.invoke(this.models,"get",e)},fetch:function(e){e=e?a.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=e.success,i=this;return e.success=function(n){var o=e.reset?"reset":"set";i[o](n,e),t&&t(i,n,e),i.trigger("sync",i,n,e)},B(this,e),this.sync("read",this,e)},create:function(e,t){if(t=t?a.clone(t):{},!(e=this._prepareModel(e,t)))return!1;t.wait||this.add(e,t);var i=this,n=t.success;return t.success=function(o){t.wait&&i.add(e,t),n&&n(e,o,t)},e.save(null,t),e},parse:function(e){return e},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(e instanceof p)return e.collection||(e.collection=this),e;t||(t={}),t.collection=this;var i=new this.model(e,t);return i._validate(e,t)?i:(this.trigger("invalid",this,e,t),!1)},_removeReference:function(e){this===e.collection&&delete e.collection,e.off("all",this._onModelEvent,this)},_onModelEvent:function(e,t,i,n){("add"!==e&&"remove"!==e||i===this)&&("destroy"===e&&this.remove(t,n),t&&e==="change:"+t.idAttribute&&(delete this._byId[t.previous(t.idAttribute)],null!=t.id&&(this._byId[t.id]=t)),this.trigger.apply(this,arguments))}});var y=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","indexOf","shuffle","lastIndexOf","isEmpty","chain"];a.each(y,function(e){m.prototype[e]=function(){var t=r.call(arguments);return t.unshift(this.models),a[e].apply(a,t)}});var b=["groupBy","countBy","sortBy"];a.each(b,function(e){m.prototype[e]=function(t,i){var n=a.isFunction(t)?t:function(e){return e.get(t)};return a[e](this.models,n,i)}});var k=e.View=function(e){this.cid=a.uniqueId("view"),this._configure(e||{}),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},I=/^(\S+)\s*(.*)$/,$=["model","collection","el","id","attributes","className","tagName","events"];a.extend(k.prototype,l,{tagName:"div",$:function(e){return this.$el.find(e)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this.stopListening(),this},setElement:function(t,i){return this.$el&&this.undelegateEvents(),this.$el=t instanceof e.$?t:e.$(t),this.el=this.$el[0],i!==!1&&this.delegateEvents(),this},delegateEvents:function(e){if(!e&&!(e=a.result(this,"events")))return this;this.undelegateEvents();for(var t in e){var i=e[t];if(a.isFunction(i)||(i=this[e[t]]),i){var n=t.match(I),o=n[1],r=n[2];i=a.bind(i,this),o+=".delegateEvents"+this.cid,""===r?this.$el.on(o,i):this.$el.on(o,r,i)}}return this},undelegateEvents:function(){return this.$el.off(".delegateEvents"+this.cid),this},_configure:function(e){this.options&&(e=a.extend({},a.result(this,"options"),e)),a.extend(this,a.pick(e,$)),this.options=e},_ensureElement:function(){if(this.el)this.setElement(a.result(this,"el"),!1);else{var t=a.extend({},a.result(this,"attributes"));this.id&&(t.id=a.result(this,"id")),this.className&&(t["class"]=a.result(this,"className"));var i=e.$("<"+a.result(this,"tagName")+">").attr(t);this.setElement(i,!1)}}}),e.sync=function(t,i,n){var o=_[t];a.defaults(n||(n={}),{emulateHTTP:e.emulateHTTP,emulateJSON:e.emulateJSON});var r={type:o,dataType:"json"};if(n.url||(r.url=a.result(i,"url")||z()),null!=n.data||!i||"create"!==t&&"update"!==t&&"patch"!==t||(r.contentType="application/json",r.data=JSON.stringify(n.attrs||i.toJSON(n))),n.emulateJSON&&(r.contentType="application/x-www-form-urlencoded",r.data=r.data?{model:r.data}:{}),n.emulateHTTP&&("PUT"===o||"DELETE"===o||"PATCH"===o)){r.type="POST",n.emulateJSON&&(r.data._method=o);var s=n.beforeSend;n.beforeSend=function(e){return e.setRequestHeader("X-HTTP-Method-Override",o),s?s.apply(this,arguments):void 0}}"GET"===r.type||n.emulateJSON||(r.processData=!1),"PATCH"!==r.type||!window.ActiveXObject||window.external&&window.external.msActiveXFilteringEnabled||(r.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var l=n.xhr=e.ajax(a.extend(r,n));return i.trigger("request",i,l,n),l};var _={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};e.ajax=function(){return e.$.ajax.apply(e.$,arguments)};var x=e.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},E=/\((.*?)\)/g,S=/(\(\?)?:\w+/g,N=/\*\w+/g,C=/[\-{}\[\]+?.,\\\^$|#\s]/g;a.extend(x.prototype,l,{initialize:function(){},route:function(t,i,n){a.isRegExp(t)||(t=this._routeToRegExp(t)),a.isFunction(i)&&(n=i,i=""),n||(n=this[i]);var o=this;return e.history.route(t,function(r){var s=o._extractParameters(t,r);n&&n.apply(o,s),o.trigger.apply(o,["route:"+i].concat(s)),o.trigger("route",i,s),e.history.trigger("route",o,i,s)}),this},navigate:function(t,i){return e.history.navigate(t,i),this},_bindRoutes:function(){if(this.routes){this.routes=a.result(this,"routes");for(var e,t=a.keys(this.routes);null!=(e=t.pop());)this.route(e,this.routes[e])}},_routeToRegExp:function(e){return e=e.replace(C,"\\$&").replace(E,"(?:$1)?").replace(S,function(e,t){return t?e:"([^/]+)"}).replace(N,"(.*?)"),RegExp("^"+e+"$")},_extractParameters:function(e,t){var i=e.exec(t).slice(1);return a.map(i,function(e){return e?decodeURIComponent(e):null})}});var P=e.History=function(){this.handlers=[],a.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},T=/^[#\/]|\s+$/g,O=/^\/+|\/+$/g,G=/msie [\w.]+/,L=/\/$/;P.started=!1,a.extend(P.prototype,l,{interval:50,getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getFragment:function(e,t){if(null==e)if(this._hasPushState||!this._wantsHashChange||t){e=this.location.pathname;var i=this.root.replace(L,"");e.indexOf(i)||(e=e.substr(i.length))}else e=this.getHash();return e.replace(T,"")},start:function(t){if(P.started)throw Error("Backbone.history has already been started");P.started=!0,this.options=a.extend({},{root:"/"},this.options,t),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var i=this.getFragment(),n=document.documentMode,o=G.exec(navigator.userAgent.toLowerCase())&&(!n||7>=n);this.root=("/"+this.root+"/").replace(O,"/"),o&&this._wantsHashChange&&(this.iframe=e.$('