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