Click here to Skip to main content
15,886,788 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.2K   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.ContentPanel=function(el,_2,_3){Ext.ContentPanel.superclass.constructor.call(this);if(el.autoCreate){_2=el;el=Ext.id();}this.el=Ext.get(el);if(!this.el&&_2&&_2.autoCreate){if(typeof _2.autoCreate=="object"){if(!_2.autoCreate.id){_2.autoCreate.id=_2.id||el;}this.el=Ext.DomHelper.append(document.body,_2.autoCreate,true);}else{this.el=Ext.DomHelper.append(document.body,{tag:"div",cls:"x-layout-inactive-content",id:_2.id||el},true);}}this.closable=false;this.loaded=false;this.active=false;if(typeof _2=="string"){this.title=_2;}else{Ext.apply(this,_2);}if(this.resizeEl){this.resizeEl=Ext.get(this.resizeEl,true);}else{this.resizeEl=this.el;}this.addEvents({"activate":true,"deactivate":true,"resize":true});if(this.autoScroll){this.resizeEl.setStyle("overflow","auto");}_3=_3||this.content;if(_3){this.setContent(_3);}if(_2&&_2.url){this.setUrl(this.url,this.params,this.loadOnce);}};Ext.extend(Ext.ContentPanel,Ext.util.Observable,{tabTip:"",setRegion:function(_4){this.region=_4;if(_4){this.el.replaceClass("x-layout-inactive-content","x-layout-active-content");}else{this.el.replaceClass("x-layout-active-content","x-layout-inactive-content");}},getToolbar:function(){return this.toolbar;},setActiveState:function(_5){this.active=_5;if(!_5){this.fireEvent("deactivate",this);}else{this.fireEvent("activate",this);}},setContent:function(_6,_7){this.el.update(_6,_7);},ignoreResize:function(w,h){if(this.lastSize&&this.lastSize.width==w&&this.lastSize.height==h){return true;}else{this.lastSize={width:w,height:h};return false;}},getUpdateManager:function(){return this.el.getUpdateManager();},load:function(){var um=this.el.getUpdateManager();um.update.apply(um,arguments);return this;},setUrl:function(_b,_c,_d){if(this.refreshDelegate){this.removeListener("activate",this.refreshDelegate);}this.refreshDelegate=this._handleRefresh.createDelegate(this,[_b,_c,_d]);this.on("activate",this._handleRefresh.createDelegate(this,[_b,_c,_d]));return this.el.getUpdateManager();},_handleRefresh:function(_e,_f,_10){if(!_10||!this.loaded){var _11=this.el.getUpdateManager();_11.update(_e,_f,this._setLoaded.createDelegate(this));}},_setLoaded:function(){this.loaded=true;},getId:function(){return this.el.id;},getEl:function(){return this.el;},adjustForComponents:function(_12,_13){if(this.resizeEl!=this.el){_12-=this.el.getFrameWidth("lr");_13-=this.el.getFrameWidth("tb");}if(this.toolbar){var te=this.toolbar.getEl();_13-=te.getHeight();te.setWidth(_12);}if(this.adjustments){_12+=this.adjustments[0];_13+=this.adjustments[1];}return {"width":_12,"height":_13};},setSize:function(_15,_16){if(this.fitToFrame&&!this.ignoreResize(_15,_16)){if(this.fitContainer&&this.resizeEl!=this.el){this.el.setSize(_15,_16);}var _17=this.adjustForComponents(_15,_16);this.resizeEl.setSize(this.autoWidth?"auto":_17.width,this.autoHeight?"auto":_17.height);this.fireEvent("resize",this,_17.width,_17.height);}},getTitle:function(){return this.title;},setTitle:function(_18){this.title=_18;if(this.region){this.region.updatePanelTitle(this,_18);}},isClosable:function(){return this.closable;},beforeSlide:function(){this.el.clip();this.resizeEl.clip();},afterSlide:function(){this.el.unclip();this.resizeEl.unclip();},refresh:function(){if(this.refreshDelegate){this.loaded=false;this.refreshDelegate();}},destroy:function(){this.el.removeAllListeners();var _19=document.createElement("span");_19.appendChild(this.el.dom);_19.innerHTML="";this.el.remove();this.el=null;}});Ext.GridPanel=function(_1a,_1b){this.wrapper=Ext.DomHelper.append(document.body,{tag:"div",cls:"x-layout-grid-wrapper x-layout-inactive-content"},true);this.wrapper.dom.appendChild(_1a.container.dom);Ext.GridPanel.superclass.constructor.call(this,this.wrapper,_1b);if(this.toolbar){this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);}_1a.monitorWindowResize=false;_1a.autoHeight=false;_1a.autoWidth=false;this.grid=_1a;this.grid.container.replaceClass("x-layout-inactive-content","x-layout-component-panel");};Ext.extend(Ext.GridPanel,Ext.ContentPanel,{getId:function(){return this.grid.id;},getGrid:function(){return this.grid;},setSize:function(_1c,_1d){if(!this.ignoreResize(_1c,_1d)){var _1e=this.grid;var _1f=this.adjustForComponents(_1c,_1d);_1e.container.setSize(_1f.width,_1f.height);_1e.autoSize();}},beforeSlide:function(){this.grid.getView().scroller.clip();},afterSlide:function(){this.grid.getView().scroller.unclip();},destroy:function(){this.grid.destroy();delete this.grid;Ext.GridPanel.superclass.destroy.call(this);}});Ext.NestedLayoutPanel=function(_20,_21){Ext.NestedLayoutPanel.superclass.constructor.call(this,_20.getEl(),_21);_20.monitorWindowResize=false;this.layout=_20;this.layout.getEl().addClass("x-layout-nested-layout");};Ext.extend(Ext.NestedLayoutPanel,Ext.ContentPanel,{setSize:function(_22,_23){if(!this.ignoreResize(_22,_23)){var _24=this.adjustForComponents(_22,_23);var el=this.layout.getEl();el.setSize(_24.width,_24.height);var _26=el.dom.offsetWidth;this.layout.layout();if(Ext.isIE&&!this.initialized){this.initialized=true;this.layout.layout();}}},getLayout:function(){return this.layout;}});Ext.ScrollPanel=function(el,_28,_29){_28=_28||{};_28.fitToFrame=true;Ext.ScrollPanel.superclass.constructor.call(this,el,_28,_29);this.el.dom.style.overflow="hidden";var _2a=this.el.wrap({cls:"x-scroller x-layout-inactive-content"});this.el.removeClass("x-layout-inactive-content");this.el.on("mousewheel",this.onWheel,this);var up=_2a.createChild({cls:"x-scroller-up",html:"&#160;"},this.el.dom);var _2c=_2a.createChild({cls:"x-scroller-down",html:"&#160;"});up.unselectable();_2c.unselectable();up.on("click",this.scrollUp,this);_2c.on("click",this.scrollDown,this);up.addClassOnOver("x-scroller-btn-over");_2c.addClassOnOver("x-scroller-btn-over");up.addClassOnClick("x-scroller-btn-click");_2c.addClassOnClick("x-scroller-btn-click");this.adjustments=[0,-(up.getHeight()+_2c.getHeight())];this.resizeEl=this.el;this.el=_2a;this.up=up;this.down=_2c;};Ext.extend(Ext.ScrollPanel,Ext.ContentPanel,{increment:100,wheelIncrement:5,scrollUp:function(){this.resizeEl.scroll("up",this.increment,{callback:this.afterScroll,scope:this});},scrollDown:function(){this.resizeEl.scroll("down",this.increment,{callback:this.afterScroll,scope:this});},afterScroll:function(){var el=this.resizeEl;var t=el.dom.scrollTop,h=el.dom.scrollHeight,ch=el.dom.clientHeight;this.up[t==0?"addClass":"removeClass"]("x-scroller-btn-disabled");this.down[h-t<=ch?"addClass":"removeClass"]("x-scroller-btn-disabled");},setSize:function(){Ext.ScrollPanel.superclass.setSize.apply(this,arguments);this.afterScroll();},onWheel:function(e){var d=e.getWheelDelta();this.resizeEl.dom.scrollTop-=(d*this.wheelIncrement);this.afterScroll();e.stopEvent();},setContent:function(_33,_34){this.resizeEl.update(_33,_34);}});

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