-
Notifications
You must be signed in to change notification settings - Fork 27
/
angular-classy.min.js
2 lines (2 loc) · 6.47 KB
/
angular-classy.min.js
1
2
!function(){var n="1.2.3",t={},o={},a=function(n,a){var r=function(n){if(o[n])for(var s=angular.module(n),e=0;e<s.requires.length;e++){var c=s.requires[e],l=t[c];l&&(i[c]=l,l.name||(l.name=c.replace("classy.","")),a.__classyDefaults||(a.__classyDefaults={}),a.__classyDefaults[l.name]=angular.copy(l.options||{})),r(c)}},i={};return o[n]=!0,r(n),i},r=function(n,t,o){for(var a=t[2].classy.activePlugins,r=t[0].__options||t[0].prototype.__options,i=Object.keys(a),s=0;s<i.length;s++){var e=a[i[s]];e.options=r[e.name]||{},e.classyOptions=r,o&&angular.isFunction(o.before)&&o.before(e);var c;e&&n&&angular.isFunction(e[n])&&(c=e[n].apply(e,t)),o&&angular.isFunction(o.after)&&o.after(e,c)}},i=function(n){var t,o,a,r,s;for(r=0,s=arguments.length;s>r;r++)if(o=arguments[r],o!==n)for(t in o)a=o[t],n[t]&&n[t].constructor&&n[t].constructor===Object?i(n[t],a):n[t]=angular.copy(a);return n},s=angular.module;angular.module=function(o,r,i){var c=s(o,r,i);if(r){"classy.core"===o&&(t[o]={});var l=a(o,c);l["classy.core"]&&(c.classy={version:n,plugin:{controller:function(n){t[o]=n}},options:{controller:{}},activePlugins:l,controller:function(n){function t(){e.init(this,arguments,c)}return e.preInit(t,n,c),t},controllers:function(n){for(var t=0;t<n.length;t++)this.controller(n[t]);return c}},c.cC=c.classy.controller,c.cCs=c.classy.controllers)}return c};var e={localInject:["$q"],preInit:function(n,t,o){this.buildConstructor(n,t),this.buildOptions(n,t,o),r("preInitBefore",[n,t,o]),r("preInit",[n,t,o]),r("preInitAfter",[n,t,o])},buildConstructor:function(n,t){for(var o=Object.keys(t),a=0;a<o.length;a++){var r=o[a];t.hasOwnProperty(r)&&(n.prototype[r]=t[r])}},buildOptions:function(n,t,o){for(var a,r,s=i({},o.__classyDefaults,o.classy.options.controller,t.__options),e={},c=Object.keys(s),l=0;l<c.length;l++)r=c[l],a=s[c[l]],angular.isObject(a)||(e[r]=a);if(Object.keys(e).length)for(var u=0;u<c.length;u++)r=c[u],a=s[c[u]],angular.isObject(a)&&angular.extend(a,e);n.prototype.__options=s},init:function(n,t,o){for(var a=0,i={},s=0;s<n.constructor.__classDepNames.length;s++){var e=n.constructor.__classDepNames[s];i[e]=t[a],a++}r(null,[n,i,o],{before:function(n){if(angular.isArray(n.localInject))for(var o=0;o<n.localInject.length;o++){var r=n.localInject[o];n[r]=t[a],a++}}}),r("initBefore",[n,i,o]);var c=[];r("init",[n,i,o],{after:function(n,t){t&&t.then&&c.push(t)}});var l=function(){angular.isFunction(n.init)&&n.init(),r("initAfter",[n,i,o]),this.postInit(n,i,o)},u=angular.bind(this,l);c.length?t[a].all(c).then(u):u()},postInit:function(n,t,o){r("postInitBefore",[n,t,o]),r("postInit",[n,t,o]),r("postInitAfter",[n,t,o])}};angular.module("classy.core",[]),angular.module("classy.bindData",["classy.core"]).classy.plugin.controller({localInject:["$parse"],options:{enabled:!0,addToScope:!0,addToClass:!0,privatePrefix:"_",keyName:"data"},hasPrivatePrefix:function(n){var t=this.options.privatePrefix;return t?n.slice(0,t.length)===t:!1},init:function(n,t){var o=n.constructor.prototype[this.options.keyName];if(this.options.enabled&&o){var a=angular.copy(o);if(angular.isFunction(a))a=a.call(n);else if(angular.isObject(a))for(var r in a){var i=a[r];if(angular.isString(i)){var s=this.$parse(i);a[r]=s(n)}else a[r]=i}for(var e in a){var c=a[e];this.options.addToClass&&(n[e]=c),this.options.addToScope&&!this.hasPrivatePrefix(e)&&t.$scope&&(t.$scope[e]=c)}}}}),angular.module("classy.bindDependencies",["classy.core"]).classy.plugin.controller({options:{enabled:!0,scopeShortcut:"$"},preInit:function(n,t,o){var a=t.inject||[];angular.isArray(a)&&this.inject(n,a,o)},inject:function(n,t,o){var a=[];for(var r in o.classy.activePlugins){var i=o.classy.activePlugins[r];angular.isArray(i.localInject)&&(a=a.concat(i.localInject))}a=a.concat(e.localInject),n.__classDepNames=angular.copy(t),n.$inject=t.concat(a)},initBefore:function(n,t){if(this.options.enabled)for(var o=n.constructor.$inject,a=0;a<o.length;++a){var r=o[a];n[r]=t[r],"$scope"===r&&this.options.scopeShortcut&&(n[this.options.scopeShortcut]=n[r])}}}),angular.module("classy.bindMethods",["classy.core"]).classy.plugin.controller({localInject:["$parse"],options:{enabled:!0,addToScope:!0,addToClass:!0,privatePrefix:"_",ignore:["constructor","init"],keyName:"methods"},hasPrivatePrefix:function(n){var t;return t=this.options.privatePrefix,t?n.slice(0,t.length)===t:!1},init:function(n,t){var o=[].indexOf||function(n){for(var t=0,o=this.length;o>t;t++)if(t in this&&this[t]===n)return t;return-1};if(this.options.enabled){var a=n.constructor.prototype[this.options.keyName];for(var r in a){var i,s=a[r];if(!angular.isFunction(s)||o.call(this.options.ignore,r)>=0){if(angular.isString(s)){var e=this.$parse(s);i=function(){return e(n)}}}else i=angular.bind(n,s);angular.isFunction(i)&&(this.options.addToClass&&(n[r]=i),this.options.addToScope&&!this.hasPrivatePrefix(r)&&t.$scope&&(t.$scope[r]=i))}}}}),angular.module("classy.register",["classy.core"]).classy.plugin.controller({options:{enabled:!0,key:"name"},preInit:function(n,t,o){this.options.enabled&&angular.isString(t[this.options.key])&&o.controller(t[this.options.key],n)}}),angular.module("classy.watch",["classy.core"]).classy.plugin.controller({localInject:["$parse"],options:{enabled:!0,bindWatchToClass:!1,_watchKeywords:{normal:[],objectEquality:["{object}","{deep}"],collection:["{collection}","{shallow}"]}},isActive:function(n,t){if(this.options.enabled&&angular.isObject(n.watch)){if(!t.$scope)throw new Error("You need to inject `$scope` to use the watch object");return!0}},watchFns:{normal:function(n,t,o,a){return a.$scope.$watch(t,angular.bind(n,o))},objectEquality:function(n,t,o,a){return a.$scope.$watch(t,angular.bind(n,o),!0)},collection:function(n,t,o,a){return a.$scope.$watchCollection(t,angular.bind(n,o))}},convertToFunctionExpression:function(n,t){var o=this.$parse;return function(){return o(n)(t)}},postInit:function(n,t){if(this.isActive(n,t)){var o=this.options._watchKeywords;for(var a in n.watch){var r=n.watch[a];if(angular.isString(r)&&(r=n[r]),angular.isString(a)&&angular.isFunction(r)){var i=!1;for(var s in this.watchFns){var e=this.watchFns[s];if(i)break;for(var c=o[s],l=0;l<c.length;l++){var u=c[l];if(-1!==a.indexOf(u)){var p=a.replace(u,""),f=this.options.bindWatchToClass?this.convertToFunctionExpression(p,n):p;e(n,f,r,t),i=!0;break}}}if(!i){var f=this.options.bindWatchToClass?this.convertToFunctionExpression(a,n):a;this.watchFns.normal(n,f,r,t)}}}}}}),angular.module("classy",["classy.bindData","classy.bindDependencies","classy.bindMethods","classy.core","classy.register","classy.watch"])}();
//# sourceMappingURL=angular-classy.min.js.map