Skip to content
Snippets Groups Projects
Commit 380a5191 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

New naming convention for javascript minified library.

parent 82782d27
No related branches found
No related tags found
No related merge requests found
......@@ -8,3 +8,4 @@ errors/
private/
sessions/
uploads/
web2py.plugin.dbui.w2p
This diff is collapsed.
Ext.namespace("App");App.version="0.4.3";App.encodeField=function(b,d){var a,c;a=b[0].toUpperCase()+b.slice(1,b.length);c=d[0].toUpperCase()+d.slice(1,d.length);return a+c};App.getDirectStore=function(b){var a,c,d;c=Ext.StoreMgr.lookup(b);if(!c&&!Ext.isString(b)){throw new Error('Fail to instanciate the store: "'+b+'"')}if(!c&&Ext.isString(b)){d=b.slice(0,b.search("Store"));a=App.storeCfgs[d];c=new App.data.DirectStore(a)}return c};App.getTableName=function(a){return a.baseParams.tableName};App.isPlugin=function(a,d){var b,c;if(!a.hasOwnProperty("plugins")){return false}for(b=0;b<a.plugins.length;b+=1){c=a.plugins[b];if(c===d){return true}if((typeof(c)==="object")&&c.hasOwnProperty("ptype")&&(c.ptype===d)){return true}}return false};Ext.namespace("App");App.BasePanelWithSelector=Ext.extend(Ext.Panel,{panelCfg:null,selectorCfg:null,textGo:"Go",textReset:"Reset",constructor:function(d){var c,b,a;Ext.apply(this,d);b=Ext.ComponentMgr.create(this.panelCfg);a=Ext.ComponentMgr.create(this.selectorCfg);c={layout:"border",items:[{border:false,layout:"fit",itemId:"mainPanel",items:[b],region:"center",},{buttons:[{ref:"../../goButton",text:this.textGo},{ref:"../../resetButton",text:this.textReset}],collapsible:true,defaults:{anchor:"99%"},frame:true,layout:"form",itemId:"selectorPanel",items:[a],region:"east",split:true,width:300,}]};Ext.apply(this,c);App.BasePanelWithSelector.superclass.constructor.call(this)}});Ext.reg("xpanelwithselector",App.BasePanelWithSelector);Ext.namespace("App");App.ButtonDownload=Ext.extend(Ext.Button,{url:undefined,initComponent:function(){App.ButtonDownload.superclass.initComponent.call(this);this.on("click",this.onDownload,this)},onDownload:function(a,c){try{Ext.destroy(Ext.get("downloadIframe"))}catch(b){}Ext.DomHelper.append(document.body,{tag:"iframe",id:"downloadIframe",frameBorder:0,width:0,height:0,css:"display:none;visibility:hidden;height:0px;",src:this.url})}});Ext.reg("xbuttondownload",App.ButtonDownload);Ext.namespace("App.form");App.form.ComboBox=Ext.extend(Ext.form.ComboBox,{mode:"remote",editable:false,selectOnFocus:true,triggerAction:"all",typeAhead:true,initComponent:function(){if(this.fieldLabel&&!this.emptyText){this.emptyText="Select a "+this.fieldLabel+" ..."}this.store=App.getDirectStore(this.store);App.form.ComboBox.superclass.initComponent.call(this);if(this.store.getCount()===0){this.store.load()}this.store.on("load",function(){this.setValue(this.initialConfig.value)},this)}});Ext.reg("xcombobox",App.form.ComboBox);Ext.namespace("App.form");App.form.FormPanel=Ext.extend(Ext.form.FormPanel,{store:null,autoScroll:true,bodyStyle:"padding:5px 5px 0",buttons:[{formBind:true,text:"Action",ref:"../buttonAction"},{text:"Reset",ref:"../buttonReset"}],defaults:{anchor:"100%"},defaultType:"textfield",frame:true,monitorValid:true,currentAction:null,currentRecord:null,textCreate:"Create",textDestroy:"Delete",textDuplicate:"Duplicate",textReset:"Reset",textUpdate:"Update",initComponent:function(){function a(){this.reset()}App.form.FormPanel.superclass.initComponent.call(this);this.buttonAction.on("click",this.doAction,this);this.buttonReset.on("click",a,this.getForm());this.addFieldToolTipsListeners();this.store=App.getDirectStore(this.store);this.store.on("exception",this.onStoreException,this);this.store.on("write",a,this.getForm());this.setAction("create");this.buttonReset.setText(this.textReset)},addFieldToolTipsListeners:function(){var b;function a(d){new Ext.ToolTip({target:d.getEl(),title:d.fieldLabel,anchor:"left",trackMouse:false,html:Ext.util.Format.htmlEncode(d.tipText)})}b=this.getForm();b.items.each(function(c){if(c.tipText){c.on("render",a)}})},disableFields:function(a){var b=this.getForm();b.items.each(function(c){c.setDisabled(a)})},doAction:function(){var b=this.getForm(),a;if(!b.isValid()){return}if(!this.store){throw new Error("the store is undefined !!!")}switch(this.currentAction){case"create":a=new this.store.recordType();this.updateRecord(a);this.store.add(a);break;case"destroy":this.store.remove(this.currentRecord);break;case"duplicate":a=new this.store.recordType();this.updateRecord(a);this.store.add(a);break;case"update":this.currentRecord.beginEdit();this.updateRecord(this.currentRecord);this.currentRecord.endEdit();break}if(this.store.autoSave===false){this.store.save()}},hardReset:function(){var a=this.getForm();a.items.each(function(b){b.originalValue=Ext.value(b.initialConfig.value,"");b.setValue(b.originalValue)})},onStoreException:function(e,f,b,j,c,i){var g,h,a=this.getForm(),d;for(h in c.errors){if(c.errors.hasOwnProperty(h)){g=a.findField(h);g.markInvalid(c.errors[h])}}d=i[0];this.store.remove(d)},setAction:function(e,a){var d=this.getForm(),c,b;this.buttonReset.show();this.buttonAction.show();this.disableFields(false);this.currentAction=e;this.currentRecord=a;switch(e){case"create":this.hardReset();this.buttonAction.setText(this.textCreate);break;case"destroy":this.buttonAction.setText(this.textDestroy);d.loadRecord(a);break;case"duplicate":this.buttonAction.setText(this.textDuplicate);this.hardReset();c=App.getTableName(this.store);b=App.encodeField(c,"id");delete a.data[b];d.loadRecord(a);break;case"update":this.buttonAction.setText(this.textUpdate);d.loadRecord(a);break;case"view":this.buttonReset.hide();this.buttonAction.hide();d.loadRecord(a);this.disableFields(true);break}},updateRecord:function(b){var g,f,a=[],d,c,h,e;c=this.findByType("field");for(d=0;d<c.length;d+=1){f=c[d];if(f.getXType()!=="compositefield"){a.push(f)}}c=this.findByType("compositefield");for(d=0;d<c.length;d+=1){c[d].items.eachKey(function(j,i){a.push(i)})}for(d=0;d<a.length;d+=1){f=a[d];e=f.getValue();switch(f.getXType()){case"datefield":if(Ext.isDate(e)){e=e.format(f.format)}break;case"xcombobox":g=f;h=g.findRecord(g.valueField,g.getValue());b.set(g.displayField,h.get(g.displayField));break}b.set(f.getName(),e)}}});Ext.reg("xform",App.form.FormPanel);Ext.namespace("App.grid");App.grid.GridFilter=Ext.extend(Ext.form.FieldSet,{filterConditions:{},initialFilterConditions:[],pagingToolbar:null,store:null,defaults:{anchor:"99%",enableKeyEvents:true},initComponent:function(){var c,a,b;App.grid.GridFilter.superclass.initComponent.call(this);a=this.findByType("field");for(b=0;b<a.length;b+=1){c=a[b];if(c.xtype==="xcombobox"){c.on("select",this.onChange,this)}else{c.on("keyup",this.onChange,this,{buffer:500})}}},bind:function(b){var c,a;this.store=b.getStore();if(b.pagingInitialized){this.pagingToolbar=b.getBottomToolbar()}c=this.store.baseParams;for(a=0;a<c.where.length;a+=1){this.initialFilterConditions.push(c.where[a])}},onChange:function(a){this.setupCondition(a)},onReset:function(){var a,b;a=this.findByType("field");for(b=0;b<a.length;b+=1){a[b].reset()}this.filterConditions={};this.store.baseParams.where=this.initialFilterConditions;this.updateStore()},setupCondition:function(f){var e=[],c,a,d,b;d=f.getValue();b=f.name+" "+f.filterOperator+" '"+d+"'";if(d===""){delete this.filterConditions[f.name]}else{this.filterConditions[f.name]=b}for(c=0;c<this.initialFilterConditions.length;c+=1){e.push(this.initialFilterConditions[c])}for(a in this.filterConditions){if(this.filterConditions.hasOwnProperty(a)){e.push(this.filterConditions[a])}}this.store.baseParams.where=e;this.updateStore()},updateStore:function(){if(this.pagingToolbar){this.pagingToolbar.doRefresh()}else{this.store.load()}}});Ext.reg("xgridfilter",App.grid.GridFilter);Ext.namespace("App.grid");App.grid.Grid=Ext.extend(Ext.grid.GridPanel,{rowEditor:null,initComponent:function(){this.store=App.getDirectStore(this.store);this.bbar=new Ext.PagingToolbar();this.bbar.hide();App.grid.Grid.superclass.initComponent.call(this);if(!this.store.getTotalCount()){if(App.isPlugin(this,"pGridPaging")){this.store.load({params:{start:0,limit:10}})}else{this.store.load()}}}});Ext.reg("xgrid",App.grid.Grid);Ext.namespace("App.grid");App.grid.MathJax=Ext.extend(Object,{init:function(a){function b(d){var c=Ext.getDom(d.el);MathJax.Hub.Queue(["Typeset",MathJax.Hub,c])}a.getView().on("refresh",b,a);a.store.on("write",b,a)}});Ext.preg("pGridMathJax",App.grid.MathJax);Ext.namespace("App.grid");App.grid.Paging=Ext.extend(Object,{ptype:"pGridPaging",textExport:"Export",textSlider:"Rows per page",init:function(a){var b;b=a.getBottomToolbar();b.bindStore(a.store);b.add("-",this.textSlider,{xtype:"slider",plugins:new Ext.slider.Tip(),listeners:{changecomplete:this.onChangePageSize,scope:b},minValue:1,width:100},"->",{xtype:"xbuttondownload",text:this.textExport,url:App.csvUrl+"?tableName="+App.getTableName(a.store)});b.show();if(a.store.getTotalCount()>0){this.onInit.call(a,a.store)}else{a.store.on("load",this.onInit,a,{single:true})}a.store.on("write",this.onWrite,a)},onChangePageSize:function(b,c,a){var d=this;d.pageSize=c;d.moveFirst()},onInit:function(b,a,c){var g,e=this,d=b.getCount(),f;g=e.getBottomToolbar();g.pageSize=d;f=g.findByType("slider")[0];f.setMaxValue(b.getTotalCount());f.setValue(d)},onWrite:function(){var c,a=this,b;c=a.getBottomToolbar();c.pageSize=a.store.getCount();b=c.findByType("slider")[0];b.setMaxValue(a.store.getTotalCount());b.setValue(a.store.getCount())}});Ext.preg("pGridPaging",App.grid.Paging);Ext.namespace("App.grid");App.grid.RowEditorContextMenu=Ext.extend(Object,{ptype:"pGridRowEditorContextMenu",textAdd:"Add",textCreate:"Create",textDestroy:"Delete",textDuplicate:"Duplicate",textUpdate:"Update",textView:"View",init:function(a){var b=new Ext.menu.Menu();if(!a.rowEditor){throw new Error("no grid row editor !!!")}a.addListener("containercontextmenu",this.onContainerContextMenu,b);a.addListener("headercontextmenu",this.onHeaderContextMenu,b);a.addListener("rowcontextmenu",this.onRowContextMenu,b);b.add({text:this.textAdd,iconCls:"xaction-create",handler:a.rowEditor.onAddRow,scope:a.rowEditor},"-",{text:this.textDuplicate,iconCls:"xaction-duplicate",handler:a.rowEditor.onDuplicateRow,scope:a.rowEditor},{text:this.textUpdate,iconCls:"xaction-update",handler:a.rowEditor.onEditRow,scope:a.rowEditor},{text:this.textView,iconCls:"xaction-view",handler:a.rowEditor.onViewRow,scope:a.rowEditor},"-",{text:this.textDestroy,iconCls:"xaction-destroy",handler:a.rowEditor.onDeleteRow,scope:a.rowEditor})},onContainerContextMenu:function(a,b){var c=this;b.stopEvent();c.showAt(b.getXY())},onHeaderContextMenu:function(b,a,c){c.stopEvent()},onRowContextMenu:function(a,d,b){var c=this;b.stopEvent();a.selModel.selectRow(d);c.showAt(b.getXY())}});Ext.preg("pGridRowEditorContextMenu",App.grid.RowEditorContextMenu);Ext.namespace("App.grid");App.grid.RowEditor=Ext.extend(Ext.Window,{ptype:"pGridRowEditor",formPanel:null,grid:null,addTitle:"Create a new record...",deleteTitle:"Delete the record...",duplicateTitle:"Duplicate the record...",editTitle:"Update the record...",viewTitle:"View the record...",textMsg:"Select a row please",autoScroll:true,closeAction:"hide",constrainHeader:true,defaults:{autoScroll:true},modal:true,plain:true,init:function(a){var b;this.grid=a;this.grid.rowEditor=this;this.grid.selModel=new Ext.grid.RowSelectionModel({singleSelect:true});this.grid.store.on("write",this.onWrite,this);b=App.getTableName(this.grid.store);Dbui.getForm(b,this.addFormPanel,this)},addFormPanel:function(c,a){var b=a.result;this.formPanel=new App.form.FormPanel(b);this.add(this.formPanel);this.grid.store.on("exception",this.formPanel.onStoreException,this.formPanel)},getSelected:function(){var a=this.grid.getSelectionModel().getSelected();if(!a){Ext.MessageBox.alert("Warning",this.textMsg);return false}return a},onAddRow:function(){this.formPanel.setAction("create");this.setTitle(this.addTitle);this.show()},onDeleteRow:function(){var a=this.getSelected();if(!a){return}this.formPanel.setAction("destroy",a);this.setTitle(this.deleteTitle);this.formPanel.doAction()},onDuplicateRow:function(){var a=this.getSelected();if(!a){return}this.formPanel.setAction("duplicate",a);this.setTitle(this.duplicateTitle);this.show()},onEditRow:function(){var a=this.getSelected();if(!a){return}this.formPanel.setAction("update",a);this.setTitle(this.editTitle);this.show()},onViewRow:function(){var a=this.getSelected();if(!a){return}this.formPanel.setAction("view",a);this.setTitle(this.viewTitle);this.show()},onWrite:function(c,d,a,e,b){this.hide()}});Ext.preg("pGridRowEditor",App.grid.RowEditor);Ext.namespace("App.grid");App.grid.RowEditorToolbar=Ext.extend(Object,{ptype:"pGridRowEditorToolbar",init:function(a){var b;if(!a.rowEditor){throw new Error("no grid row editor !!!")}b=a.getTopToolbar();b.add([{text:"Add",iconCls:"silk-add",handler:a.rowEditor.onAddRow,scope:a.rowEditor}," ",{text:"Delete",iconCls:"silk-delete",handler:a.rowEditor.onDeleteRow,scope:a.rowEditor}," ",{text:"Duplicate",iconCls:"silk-clone",handler:a.rowEditor.onDuplicateRow,scope:a.rowEditor}," ",{text:"Update",iconCls:"silk-update",handler:a.rowEditor.onEditRow,scope:a.rowEditor}," ",{text:"View",iconCls:"silk-view",handler:a.rowEditor.onViewRow,scope:a.rowEditor},"-"])}});Ext.preg("pGridRowEditorToolbar",App.grid.RowEditorToolbar);Ext.namespace("App.grid");App.grid.GridWithFilter=Ext.extend(App.BasePanelWithSelector,{initComponent:function(){var b,a;this.items[1].collapsed=true;App.grid.GridWithFilter.superclass.initComponent.call(this);b=this.findByType("xgridfilter")[0];a=this.findByType("xgrid")[0];b.bind(a);this.goButton.hide();this.resetButton.on("click",b.onReset,b)}});Ext.reg("xgridwithfilter",App.grid.GridWithFilter);Ext.namespace("App.data");App.data.DirectStore=Ext.extend(Ext.data.DirectStore,{autoLoad:true,autoSave:true,constructor:function(c){var a,b;a=Ext.apply({},{encode:false,listful:true,writeAllFields:false},c);a=Ext.apply(a,{api:{create:Dbui.create,destroy:Dbui.destroy,read:Dbui.read,update:Dbui.update}});if(!Ext.isDefined(a.writer)){b=Ext.copyTo({},a,"encode, listful, writeAllFields");a.writer=new Ext.data.JsonWriter(b)}App.data.DirectStore.superclass.constructor.call(this,a);this.on("write",this.onWrite)},onWrite:function(a,b){switch(b){case"create":a.totalLength+=1;break;case"destroy":a.totalLength-=1;break}}});Ext.reg("xdirectstore",App.data.DirectStore);Ext.namespace("App.panel");App.panel.MathJax=Ext.extend(Object,{init:function(a){a.on("render",this.onPanelRender,this,{single:true})},onPanelRender:function(a){var b=a.body.getUpdater();b.on("update",this.onProcess)},onProcess:function(a,b){MathJax.Hub.PreProcess();MathJax.Hub.Process()}});Ext.preg("pPanelMathJax",App.panel.MathJax);Ext.namespace("App");App.PanelWithUrlSelector=Ext.extend(App.BasePanelWithSelector,{baseUrl:null,initComponent:function(){App.PanelWithUrlSelector.superclass.initComponent.call(this);this.goButton.on("click",this.onGo,this);this.resetButton.on("click",this.onReset,this)},onGo:function(){var b,d,c=this.getComponent("mainPanel"),e={},a=this.getComponent("selectorPanel");b=a.findByType("field");for(d=0;d<b.length;d+=1){e[b[d].getName()]=b[d].getValue()}c.load({url:this.baseUrl,params:e,text:"Loading...",timeout:30})},onReset:function(){var b,c,a=this.getComponent("selectorPanel");b=a.findByType("field");for(c=0;c<b.length;c+=1){b[c].reset()}}});Ext.reg("xpanelwithurlselector",App.PanelWithUrlSelector);Ext.namespace("App.form");App.form.SetBox=Ext.extend(Ext.form.ComboBox,{model:null,editable:false,emptyText:"Select...",selectOnFocus:true,triggerAction:"all",typeAhead:true,initComponent:function(){var b,a=[];if(!this.model){throw new Error("the property model is missing !!!")}a=[];for(b=0;b<this.model.setData.length;b+=1){a.push([this.model.setData[b]])}this.store=new Ext.data.ArrayStore({fields:[this.model.name],data:a});this.displayField=this.model.name;this.mode="local";App.form.SetBox.superclass.initComponent.call(this)}});Ext.reg("xsetbox",App.form.SetBox);Ext.namespace("App");App.Viewport=Ext.extend(Ext.Viewport,{tabPanel:null,treePanel:null,constructor:function(d){var e,b,c,f,a;Ext.apply(this,d);c=new Ext.tree.AsyncTreeNode({id:"root",nodeType:"async",expanded:true,text:App.name});b=new Ext.tree.TreeLoader({directFn:Dbui.getTree});cfg={layout:"border",title:"Ext Layout Browser",items:[{autoScroll:true,collapsible:true,itemId:"treePanel",loader:b,region:"west",root:c,rootVisible:false,split:true,title:App.name,width:200,xtype:"treepanel"},{autoScroll:true,defaults:{layout:"fit"},itemId:"tabPanel",region:"center",xtype:"tabpanel"}]};Ext.apply(this,cfg);App.Viewport.superclass.constructor.call(this);this.tabPanel=this.getComponent("tabPanel");this.treePanel=this.getComponent("treePanel");this.treePanel.on("click",this.onCreateTab,this);this.treePanel.on("contextmenu",function(h,g){g.stopEvent()})},onCreateTab:function(d,b){var f,h=d.parentNode,a,c,g=this,e=d.attributes.cfg,i=d.attributes.cfg.xtype;if(!d.isLeaf()){return}c=d.attributes.text+"/"+i;if(this.tabPanel.getComponent(c)){this.tabPanel.setActiveTab(c);return}f={closable:true,itemId:c,title:h.attributes.text+" "+d.attributes.text};if(i==="panel"){delete e.xtype;Ext.apply(f,e)}else{f.items=[d.attributes.cfg]}a=this.tabPanel.add(f);this.tabPanel.setActiveTab(c)}});
\ No newline at end of file
Ext.namespace("App.grid");App.grid.MathJax=Ext.extend(Object,{init:function(a){function b(d){var c=Ext.getDom(d.el);MathJax.Hub.Queue(["Typeset",MathJax.Hub,c])}a.getView().on("refresh",b,a);a.store.on("write",b,a)}});Ext.preg("pGridMathJax",App.grid.MathJax);Ext.namespace("App.grid");App.grid.Grid=Ext.extend(Ext.grid.GridPanel,{rowEditor:null,initComponent:function(){this.store=App.getDirectStore(this.store);this.bbar=new Ext.PagingToolbar();this.bbar.hide();App.grid.Grid.superclass.initComponent.call(this);if(!this.store.getTotalCount()){if(App.isPlugin(this,"pGridPaging")){this.store.load({params:{start:0,limit:10}})}else{this.store.load()}}}});Ext.reg("xgrid",App.grid.Grid);Ext.namespace("App");App.version="0.4.3";App.encodeField=function(b,d){var a,c;a=b[0].toUpperCase()+b.slice(1,b.length);c=d[0].toUpperCase()+d.slice(1,d.length);return a+c};App.getDirectStore=function(b){var a,c,d;c=Ext.StoreMgr.lookup(b);if(!c&&!Ext.isString(b)){throw new Error('Fail to instanciate the store: "'+b+'"')}if(!c&&Ext.isString(b)){d=b.slice(0,b.search("Store"));a=App.storeCfgs[d];c=new App.data.DirectStore(a)}return c};App.getTableName=function(a){return a.baseParams.tableName};App.isPlugin=function(a,d){var b,c;if(!a.hasOwnProperty("plugins")){return false}for(b=0;b<a.plugins.length;b+=1){c=a.plugins[b];if(c===d){return true}if((typeof(c)==="object")&&c.hasOwnProperty("ptype")&&(c.ptype===d)){return true}}return false};Ext.namespace("App.grid");App.grid.Paging=Ext.extend(Object,{ptype:"pGridPaging",textExport:"Export",textSlider:"Rows per page",init:function(a){var b;b=a.getBottomToolbar();b.bindStore(a.store);b.add("-",this.textSlider,{xtype:"slider",plugins:new Ext.slider.Tip(),listeners:{changecomplete:this.onChangePageSize,scope:b},minValue:1,width:100},"->",{xtype:"xbuttondownload",text:this.textExport,url:App.csvUrl+"?tableName="+App.getTableName(a.store)});b.show();if(a.store.getTotalCount()>0){this.onInit.call(a,a.store)}else{a.store.on("load",this.onInit,a,{single:true})}a.store.on("write",this.onWrite,a)},onChangePageSize:function(b,c,a){var d=this;d.pageSize=c;d.moveFirst()},onInit:function(b,a,c){var g,e=this,d=b.getCount(),f;g=e.getBottomToolbar();g.pageSize=d;f=g.findByType("slider")[0];f.setMaxValue(b.getTotalCount());f.setValue(d)},onWrite:function(){var c,a=this,b;c=a.getBottomToolbar();c.pageSize=a.store.getCount();b=c.findByType("slider")[0];b.setMaxValue(a.store.getTotalCount());b.setValue(a.store.getCount())}});Ext.preg("pGridPaging",App.grid.Paging);Ext.namespace("App.grid");App.grid.RowEditor=Ext.extend(Ext.Window,{ptype:"pGridRowEditor",formPanel:null,grid:null,addTitle:"Create a new record...",deleteTitle:"Delete the record...",duplicateTitle:"Duplicate the record...",editTitle:"Update the record...",viewTitle:"View the record...",textMsg:"Select a row please",autoScroll:true,closeAction:"hide",constrainHeader:true,defaults:{autoScroll:true},modal:true,plain:true,init:function(a){var b;this.grid=a;this.grid.rowEditor=this;this.grid.selModel=new Ext.grid.RowSelectionModel({singleSelect:true});this.grid.store.on("write",this.onWrite,this);b=App.getTableName(this.grid.store);Dbui.getForm(b,this.addFormPanel,this)},addFormPanel:function(c,a){var b=a.result;this.formPanel=new App.form.FormPanel(b);this.add(this.formPanel);this.grid.store.on("exception",this.formPanel.onStoreException,this.formPanel)},getSelected:function(){var a=this.grid.getSelectionModel().getSelected();if(!a){Ext.MessageBox.alert("Warning",this.textMsg);return false}return a},onAddRow:function(){this.formPanel.setAction("create");this.setTitle(this.addTitle);this.show()},onDeleteRow:function(){var a=this.getSelected();if(!a){return}this.formPanel.setAction("destroy",a);this.setTitle(this.deleteTitle);this.formPanel.doAction()},onDuplicateRow:function(){var a=this.getSelected();if(!a){return}this.formPanel.setAction("duplicate",a);this.setTitle(this.duplicateTitle);this.show()},onEditRow:function(){var a=this.getSelected();if(!a){return}this.formPanel.setAction("update",a);this.setTitle(this.editTitle);this.show()},onViewRow:function(){var a=this.getSelected();if(!a){return}this.formPanel.setAction("view",a);this.setTitle(this.viewTitle);this.show()},onWrite:function(c,d,a,e,b){this.hide()}});Ext.preg("pGridRowEditor",App.grid.RowEditor);Ext.namespace("App");App.ButtonDownload=Ext.extend(Ext.Button,{url:undefined,initComponent:function(){App.ButtonDownload.superclass.initComponent.call(this);this.on("click",this.onDownload,this)},onDownload:function(a,c){try{Ext.destroy(Ext.get("downloadIframe"))}catch(b){}Ext.DomHelper.append(document.body,{tag:"iframe",id:"downloadIframe",frameBorder:0,width:0,height:0,css:"display:none;visibility:hidden;height:0px;",src:this.url})}});Ext.reg("xbuttondownload",App.ButtonDownload);Ext.namespace("App.form");App.form.FormPanel=Ext.extend(Ext.form.FormPanel,{store:null,autoScroll:true,bodyStyle:"padding:5px 5px 0",buttons:[{formBind:true,text:"Action",ref:"../buttonAction"},{text:"Reset",ref:"../buttonReset"}],defaults:{anchor:"100%"},defaultType:"textfield",frame:true,monitorValid:true,currentAction:null,currentRecord:null,textCreate:"Create",textDestroy:"Delete",textDuplicate:"Duplicate",textReset:"Reset",textUpdate:"Update",initComponent:function(){function a(){this.reset()}App.form.FormPanel.superclass.initComponent.call(this);this.buttonAction.on("click",this.doAction,this);this.buttonReset.on("click",a,this.getForm());this.addFieldToolTipsListeners();this.store=App.getDirectStore(this.store);this.store.on("exception",this.onStoreException,this);this.store.on("write",a,this.getForm());this.setAction("create");this.buttonReset.setText(this.textReset)},addFieldToolTipsListeners:function(){var b;function a(d){new Ext.ToolTip({target:d.getEl(),title:d.fieldLabel,anchor:"left",trackMouse:false,html:Ext.util.Format.htmlEncode(d.tipText)})}b=this.getForm();b.items.each(function(c){if(c.tipText){c.on("render",a)}})},disableFields:function(a){var b=this.getForm();b.items.each(function(c){c.setDisabled(a)})},doAction:function(){var b=this.getForm(),a;if(!b.isValid()){return}if(!this.store){throw new Error("the store is undefined !!!")}switch(this.currentAction){case"create":a=new this.store.recordType();this.updateRecord(a);this.store.add(a);break;case"destroy":this.store.remove(this.currentRecord);break;case"duplicate":a=new this.store.recordType();this.updateRecord(a);this.store.add(a);break;case"update":this.currentRecord.beginEdit();this.updateRecord(this.currentRecord);this.currentRecord.endEdit();break}if(this.store.autoSave===false){this.store.save()}},hardReset:function(){var a=this.getForm();a.items.each(function(b){b.originalValue=Ext.value(b.initialConfig.value,"");b.setValue(b.originalValue)})},onStoreException:function(e,f,b,j,c,i){var g,h,a=this.getForm(),d;for(h in c.errors){if(c.errors.hasOwnProperty(h)){g=a.findField(h);g.markInvalid(c.errors[h])}}d=i[0];this.store.remove(d)},setAction:function(e,a){var d=this.getForm(),c,b;this.buttonReset.show();this.buttonAction.show();this.disableFields(false);this.currentAction=e;this.currentRecord=a;switch(e){case"create":this.hardReset();this.buttonAction.setText(this.textCreate);break;case"destroy":this.buttonAction.setText(this.textDestroy);d.loadRecord(a);break;case"duplicate":this.buttonAction.setText(this.textDuplicate);this.hardReset();c=App.getTableName(this.store);b=App.encodeField(c,"id");delete a.data[b];d.loadRecord(a);break;case"update":this.buttonAction.setText(this.textUpdate);d.loadRecord(a);break;case"view":this.buttonReset.hide();this.buttonAction.hide();d.loadRecord(a);this.disableFields(true);break}},updateRecord:function(b){var g,f,a=[],d,c,h,e;c=this.findByType("field");for(d=0;d<c.length;d+=1){f=c[d];if(f.getXType()!=="compositefield"){a.push(f)}}c=this.findByType("compositefield");for(d=0;d<c.length;d+=1){c[d].items.eachKey(function(j,i){a.push(i)})}for(d=0;d<a.length;d+=1){f=a[d];e=f.getValue();switch(f.getXType()){case"datefield":if(Ext.isDate(e)){e=e.format(f.format)}break;case"xcombobox":g=f;h=g.findRecord(g.valueField,g.getValue());b.set(g.displayField,h.get(g.displayField));break}b.set(f.getName(),e)}}});Ext.reg("xform",App.form.FormPanel);Ext.namespace("App");App.Viewport=Ext.extend(Ext.Viewport,{tabPanel:null,treePanel:null,constructor:function(d){var e,b,c,f,a;Ext.apply(this,d);c=new Ext.tree.AsyncTreeNode({id:"root",nodeType:"async",expanded:true,text:App.name});b=new Ext.tree.TreeLoader({directFn:Dbui.getTree});cfg={layout:"border",title:"Ext Layout Browser",items:[{autoScroll:true,collapsible:true,itemId:"treePanel",loader:b,region:"west",root:c,rootVisible:false,split:true,title:App.name,width:200,xtype:"treepanel"},{autoScroll:true,defaults:{layout:"fit"},itemId:"tabPanel",region:"center",xtype:"tabpanel"}]};Ext.apply(this,cfg);App.Viewport.superclass.constructor.call(this);this.tabPanel=this.getComponent("tabPanel");this.treePanel=this.getComponent("treePanel");this.treePanel.on("click",this.onCreateTab,this);this.treePanel.on("contextmenu",function(h,g){g.stopEvent()})},onCreateTab:function(d,b){var f,h=d.parentNode,a,c,g=this,e=d.attributes.cfg,i=d.attributes.cfg.xtype;if(!d.isLeaf()){return}c=d.attributes.text+"/"+i;if(this.tabPanel.getComponent(c)){this.tabPanel.setActiveTab(c);return}f={closable:true,itemId:c,title:h.attributes.text+" "+d.attributes.text};if(i==="panel"){delete e.xtype;Ext.apply(f,e)}else{f.items=[d.attributes.cfg]}a=this.tabPanel.add(f);this.tabPanel.setActiveTab(c)}});Ext.namespace("App");App.BasePanelWithSelector=Ext.extend(Ext.Panel,{panelCfg:null,selectorCfg:null,textGo:"Go",textReset:"Reset",constructor:function(d){var c,b,a;Ext.apply(this,d);b=Ext.ComponentMgr.create(this.panelCfg);a=Ext.ComponentMgr.create(this.selectorCfg);c={layout:"border",items:[{border:false,layout:"fit",itemId:"mainPanel",items:[b],region:"center",},{buttons:[{ref:"../../goButton",text:this.textGo},{ref:"../../resetButton",text:this.textReset}],collapsible:true,defaults:{anchor:"99%"},frame:true,layout:"form",itemId:"selectorPanel",items:[a],region:"east",split:true,width:300,}]};Ext.apply(this,c);App.BasePanelWithSelector.superclass.constructor.call(this)}});Ext.reg("xpanelwithselector",App.BasePanelWithSelector);Ext.namespace("App.form");App.form.ComboBox=Ext.extend(Ext.form.ComboBox,{mode:"remote",editable:false,selectOnFocus:true,triggerAction:"all",typeAhead:true,initComponent:function(){if(this.fieldLabel&&!this.emptyText){this.emptyText="Select a "+this.fieldLabel+" ..."}this.store=App.getDirectStore(this.store);App.form.ComboBox.superclass.initComponent.call(this);if(this.store.getCount()===0){this.store.load()}this.store.on("load",function(){this.setValue(this.initialConfig.value)},this)}});Ext.reg("xcombobox",App.form.ComboBox);Ext.namespace("App.grid");App.grid.GridWithFilter=Ext.extend(App.BasePanelWithSelector,{initComponent:function(){var b,a;this.items[1].collapsed=true;App.grid.GridWithFilter.superclass.initComponent.call(this);b=this.findByType("xgridfilter")[0];a=this.findByType("xgrid")[0];b.bind(a);this.goButton.hide();this.resetButton.on("click",b.onReset,b)}});Ext.reg("xgridwithfilter",App.grid.GridWithFilter);Ext.namespace("App.form");App.form.SetBox=Ext.extend(Ext.form.ComboBox,{model:null,editable:false,emptyText:"Select...",selectOnFocus:true,triggerAction:"all",typeAhead:true,initComponent:function(){var b,a=[];if(!this.model){throw new Error("the property model is missing !!!")}a=[];for(b=0;b<this.model.setData.length;b+=1){a.push([this.model.setData[b]])}this.store=new Ext.data.ArrayStore({fields:[this.model.name],data:a});this.displayField=this.model.name;this.mode="local";App.form.SetBox.superclass.initComponent.call(this)}});Ext.reg("xsetbox",App.form.SetBox);Ext.namespace("App.grid");App.grid.RowEditorToolbar=Ext.extend(Object,{ptype:"pGridRowEditorToolbar",init:function(a){var b;if(!a.rowEditor){throw new Error("no grid row editor !!!")}b=a.getTopToolbar();b.add([{text:"Add",iconCls:"silk-add",handler:a.rowEditor.onAddRow,scope:a.rowEditor}," ",{text:"Delete",iconCls:"silk-delete",handler:a.rowEditor.onDeleteRow,scope:a.rowEditor}," ",{text:"Duplicate",iconCls:"silk-clone",handler:a.rowEditor.onDuplicateRow,scope:a.rowEditor}," ",{text:"Update",iconCls:"silk-update",handler:a.rowEditor.onEditRow,scope:a.rowEditor}," ",{text:"View",iconCls:"silk-view",handler:a.rowEditor.onViewRow,scope:a.rowEditor},"-"])}});Ext.preg("pGridRowEditorToolbar",App.grid.RowEditorToolbar);Ext.namespace("App.grid");App.grid.RowEditorContextMenu=Ext.extend(Object,{ptype:"pGridRowEditorContextMenu",textAdd:"Add",textCreate:"Create",textDestroy:"Delete",textDuplicate:"Duplicate",textUpdate:"Update",textView:"View",init:function(a){var b=new Ext.menu.Menu();if(!a.rowEditor){throw new Error("no grid row editor !!!")}a.addListener("containercontextmenu",this.onContainerContextMenu,b);a.addListener("headercontextmenu",this.onHeaderContextMenu,b);a.addListener("rowcontextmenu",this.onRowContextMenu,b);b.add({text:this.textAdd,iconCls:"xaction-create",handler:a.rowEditor.onAddRow,scope:a.rowEditor},"-",{text:this.textDuplicate,iconCls:"xaction-duplicate",handler:a.rowEditor.onDuplicateRow,scope:a.rowEditor},{text:this.textUpdate,iconCls:"xaction-update",handler:a.rowEditor.onEditRow,scope:a.rowEditor},{text:this.textView,iconCls:"xaction-view",handler:a.rowEditor.onViewRow,scope:a.rowEditor},"-",{text:this.textDestroy,iconCls:"xaction-destroy",handler:a.rowEditor.onDeleteRow,scope:a.rowEditor})},onContainerContextMenu:function(a,b){var c=this;b.stopEvent();c.showAt(b.getXY())},onHeaderContextMenu:function(b,a,c){c.stopEvent()},onRowContextMenu:function(a,d,b){var c=this;b.stopEvent();a.selModel.selectRow(d);c.showAt(b.getXY())}});Ext.preg("pGridRowEditorContextMenu",App.grid.RowEditorContextMenu);Ext.namespace("App.grid");App.grid.GridFilter=Ext.extend(Ext.form.FieldSet,{filterConditions:{},initialFilterConditions:[],pagingToolbar:null,store:null,defaults:{anchor:"99%",enableKeyEvents:true},initComponent:function(){var c,a,b;App.grid.GridFilter.superclass.initComponent.call(this);a=this.findByType("field");for(b=0;b<a.length;b+=1){c=a[b];if(c.xtype==="xcombobox"){c.on("select",this.onChange,this)}else{c.on("keyup",this.onChange,this,{buffer:500})}}},bind:function(b){var c,a;this.store=b.getStore();if(b.pagingInitialized){this.pagingToolbar=b.getBottomToolbar()}c=this.store.baseParams;for(a=0;a<c.where.length;a+=1){this.initialFilterConditions.push(c.where[a])}},onChange:function(a){this.setupCondition(a)},onReset:function(){var a,b;a=this.findByType("field");for(b=0;b<a.length;b+=1){a[b].reset()}this.filterConditions={};this.store.baseParams.where=this.initialFilterConditions;this.updateStore()},setupCondition:function(f){var e=[],c,a,d,b;d=f.getValue();b=f.name+" "+f.filterOperator+" '"+d+"'";if(d===""){delete this.filterConditions[f.name]}else{this.filterConditions[f.name]=b}for(c=0;c<this.initialFilterConditions.length;c+=1){e.push(this.initialFilterConditions[c])}for(a in this.filterConditions){if(this.filterConditions.hasOwnProperty(a)){e.push(this.filterConditions[a])}}this.store.baseParams.where=e;this.updateStore()},updateStore:function(){if(this.pagingToolbar){this.pagingToolbar.doRefresh()}else{this.store.load()}}});Ext.reg("xgridfilter",App.grid.GridFilter);Ext.namespace("App.panel");App.panel.MathJax=Ext.extend(Object,{init:function(a){a.on("render",this.onPanelRender,this,{single:true})},onPanelRender:function(a){var b=a.body.getUpdater();b.on("update",this.onProcess)},onProcess:function(a,b){MathJax.Hub.PreProcess();MathJax.Hub.Process()}});Ext.preg("pPanelMathJax",App.panel.MathJax);Ext.namespace("App.data");App.data.DirectStore=Ext.extend(Ext.data.DirectStore,{autoLoad:true,autoSave:true,constructor:function(c){var a,b;a=Ext.apply({},{encode:false,listful:true,writeAllFields:false},c);a=Ext.apply(a,{api:{create:Dbui.create,destroy:Dbui.destroy,read:Dbui.read,update:Dbui.update}});if(!Ext.isDefined(a.writer)){b=Ext.copyTo({},a,"encode, listful, writeAllFields");a.writer=new Ext.data.JsonWriter(b)}App.data.DirectStore.superclass.constructor.call(this,a);this.on("write",this.onWrite)},onWrite:function(a,b){switch(b){case"create":a.totalLength+=1;break;case"destroy":a.totalLength-=1;break}}});Ext.reg("xdirectstore",App.data.DirectStore);Ext.namespace("App");App.PanelWithUrlSelector=Ext.extend(App.BasePanelWithSelector,{baseUrl:null,initComponent:function(){App.PanelWithUrlSelector.superclass.initComponent.call(this);this.goButton.on("click",this.onGo,this);this.resetButton.on("click",this.onReset,this)},onGo:function(){var b,d,c=this.getComponent("mainPanel"),e={},a=this.getComponent("selectorPanel");b=a.findByType("field");for(d=0;d<b.length;d+=1){e[b[d].getName()]=b[d].getValue()}c.load({url:this.baseUrl,params:e,text:"Loading...",timeout:30})},onReset:function(){var b,c,a=this.getComponent("selectorPanel");b=a.findByType("field");for(c=0;c<b.length;c+=1){b[c].reset()}}});Ext.reg("xpanelwithurlselector",App.PanelWithUrlSelector);
\ No newline at end of file
......@@ -36,7 +36,7 @@
<!-- dbui + user javascript library and main script -->
<script type="text/javascript" src="/{{=request.application}}/plugin_dbui/get_api"></script>
<script type="text/javascript" src="/{{=request.application}}/static/plugin_dbui/dbui.min.js"></script>
<script type="text/javascript" src="/{{=request.application}}/static/plugin_dbui/dbui-min.js"></script>
<script type="text/javascript" src="/{{=request.application}}/static/plugin_dbui/locale/app-lang-{{=lg}}.js"></script>
{{for el in response.files:}}<script type="text/javascript" src="{{=el}}"></script>{{pass}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment