UNPKG

modularity-framework

Version:

Lightweight component-oriented Web UI framework

6 lines 4.66 kB
/*! modularity-framework 0.33.0, copyright 2014 Kevin Goslar, see http://github.com/kevgo/modularity-framework */ /*! eventualize 0.0.5, copyright 2014 Kevin Goslar, see https://github.com/kevgo/eventualize */ (function(){var n;n=function(t){var e,r,i,o,a,c,l,s,u;for(u=n.categorize_members(t),o=u[0],r=u[1],a=0,l=o.length;l>a;a++)for(i=o[a],c=0,s=r.length;s>c;c++)e=r[c],n.is_callback_for(e,i)&&t[i].on(n.callback_event_name(e,i),t[e]);return void 0},n.categorize_members=function(t){var e,r,i;i=[],e=[];for(r in t)switch(typeof t[r]){case"object":i.push(r);break;case"function":n.is_callback_method(r)&&e.push(r)}return[i,e]},n.is_callback_method=function(t){return n.string_starts_with(t,"on_")},n.is_callback_for=function(t,e){return n.string_starts_with(t,"on_"+e+"_")},n.callback_event_name=function(n,t){return n.substring(t.length+4)},n.string_starts_with=function(n,t){return n.substring(0,t.length)===t},"undefined"!=typeof module&&null!==module&&(module.exports=n),"undefined"!=typeof window&&null!==window&&(window.eventualize=n)}).call(this); (function(){window.modularity={assert:function(e,t){return e&&0!==(null!=e?e.length:void 0)?!0:(console.error(t),!1)},on:function(e,t){return modularity.assert("string"==typeof e,"modularity.on: parameter 'event_type' is empty")?"function"!=typeof t?console.error("modularity.on: parameter 'callback' must be a function, "+t+" ("+typeof t+") given."):modularity.global_event_container().on(e,t):void 0},trigger:function(e,t){return modularity.assert(e,"Module.trigger: You must provide the event type to fire."),"string"!=typeof e?console.error("Module.trigger: Event type must be a string, "+e+" ("+typeof e+") given."):modularity.global_event_container().trigger(e,null!=t?t:t={})},global_event_container:function(){return modularity.global_event_container_cache||(modularity.global_event_container_cache=$("body"))}}}).call(this); (function(){var t=function(t,n){return function(){return t.apply(n,arguments)}},n=[].slice;window.modularity.Module=function(){function e(n){this.trigger=t(this.trigger,this),this.on=t(this.on,this);var e,r,i,o,s,u,l,c,a,h;if("string"==typeof n&&"testing"!==n&&(n=$(n)),this.container=n,null==this.container)return console.error("Error in Module constructor: No container given.");if("testing"!==n){if("string"!=typeof n.jquery)return console.error("Error in Module constructor: The given container must be a jQuery object.");if(!(null!=n&&n.length>0))return console.error("Error in Module constructor: The given container ('"+n.selector+"') is empty.");if(null==n||1!==n.length)return console.error("Error in Module constructor: The given container ('"+n.selector+"') has more than one element.")}if(null!=this.mixins)for(l=this.mixins,s=0,u=l.length;u>s;s++){i=l[s],c=i.mixin,o=function(t){return function(n,e){return t[n]?void 0:t[n]=function(){return e.apply(t,arguments)}}}(this);for(r in c)e=c[r],o(r,e);null!=(a=i.mixin)&&null!=(h=a.constructor)&&h.apply(this,arguments)}}return e.prototype.$=function(t,n){var e;return null==n&&(n={reportEmptyResults:!0}),e=this.container.find(t),0===e.length&&n.reportEmptyResults?console.error("@$: element not found: "+e.selector):e},e.prototype.on=function(t,n){return modularity.assert("string"==typeof t,"Module.bind_event: parameter 'event_type' is empty")?"function"!=typeof n?console.error("Module.bind_event: parameter 'callback' must be a function, "+n+" ("+typeof n+") given."):(this.container.bind(t,n),this):void 0},e.prototype.trigger=function(t,n){return modularity.assert(t,"Module.fire_event: You must provide the event type to fire."),"string"!=typeof t?console.error("Module.fire_event: Event type must be a string, "+t+" ("+typeof t+") given."):(this.container.trigger(t,null!=n?n:n={}),this)},e.prototype.hide=function(){return this.container.hide(),this.container.trigger("hide"),this},e.mixin=function(){var t,e,r;return t=arguments[0],e=2<=arguments.length?n.call(arguments,1):[],t||console.error("mixin not found"),(r=this.prototype).mixins||(r.mixins=[]),this.prototype.mixins.push({mixin:t,params:e})},e.prototype.show=function(){return this.container.show(),this.container.trigger("show"),this},e.prototype.visible=function(){return this.container.is(":visible")},e}()}).call(this); (function(){var t={}.hasOwnProperty,o=function(o,n){function r(){this.constructor=o}for(var i in n)t.call(n,i)&&(o[i]=n[i]);return r.prototype=n.prototype,o.prototype=new r,o.__super__=n.prototype,o};window.modularity.EventualizedModule=function(t){function n(){n.__super__.constructor.apply(this,arguments),this.init.apply(this,arguments),eventualize(this)}return o(n,t),n}(window.modularity.Module)}).call(this);