-
Notifications
You must be signed in to change notification settings - Fork 5
/
carpet.min.js
7 lines (6 loc) · 2.2 KB
/
carpet.min.js
1
2
3
4
5
6
7
/*!
* Carpet.js v3.1.3 (http://mateuszgachowski.github.io/Carpet.js/)
* Copyright 2014-2017 Mateusz Gachowski <mateusz.gachowski@gmail.com>
* Licensed under MIT
*/
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):a.Carpet=b()}(this,function(){"use strict";return new function(){var a,b,c;return a={},b={},c=Array.prototype.slice,{loggingEnabled:!1,log:function(){this.debug.apply(this,["log"].concat(c.call(arguments)))},warn:function(){this.debug.apply(this,["warn"].concat(c.call(arguments)))},error:function(){this.debug.apply(this,["error"].concat(c.call(arguments)))},info:function(){this.debug.apply(this,["info"].concat(c.call(arguments)))},clearConsole:function(){this.debug.apply(this,["clear"])},debug:function(a){var b;this.loggingEnabled&&window.console&&window.console[a]&&window.console[a].apply&&(b=c.call(arguments,1),window.console[a].apply(window.console,["Carpet:{0}".replace("{0}",a),b]))},module:function(b,c){if(a[b])return void this.warn("Module: {0} already exists. Name collision".replace("{0}",b));a[b]={moduleBody:c,name:b,settings:{},methods:{},component:this.getComponent},this.info("Module: {0} has been loaded to memory".replace("{0}",b))},registerComponent:function(a,c){b[a]&&this.warn("Component: {0} already exists. Name collision".replace("{0}",a)),b[a]={name:a,componentBody:c,initialized:!1},this.info("Component: {0} has been loaded to memory".replace("{0}",a))},getModule:function(b){if(a[b])return a[b];this.warn("Module: {0} has not been found in memory".replace("{0}",b))},getComponent:function(a){var c;if(c=b[a])return c.initialized||(c.initialized=!0,c.instance=c.componentBody.call(c)),c.instance;this.warn("Component: {0} has not been found in memory".replace("{0}",a))},init:function(){var b,c,d,e,f=document.querySelectorAll("[data-module]"),g=this;b=function(b){e=a[b],e?(e.settings=d,e.moduleBody.call(e,e.methods,e.settings,c),"function"==typeof e.methods.init&&(g.info("Module: {0} has been autoinited".replace("{0}",e.name)),e.methods.init())):g.warn("Module: {0} has not been found".replace("{0}",b))};for(var h=0;h<f.length;h++){var i;c=f[h],i=c.getAttribute("data-module").split(" "),d=new Function("return "+c.getAttribute("data-settings"))()||{},i.forEach(b)}}}}});