-
Notifications
You must be signed in to change notification settings - Fork 1
/
puremvc.min.js
1 lines (1 loc) · 13.1 KB
/
puremvc.min.js
1
var org={puremvc:{js:{core:{},patterns:{}}}},Relegate={};Object.extend=function(a,b){var c=function(){};c.prototype=b.prototype;a.superClass=b.prototype;a.prototype=new c;a.prototype.constructor=a};Object.declare=function(a,b,c){var d=a.split("."),e,f,g;c=c||window;b=b||{};f=c;while((e=d.shift())!==undefined){g=d.length>0?typeof f[e]!=="undefined"?f[e]:{}:b;f[e]=g;f=f[e]}return f};Relegate.create=function(a,b){var c=[],d,e;for(d=2,e=arguments.length;d<e;d+=1){c.push(arguments[d])}return function(){var d=[],e,f;for(e=0,f=arguments.length;e<f;e+=1){d.push(arguments[e])}return b.apply(a,d.concat(c))}};Date.fromISO8601=function(a){var b=/(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/,c=new Date,d,e;if(!a.toString().match(new RegExp(b))){c.setTime(Date.parse(a));return c}e=a.match(new RegExp(b));d=0;c.setUTCDate(1);c.setUTCFullYear(parseInt(e[1],10));c.setUTCMonth(parseInt(e[3],10)-1);c.setUTCDate(parseInt(e[5],10));c.setUTCHours(parseInt(e[7],10));c.setUTCMinutes(parseInt(e[9],10));c.setUTCSeconds(parseInt(e[11],10));c.setUTCMilliseconds(e[12]?parseFloat(e[12])*1e3:0);if(e[13]!="Z"){d=e[15]*60+parseInt(e[17],10);d*=e[14]=="-"?-1:1;c.setTime(c.getTime()-d*60*1e3)}return c};Object.declare("org.puremvc.js.Init",function(a,b){var c=b.substr(b.length-1),d='<script type="text/javascript" src="',e='"></script>',f=c==="/"||c==="\\"?b:b+"/",g=["org/puremvc/js/patterns/observer/Notifier.js","org/puremvc/js/patterns/observer/Notification.js","org/puremvc/js/patterns/observer/Observer.js","org/puremvc/js/patterns/command/SimpleCommand.js","org/puremvc/js/patterns/command/MacroCommand.js","org/puremvc/js/patterns/mediator/Mediator.js","org/puremvc/js/patterns/proxy/Proxy.js","org/puremvc/js/patterns/facade/Facade.js","org/puremvc/js/core/Model.js","org/puremvc/js/core/View.js","org/puremvc/js/core/Controller.js"],h=g.length,i;for(i=0;i<h;i=i+1){a.write(d+f+g[i]+e)}});Object.declare("org.puremvc.js.patterns.observer.Notifier");org.puremvc.js.patterns.observer.Notifier=function(){this._initializeFacade()};var _p=org.puremvc.js.patterns.observer.Notifier.prototype;_p._facade=null;_p._initializeFacade=function(){this._facade=org.puremvc.js.patterns.facade.Facade.getInstance()};_p.getFacade=function(){return this._facade};_p.sendNotification=function(a,b,c){this._facade.sendNotification(a,b,c)};Object.declare("org.puremvc.js.patterns.observer.Notification");org.puremvc.js.patterns.observer.Notification=function(a,b,c){this._name=a;this._body=b;this._type=c};var _p=org.puremvc.js.patterns.observer.Notification.prototype;_p._name="";_p._type="";_p._body=null;_p.getName=function(){return this._name};_p.setBody=function(a){this._body=a};_p.getBody=function(){return this._body};_p.setType=function(a){this._type=a};_p.getType=function(){return this._type};_p.toString=function(){var a="Notification Name: "+this.getName();a+="\r\nBody:"+(this._body===null?"null":this._body.toString());a+="\r\nType:"+(this._type===null?"null":this._type);return a};Object.declare("org.puremvc.js.patterns.observer.Observer");org.puremvc.js.patterns.observer.Observer=function(a,b){this.setNotifyMethod(a);this.setNotifyContext(b)};var _p=org.puremvc.js.patterns.observer.Observer.prototype;_p._notify=null;_p._context=null;_p.setNotifyMethod=function(a){this._notify=a};_p.getNotifyMethod=function(){return this._notify};_p.setNotifyContext=function(a){this._context=a};_p.getNotifyContext=function(){return this._context};_p.notifyObserver=function(a){this.getNotifyMethod().apply(this.getNotifyContext(),[a])};_p.compareNotifyContext=function(a){return this._context===a};Object.declare("org.puremvc.js.patterns.command.SimpleCommand");org.puremvc.js.patterns.command.SimpleCommand=function(){org.puremvc.js.patterns.observer.Notifier.call(this)};Object.extend(org.puremvc.js.patterns.command.SimpleCommand,org.puremvc.js.patterns.observer.Notifier);var _p=org.puremvc.js.patterns.command.SimpleCommand.prototype;_p.execute=function(a){throw new Error("execute() method must be overwritten by command implementation")};Object.declare("org.puremvc.js.patterns.command.MacroCommand");org.puremvc.js.patterns.command.MacroCommand=function(){org.puremvc.js.patterns.observer.Notifier.call(this);this._subCommands=new Array;this._initializeMacroCommand()};Object.extend(org.puremvc.js.patterns.command.MacroCommand,org.puremvc.js.patterns.observer.Notifier);var _p=org.puremvc.js.patterns.command.MacroCommand.prototype;_p._subCommands=null;_p._initializeMacroCommand=function(){};_p.addSubCommand=function(a){this._subCommands.push(a)};_p.execute=function(a){var b,c=[],d,e;for(d=0,e=this._subCommands.length;d<e;d+=1){b=this._subCommands[d];c.push(new b)}for(d=0,e=c.length;d<e;d+=1){c[d].execute(a)}};Object.declare("org.puremvc.js.patterns.mediator.Mediator");org.puremvc.js.patterns.mediator.Mediator=function(a,b){org.puremvc.js.patterns.observer.Notifier.call(this);this._mediatorName=a||org.puremvc.js.patterns.mediator.Mediator.NAME;this._view=b};Object.extend(org.puremvc.js.patterns.mediator.Mediator,org.puremvc.js.patterns.observer.Notifier);org.puremvc.js.patterns.mediator.Mediator.NAME="Mediator";var _p=org.puremvc.js.patterns.mediator.Mediator.prototype;_p._mediatorName="";_p._view=null;_p.getMediatorName=function(){return this._mediatorName};_p.setViewComponent=function(a){this._view=a};_p.getViewComponent=function(){return this._view};_p.listNotificationInterests=function(){return[]};_p.handleNotification=function(a){throw new Error("handleNotification() should be extended on concrete implementations of Mediator")};_p.onRegisterInitialize=function(){};_p.onRegister=function(){};_p.onRemove=function(){};Object.declare("org.puremvc.js.patterns.proxy.Proxy");org.puremvc.js.patterns.proxy.Proxy=function(a,b){org.puremvc.js.patterns.observer.Notifier.call(this);this._proxyName=a||org.puremvc.js.patterns.proxy.Proxy.NAME;if(b!==undefined){this.setData(b)}};Object.extend(org.puremvc.js.patterns.proxy.Proxy,org.puremvc.js.patterns.observer.Notifier);org.puremvc.js.patterns.proxy.Proxy.NAME="Proxy";var _p=org.puremvc.js.patterns.proxy.Proxy.prototype;_p._proxyName="";_p._data=null;_p.getProxyName=function(){return this._proxyName};_p.setData=function(a){this._data=a};_p.getData=function(){return this._data};_p.onRegister=function(){};_p.onRemove=function(){};Object.declare("org.puremvc.js.patterns.facade.Facade");org.puremvc.js.patterns.facade.Facade=function(){if(org.puremvc.js.patterns.facade.Facade.instance!==null){throw new Error(org.puremvc.js.patterns.facade.Facade.SINGLETON_MESSAGE)}org.puremvc.js.patterns.facade.Facade.instance=this;this._initializeFacade()};org.puremvc.js.patterns.facade.Facade.instance=null;org.puremvc.js.patterns.facade.Facade.SINGLETON_MESSAGE="Facade Singleton already constructed!";org.puremvc.js.patterns.facade.Facade.getInstance=function(){if(org.puremvc.js.patterns.facade.Facade.instance===null){org.puremvc.js.patterns.facade.Facade.instance=new org.puremvc.js.patterns.facade.Facade}return org.puremvc.js.patterns.facade.Facade.instance};var _p=org.puremvc.js.patterns.facade.Facade.prototype;_p._controller=null;_p._model=null;_p._view=null;_p._initializeFacade=function(){this._initializeModel();this._initializeController();this._initializeView()};_p._initializeController=function(){if(this._controller===null){this._controller=org.puremvc.js.core.Controller.getInstance()}};_p._initializeModel=function(){if(this._model===null){this._model=org.puremvc.js.core.Model.getInstance()}};_p.getModel=function(){return this._model};_p._initializeView=function(){if(this._view===null){this._view=org.puremvc.js.core.View.getInstance()}};_p.getView=function(){return this._view};_p.registerCommand=function(a,b){this._controller.registerCommand(a,b)};_p.removeCommand=function(a){this._controller.removeCommand(a)};_p.hasCommand=function(a){return this._controller.hasCommand(a)};_p.registerProxy=function(a){this._initializeModel();this._model.registerProxy(a)};_p.retrieveProxy=function(a){this._initializeModel();return this._model.retrieveProxy(a)};_p.removeProxy=function(a){var b=null;if(this._model!==null){b=this._model.removeProxy(a)}return b};_p.hasProxy=function(a){this._initializeModel();return this._model.hasProxy(a)};_p.registerMediator=function(a){this._initializeView();this._view.registerMediator(a)};_p.retrieveMediator=function(a){this._initializeView();return this._view.retrieveMediator(a)};_p.removeMediator=function(a){var b=null;if(this._view!==null){b=this._view.removeMediator(a)}return b};_p.hasMediator=function(a){this._initializeView();return this._view.hasMediator(a)};_p.sendNotification=function(a,b,c){var d;if(this._view!==null){d=new org.puremvc.js.patterns.observer.Notification(a,b,c);this._view.notifyObservers(d)}};Object.declare("org.puremvc.js.core.Model");org.puremvc.js.core.Model=function(){if(org.puremvc.js.core.Model.instance!==null){throw new Error(org.puremvc.js.core.Model.SINGLETON_MESSAGE)}org.puremvc.js.core.Model.instance=this;this._proxyMap={};this._initializeModel()};org.puremvc.js.core.Model.instance=null;org.puremvc.js.core.Model.SINGLETON_MESSAGE="Model Singleton already constructed!";org.puremvc.js.core.Model.getInstance=function(){if(org.puremvc.js.core.Model.instance===null){org.puremvc.js.core.Model.instance=new org.puremvc.js.core.Model}return org.puremvc.js.core.Model.instance};var _p=org.puremvc.js.core.Model.prototype;_p._proxyMap=null;_p._initializeModel=function(){};_p.registerProxy=function(a){this._proxyMap[a.getProxyName()]=a;if(typeof a.onRegister==="function"){a.onRegister()}};_p.retrieveProxy=function(a){return this._proxyMap[a]};_p.hasProxy=function(a){return typeof this._proxyMap[a]!=="undefined"};_p.removeProxy=function(a){var b=null;if(this.hasProxy(a)){b=this.retrieveProxy(a);this._proxyMap[a]=null;delete this._proxyMap[a];if(typeof b.onRemove==="function"){b.onRemove()}}return b};Object.declare("org.puremvc.js.core.View");org.puremvc.js.core.View=function(){if(org.puremvc.js.core.View.instance!==null){throw new Error(org.puremvc.js.core.View.SINGLETON_MESSAGE)}org.puremvc.js.core.View.instance=this;this._mediatorMap={};this._observerMap={};this._initializeView()};org.puremvc.js.core.View.instance=null;org.puremvc.js.core.View.SINGLETON_MESSAGE="View Singleton already constructed!";org.puremvc.js.core.View.getInstance=function(){if(org.puremvc.js.core.View.instance===null){org.puremvc.js.core.View.instance=new org.puremvc.js.core.View}return org.puremvc.js.core.View.instance};var _p=org.puremvc.js.core.View.prototype;_p._mediatorMap=null;_p._observerMap=null;_p._initializeView=function(){};_p.registerObserver=function(a,b){if(typeof this._observerMap[a]==="undefined"){this._observerMap[a]=new Array}this._observerMap[a].push(b)};_p.notifyObservers=function(a){var b=a.getName(),c=null,d=[],e,f;if(typeof this._observerMap[b]!=="undefined"){c=this._observerMap[b];for(e=0,f=c.length;e<f;e+=1){d.push(c[e])}for(e=0,f=d.length;e<f;e+=1){d[e].notifyObserver(a)}}};_p.removeObserver=function(a,b){var c,d,e;if(typeof this._observerMap[a]!=="undefined"){c=this._observerMap[a];for(d=0,e=c.length;d<e;d+=1){if(c[d].compareNotifyContext(b)===true){c.splice(d,1);break}}if(c.length===0){this._observerMap[a]=null;delete this._observerMap[a]}}};_p.registerMediator=function(a){var b=a.getMediatorName(),c,d,e,f;if(this.hasMediator(b)){return}this._mediatorMap[b]=a;a.onRegisterInitialize();c=a.listNotificationInterests();if(typeof c==="object"&&typeof c.length==="number"&&c.length>0){f=c.length;d=new org.puremvc.js.patterns.observer.Observer(a.handleNotification,a);for(e=0;e<f;e+=1){this.registerObserver(c[e],d)}}a.onRegister()};_p.retrieveMediator=function(a){if(this.hasMediator(a)){return this._mediatorMap[a]}return null};_p.removeMediator=function(a){var b,c,d,e;if(this.hasMediator(a)){b=this._mediatorMap[a];c=b.listNotificationInterests();e=c.length;for(d=0;d<e;d+=1){this.removeObserver(c[d],b)}this._mediatorMap[a]=null;delete this._mediatorMap[a];b.onRemove()}return b};_p.hasMediator=function(a){return typeof this._mediatorMap[a]!=="undefined"};Object.declare("org.puremvc.js.core.Controller");org.puremvc.js.core.Controller=function(){if(org.puremvc.js.core.Controller.instance!==null){throw new Error(org.puremvc.js.core.Controller.SINGLETON_MESSAGE)}org.puremvc.js.core.Controller.instance=this;this._commandMap={};this._initializeController()};org.puremvc.js.core.Controller.instance=null;org.puremvc.js.core.Controller.SINGLETON_MESSAGE="Controller Singleton already constructed!";org.puremvc.js.core.Controller.getInstance=function(){if(org.puremvc.js.core.Controller.instance===null){org.puremvc.js.core.Controller.instance=new org.puremvc.js.core.Controller}return org.puremvc.js.core.Controller.instance};var _p=org.puremvc.js.core.Controller.prototype;_p._commandMap=null;_p._view=null;_p._initializeController=function(){this._view=org.puremvc.js.core.View.getInstance()};_p.executeCommand=function(a){var b=a.getName(),c,d;if(!this.hasCommand(b)){return}c=this._commandMap[b],d=new c;d.execute(a)};_p.registerCommand=function(a,b){if(!this.hasCommand(a)){this._view.registerObserver(a,new org.puremvc.js.patterns.observer.Observer(this.executeCommand,this))}this._commandMap[a]=b};_p.hasCommand=function(a){return typeof this._commandMap[a]!=="undefined"};_p.removeCommand=function(a){if(this.hasCommand(a)){this._view.removeObserver(a,this);this._commandMap[a]=null;delete this._commandMap[a]}}