forked from davej/angular-classy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-classy.min.js
1 lines (1 loc) · 3.61 KB
/
angular-classy.min.js
1
(function(){"use strict";var a,b,c,d=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},e={}.hasOwnProperty;b={controller:{addFnsToScope:!0,watchObject:!0,_scopeName:"$scope",_scopeShortcut:!0,_scopeShortcutName:"$",_watchKeywords:{objectEquality:["{object}","{deep}"],collection:["{collection}","{shallow}"]}}},c=angular.module,angular.module=function(f,g,h){var i;return i=c(f,g,h),g&&d.call(g,"classy")>=0&&(i.classy={options:{controller:{}},controller:function(c){var d,f,g,h;c.__options=angular.extend({},b.controller,i.classy.options.controller,c.__options),d=f=function(){function b(){a.construct(this,arguments)}return b.prototype.__options=c.__options,a.create(i,c,b),b}();for(g in c)e.call(c,g)&&(h=c[g],d.prototype[g]=h);return d}},i.cC=i.classyController=i.classy.controller),i},angular.module("classy",[]),a={selectorControllerCount:0,construct:function(a,b){var c;return c=a.constructor.prototype.__options,this.bindDependencies(a,b),c.addFnsToScope&&this.addFnsToScope(a),"function"==typeof a.init&&a.init(),c.watchObject&&angular.isObject(a.watch)?this.registerWatchers(a):void 0},addFnsToScope:function(a){var b,c,d,e,f;b=a[a.constructor.prototype.__options._scopeName],e=a.constructor.prototype,f=[];for(d in e)c=e[d],angular.isFunction(c)&&"constructor"!==d&&"init"!==d&&"watch"!==d&&(a[d]=angular.bind(a,c),f.push("_"!==d[0]?b[d]=a[d]:void 0));return f},bindDependencies:function(a,b){var c,d,e,f,g,h,i,j,k,l;for(e=a.__classyControllerInjectObject,f=!!e,h=a.constructor.prototype.__options,k=a.constructor.$inject,l=[],c=i=0,j=k.length;j>i;c=++i)g=k[c],f&&(d=e[g])&&"."!==d?l.push(a[d]=b[c]):(a[g]=b[c],l.push(g===h._scopeName&&h._scopeShortcut?a[h._scopeShortcutName]=a[g]:void 0));return l},registerWatchers:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;if(b=a[a.constructor.prototype.__options._scopeName],!b)throw new Error("You need to inject `$scope` to use the watch object");f=a.constructor.prototype.__options._watchKeywords,i={normal:{keywords:[],fnCall:function(a,c,d){return b.$watch(c,angular.bind(a,d))}},objectEquality:{keywords:f.objectEquality,fnCall:function(a,c,d){return b.$watch(c,angular.bind(a,d),!0)}},collection:{keywords:f.collection,fnCall:function(a,c,d){return b.$watchCollection(c,angular.bind(a,d))}}},l=a.watch,n=[];for(c in l)if(d=l[c],angular.isString(d)&&(d=a[d]),angular.isString(c)&&angular.isFunction(d)){g=!1;for(h in i){if(g)break;for(m=i[h].keywords,j=0,k=m.length;k>j&&(e=m[j],!g);j++)-1!==c.indexOf(e)&&(i[h].fnCall(a,c.replace(e,""),d),g=!0)}n.push(g?void 0:i.normal.fnCall(a,c,d))}else n.push(void 0);return n},inject:function(a,b){var c,d,e,f;return angular.isObject(b[0])&&(a.prototype.__classyControllerInjectObject=c=b[0],b=function(){var a;a=[];for(f in c)d=c[f],a.push(f);return a}(),e=a.prototype.__options._scopeName,(null!=c?c[e]:void 0)&&"."!==c[e]&&(a.prototype.__options._scopeName=c[e])),a.$inject=b},registerSelector:function(a,b,c){var d,e,f,g,h,i;if(this.selectorControllerCount++,d="ClassySelector"+this.selectorControllerCount+"Controller",a.controller(d,c),angular.isElement(b))return void b.setAttribute("data-ng-controller",d);if(angular.isString(b))f=("function"==typeof window.jQuery?window.jQuery(b):void 0)||document.querySelectorAll(b);else{if(!angular.isArray(b))return;f=b}for(i=[],g=0,h=f.length;h>g;g++)e=f[g],i.push(angular.isElement(e)?e.setAttribute("data-ng-controller",d):void 0);return i},create:function(a,b,c){var d;return(b.el||b.selector)&&this.registerSelector(a,b.el||b.selector,c),angular.isString(b.name)&&a.controller(b.name,c),d=b.inject,angular.isArray(d)?this.inject(c,d):angular.isObject(d)?this.inject(c,[d]):void 0}}}).call(this);