canjs-rails 1.1.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +47 -0
- data/README.md +1 -2
- data/lib/canjs/rails/version.rb +2 -2
- data/vendor/assets/javascripts/can.jquery.js +8568 -3599
- metadata +10 -29
- data/vendor/assets/javascripts/can.construct.proxy.js +0 -61
- data/vendor/assets/javascripts/can.construct.super.js +0 -48
- data/vendor/assets/javascripts/can.control.plugin.js +0 -108
- data/vendor/assets/javascripts/can.control.view.js +0 -94
- data/vendor/assets/javascripts/can.fixture.js +0 -727
- data/vendor/assets/javascripts/can.jquery.min.js +0 -70
- data/vendor/assets/javascripts/can.observe.attributes.js +0 -154
- data/vendor/assets/javascripts/can.observe.backup.js +0 -170
- data/vendor/assets/javascripts/can.observe.delegate.js +0 -206
- data/vendor/assets/javascripts/can.observe.setter.js +0 -59
- data/vendor/assets/javascripts/can.observe.validations.js +0 -199
- data/vendor/assets/javascripts/can.view.modifiers.js +0 -159
- data/vendor/assets/javascripts/can.view.mustache.js +0 -758
- data/vendor/assets/javascripts/download_canjs.sh +0 -20
@@ -1,70 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* CanJS - 1.1.2 (2012-11-28)
|
3
|
-
* http://canjs.us/
|
4
|
-
* Copyright (c) 2012 Bitovi
|
5
|
-
* Licensed MIT
|
6
|
-
*/
|
7
|
-
(function(p,l,m){var c=p.can||{};if("undefined"===typeof GLOBALCAN||!1!==GLOBALCAN)p.can=c;c.isDeferred=function(a){var b=this.isFunction;return a&&b(a.then)&&b(a.pipe)};c.each=function(a,b,d){var c=0,f;if(a)if("number"===typeof a.length&&a.pop){a.attr&&a.attr("length");for(f=a.length;c<f&&!1!==b.call(d||a[c],a[c],c,a);c++);}else if(a.hasOwnProperty)for(f in a)if(a.hasOwnProperty(f)&&!1===b.call(d||a[f],a[f],f,a))break;return a};l.extend(c,l,{trigger:function(a,b,d){a.trigger?a.trigger(b,d):l.event.trigger(b,
|
8
|
-
d,a,!0)},addEvent:function(a,b){l([this]).bind(a,b);return this},removeEvent:function(a,b){l([this]).unbind(a,b);return this},buildFragment:function(a,b){var d=l.buildFragment([a],l(b));return d.cacheable?l.clone(d.fragment):d.fragment},$:l,each:c.each});l.each(["bind","unbind","undelegate","delegate"],function(a,b){c[b]=function(){var a=this[b]?this:l([this]);a[b].apply(a,arguments);return this}});l.each("append filter addClass remove data get".split(" "),function(a,b){c[b]=function(a){return a[b].apply(a,
|
9
|
-
c.makeArray(arguments).slice(1))}});var Ia=l.cleanData;l.cleanData=function(a){l.each(a,function(a,d){d&&c.trigger(d,"destroyed",[],!1)});Ia(a)};var Ja=/\=\=/,Ka=/([A-Z]+)([A-Z][a-z])/g,La=/([a-z\d])([A-Z])/g,Ma=/([a-z\d])([A-Z])/g,ja=/\{([^\}]+)\}/g,x=/"/g,Na=/'/g;c.extend(c,{esc:function(a){return(""+(null===a||a===m||isNaN(a)&&"NaN"===""+a?"":a)).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(x,""").replace(Na,"'")},getObject:function(a,b,d){var a=a?a.split("."):
|
10
|
-
[],e=a.length,f,h=0,g,i,b=c.isArray(b)?b:[b||p];if(!e)return b[0];for(;b[h];){f=b[h];for(i=0;i<e-1&&/^f|^o/.test(typeof f);i++)f=a[i]in f?f[a[i]]:d&&(f[a[i]]={});if(/^f|^o/.test(typeof f)&&(g=a[i]in f?f[a[i]]:d&&(f[a[i]]={}),g!==m))return!1===d&&delete f[a[i]],g;h++}},capitalize:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},underscore:function(a){return a.replace(Ja,"/").replace(Ka,"$1_$2").replace(La,"$1_$2").replace(Ma,"_").toLowerCase()},sub:function(a,b,d){var e=[];e.push(a.replace(ja,
|
11
|
-
function(a,h){var g=c.getObject(h,b,d===m?d:!d);return g===m?(e=null,""):/^f|^o/.test(typeof g)&&e?(e.push(g),""):""+g}));return null===e?e:1>=e.length?e[0]:e},replacer:ja,undHash:/_|-/});var Q=0;c.Construct=function(){if(arguments.length)return c.Construct.extend.apply(c.Construct,arguments)};c.extend(c.Construct,{newInstance:function(){var a=this.instance(),b;a.setup&&(b=a.setup.apply(a,arguments));a.init&&a.init.apply(a,b||arguments);return a},_inherit:function(a,b,d){c.extend(d||a,a||{})},_overwrite:function(a,
|
12
|
-
b,d,c){a[d]=c},setup:function(a){this.defaults=c.extend(!0,{},a.defaults,this.defaults)},instance:function(){Q=1;var a=new this;Q=0;return a},extend:function(a,b,d){function e(){if(!Q)return this.constructor!==e&&arguments.length?arguments.callee.extend.apply(arguments.callee,arguments):this.constructor.newInstance.apply(this.constructor,arguments)}"string"!=typeof a&&(d=b,b=a,a=null);d||(d=b,b=null);var d=d||{},f=this.prototype,h,g,i,y;y=this.instance();c.Construct._inherit(d,f,y);for(h in this)this.hasOwnProperty(h)&&
|
13
|
-
(e[h]=this[h]);c.Construct._inherit(b,this,e);if(a){i=a.split(".");g=i.pop();i=f=c.getObject(i.join("."),p,!0);var j=c.underscore(a.replace(/\./g,"_")),s=c.underscore(g);f[g]=e}c.extend(e,{constructor:e,prototype:y,namespace:i,shortName:g,_shortName:s,fullName:a,_fullName:j});e.prototype.constructor=e;g=[this].concat(c.makeArray(arguments));y=e.setup.apply(e,g);e.init&&e.init.apply(e,y||g);return e}});var v=function(a){return a&&(c.isArray(a)||c.isPlainObject(a)||a instanceof c.Observe)},K=function(a,
|
14
|
-
b){return c.each(a,function(a){a&&a.unbind&&a.unbind("change"+b)})},R=function(a,b,d,e,f){e=e||j;f=f||j.List;a instanceof j?K([a],d._cid):a=c.isArray(a)?new f(a):new e(a);a.bind("change"+d._cid,function(){var e=c.makeArray(arguments),f=e.shift();e[0]=("*"===b?[d.indexOf(a),e[0]]:[b,e[0]]).join(".");f.triggeredNS=f.triggeredNS||{};f.triggeredNS[d._cid]||(f.triggeredNS[d._cid]=!0,c.trigger(d,f,e))});return a},L=function(a,b,d){a.each(function(a,f){d[f]=v(a)&&c.isFunction(a[b])?a[b]():a});return d},
|
15
|
-
E=function(a){return function(){return c[a].apply(this,arguments)}},F=E("addEvent"),E=E("removeEvent"),S=function(a){return c.isArray(a)?a:(""+a).split(".")},ka=1,G=0,T=[],U=[],Oa=0;c.cid=function(a,b){return a._cid?a._cid:a._cid=(b||"")+ ++Oa};var j=c.Observe=c.Construct({bind:F,unbind:E,id:"id",canMakeObserve:v,startBatch:function(a){G++;a&&U.push(a)},stopBatch:function(a,b){a?G=0:G--;if(0==G){var d=T.slice(0),e=U.slice(0);T=[];U=[];ka++;b&&this.startBatch();c.each(d,function(a){c.trigger.apply(c,
|
16
|
-
a)});c.each(e,function(a){a})}},triggerBatch:function(a,b,d){if(!a._init){if(0==G)return c.trigger(a,b,d);T.push([a,{type:b,batchNum:ka},d])}},keys:function(a){var b=[];j.__reading&&j.__reading(a,"__keys");for(var d in a._data)b.push(d);return b}},{setup:function(a){this._data={};c.cid(this,".observe");this._init=1;this.attr(a);this.bind("change"+this._cid,c.proxy(this._changes,this));delete this._init},_changes:function(a,b,d,c,f){j.triggerBatch(this,{type:b,batchNum:a.batchNum},[c,f])},attr:function(a,
|
17
|
-
b){var d=typeof a;if("string"!==d&&"number"!==d)return this._attrs(a,b);if(b===m)return j.__reading&&j.__reading(this,a),this._get(a);this._set(a,b);return this},each:function(){j.__reading&&j.__reading(this,"__keys");return c.each.apply(m,[this.__get()].concat(c.makeArray(arguments)))},removeAttr:function(a){var a=S(a),b=a.shift(),d=this._data[b];if(a.length)return d.removeAttr(a);b in this._data&&(delete this._data[b],b in this.constructor.prototype||delete this[b],j.triggerBatch(this,"__keys",
|
18
|
-
m),j.triggerBatch(this,"change",[b,"remove",m,d]),j.triggerBatch(this,b,[m,d]));return d},_get:function(a){var a=S(a),b=this.__get(a.shift());return a.length?b?b._get(a):m:b},__get:function(a){return a?this._data[a]:this._data},_set:function(a,b){var d=S(a),c=d.shift(),f=this.__get(c);if(v(f)&&d.length)f._set(d,b);else{if(d.length)throw"can.Observe: Object does not exist";this.__convert&&(b=this.__convert(c,b));f||j.triggerBatch(this,"__keys",m);this.__set(c,b,f)}},__set:function(a,b,d){if(b!==d){var c=
|
19
|
-
this.__get().hasOwnProperty(a)?"set":"add";this.___set(a,v(b)?R(b,a,this):b);j.triggerBatch(this,"change",[a,c,b,d]);d&&K([d],this._cid)}},___set:function(a,b){this._data[a]=b;a in this.constructor.prototype||(this[a]=b)},bind:F,unbind:E,serialize:function(){return L(this,"serialize",{})},_attrs:function(a,b){if(a===m)return L(this,"attr",{});var a=c.extend(!0,{},a),d,e=this,f;j.startBatch();this.each(function(d,g,i){f=a[g];f===m?b&&e.removeAttr(g):(e.__convert&&(f=e.__convert(g,f)),d!==f&&(d instanceof
|
20
|
-
c.Observe&&f instanceof c.Observe&&K([d],e._cid),f instanceof c.Observe?e._set(g,f):v(d)&&v(f)?d.attr(f,i):d!=f&&e._set(g,f)),delete a[g])});for(d in a)f=a[d],this._set(d,f);j.stopBatch();return this}}),Pa=[].splice,M=j({setup:function(a,b){this.length=0;c.cid(this,".observe");this._init=1;this.push.apply(this,c.makeArray(a||[]));this.bind("change"+this._cid,c.proxy(this._changes,this));c.extend(this,b);delete this._init},_changes:function(a,b,d,c,f){~b.indexOf(".")||("add"===d?(j.triggerBatch(this,
|
21
|
-
d,[c,+b]),j.triggerBatch(this,"length",[this.length])):"remove"===d?(j.triggerBatch(this,d,[f,+b]),j.triggerBatch(this,"length",[this.length])):j.triggerBatch(this,d,[c,+b]));j.prototype._changes.apply(this,arguments)},__get:function(a){return a?this[a]:this},___set:function(a,b){this[a]=b;+a>=this.length&&(this.length=+a+1)},serialize:function(){return L(this,"serialize",[])},splice:function(a,b){var d=c.makeArray(arguments),e;for(e=2;e<d.length;e++){var f=d[e];v(f)&&(d[e]=R(f,"*",this))}b===m&&
|
22
|
-
(b=d[1]=this.length-a);e=Pa.apply(this,d);0<b&&(j.triggerBatch(this,"change",[""+a,"remove",m,e]),K(e,this._cid));2<d.length&&j.triggerBatch(this,"change",[""+a,"add",d.slice(2),e]);return e},_attrs:function(a,b){if(a===m)return L(this,"attr",[]);a=c.makeArray(a);j.startBatch();this._updateAttrs(a,b);j.stopBatch()},_updateAttrs:function(a,b){for(var d=Math.min(a.length,this.length),c=0;c<d;c++){var f=this[c],h=a[c];v(f)&&v(h)?f.attr(h,b):f!=h&&this._set(c,h)}a.length>this.length?this.push.apply(this,
|
23
|
-
a.slice(this.length)):a.length<this.length&&b&&this.splice(a.length)}});c.each({push:"length",unshift:0},function(a,b){M.prototype[b]=function(){for(var d=c.makeArray(arguments),e=a?this.length:0,f=0;f<d.length;f++){var h=d[f];v(h)&&(d[f]=R(h,"*",this,this.constructor.Observe,this.constructor))}f=[][b].apply(this,d);(!this.comparator||!d.length)&&j.triggerBatch(this,"change",[""+e,"add",d,m]);return f}});c.each({pop:"length",shift:0},function(a,b){M.prototype[b]=function(){var d=arguments[0]&&c.isArray(arguments[0])?
|
24
|
-
arguments[0]:c.makeArray(arguments),e=a&&this.length?this.length-1:0,d=[][b].apply(this,d);j.triggerBatch(this,"change",[""+e,"remove",m,[d]]);d&&d.unbind&&d.unbind("change"+this._cid);return d}});c.extend(M.prototype,{indexOf:function(a){this.attr("length");return c.inArray(a,this)},join:[].join,slice:function(){return new this.constructor(Array.prototype.slice.apply(this,arguments))},concat:function(){var a=[];c.each(c.makeArray(arguments),function(b,d){a[d]=b instanceof c.Observe.List?b.serialize():
|
25
|
-
b});return new this.constructor(Array.prototype.concat.apply(this.serialize(),a))},forEach:function(a,b){c.each(this,a,b||this)}});j.List=M;j.setup=function(){c.Construct.setup.apply(this,arguments);this.List=j.List({Observe:this},{})};var Qa=function(a,b,d){var e=new c.Deferred;a.then(function(){var a=c.makeArray(arguments);a[0]=b[d](a[0]);e.resolveWith(e,a)},function(){e.rejectWith(this,arguments)});"function"===typeof a.abort&&(e.abort=function(){return a.abort()});return e},Ra=0,la=/change.observe\d+/,
|
26
|
-
H=function(a){c.Observe.__reading&&c.Observe.__reading(a,a.constructor.id);return a.__get(a.constructor.id)},ma=function(a,b,d,c,f){var h;h=[a.serialize()];var g=a.constructor,i;"destroy"==b&&h.shift();"create"!==b&&h.unshift(H(a));i=g[b].apply(g,h);h=i.pipe(function(c){a[f||b+"d"](c,i);return a});i.abort&&(h.abort=function(){i.abort()});h.then(d,c);return h},Sa={create:{url:"_shortName",type:"post"},update:{data:function(a,b){var b=b||{},d=this.id;b[d]&&b[d]!==a&&(b["new"+c.capitalize(a)]=b[d],delete b[d]);
|
27
|
-
b[d]=a;return b},type:"put"},destroy:{type:"delete",data:function(a){var b={};b.id=b[this.id]=a;return b}},findAll:{url:"_shortName"},findOne:{}},na=function(a,b){return function(d){var d=a.data?a.data.apply(this,arguments):d,e=b||this[a.url||"_url"],f=d,h=a.type||"get",g={};"string"==typeof e?(e=e.split(/\s/),g.url=e.pop(),e.length&&(g.type=e.pop())):c.extend(g,e);g.data="object"==typeof f&&!c.isArray(f)?c.extend(g.data||{},f):f;g.url=c.sub(g.url,g.data,!0);return c.ajax(c.extend({type:h||"post",
|
28
|
-
dataType:"json",success:void 0,error:void 0},g))}};c.Model=c.Observe({fullName:"can.Model",setup:function(a){this.store={};c.Observe.setup.apply(this,arguments);if(c.Model){this.List=V({Observe:this},{});var b=this,d=c.proxy(this._clean,b);c.each(Sa,function(e,f){c.isFunction(b[f])||(b[f]=na(e,b[f]));if(b["make"+c.capitalize(f)]){var h=b["make"+c.capitalize(f)](b[f]);c.Construct._overwrite(b,a,f,function(){this._reqs++;var a=h.apply(this,arguments),b=a.then(d,d);b.abort=a.abort;return b})}});if("can.Model"==
|
29
|
-
b.fullName||!b.fullName)b.fullName="Model"+ ++Ra;this._reqs=0;this._url=this._shortName+"/{"+this.id+"}"}},_ajax:na,_clean:function(a){this._reqs--;if(!this._reqs)for(var b in this.store)this.store[b]._bindings||delete this.store[b];return a},models:function(a,b){if(a){if(a instanceof this.List)return a;var d=this,e=[],f=b instanceof c.Observe.List?b:new (d.List||V),h=c.isArray(a),g=a instanceof V,g=h?a:g?a.serialize():a.data;0<f.length&&f.splice(0);c.each(g,function(a){e.push(d.model(a))});f.push.apply(f,
|
30
|
-
e);h||c.each(a,function(a,b){"data"!==b&&f.attr(b,a)});return f}},model:function(a){if(a){a instanceof this&&(a=a.serialize());var b=a[this.id],b=b&&this.store[b]?this.store[b].attr(a):new this(a);this._reqs&&(this.store[a[this.id]]=b);return b}}},{isNew:function(){var a=H(this);return!(a||0===a)},save:function(a,b){return ma(this,this.isNew()?"create":"update",a,b)},destroy:function(a,b){return ma(this,"destroy",a,b,"destroyed")},bind:function(a){la.test(a)||(this._bindings||(this.constructor.store[H(this)]=
|
31
|
-
this,this._bindings=0),this._bindings++);return c.Observe.prototype.bind.apply(this,arguments)},unbind:function(a){la.test(a)||(this._bindings--,this._bindings||delete this.constructor.store[H(this)]);return c.Observe.prototype.unbind.apply(this,arguments)},___set:function(a,b){c.Observe.prototype.___set.call(this,a,b);a===this.constructor.id&&this._bindings&&(this.constructor.store[H(this)]=this)}});c.each({makeFindAll:"models",makeFindOne:"model"},function(a,b){c.Model[b]=function(b){return function(c,
|
32
|
-
f,h){c=Qa(b.call(this,c),this,a);c.then(f,h);return c}}});c.each(["created","updated","destroyed"],function(a){c.Model.prototype[a]=function(b){var d=this.constructor;b&&"object"==typeof b&&this.attr(b.attr?b.attr():b);c.trigger(this,a);c.trigger(this,"change",a);c.trigger(d,a,this)}});var V=c.Model.List=c.Observe.List({setup:function(){c.Observe.List.prototype.setup.apply(this,arguments);var a=this;this.bind("change",function(b,c){if(/\w+\.destroyed/.test(c)){var e=a.indexOf(b.target);-1!=e&&a.splice(e,
|
33
|
-
1)}})}}),Ta=/^\d+$/,Ua=/([^\[\]]+)|(\[\])/g,Va=/([^?#]*)(#.*)?$/,oa=function(a){return decodeURIComponent(a.replace(/\+/g," "))};c.extend(c,{deparam:function(a){var b={},d;a&&Va.test(a)&&(a=a.split("&"),c.each(a,function(a){for(var a=a.split("="),c=oa(a.shift()),h=oa(a.join("=")),g=b,a=c.match(Ua),c=0,i=a.length-1;c<i;c++)g[a[c]]||(g[a[c]]=Ta.test(a[c+1])||"[]"==a[c+1]?[]:{}),g=g[a[c]];d=a.pop();"[]"==d?g.push(h):g[d]=h}));return b}});var pa=/\:([\w\.]+)/g,Wa=function(a){var b=[];c.each(a,function(a,
|
34
|
-
e){b.push(("className"===e?"class":e)+'="'+("href"===e?a:c.esc(a))+'"')});return b.join(" ")},qa=function(a,b){var c=0,e=0,f={},h;for(h in a.defaults)a.defaults[h]===b[h]&&(f[h]=1,c++);for(;e<a.names.length;e++){if(!b.hasOwnProperty(a.names[e]))return-1;f[a.names[e]]||c++}return c},ra=!0,W=p.location,z=c.each,o=c.extend;c.route=function(a,b){var b=b||{},d=[],e=a.replace(pa,function(e,h,g){d.push(h);return"([^\\"+(a.substr(g+e.length,1)||c.route._querySeparator)+"]"+(b[h]?"*":"+")+")"});c.route.routes[a]=
|
35
|
-
{test:RegExp("^"+e+"($|"+(c.route._querySeparator+"").replace(/([.?*+\^$\[\]\\(){}|\-])/g,"\\$1")+")"),route:a,names:d,defaults:b,length:a.split("/").length};return c.route};o(c.route,{_querySeparator:"&",_paramsMatcher:/^(?:&[^=]+=[^&]*)+/,param:function(a,b){var d,e=0,f,h=a.route,g=0;delete a.route;z(a,function(){g++});z(c.route.routes,function(b){f=qa(b,a);f>e&&(d=b,e=f);if(f>=g)return!1});c.route.routes[h]&&qa(c.route.routes[h],a)===e&&(d=c.route.routes[h]);if(d){var i=o({},a),h=d.route.replace(pa,
|
36
|
-
function(b,c){delete i[c];return a[c]===d.defaults[c]?"":encodeURIComponent(a[c])}),y;z(d.defaults,function(a,b){i[b]===a&&delete i[b]});y=c.param(i);b&&c.route.attr("route",d.route);return h+(y?c.route._querySeparator+y:"")}return c.isEmptyObject(a)?"":c.route._querySeparator+c.param(a)},deparam:function(a){var b={length:-1};z(c.route.routes,function(c){c.test.test(a)&&c.length>b.length&&(b=c)});if(-1<b.length){var d=a.match(b.test),e=d.shift(),f=(e=a.substr(e.length-(d[d.length-1]===c.route._querySeparator?
|
37
|
-
1:0)))&&c.route._paramsMatcher.test(e)?c.deparam(e.slice(1)):{},f=o(!0,{},b.defaults,f);z(d,function(a,d){a&&a!==c.route._querySeparator&&(f[b.names[d]]=decodeURIComponent(a))});f.route=b.route;return f}a.charAt(0)!==c.route._querySeparator&&(a=c.route._querySeparator+a);return c.route._paramsMatcher.test(a)?c.deparam(a.slice(1)):{}},data:new c.Observe({}),routes:{},ready:function(a){!1===a&&(ra=a);if(!0===a||!0===ra)c.route._setup(),sa();return c.route},url:function(a,b){b&&(a=o({},X,a));return"#!"+
|
38
|
-
c.route.param(a)},link:function(a,b,d,e){return"<a "+Wa(o({href:c.route.url(b,e)},d))+">"+a+"</a>"},current:function(a){return W.hash=="#!"+c.route.param(a)},_setup:function(){c.bind.call(p,"hashchange",sa)},_getHash:function(){return W.href.split(/#!?/)[1]||""},_setHash:function(a){a=c.route.param(a,!0);W.hash="#!"+a;return a}});z("bind unbind delegate undelegate attr removeAttr".split(" "),function(a){c.route[a]=function(){return c.route.data[a].apply(c.route.data,arguments)}});var ta,X,sa=c.route.setState=
|
39
|
-
function(){var a=c.route._getHash();X=c.route.deparam(a);(!Y||a!==ua)&&c.route.attr(X,!0)},ua,Y;c.route.bind("change",function(){Y=1;clearTimeout(ta);ta=setTimeout(function(){Y=0;var a=c.route.data.serialize();ua=c.route._setHash(a)},1)});c.bind.call(document,"ready",c.route.ready);c.route.constructor.canMakeObserve=c.Observe.canMakeObserve;var F=function(a,b,d){c.bind.call(a,b,d);return function(){c.unbind.call(a,b,d)}},C=c.isFunction,o=c.extend,z=c.each,Xa=[].slice,va=/\{([^\}]+)\}/g,Ya=c.getObject("$.event.special")||
|
40
|
-
{},wa=function(a,b,d,e){c.delegate.call(a,b,d,e);return function(){c.undelegate.call(a,b,d,e)}},Z;c.Control=c.Construct({setup:function(){c.Construct.setup.apply(this,arguments);if(c.Control){var a;this.actions={};for(a in this.prototype)this._isAction(a)&&(this.actions[a]=this._action(a))}},_shifter:function(a,b){var d="string"==typeof b?a[b]:b;C(d)||(d=a[d]);return function(){a.called=b;return d.apply(a,[this.nodeName?c.$(this):this].concat(Xa.call(arguments,0)))}},_isAction:function(a){var b=this.prototype[a],
|
41
|
-
c=typeof b;return"constructor"!==a&&("function"==c||"string"==c&&C(this.prototype[b]))&&!(!Ya[a]&&!$[a]&&!/[^\w]/.test(a))},_action:function(a,b){va.lastIndex=0;if(b||!va.test(a)){var d=b?c.sub(a,[b,p]):a;if(!d)return null;var e=c.isArray(d),f=e?d[1]:d,h=f.split(/\s+/g),g=h.pop();return{processor:$[g]||Z,parts:[f,h.join(" "),g],delegate:e?d[0]:m}}},processors:{},defaults:{}},{setup:function(a,b){var d=this.constructor,e=d.pluginName||d._fullName;this.element=c.$(a);e&&"can_control"!==e&&this.element.addClass(e);
|
42
|
-
(e=c.data(this.element,"controls"))||c.data(this.element,"controls",e=[]);e.push(this);this.options=o({},d.defaults,b);this.on();return[this.element,this.options]},on:function(a,b,d,e){if(!a){this.off();var a=this.constructor,b=this._bindings,d=a.actions,e=this.element,f=c.Control._shifter(this,"destroy"),h,g;for(h in d)if(d.hasOwnProperty(h)&&(g=d[h]||a._action(h,this.options)))b.push(g.processor(g.delegate||e,g.parts[2],g.parts[1],h,this));c.bind.call(e,"destroyed",f);b.push(function(a){c.unbind.call(a,
|
43
|
-
"destroyed",f)});return b.length}"string"==typeof a&&(e=d,d=b,b=a,a=this.element);e===m&&(e=d,d=b,b=null);"string"==typeof e&&(e=c.Control._shifter(this,e));this._bindings.push(b?wa(a,c.trim(b),d,e):F(a,d,e));return this._bindings.length},off:function(){var a=this.element[0];z(this._bindings||[],function(b){b(a)});this._bindings=[]},destroy:function(){var a=this.constructor,a=a.pluginName||a._fullName;this.off();a&&"can_control"!==a&&this.element.removeClass(a);a=c.data(this.element,"controls");a.splice(c.inArray(this,
|
44
|
-
a),1);c.trigger(this,"destroyed");this.element=null}});var $=c.Control.processors;Z=function(a,b,d,e,f){e=c.Control._shifter(f,e);return d?wa(a,c.trim(d),b,e):F(a,b,e)};z("change click contextmenu dblclick keydown keyup keypress mousedown mousemove mouseout mouseover mouseup reset resize scroll select submit focusin focusout mouseenter mouseleave touchstart touchmove touchcancel touchend touchleave".split(" "),function(a){$[a]=Z});c.Control.processors.route=function(a,b,d,e,f){d=d||"";c.route(d);
|
45
|
-
var h,g=function(a){if(c.route.attr("route")===d&&(a.batchNum===m||a.batchNum!==h))if(h=a.batchNum,a=c.route.attr(),delete a.route,c.isFunction(f[e]))f[e](a);else f[f[e]](a)};c.route.bind("change",g);return function(){c.route.unbind("change",g)}};var C=c.isFunction,Za=c.makeArray,xa=1,k=c.view=function(a,b,d,e){a=k.render(a,b,d,e);return C(a)?a:c.isDeferred(a)?a.pipe(function(a){return k.frag(a)}):k.frag(a)};c.extend(k,{frag:function(a,b){return k.hookup(k.fragment(a),b)},fragment:function(a){a=c.buildFragment(a,
|
46
|
-
document.body);a.childNodes.length||a.appendChild(document.createTextNode(""));return a},toId:function(a){return c.map(a.toString().split(/\/|\./g),function(a){if(a)return a}).join("_")},hookup:function(a,b){var d=[],e,f;c.each(a.childNodes?c.makeArray(a.childNodes):a,function(a){1===a.nodeType&&(d.push(a),d.push.apply(d,c.makeArray(a.getElementsByTagName("*"))))});c.each(d,function(a){if(a.getAttribute&&(e=a.getAttribute("data-view-id"))&&(f=k.hookups[e]))f(a,b,e),delete k.hookups[e],a.removeAttribute("data-view-id")});
|
47
|
-
return a},hookups:{},hook:function(a){k.hookups[++xa]=a;return" data-view-id='"+xa+"'"},cached:{},cachedRenderers:{},cache:!0,register:function(a){this.types["."+a.suffix]=a},types:{},ext:".ejs",registerScript:function(){},preload:function(){},render:function(a,b,d,e){C(d)&&(e=d,d=m);var f=$a(b);if(f.length){var h=new c.Deferred;f.push(ya(a,!0));c.when.apply(c,f).then(function(a){var f=Za(arguments),g=f.pop();if(c.isDeferred(b))b=za(a);else for(var j in b)c.isDeferred(b[j])&&(b[j]=za(f.shift()));
|
48
|
-
f=g(b,d);h.resolve(f);e&&e(f)});return h}var g,f=C(e),h=ya(a,f);if(f)g=h,h.then(function(a){e(b?a(b,d):a)});else{if("resolved"===h.state()&&h.__view_id)return a=k.cachedRenderers[h.__view_id],b?a(b,d):a;h.then(function(a){g=b?a(b,d):a})}return g},registerView:function(a,b,d,e){b=(d||k.types[k.ext]).renderer(a,b);e=e||new c.Deferred;k.cache&&(k.cached[a]=e,e.__view_id=a,k.cachedRenderers[a]=b);return e.resolve(b)}});var Aa=function(a,b){if(!a.length)throw"can.view: No template or empty template:"+
|
49
|
-
b;},ya=function(a,b){var d=a.match(/\.[\w\d]+$/),e,f,h;a.match(/^#/)&&(a=a.substr(1));if(f=document.getElementById(a))d="."+f.type.match(/\/(x\-)?(.+)/)[2];!d&&!k.cached[a]&&(a+=d=k.ext);c.isArray(d)&&(d=d[0]);h=k.toId(a);if(a.match(/^\/\//))var g=a.substr(2),a=!p.steal?g:steal.config().root.mapJoin(g);e=k.types[d];if(k.cached[h])return k.cached[h];if(f)return k.registerView(h,f.innerHTML,e);var i=new c.Deferred;c.ajax({async:b,url:a,dataType:"text",error:function(b){Aa("",a);i.reject(b)},success:function(b){Aa(b,
|
50
|
-
a);k.registerView(h,b,e,i)}});return i},$a=function(a){var b=[];if(c.isDeferred(a))return[a];for(var d in a)c.isDeferred(a[d])&&b.push(a[d]);return b},za=function(a){return c.isArray(a)&&"success"===a[1]?a[0]:a};p.steal&&steal.type("view js",function(a,b){var c=k.types["."+a.type],e=k.toId(a.id);a.text="steal('"+(c.plugin||"can/view/"+a.type)+"',function(can){return can.view.preload('"+e+"',"+a.text+");\n})";b()});c.extend(k,{register:function(a){this.types["."+a.suffix]=a;p.steal&&steal.type(a.suffix+
|
51
|
-
" view js",function(a,c){var e=k.types["."+a.type],f=k.toId(a.id+"");a.text=e.script(f,a.text);c()});k[a.suffix]=function(b,d){if(!d)return a.renderer(null,b);k.preload(b,a.renderer(b,d));return c.view(b)}},registerScript:function(a,b,c){return"can.view.preload('"+b+"',"+k.types["."+a].script(b,c)+");"},preload:function(a,b){k.cached[a]=(new c.Deferred).resolve(function(a,c){return b.call(a,a,c)});return function(){return k.frag(b.apply(this,arguments))}}});var ab=function(a,b){var d;c.Observe&&(d=
|
52
|
-
c.Observe.__reading,c.Observe.__reading=function(a,b){e.push({obj:a,attr:b})});var e=[],f=a.call(b);c.Observe&&(c.Observe.__reading=d);return{value:f,observed:e}},Ba=function(a,b,d){var e={},f=!0,h={value:m,teardown:function(){for(var a in e){var b=e[a];b.observe.obj.unbind(b.observe.attr,i);delete e[a]}}},g,i=function(a){if(a.batchNum===m||a.batchNum!==g){var b=h.value,c=j();h.value=c;c!==b&&d(c,b);g=g=a.batchNum}},j=function(){var d=ab(a,b),g=d.observed,d=d.value;f=!f;c.each(g,function(a){e[a.obj._cid+
|
53
|
-
"|"+a.attr]?e[a.obj._cid+"|"+a.attr].matched=f:(e[a.obj._cid+"|"+a.attr]={matched:f,observe:a},a.obj.bind(a.attr,i))});for(var h in e)g=e[h],g.matched!==f&&(g.observe.obj.unbind(g.observe.attr,i),delete e[h]);return d};h.value=j();h.isListening=!c.isEmptyObject(e);return h};c.compute=function(a,b){if(a&&a.isComputed)return a;var d,e=0,f,h=!0;"function"===typeof a?f=function(g){return g===m?d?(e&&c.Observe.__reading&&c.Observe.__reading(f,"change"),d.value):a.call(b||this):a.apply(b||this,arguments)}:
|
54
|
-
(f=function(b){if(b===m)return c.Observe.__reading&&c.Observe.__reading(f,"change"),a;var d=a;a=b;d!==b&&c.Observe.triggerBatch(f,"change",[b,d]);return b},h=!1);f.isComputed=!0;f.bind=function(g,i){c.addEvent.apply(f,arguments);e===0&&h&&(d=Ba(a,b||this,function(a,b){c.Observe.triggerBatch(f,"change",[a,b])}));e++};f.unbind=function(a,b){c.removeEvent.apply(f,arguments);e--;e===0&&h&&d.teardown()};return f};c.compute.binder=Ba;var bb=/(\r|\n)+/g,aa={option:"textContent",textarea:"value"},Ca={tr:"tbody",
|
55
|
-
option:"select",td:"tr",li:"ul"},cb=function(a,b,c){if(a)return a;for(;c<b.length;){if("<"==b[c]&&Ca[b[c+1]])return Ca[b[c+1]];c++}},db=function(a){eval(a)},eb=/([^\s]+)[\s]*=[\s]*$/,A=null,ba=x=null,u=null,ca=function(){return x?"'"+ba.match(eb)[1]+"'":A?1:0};c.view.Scanner=Scanner=function(a){c.extend(this,{text:{},tokens:[]},a);this.tokenReg=[];this.tokenSimple={"<":"<",">":">",'"':'"',"'":"'"};this.tokenComplex=[];this.tokenMap={};for(var a=0,b;b=this.tokens[a];a++)b[2]?(this.tokenReg.push(b[2]),
|
56
|
-
this.tokenComplex.push({abbr:b[1],re:RegExp(b[2]),rescan:b[3]})):(this.tokenReg.push(b[1]),this.tokenSimple[b[1]]=b[0]),this.tokenMap[b[0]]=b[1];this.tokenReg=RegExp("("+this.tokenReg.slice(0).concat(["<",">",'"',"'"]).join("|")+")","g")};Scanner.prototype={helpers:[{name:/\s*\(([\$\w]+)\)\s*->([^\n]*)/,fn:function(a){a=a.match(/\s*\(([\$\w]+)\)\s*->([^\n]*)/);return"function(__){var "+a[1]+"=can.$(__);"+a[2]+"}"}}],scan:function(a,b){var c=[],e=0,f=this.tokenSimple,h=this.tokenComplex,a=a.replace(bb,
|
57
|
-
"\n");a.replace(this.tokenReg,function(b,g){var i=arguments[arguments.length-2];i>e&&c.push(a.substring(e,i));if(f[b])c.push(b);else for(var j=0,n;n=h[j];j++)if(n.re.test(b)){c.push(n.abbr);n.rescan&&c.push(n.rescan(g));break}e=i+g.length});e<a.length&&c.push(a.substr(e));var g="",i=["var ___v1ew = [];"+(this.text.start||"")],j=function(a,b){i.push("___v1ew.push(",'"',a.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split("\t").join("\\t"),'"'+(b||"")+");")},k=[],s,l=null,
|
58
|
-
o=!1,r="",q=[],I=0,t,n=this.tokenMap;for(A=x=ba=null;(t=c[I++])!==m;){if(null===l)switch(t){case n.left:case n.escapeLeft:case n.returnLeft:o=A&&1;case n.commentLeft:l=t;g.length&&j(g);g="";break;case n.escapeFull:o=A&&1;u=1;l=n.escapeLeft;g.length&&j(g);u=c[I++];g=u.content||u;u.before&&j(u.before);c.splice(I,0,n.right);break;case n.commentFull:break;case n.templateLeft:g+=n.left;break;case "<":0!==c[I].indexOf("!--")&&(A=1,o=0);g+=t;break;case ">":A=0;s="/"==g.substr(g.length-1);o||aa[q[q.length-
|
59
|
-
1]]?(s?j(g.substr(0,g.length-1),',can.view.pending(),"/>"'):j(g,',can.view.pending(),">"'),g=""):g+=t;s&&(q.pop(),r=q[q.length-1]);break;case "'":case '"':A&&(x&&x===t?x=null:null===x&&(x=t,ba=s));default:"<"===s&&(r=t.split(/\s/)[0],0===r.indexOf("/")&&q.pop()===r.substr(1)?r=q[q.length-1]:q.push(r)),g+=t}else switch(t){case n.right:case n.returnRight:switch(l){case n.left:s=--g.split("{").length- --g.split("}").length;1==s?(i.push("___v1ew.push(","can.view.txt(0,'"+cb(r,c,I)+"',"+ca()+",this,function(){",
|
60
|
-
"var ___v1ew = [];",g),k.push({before:"",after:"return ___v1ew.join('')}));\n"})):(e=k.length&&-1==s?k.pop():{after:";"},e.before&&i.push(e.before),i.push(g,";",e.after));break;case n.escapeLeft:case n.returnLeft:(s=--g.split("{").length- --g.split("}").length)&&k.push({before:"return ___v1ew.join('')",after:"}));"});for(var l=l===n.escapeLeft?1:0,fb={insert:"___v1ew.push(",tagName:r,status:ca()},da=0;da<this.helpers.length;da++){var p=this.helpers[da];if(p.name.test(g)){g=p.fn(g,fb);p.name.source==
|
61
|
-
/^>[\s|\w]\w*/.source&&(l=0);break}}"object"==typeof g?g.raw&&i.push(g.raw):i.push("___v1ew.push(","can.view.txt("+l+",'"+r+"',"+ca()+",this,function(){ "+(this.text.escape||"")+"return ",g,s?"var ___v1ew = [];":"}));");u&&(u.after&&u.after.length)&&(j(u.after.length),u=null)}l=null;g="";break;case n.templateLeft:g+=n.left;break;default:g+=t}s=t}g.length&&j(g);i.push(";");g={out:"with(_VIEW) { with (_CONTEXT) {"+i.join("")+" return ___v1ew.join('')}}"};db.call(g,"this.fn = (function(_CONTEXT,_VIEW){"+
|
62
|
-
g.out+"});\r\n//@ sourceURL="+b+".js");return g}};var ea=!0;try{document.createTextNode()._=0}catch(ib){ea=!1}var N={"class":"className",value:"value",textContent:"textContent"},Da={"":"span",table:"tr",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr",select:"option",optgroup:"option"},gb=/__!!__/g,aa={option:"textContent",textarea:"value"},Ea=c.each(["checked","disabled","readonly","required"],function(a){N[a]=a}),fa=function(a,b,d){var e=a.nodeName.toString().toLowerCase(),f=N[b];f?(a[f]=
|
63
|
-
-1<c.inArray(b,Ea)?!0:d,"value"===f&&"input"===e&&(a.defaultValue=d)):a.setAttribute(b,d)},J=[],ga=function(a){if("string"==typeof a)return a;if(!a&&0!==a)return"";var b=a.hookup&&function(b,c){a.hookup.call(a,b,c)}||"function"==typeof a&&a;return b?(J.push(b),""):""+a},hb=function(a){return"string"==typeof a||"number"==typeof a?c.esc(a):ga(a)},D={},O={},P={},ha="ejs_"+Math.random(),ia=0,B=function(a){if(ea||3!==a.nodeType)return a[ha]?a[ha]:a[ha]=(a.nodeName?"element_":"obj_")+ ++ia;for(var b in O)if(O[b]===
|
64
|
-
a)return b;O["text_"+ ++ia]=a;return"text_"+ia},Fa=function(a,b){var d=D[B(a)];if(d){var e=c.inArray(b,d);0<=e&&d.splice(e,1);d.length||delete D[B(a)]}},Ga=function(a,b){var c=D[B(a)];c||(c=D[B(a)]=[]);c.push(b)},Ha=function(a){a=Da[a]||"span";return"span"===a?"@@!!@@":"<"+a+">"+Ha(a)+"</"+a+">"};c.extend(c.view,{pending:function(){var a=J.slice(0);lastHookups=a;J=[];return c.view.hook(function(b){c.each(a,function(a){a(b)})})},registerNode:function(a){var b=B(a);P[b]=a;c.each(a,function(a){Ga(a,
|
65
|
-
b)})},unregisterNode:function(a){var b=B(a);c.each(a,function(a){Fa(a,b)});delete P[b]},txt:function(a,b,d,e,f){var h=c.compute.binder(f,e,function(a,b){o(a,b)});if(!h.isListening)return(a||0!==d?hb:ga)(h.value);var g,i,j=function(){h.teardown();i&&c.view.unregisterNode(i)},k=function(a){c.bind.call(a,"destroyed",j);g=a},l=function(a){a||(j(),c.unbind.call(g,"destroyed",j))},e=Da[b]||"span",o,p=aa[b];if(0===d&&!p)return"<"+e+c.view.hook(a?function(a,b){o=function(a){d.nodeValue=""+a;l(d.parentNode)};
|
66
|
-
var c=b&&11===a.parentNode.nodeType?b:a.parentNode,d=document.createTextNode(h.value);c.insertBefore(d,a);c.removeChild(a);k(c)}:function(a,b){o=function(a){d[0].parentNode&&e(a);l(d[0].parentNode)};var b=b&&11===a.parentNode.nodeType?b:a.parentNode,d,e=function(e){var e=c.view.frag(e,b),f=c.makeArray(e.childNodes),g=d?d[d.length-1]:a;g.nextSibling?g.parentNode.insertBefore(e,g.nextSibling):g.parentNode.appendChild(e);d?(c.remove(c.$(d)),c.view.replace(d,f)):(c.remove(c.$(a)),i=d=f,c.view.registerNode(d))};
|
67
|
-
e(h.value,[a]);k(b)})+">"+Ha(e)+"</"+e+">";if(1===d){var r=h.value.replace(/['"]/g,"").split("=")[0];J.push(function(a){o=function(b){var b=(b||"").replace(/['"]/g,"").split("="),d=b[0];if(d!=r&&r){var e=r;-1<c.inArray(e,Ea)?a[e]=!1:a.removeAttribute(e)}d&&(fa(a,d,b[1]),r=d)};k(a)});return h.value}var q=0===d?p:d;(0===d?lastHookups:J).push(function(a){o=function(){fa(a,q,g.render(),p)};var b=c.$(a),d;(d=c.data(b,"hooks"))||c.data(b,"hooks",d={});var e=(N[q]?a[N[q]]:a.getAttribute(q))||"",b=e.split("__!!__"),
|
68
|
-
f=[],g;f.push(b.shift(),b.join("__!!__"));d[q]?d[q].bindings.push(h):d[q]={render:function(){var a=0;return e.replace(gb,function(){return ga(g.bindings[a++].value)})},bindings:[h],batchNum:m};g=d[q];f.splice(1,0,h.value);fa(a,q,f.join(""),p);k(a)});return"__!!__"},replace:function(a,b){a=c.makeArray(a);c.each(a,function(d){c.each(c.makeArray(D[B(d)]),function(e){var f=P[e],h=c.inArray(d,f),g=c.inArray(a[a.length-1],f);if(0<=h&&0<=g){for(var i=h;i<=g;i++)Fa(f[i],e);f.splice.apply(f,[h,g-h+1].concat(b));
|
69
|
-
c.each(b,function(a){Ga(a,e)})}else c.view.unregisterNode(f)})})},canExpando:ea,textNodeMap:O,nodeMap:D,nodeListMap:P});var o=c.extend,w=function(a){if(this.constructor!=w){var b=new w(a);return function(a,c){return b.render(a,c)}}"function"==typeof a?this.template={fn:a}:(o(this,a),this.template=this.scanner.scan(this.text,this.name))};c.EJS=w;w.prototype.render=function(a,b){a=a||{};return this.template.fn.call(a,a,new w.Helpers(a,b||{}))};o(w.prototype,{scanner:new c.view.Scanner({tokens:[["templateLeft",
|
70
|
-
"<%%"],["templateRight","%>"],["returnLeft","<%=="],["escapeLeft","<%="],["commentLeft","<%#"],["left","<%"],["right","%>"],["returnRight","%>"]]})});w.Helpers=function(a,b){this._data=a;this._extras=b;o(this,b)};w.Helpers.prototype={list:function(a,b){c.each(a,function(c,e){b(c,e,a)})}};c.view.register({suffix:"ejs",script:function(a,b){return"can.EJS(function(_CONTEXT,_VIEW) { "+(new w({text:b,name:a})).template.out+" })"},renderer:function(a,b){return w({text:b,name:a})}})})(this,jQuery);
|
@@ -1,154 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* CanJS - 1.1.2 (2012-11-28)
|
3
|
-
* http://canjs.us/
|
4
|
-
* Copyright (c) 2012 Bitovi
|
5
|
-
* Licensed MIT
|
6
|
-
*/
|
7
|
-
(function (can, window, undefined) {
|
8
|
-
// ## can/observe/attributes/attributes.js
|
9
|
-
can.each([can.Observe, can.Model], function (clss) {
|
10
|
-
// in some cases model might not be defined quite yet.
|
11
|
-
if (clss === undefined) {
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
|
15
|
-
can.extend(clss, {
|
16
|
-
|
17
|
-
attributes: {},
|
18
|
-
|
19
|
-
|
20
|
-
convert: {
|
21
|
-
"date": function (str) {
|
22
|
-
var type = typeof str;
|
23
|
-
if (type === "string") {
|
24
|
-
return isNaN(Date.parse(str)) ? null : Date.parse(str)
|
25
|
-
} else if (type === 'number') {
|
26
|
-
return new Date(str)
|
27
|
-
} else {
|
28
|
-
return str
|
29
|
-
}
|
30
|
-
},
|
31
|
-
"number": function (val) {
|
32
|
-
return parseFloat(val);
|
33
|
-
},
|
34
|
-
"boolean": function (val) {
|
35
|
-
return Boolean(val === "false" ? 0 : val);
|
36
|
-
},
|
37
|
-
"default": function (val, oldVal, error, type) {
|
38
|
-
var construct = can.getObject(type),
|
39
|
-
context = window,
|
40
|
-
realType;
|
41
|
-
// if type has a . we need to look it up
|
42
|
-
if (type.indexOf(".") >= 0) {
|
43
|
-
// get everything before the last .
|
44
|
-
realType = type.substring(0, type.lastIndexOf("."));
|
45
|
-
// get the object before the last .
|
46
|
-
context = can.getObject(realType);
|
47
|
-
}
|
48
|
-
return typeof construct == "function" ? construct.call(context, val, oldVal) : val;
|
49
|
-
}
|
50
|
-
},
|
51
|
-
|
52
|
-
serialize: {
|
53
|
-
"default": function (val, type) {
|
54
|
-
return isObject(val) && val.serialize ? val.serialize() : val;
|
55
|
-
},
|
56
|
-
"date": function (val) {
|
57
|
-
return val && val.getTime()
|
58
|
-
}
|
59
|
-
}
|
60
|
-
});
|
61
|
-
|
62
|
-
// overwrite setup to do this stuff
|
63
|
-
var oldSetup = clss.setup;
|
64
|
-
|
65
|
-
|
66
|
-
clss.setup = function (superClass, stat, proto) {
|
67
|
-
var self = this;
|
68
|
-
oldSetup.call(self, superClass, stat, proto);
|
69
|
-
|
70
|
-
can.each(["attributes"], function (name) {
|
71
|
-
if (!self[name] || superClass[name] === self[name]) {
|
72
|
-
self[name] = {};
|
73
|
-
}
|
74
|
-
});
|
75
|
-
|
76
|
-
can.each(["convert", "serialize"], function (name) {
|
77
|
-
if (superClass[name] != self[name]) {
|
78
|
-
self[name] = can.extend({}, superClass[name], self[name]);
|
79
|
-
}
|
80
|
-
});
|
81
|
-
};
|
82
|
-
});
|
83
|
-
|
84
|
-
var oldSetup = can.Observe.prototype.setup;
|
85
|
-
|
86
|
-
can.Observe.prototype.setup = function (obj) {
|
87
|
-
|
88
|
-
var diff = {};
|
89
|
-
|
90
|
-
oldSetup.call(this, obj);
|
91
|
-
|
92
|
-
can.each(this.constructor.defaults, function (value, key) {
|
93
|
-
if (!this.hasOwnProperty(key)) {
|
94
|
-
diff[key] = value;
|
95
|
-
}
|
96
|
-
}, this);
|
97
|
-
|
98
|
-
this._init = 1;
|
99
|
-
this.attr(diff);
|
100
|
-
delete this._init;
|
101
|
-
};
|
102
|
-
|
103
|
-
can.Observe.prototype.__convert = function (prop, value) {
|
104
|
-
// check if there is a
|
105
|
-
var Class = this.constructor,
|
106
|
-
oldVal = this.attr(prop),
|
107
|
-
type, converter;
|
108
|
-
|
109
|
-
if (Class.attributes) {
|
110
|
-
// the type of the attribute
|
111
|
-
type = Class.attributes[prop];
|
112
|
-
converter = Class.convert[type] || Class.convert['default'];
|
113
|
-
}
|
114
|
-
|
115
|
-
return value === null || !type ?
|
116
|
-
// just use the value
|
117
|
-
value :
|
118
|
-
// otherwise, pass to the converter
|
119
|
-
converter.call(Class, value, oldVal, function () {}, type);
|
120
|
-
};
|
121
|
-
|
122
|
-
can.Observe.prototype.serialize = function (attrName) {
|
123
|
-
var where = {},
|
124
|
-
Class = this.constructor,
|
125
|
-
attrs = {};
|
126
|
-
|
127
|
-
if (attrName != undefined) {
|
128
|
-
attrs[attrName] = this[attrName];
|
129
|
-
} else {
|
130
|
-
attrs = this.__get();
|
131
|
-
}
|
132
|
-
|
133
|
-
can.each(attrs, function (val, name) {
|
134
|
-
var type, converter;
|
135
|
-
|
136
|
-
type = Class.attributes ? Class.attributes[name] : 0;
|
137
|
-
converter = Class.serialize ? Class.serialize[type] : 0;
|
138
|
-
|
139
|
-
// if the value is an object, and has a attrs or serialize function
|
140
|
-
where[name] = val && typeof val.serialize == 'function' ?
|
141
|
-
// call attrs or serialize to get the original data back
|
142
|
-
val.serialize() :
|
143
|
-
// otherwise if we have a converter
|
144
|
-
converter ?
|
145
|
-
// use the converter
|
146
|
-
converter(val, type) :
|
147
|
-
// or return the val
|
148
|
-
val
|
149
|
-
});
|
150
|
-
|
151
|
-
return attrName != undefined ? where[attrName] : where;
|
152
|
-
};
|
153
|
-
|
154
|
-
})(can, this);
|
@@ -1,170 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* CanJS - 1.1.2 (2012-11-28)
|
3
|
-
* http://canjs.us/
|
4
|
-
* Copyright (c) 2012 Bitovi
|
5
|
-
* Licensed MIT
|
6
|
-
*/
|
7
|
-
(function (can, window, undefined) {
|
8
|
-
// ## can/util/object/object.js
|
9
|
-
|
10
|
-
var isArray = can.isArray,
|
11
|
-
// essentially returns an object that has all the must have comparisons ...
|
12
|
-
// must haves, do not return true when provided undefined
|
13
|
-
cleanSet = function (obj, compares) {
|
14
|
-
var copy = can.extend({}, obj);
|
15
|
-
for (var prop in copy) {
|
16
|
-
var compare = compares[prop] === undefined ? compares["*"] : compares[prop];
|
17
|
-
if (same(copy[prop], undefined, compare)) {
|
18
|
-
delete copy[prop]
|
19
|
-
}
|
20
|
-
}
|
21
|
-
return copy;
|
22
|
-
},
|
23
|
-
propCount = function (obj) {
|
24
|
-
var count = 0;
|
25
|
-
for (var prop in obj) count++;
|
26
|
-
return count;
|
27
|
-
};
|
28
|
-
|
29
|
-
can.Object = {};
|
30
|
-
|
31
|
-
var same = can.Object.same = function (a, b, compares, aParent, bParent, deep) {
|
32
|
-
var aType = typeof a,
|
33
|
-
aArray = isArray(a),
|
34
|
-
comparesType = typeof compares,
|
35
|
-
compare;
|
36
|
-
|
37
|
-
if (comparesType == 'string' || compares === null) {
|
38
|
-
compares = compareMethods[compares];
|
39
|
-
comparesType = 'function'
|
40
|
-
}
|
41
|
-
if (comparesType == 'function') {
|
42
|
-
return compares(a, b, aParent, bParent)
|
43
|
-
}
|
44
|
-
compares = compares || {};
|
45
|
-
|
46
|
-
if (a instanceof Date) {
|
47
|
-
return a === b;
|
48
|
-
}
|
49
|
-
if (deep === -1) {
|
50
|
-
return aType === 'object' || a === b;
|
51
|
-
}
|
52
|
-
if (aType !== typeof b || aArray !== isArray(b)) {
|
53
|
-
return false;
|
54
|
-
}
|
55
|
-
if (a === b) {
|
56
|
-
return true;
|
57
|
-
}
|
58
|
-
if (aArray) {
|
59
|
-
if (a.length !== b.length) {
|
60
|
-
return false;
|
61
|
-
}
|
62
|
-
for (var i = 0; i < a.length; i++) {
|
63
|
-
compare = compares[i] === undefined ? compares["*"] : compares[i]
|
64
|
-
if (!same(a[i], b[i], a, b, compare)) {
|
65
|
-
return false;
|
66
|
-
}
|
67
|
-
};
|
68
|
-
return true;
|
69
|
-
} else if (aType === "object" || aType === 'function') {
|
70
|
-
var bCopy = can.extend({}, b);
|
71
|
-
for (var prop in a) {
|
72
|
-
compare = compares[prop] === undefined ? compares["*"] : compares[prop];
|
73
|
-
if (!same(a[prop], b[prop], compare, a, b, deep === false ? -1 : undefined)) {
|
74
|
-
return false;
|
75
|
-
}
|
76
|
-
delete bCopy[prop];
|
77
|
-
}
|
78
|
-
// go through bCopy props ... if there is no compare .. return false
|
79
|
-
for (prop in bCopy) {
|
80
|
-
if (compares[prop] === undefined || !same(undefined, b[prop], compares[prop], a, b, deep === false ? -1 : undefined)) {
|
81
|
-
return false;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
return true;
|
85
|
-
}
|
86
|
-
return false;
|
87
|
-
};
|
88
|
-
|
89
|
-
can.Object.subsets = function (checkSet, sets, compares) {
|
90
|
-
var len = sets.length,
|
91
|
-
subsets = [],
|
92
|
-
checkPropCount = propCount(checkSet),
|
93
|
-
setLength;
|
94
|
-
|
95
|
-
for (var i = 0; i < len; i++) {
|
96
|
-
//check this subset
|
97
|
-
var set = sets[i];
|
98
|
-
if (can.Object.subset(checkSet, set, compares)) {
|
99
|
-
subsets.push(set)
|
100
|
-
}
|
101
|
-
}
|
102
|
-
return subsets;
|
103
|
-
};
|
104
|
-
|
105
|
-
can.Object.subset = function (subset, set, compares) {
|
106
|
-
// go through set {type: 'folder'} and make sure every property
|
107
|
-
// is in subset {type: 'folder', parentId :5}
|
108
|
-
// then make sure that set has fewer properties
|
109
|
-
// make sure we are only checking 'important' properties
|
110
|
-
// in subset (ones that have to have a value)
|
111
|
-
var setPropCount = 0,
|
112
|
-
compares = compares || {};
|
113
|
-
|
114
|
-
for (var prop in set) {
|
115
|
-
|
116
|
-
if (!same(subset[prop], set[prop], compares[prop], subset, set)) {
|
117
|
-
return false;
|
118
|
-
}
|
119
|
-
}
|
120
|
-
return true;
|
121
|
-
}
|
122
|
-
|
123
|
-
var compareMethods = {
|
124
|
-
"null": function () {
|
125
|
-
return true;
|
126
|
-
},
|
127
|
-
i: function (a, b) {
|
128
|
-
return ("" + a).toLowerCase() == ("" + b).toLowerCase()
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
// ## can/observe/backup/backup.js
|
133
|
-
var flatProps = function (a) {
|
134
|
-
var obj = {};
|
135
|
-
for (var prop in a) {
|
136
|
-
if (typeof a[prop] !== 'object' || a[prop] === null || a[prop] instanceof Date) {
|
137
|
-
obj[prop] = a[prop]
|
138
|
-
}
|
139
|
-
}
|
140
|
-
return obj;
|
141
|
-
};
|
142
|
-
|
143
|
-
can.extend(can.Observe.prototype, {
|
144
|
-
|
145
|
-
|
146
|
-
backup: function () {
|
147
|
-
this._backupStore = this._attrs();
|
148
|
-
return this;
|
149
|
-
},
|
150
|
-
|
151
|
-
|
152
|
-
isDirty: function (checkAssociations) {
|
153
|
-
return this._backupStore && !can.Object.same(this._attrs(), this._backupStore, undefined, undefined, undefined, !! checkAssociations);
|
154
|
-
},
|
155
|
-
|
156
|
-
|
157
|
-
restore: function (restoreAssociations) {
|
158
|
-
var props = restoreAssociations ? this._backupStore : flatProps(this._backupStore)
|
159
|
-
|
160
|
-
if (this.isDirty(restoreAssociations)) {
|
161
|
-
this._attrs(props);
|
162
|
-
}
|
163
|
-
|
164
|
-
return this;
|
165
|
-
}
|
166
|
-
|
167
|
-
})
|
168
|
-
|
169
|
-
|
170
|
-
})(can, this);
|
@@ -1,206 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* CanJS - 1.1.2 (2012-11-28)
|
3
|
-
* http://canjs.us/
|
4
|
-
* Copyright (c) 2012 Bitovi
|
5
|
-
* Licensed MIT
|
6
|
-
*/
|
7
|
-
(function (can, window, undefined) {
|
8
|
-
// ## can/observe/delegate/delegate.js
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
// ** - 'this' will be the deepest item changed
|
13
|
-
// * - 'this' will be any changes within *, but * will be the
|
14
|
-
// this returned
|
15
|
-
// tells if the parts part of a delegate matches the broken up props of the event
|
16
|
-
// gives the prop to use as 'this'
|
17
|
-
// - parts - the attribute name of the delegate split in parts ['foo','*']
|
18
|
-
// - props - the split props of the event that happened ['foo','bar','0']
|
19
|
-
// - returns - the attribute to delegate too ('foo.bar'), or null if not a match
|
20
|
-
var matches = function (parts, props) {
|
21
|
-
//check props parts are the same or
|
22
|
-
var len = parts.length,
|
23
|
-
i = 0,
|
24
|
-
// keeps the matched props we will use
|
25
|
-
matchedProps = [],
|
26
|
-
prop;
|
27
|
-
|
28
|
-
// if the event matches
|
29
|
-
for (i; i < len; i++) {
|
30
|
-
prop = props[i]
|
31
|
-
// if no more props (but we should be matching them)
|
32
|
-
// return null
|
33
|
-
if (typeof prop !== 'string') {
|
34
|
-
return null;
|
35
|
-
} else
|
36
|
-
// if we have a "**", match everything
|
37
|
-
if (parts[i] == "**") {
|
38
|
-
return props.join(".");
|
39
|
-
} else
|
40
|
-
// a match, but we want to delegate to "*"
|
41
|
-
if (parts[i] == "*") {
|
42
|
-
// only do this if there is nothing after ...
|
43
|
-
matchedProps.push(prop);
|
44
|
-
}
|
45
|
-
else if (prop === parts[i]) {
|
46
|
-
matchedProps.push(prop);
|
47
|
-
} else {
|
48
|
-
return null;
|
49
|
-
}
|
50
|
-
}
|
51
|
-
return matchedProps.join(".");
|
52
|
-
},
|
53
|
-
// gets a change event and tries to figure out which
|
54
|
-
// delegates to call
|
55
|
-
delegate = function (event, prop, how, newVal, oldVal) {
|
56
|
-
// pre-split properties to save some regexp time
|
57
|
-
var props = prop.split("."),
|
58
|
-
delegates = (this._observe_delegates || []).slice(0),
|
59
|
-
delegate, attr, matchedAttr, hasMatch, valuesEqual;
|
60
|
-
event.attr = prop;
|
61
|
-
event.lastAttr = props[props.length - 1];
|
62
|
-
|
63
|
-
// for each delegate
|
64
|
-
for (var i = 0; delegate = delegates[i++];) {
|
65
|
-
|
66
|
-
// if there is a batchNum, this means that this
|
67
|
-
// event is part of a series of events caused by a single
|
68
|
-
// attrs call. We don't want to issue the same event
|
69
|
-
// multiple times
|
70
|
-
// setting the batchNum happens later
|
71
|
-
if ((event.batchNum && delegate.batchNum === event.batchNum) || delegate.undelegated) {
|
72
|
-
continue;
|
73
|
-
}
|
74
|
-
|
75
|
-
// reset match and values tests
|
76
|
-
hasMatch = undefined;
|
77
|
-
valuesEqual = true;
|
78
|
-
|
79
|
-
// yeah, all this under here has to be redone v
|
80
|
-
// for each attr in a delegate
|
81
|
-
for (var a = 0; a < delegate.attrs.length; a++) {
|
82
|
-
|
83
|
-
attr = delegate.attrs[a];
|
84
|
-
|
85
|
-
// check if it is a match
|
86
|
-
if (matchedAttr = matches(attr.parts, props)) {
|
87
|
-
hasMatch = matchedAttr;
|
88
|
-
}
|
89
|
-
// if it has a value, make sure it's the right value
|
90
|
-
// if it's set, we should probably check that it has a
|
91
|
-
// value no matter what
|
92
|
-
if (attr.value && valuesEqual) {
|
93
|
-
valuesEqual = attr.value === "" + this.attr(attr.attr)
|
94
|
-
} else if (valuesEqual && delegate.attrs.length > 1) {
|
95
|
-
// if there are multiple attributes, each has to at
|
96
|
-
// least have some value
|
97
|
-
valuesEqual = this.attr(attr.attr) !== undefined
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
|
102
|
-
// if there is a match and valuesEqual ... call back
|
103
|
-
if (hasMatch && valuesEqual) {
|
104
|
-
// how to get to the changed property from the delegate
|
105
|
-
var from = prop.replace(hasMatch + ".", "");
|
106
|
-
|
107
|
-
// if this event is part of a batch, set it on the delegate
|
108
|
-
// to only send one event
|
109
|
-
if (event.batchNum) {
|
110
|
-
delegate.batchNum = event.batchNum
|
111
|
-
}
|
112
|
-
|
113
|
-
// if we listen to change, fire those with the same attrs
|
114
|
-
// TODO: the attrs should probably be using from
|
115
|
-
if (delegate.event === 'change') {
|
116
|
-
arguments[1] = from;
|
117
|
-
event.curAttr = hasMatch;
|
118
|
-
delegate.callback.apply(this.attr(hasMatch), can.makeArray(arguments));
|
119
|
-
} else if (delegate.event === how) {
|
120
|
-
|
121
|
-
// if it's a match, callback with the location of the match
|
122
|
-
delegate.callback.apply(this.attr(hasMatch), [event, newVal, oldVal, from]);
|
123
|
-
} else if (delegate.event === 'set' && how == 'add') {
|
124
|
-
// if we are listening to set, we should also listen to add
|
125
|
-
delegate.callback.apply(this.attr(hasMatch), [event, newVal, oldVal, from]);
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
}
|
130
|
-
};
|
131
|
-
|
132
|
-
can.extend(can.Observe.prototype, {
|
133
|
-
|
134
|
-
delegate: function (selector, event, handler) {
|
135
|
-
selector = can.trim(selector);
|
136
|
-
var delegates = this._observe_delegates || (this._observe_delegates = []),
|
137
|
-
attrs = [],
|
138
|
-
selectorRegex = /([^\s=,]+)(?:=("[^",]*"|'[^',]*'|[^\s"',]*))?(,?)\s*/g,
|
139
|
-
matches;
|
140
|
-
|
141
|
-
// parse each property in the selector
|
142
|
-
while (matches = selectorRegex.exec(selector)) {
|
143
|
-
// we need to do a little doctoring to make up for the quotes.
|
144
|
-
if (matches[2] && $.inArray(matches[2].substr(0, 1), ['"', "'"]) >= 0) {
|
145
|
-
matches[2] = matches[2].substr(1, -1);
|
146
|
-
}
|
147
|
-
|
148
|
-
attrs.push({
|
149
|
-
// the attribute name
|
150
|
-
attr: matches[1],
|
151
|
-
// the attribute name, pre-split for speed
|
152
|
-
parts: matches[1].split('.'),
|
153
|
-
// the value associated with this property (if there was one given)
|
154
|
-
value: matches[2],
|
155
|
-
// whether this selector combines with the one after it with AND or OR
|
156
|
-
or: matches[3] === ','
|
157
|
-
});
|
158
|
-
}
|
159
|
-
|
160
|
-
// delegates has pre-processed info about the event
|
161
|
-
delegates.push({
|
162
|
-
// the attrs name for unbinding
|
163
|
-
selector: selector,
|
164
|
-
// an object of attribute names and values {type: 'recipe',id: undefined}
|
165
|
-
// undefined means a value was not defined
|
166
|
-
attrs: attrs,
|
167
|
-
callback: handler,
|
168
|
-
event: event
|
169
|
-
});
|
170
|
-
if (delegates.length === 1) {
|
171
|
-
this.bind("change", delegate)
|
172
|
-
}
|
173
|
-
return this;
|
174
|
-
},
|
175
|
-
|
176
|
-
undelegate: function (selector, event, handler) {
|
177
|
-
selector = can.trim(selector);
|
178
|
-
|
179
|
-
var i = 0,
|
180
|
-
delegates = this._observe_delegates || [],
|
181
|
-
delegateOb;
|
182
|
-
if (selector) {
|
183
|
-
while (i < delegates.length) {
|
184
|
-
delegateOb = delegates[i];
|
185
|
-
if (delegateOb.callback === handler || (!handler && delegateOb.selector === selector)) {
|
186
|
-
delegateOb.undelegated = true;
|
187
|
-
delegates.splice(i, 1)
|
188
|
-
} else {
|
189
|
-
i++;
|
190
|
-
}
|
191
|
-
}
|
192
|
-
} else {
|
193
|
-
// remove all delegates
|
194
|
-
delegates = [];
|
195
|
-
}
|
196
|
-
if (!delegates.length) {
|
197
|
-
//can.removeData(this, "_observe_delegates");
|
198
|
-
this.unbind("change", delegate)
|
199
|
-
}
|
200
|
-
return this;
|
201
|
-
}
|
202
|
-
});
|
203
|
-
// add helpers for testing ..
|
204
|
-
can.Observe.prototype.delegate.matches = matches;
|
205
|
-
|
206
|
-
})(can, this);
|