Click here to Skip to main content
15,895,557 members
Articles / Web Development / ASP.NET

Monorail Hands-On

Rate me:
Please Sign up or sign in to vote.
4.78/5 (15 votes)
19 Feb 2008CPOL9 min read 71.3K   1.1K   40  
In this article, I will present a sample application using the Monorail framework and provide the basic concepts of the design pattern known as MVC.
/*
 * Ext JS Library 1.0.1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */

Ext.Animator=function(){this.actors=[];this.playlist=new Ext.Animator.AnimSequence();this.captureDelegate=this.capture.createDelegate(this);this.playDelegate=this.play.createDelegate(this);this.syncing=false;this.stopping=false;this.playing=false;for(var i=0;i<arguments.length;i++){this.addActor(arguments[i]);}};Ext.Animator.prototype={capture:function(_2,_3){if(this.syncing){if(!this.syncMap[_2.id]){this.syncMap[_2.id]=new Ext.Animator.AnimSequence();}this.syncMap[_2.id].add(_3);}else{this.playlist.add(_3);}},addActor:function(_4){_4.onCapture.addListener(this.captureDelegate);this.actors.push(_4);},startCapture:function(_5){for(var i=0;i<this.actors.length;i++){var a=this.actors[i];if(!this.isCapturing(a)){a.onCapture.addListener(this.captureDelegate);}a.capturing=true;}if(_5){this.playlist=new Ext.Animator.AnimSequence();}},isCapturing:function(_8){return _8.onCapture.isListening(this.captureDelegate);},stopCapture:function(){for(var i=0;i<this.actors.length;i++){var a=this.actors[i];a.onCapture.removeListener(this.captureDelegate);a.capturing=false;}},beginSync:function(){this.syncing=true;this.syncMap={};},endSync:function(){this.syncing=false;var _b=new Ext.Animator.CompositeSequence();for(key in this.syncMap){if(typeof this.syncMap[key]!="function"){_b.add(this.syncMap[key]);}}this.playlist.add(_b);this.syncMap=null;},play:function(_c){if(this.playing){return;}this.stopCapture();this.playlist.play(_c);},stop:function(){this.playlist.stop();},isPlaying:function(){return this.playlist.isPlaying();},clear:function(){this.playlist=new Ext.Animator.AnimSequence();},addCall:function(_d,_e,_f){this.playlist.add(new Ext.Actor.Action(_f,_d,_e||[]));},addAsyncCall:function(fcn,_11,_12,_13){this.playlist.add(new Ext.Actor.AsyncAction(_13,fcn,_12||[],_11));},pause:function(_14){this.playlist.add(new Ext.Actor.PauseAction(_14));}};Ext.Animator.select=function(_15){var els;if(typeof _15=="string"){els=Ext.Element.selectorFunction(_15);}else{if(_15 instanceof Array){els=_15;}else{throw "Invalid selector";}}return new Ext.AnimatorComposite(els);};Ext.actors=Ext.Animator.select;Ext.AnimatorComposite=function(els){this.animator=new Ext.Animator();this.addElements(els);this.syncAnims=true;};Ext.AnimatorComposite.prototype={isComposite:true,addElements:function(els){if(!els){return this;}var _19=this.animator;for(var i=0,len=els.length;i<len;i++){_19.addActor(new Ext.Actor(els[i]));}_19.startCapture();return this;},sequence:function(){this.syncAnims=false;return this;},sync:function(){this.syncAnims=true;return this;},invoke:function(fn,_1d){var els=this.animator.actors;if(this.syncAnims){this.animator.beginSync();}for(var i=0,len=els.length;i<len;i++){Ext.Actor.prototype[fn].apply(els[i],_1d);}if(this.syncAnims){this.animator.endSync();}return this;},play:function(_21){this.animator.play(_21);return this;},reset:function(_22){this.animator.startCapture(true);return this;},pause:function(_23){this.animator.pause(_23);return this;},getAnimator:function(){return this.animator;},each:function(fn,_25){var els=this.animator.actors;if(this.syncAnims){this.animator.beginSync();}for(var i=0,len=els.length;i<len;i++){fn.call(_25||els[i],els[i],this,i);}if(this.syncAnims){this.animator.endSync();}return this;},addCall:function(fcn,_2a,_2b){this.animator.addCall(fcn,_2a,_2b);return this;},addAsyncCall:function(fcn,_2d,_2e,_2f){this.animator.addAsyncCall(fcn,_2d,_2e,_2f);return this;}};for(var fnName in Ext.Actor.prototype){if(typeof Ext.Actor.prototype[fnName]=="function"){Ext.CompositeElement.createCall(Ext.AnimatorComposite.prototype,fnName);}}Ext.Animator.AnimSequence=function(){this.actions=[];this.nextDelegate=this.next.createDelegate(this);this.playDelegate=this.play.createDelegate(this);this.oncomplete=null;this.playing=false;this.stopping=false;this.actionIndex=-1;};Ext.Animator.AnimSequence.prototype={add:function(_30){this.actions.push(_30);},next:function(){if(this.stopping){this.playing=false;if(this.oncomplete){this.oncomplete(this,false);}return;}var _31=this.actions[++this.actionIndex];if(_31){_31.play(this.nextDelegate);}else{this.playing=false;if(this.oncomplete){this.oncomplete(this,true);}}},play:function(_32){if(this.playing){return;}this.oncomplete=_32;this.stopping=false;this.playing=true;this.actionIndex=-1;this.next();},stop:function(){this.stopping=true;},isPlaying:function(){return this.playing;},clear:function(){this.actions=[];},addCall:function(fcn,_34,_35){this.actions.push(new Ext.Actor.Action(_35,fcn,_34||[]));},addAsyncCall:function(fcn,_37,_38,_39){this.actions.push(new Ext.Actor.AsyncAction(_39,fcn,_38||[],_37));},pause:function(_3a){this.actions.push(new Ext.Actor.PauseAction(_3a));}};Ext.Animator.CompositeSequence=function(){this.sequences=[];this.completed=0;this.trackDelegate=this.trackCompletion.createDelegate(this);};Ext.Animator.CompositeSequence.prototype={add:function(_3b){this.sequences.push(_3b);},play:function(_3c){this.completed=0;if(this.sequences.length<1){if(_3c){_3c();}return;}this.onComplete=_3c;for(var i=0;i<this.sequences.length;i++){this.sequences[i].play(this.trackDelegate);}},trackCompletion:function(){++this.completed;if(this.completed>=this.sequences.length&&this.onComplete){this.onComplete();}},stop:function(){for(var i=0;i<this.sequences.length;i++){this.sequences[i].stop();}},isPlaying:function(){for(var i=0;i<this.sequences.length;i++){if(this.sequences[i].isPlaying()){return true;}}return false;}};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer Alura Cursos Online
Brazil Brazil

Comments and Discussions