// Generated by CoffeeScript 1.3.3 /* mixin-js.js 0.1.4 (c) 2011, 2012 Kevin Malakoff. Mixin is freely distributable under the MIT license. See the following for full license details: https://github.com/kmalakoff/mixin/blob/master/LICENSE Dependencies: None. Note: some code from Underscore.js is embedded in this file to remove dependencies on the full library. Please see the following for details on Underscore.js and its licensing: https://github.com/documentcloud/underscore https://github.com/documentcloud/underscore/blob/master/LICENSE */(function(){var e,t,n={}.hasOwnProperty,r=function(e,t){function i(){this.constructor=e}for(var r in t)n.call(t,r)&&(e[r]=t[r]);return i.prototype=t.prototype,e.prototype=new i,e.__super__=t.prototype,e};e=this.Mixin=typeof exports!="undefined"?exports:{},e.Core||(e.Core={}),e.VERSION="0.1.4";if(typeof require!="undefined")try{t=require("lodash")}catch(i){t=require("underscore")}else t=this._;t&&t.hasOwnProperty("_")&&(t=t._),t||(t={}),e._=t,t.isArray||(t.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"}),t.isString||(t.isString=function(e){return!!(e===""||e&&e.charCodeAt&&e.substr)}),t.isFunction||(t.isFunction=function(e){return!!(e&&e.constructor&&e.call&&e.apply)}),t.isEmpty||(t.isEmpty=function(e){var n,r;if(t.isArray(e)||t.isString(e))return e.length===0;for(n in e)return r=e[n],!1;return!0}),t.classOf||(t.classOf=function(e){return e instanceof Object?e.prototype&&e.prototype.constructor&&e.prototype.constructor.name?e.prototype.constructor.name:e.constructor&&e.constructor.name?e.constructor.name:void 0:void 0}),t.size||(t.size=function(e){var t,n;t=0;for(n in e)t++;return t}),t.find||(t.find=function(e,t){var n,r,i;for(r=0,i=e.length;r=0){i=this.instance_records[r];if(i.mix_target===e&&i.destroyMixin(n)){s=!0,t.isEmpty(i.initialized_mixins)&&(i.destroy(),this.instance_records.splice(r,1));if(n)return!0}r--}return s},n.prototype._getInstanceRecord=function(e){var t,n,r,i;i=this.instance_records;for(n=0,r=i.length;n1){s=i[1];if(!(t.isString(s)&&n.isAvailable(s)||t.isArray(s)&&s.length>=1&&t.isString(s[0])&&n.isAvailable(s[0])))return u.apply(this,arguments),r}for(a=0,f=i.length;a1){l=Array.prototype.slice.call(arguments,1);for(o=0,a=l.length;o1?e[1]:void 0;if(!t.keypathExists(this.owner,r))throw new Error("Mixin.AutoMemory: property '"+r+"' doesn't exist on '"+t.classOf(this.owner)+"'");if(n&&!t.isFunction(n)&&!t.isString(n))throw new Error("Mixin.AutoMemory: unexpected function reference for property '"+r+"' on '"+t.classOf(this.owner)+"'")},n.prototype._destroyEntry=function(e){var n,r,i,s,o,u,a,f;r=e[0],n=e.length>1?e[1]:void 0;if(!n){i=t.keypathValueOwner(this.owner,r);if(!i)throw new Error("Mixin.AutoMemory: property '"+r+"' doesn't exist on '"+t.classOf(this.owner)+"'");i[r]=null;return}o=t.keypath(this.owner,r);if(!o)return;if(t.isFunction(n))n.apply(this.owner,[o].concat(e.length>2?e.slice(2):[]));else if(t.isFunction(o[n]))o[n].apply(o,e.length>2?e.slice(2):[]);else{f=e.slice(1);for(u=0,a=f.length;ue.Subscription.TYPE.EXCLUSIVE)throw new Error("Mixin.Subscriptions: Mixin.Subscription.TYPE is invalid");this.subscription_links=[]}return n.prototype.addSubscriber=function(t,n,r){return this.subscription_type===e.Subscription.TYPE.EXCLUSIVE&&this.removeSubscribers(function(e){return e.mustKeepUntilDestroyed()}),this.subscription_links.push(new e.Subscriptions._SubscriptionLink(this,t,n,r))},n.prototype.removeSubscriber=function(e,n,r){var i;i=t.find(this.subscription_links,function(t){return e===t.subscriber&&n===t.notification_callback});if(!i)throw new Error("Mixin.Subscriptions.removeSubscriber: subscription '"+r+"' does not exist for '"+t.classOf(e)+"'");return t.remove(this.subscription_links,i),i.destroy()},n.prototype.subscribers=function(e){var t,n,r,i,s;i=this.subscription_links,s=[];for(n=0,r=i.length;n1){s=i[1];if(!(t.isString(s)&&this.hasSubscription(s)||t.isArray(s)&&s.length>=1&&t.isString(s[0])&&this.hasSubscription(s[0])))return a.apply(this,Array.prototype.slice.call(arguments,1)),this}for(f=0,l=i.length;f1){o=s[1];if(!(t.isString(o)&&this.hasSubscription(o)||t.isArray(o)&&o.length>=1&&t.isString(o[0])&&this.hasSubscription(o[0])))return f.apply(this,Array.prototype.slice.call(arguments,1)),this}for(l=0,c=s.length;l