padrino-admin 0.6.3 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +16 -0
- data/VERSION +1 -1
- data/lib/padrino-admin.rb +24 -5
- data/lib/padrino-admin/access_control.rb +75 -29
- data/lib/padrino-admin/{ext_js/column_store.rb → column_store.rb} +31 -15
- data/lib/padrino-admin/config.rb +36 -0
- data/lib/padrino-admin/generators/actions.rb +62 -7
- data/lib/padrino-admin/generators/admin_app.rb +27 -26
- data/lib/padrino-admin/generators/admin_page.rb +20 -18
- data/lib/padrino-admin/generators/admin_uploader.rb +83 -0
- data/lib/padrino-admin/generators/app/app.rb.tt +1 -3
- data/lib/padrino-admin/generators/app/controllers/accounts.rb +1 -1
- data/lib/padrino-admin/generators/app/public/flash/swfupload.swf +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/back.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/background.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-content.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-hd-slate.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-hd.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-intro.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-login.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-menu-slate.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-menu.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/btn-login.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/admin/cancel.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/categories.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/admin/close.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/admin/close.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/delete.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/download.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/duplicate.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/edit.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/export.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/hd-bg.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/image.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/loader.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/logo-loader.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/logo-small.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/new.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/no-image.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/preview.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/print.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/save.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/support.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/admin/up.gif +0 -0
- data/lib/padrino-admin/generators/app/public/javascripts/ext.js +4 -1
- data/lib/padrino-admin/generators/app/public/javascripts/swfupload.js +4 -0
- data/lib/padrino-admin/generators/app/public/stylesheets/admin.css +25 -43
- data/lib/padrino-admin/generators/app/public/stylesheets/login.css +3 -3
- data/lib/padrino-admin/generators/app/public/stylesheets/standard.css +53 -52
- data/lib/padrino-admin/generators/app/views/accounts/_form.haml +1 -0
- data/lib/padrino-admin/generators/app/views/base/index.haml +5 -7
- data/lib/padrino-admin/generators/app/views/javascripts/admin.js.erb +217 -297
- data/lib/padrino-admin/generators/app/views/sessions/new.haml +1 -1
- data/lib/padrino-admin/generators/templates/{controller.rb.tt → page/controller.rb.tt} +1 -1
- data/lib/padrino-admin/generators/templates/{db → page/db}/seeds.rb.tt +0 -0
- data/lib/padrino-admin/generators/templates/{views → page/views}/_form.haml.tt +0 -0
- data/lib/padrino-admin/generators/templates/{views → page/views}/edit.haml.tt +0 -0
- data/lib/padrino-admin/generators/templates/{views → page/views}/grid.js.erb.tt +1 -1
- data/lib/padrino-admin/generators/templates/{views → page/views}/new.haml.tt +0 -0
- data/lib/padrino-admin/generators/templates/{views → page/views}/store.jml.tt +0 -0
- data/lib/padrino-admin/generators/templates/uploader/controller.rb +24 -0
- data/lib/padrino-admin/generators/templates/uploader/lib/uploader.rb +54 -0
- data/lib/padrino-admin/generators/templates/uploader/views/grid.js.erb +56 -0
- data/lib/padrino-admin/generators/templates/uploader/views/store.jml +10 -0
- data/lib/padrino-admin/helpers/authentication.rb +30 -19
- data/lib/padrino-admin/helpers/view.rb +172 -35
- data/lib/padrino-admin/locale/admin/en.yml +1 -0
- data/lib/padrino-admin/middleware/flash_middleware.rb +36 -0
- data/lib/padrino-admin/orm.rb +33 -0
- data/lib/padrino-admin/orm/abstract.rb +94 -0
- data/lib/padrino-admin/{adapters/ar.rb → orm/activerecord.rb} +69 -36
- data/lib/padrino-admin/orm/datamapper.rb +214 -0
- data/lib/padrino-admin/{adapters/mm.rb → orm/mongomapper.rb} +36 -20
- data/lib/padrino-admin/utils/literal.rb +1 -1
- data/padrino-admin.gemspec +62 -51
- data/test/fixtures/active_record.rb +14 -2
- data/test/fixtures/data_mapper.rb +2 -1
- data/test/fixtures/mongo_mapper.rb +1 -1
- data/test/fixtures/test_column_store.jml +1 -0
- data/test/helper.rb +3 -2
- data/test/test_access_control.rb +1 -1
- data/test/test_active_record.rb +56 -1
- data/test/test_column_store.rb +56 -10
- data/test/test_data_mapper.rb +67 -1
- metadata +58 -47
- data/lib/padrino-admin/adapters.rb +0 -108
- data/lib/padrino-admin/adapters/dm.rb +0 -147
- data/lib/padrino-admin/ext_js/config.rb +0 -186
- data/test/fixtures/test_generic.jml +0 -7
- data/test/fixtures/test_javascript.jml +0 -81
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
@@ -23,4 +23,7 @@ Ext.util.Format.eurMoney=function(v){v=(Math.round((v-0)*100))/100;v=(v==Math.fl
|
|
23
23
|
}var hh=da[1].split(":");this.setTime(hh[0]+":"+hh[1])}}},setVisible:function(visible){if(visible){this.df.show();this.tf.show()}else{this.df.hide();this.tf.hide()}return this},show:function(){return this.setVisible(true)},hide:function(){return this.setVisible(false)},updateDate:function(){var d=this.df.getValue();if(d){if(!(this.dateValue instanceof Date)){this.initDateValue();if(!this.tf.getValue()){this.setTime(this.dateValue)}}this.dateValue.setMonth(0);this.dateValue.setFullYear(d.getFullYear());this.dateValue.setMonth(d.getMonth());this.dateValue.setDate(d.getDate())}else{this.dateValue="";this.setTime("")}},updateTime:function(){var t=this.tf.getValue();if(t&&!(t instanceof Date)){t=Date.parseDate(t,this.tf.format)}if(t&&!this.df.getValue()){this.initDateValue();this.setDate(this.dateValue)}if(this.dateValue instanceof Date){if(t){this.dateValue.setHours(t.getHours());this.dateValue.setMinutes(t.getMinutes());this.dateValue.setSeconds(t.getSeconds())}else{this.dateValue.setHours(0);this.dateValue.setMinutes(0);this.dateValue.setSeconds(0)}}},updateHidden:function(){if(this.isRendered){var value=this.dateValue instanceof Date?this.dateValue.format(this.hiddenFormat):"";this.el.dom.value=value}},updateValue:function(){this.updateDate();this.updateTime();this.updateHidden();return},validate:function(){return this.df.validate()&&this.tf.validate()},renderer:function(field){var format=field.editor.dateFormat||Ext.form.DateTime.prototype.dateFormat;format+=" "+(field.editor.timeFormat||Ext.form.DateTime.prototype.timeFormat);var renderer=function(val){var retval=Ext.util.Format.date(val,format);return retval};return renderer}});Ext.reg("datetimefield",Ext.form.DateTimeField);Ext.grid.Search=function(config){Ext.apply(this,config);Ext.grid.Search.superclass.constructor.call(this)};Ext.extend(Ext.grid.Search,Ext.util.Observable,{autoFocus:true,searchText:"Search",searchTipText:"Insert a word or press Search",selectAllText:"Select All",position:"top",iconCls:"check",checkIndexes:"all",disableIndexes:[],dateFormat:undefined,showSelectAll:true,menuStyle:"checkbox",minCharsTipText:"Insert at least {0} characters",mode:"remote",width:200,xtype:"gridsearch",paramNames:{fields:"fields",query:"query"},shortcutKey:"r",shortcutModifier:"alt",align:"right",minLength:3,init:function(grid){this.grid=grid;this.id=this.grid.id+"-search";if("string"===typeof this.toolbarContainer){this.toolbarContainer=Ext.getCmp(this.toolbarContainer)}grid.store.load=grid.store.load.createInterceptor(this.load,this);grid.onRender=grid.onRender.createSequence(this.onRender,this);grid.reconfigure=grid.reconfigure.createSequence(this.reconfigure,this)},onRender:function(){var panel=this.toolbarContainer||this.grid;var tb="bottom"===this.position?panel.bottomToolbar:panel.topToolbar;this.menu=new Ext.menu.Menu();if("right"===this.align){tb.addFill()}else{if(0<tb.items.getCount()){tb.addSeparator()}}tb.add({text:this.searchText,menu:this.menu});this.field=new Ext.form.TwinTriggerField({width:this.width,selectOnFocus:undefined===this.selectOnFocus?true:this.selectOnFocus,trigger1Class:"x-form-clear-trigger",trigger2Class:this.minChars?"x-hidden":"x-form-search-trigger",onTrigger1Click:this.minChars?Ext.emptyFn:this.onTriggerClear.createDelegate(this),onTrigger2Click:this.onTriggerSearch.createDelegate(this),minLength:this.minLength});this.field.on("render",function(){this.field.el.dom.qtip=this.minChars?String.format(this.minCharsTipText,this.minChars):this.searchTipText;if(this.minChars){this.field.el.on({scope:this,buffer:300,keyup:this.onKeyUp})}var map=new Ext.KeyMap(this.field.el,[{key:Ext.EventObject.ENTER,scope:this,fn:this.onTriggerSearch},{key:Ext.EventObject.ESC,scope:this,fn:this.onTriggerClear}]);map.stopEvent=true},this,{single:true});tb.add(this.field);this.initState();if(this.shortcutKey&&this.shortcutModifier){var shortcutEl=this.grid.getEl();var shortcutCfg=[{key:this.shortcutKey,scope:this,stopEvent:true,fn:function(){this.field.focus()}}];shortcutCfg[0][this.shortcutModifier]=true;this.keymap=new Ext.KeyMap(shortcutEl,shortcutCfg)}if(true===this.autoFocus){this.grid.store.on({scope:this,load:function(){this.field.focus()}})}},initState:function(){if(Ext.state.Manager){var state=Ext.state.Manager.get(this.id);this.applyState(state)}},applyState:function(state){if(state){if(state.checked&&state.checked instanceof Array){this.checkIndexes=state.checked}if(state.value){this.field.setValue(state.value)}}this.reconfigure();this.onTriggerSearch()},saveState:function(){if(Ext.state.Manager){var state=this.getState();Ext.state.Manager.set(this.id,state)}},getState:function(){var checked=[];this.menu.items.each(function(item){if(item.dataIndex&&item.checked){checked.push(item.dataIndex)}});this.inited=true;return{value:this.field.getValue(),checked:checked}},load:function(){return(this.field!=undefined&&this.inited==true)},onKeyUp:function(){var length=this.field.getValue().toString().length;if(0===length||this.minChars<=length){this.onTriggerSearch()}},onTriggerClear:function(){if(this.field.getValue()){this.field.setValue("");this.field.focus();this.onTriggerSearch()}this.saveState()},onTriggerSearch:function(){if(!this.field.isValid()){return}var val=this.field.getValue();var store=this.grid.store;if("local"===this.mode){store.clearFilter();if(val){store.filterBy(function(r){var retval=false;this.menu.items.each(function(item){if(!item.checked||retval){return}var rv=r.get(item.dataIndex);rv=rv instanceof Date?rv.format(this.dateFormat||r.fields.get(item.dataIndex).dateFormat):rv;var re=new RegExp(val,"gi");retval=re.test(rv)},this);if(retval){return true}return retval},this)}else{}}else{if(store.lastOptions&&store.lastOptions.params){store.lastOptions.params[store.paramNames.start]=0}var fields=[];this.menu.items.each(function(item){if(item.checked&&item.dataIndex){fields.push(item.dataIndex)}});delete (store.baseParams[this.paramNames.fields]);delete (store.baseParams[this.paramNames.query]);if(store.lastOptions&&store.lastOptions.params){delete (store.lastOptions.params[this.paramNames.fields]);delete (store.lastOptions.params[this.paramNames.query])}if(fields.length){store.baseParams[this.paramNames.fields]=fields.compact().join();store.baseParams[this.paramNames.query]=val}store.reload()}this.saveState()},setDisabled:function(){this.field.setDisabled.apply(this.field,arguments)},enable:function(){this.setDisabled(false)},disable:function(){this.setDisabled(true)},reconfigure:function(){var menu=this.menu;menu.removeAll();if(this.showSelectAll&&"radio"!==this.menuStyle){menu.add(new Ext.menu.CheckItem({text:this.selectAllText,checked:!(this.checkIndexes instanceof Array),hideOnClick:false,handler:function(item){var checked=!item.checked;item.parentMenu.items.each(function(i){if(item!==i&&i.setChecked&&!i.disabled){i.setChecked(checked)}})}}),"-")}var cm=this.grid.colModel;var group=undefined;if("radio"===this.menuStyle){group="g"+(new Date).getTime()}Ext.each(cm.config,function(config){var disable=false;if(config.header&&config.dataIndex&&config.sortable){Ext.each(this.disableIndexes,function(item){disable=disable?disable:item===config.dataIndex});if(!disable){menu.add(new Ext.menu.CheckItem({text:config.header,hideOnClick:false,group:group,checked:"all"===this.checkIndexes,dataIndex:config.dataIndex}))}}},this);if(this.checkIndexes instanceof Array){Ext.each(this.checkIndexes,function(di){var item=menu.items.find(function(itm){return itm.dataIndex===di});if(item){item.setChecked(true,true)}},this)}if(this.readonlyIndexes instanceof Array){Ext.each(this.readonlyIndexes,function(di){var item=menu.items.find(function(itm){return itm.dataIndex===di});if(item){item.disable()}},this)}}});Ext.state.DataBaseProvider=function(config){Ext.state.DataBaseProvider.superclass.constructor.call(this);this.path="/admin/state_sessions";Ext.apply(this,config);this.state=this.readCookies()};Ext.extend(Ext.state.DataBaseProvider,Ext.state.Provider,{set:function(name,value){if(typeof value=="undefined"||value===null){this.clear(name);
|
24
24
|
return}this.setCookie(name,value);Ext.state.DataBaseProvider.superclass.set.call(this,name,value)},clear:function(name){this.clearCookie(name);Ext.state.DataBaseProvider.superclass.clear.call(this,name)},readCookies:function(){var cookies={};var values=[];new Ajax.Request(this.path,{method:"GET",asynchronous:false,onSuccess:function(response,request){values=Ext.decode(response.responseText)}});values.each(function(f){if(f.state_session&&f.state_session.component&&f.state_session.component.substring(0,3)=="ys-"){cookies[f.state_session.component.substr(3)]=this.decodeValue(f.state_session.data)}},this);return cookies},setCookie:function(name,value){Ext.Ajax.request({url:this.path,method:"POST",params:{id:"ys-"+name,data:this.encodeValue(value)}})},clearCookie:function(name){Ext.Ajax.request({url:this.path+"/ys-"+name,method:"DELETE"})}});
|
25
25
|
/*Fix for stack overflow*/
|
26
|
-
(function(){var eDefer=Function.prototype.defer;Function.prototype.defer=function(){var args=arguments,L=args.length;if(L==0||(L==1&&args[0]==1)){return this.delay.curry(0.01).apply(this,args)}return eDefer.apply(this,args)}})();
|
26
|
+
(function(){var eDefer=Function.prototype.defer;Function.prototype.defer=function(){var args=arguments,L=args.length;if(L==0||(L==1&&args[0]==1)){return this.delay.curry(0.01).apply(this,args)}return eDefer.apply(this,args)}})();
|
27
|
+
/*Upload Panel*/
|
28
|
+
Ext.SwfUploadPanel=Ext.extend(Ext.grid.GridPanel,{strings:{text_add:"Add File(s)",text_upload:"Upload File(s)",text_cancel:"Cancel Upload",text_clear:"Clear Queue",text_progressbar:"Progress Bar",text_remove:"Remove File",text_remove_sure:"Are you sure you wish to remove this file from queue?",text_error:"Error",text_uploading:"Uploading file: {0} ({1} of {2})",header_filename:"Filename",header_size:"Size",header_status:"Status",status:{0:"Queued",1:"Uploading...",2:"Completed",3:"Error",4:"Cancelled"},error_queue_exceeded:"The selected file(s) exceed(s) the maximum number of {0} queued files.",error_queue_slots_0:"There is no slot left",error_queue_slots_1:"There is only one slot left",error_queue_slots_2:"There are only {0} slots left",error_size_exceeded:"The selected files size exceeds the allowed limit of 1 MB.",error_zero_byte_file:"Zero byte file selected.",error_invalid_filetype:"Invalid filetype selected.",error_file_not_found:"File not found 404.",error_security_error:"Security Error. Not allowed to post to different url."},single_select:true,confirm_delete:true,file_types:"*.*",file_types_description:"All Files",file_size_limit:"1MB",file_upload_limit:"0",file_queue_limit:"0",file_post_name:"file",flash_url:"swfupload.swf",debug:false,autoExpandColumn:"name",enableColumnResize:false,enableColumnMove:false,border:false,viewConfig:{forceFit:true},upload_cancelled:false,initComponent:function(){this.addEvents("swfUploadLoaded","fileQueued","startUpload","fileUploadError","fileUploadSuccess","fileUploadComplete","allUploadsComplete","removeFiles","removeAllFiles");this.rec=Ext.data.Record.create([{name:"name"},{name:"size"},{name:"id"},{name:"type"},{name:"creationdate",type:"date",dateFormat:"m/d/Y"},{name:"status"}]);this.store=new Ext.data.Store({reader:new Ext.data.JsonReader({id:"id"},this.rec)});this.columns=[{id:"name",header:this.strings.header_filename,dataIndex:"name"},{id:"size",header:this.strings.header_size,width:80,dataIndex:"size",renderer:this.formatBytes},{id:"status",header:this.strings.header_status,width:100,dataIndex:"status",renderer:this.formatStatus.createDelegate(this)},{id:"progress",header:"Progess",width:150,renderer:this.formatProgressBar}];this.sm=new Ext.grid.RowSelectionModel({singleSelect:this.single_select});this.tbar=[{text:this.strings.text_add,cls:"x-btn-text-icon add",xhandler:function(){if(this.single_select){this.suo.selectFile()}else{this.suo.selectFiles()}},xscope:this,listeners:{render:function(){this.initButton()},scope:this}},"->",{text:this.strings.text_cancel,cls:"x-btn-text-icon remove",handler:this.stopUpload,scope:this,hidden:true},{text:this.strings.text_upload,cls:"x-btn-text-icon upload",handler:this.startUpload,scope:this,hidden:true},{text:this.strings.text_clear,cls:"x-btn-text-icon remove",handler:this.removeAllFiles,scope:this,hidden:false}];this.addListener({keypress:{fn:function(e){if(this.confirm_delete){if(e.getKey()==e.DELETE){Ext.MessageBox.confirm(this.strings.text_remove,this.strings.text_remove_sure,function(e){if(e=="yes"){this.removeFiles()}},this)}}else{this.removeFiles(this)}},scope:this},contextmenu:function(e){e.stopEvent()},render:function(){this.addBtn=this.getTopToolbar().items.items[0];this.cancelBtn=this.getTopToolbar().items.items[2];this.uploadBtn=this.getTopToolbar().items.items[3];this.clearBtn=this.getTopToolbar().items.items[4]}});Ext.SwfUploadPanel.superclass.initComponent.call(this)},initButton:function(){var suoID=Ext.id();var em=this.addBtn.el.child("em");em.setStyle({position:"relative",display:"block"});em.createChild({tag:"div",id:suoID});this.suo=new SWFUpload({button_placeholder_id:suoID,button_width:em.getWidth(),button_height:em.getHeight(),button_cursor:SWFUpload.CURSOR.HAND,button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,upload_url:this.upload_url,post_params:this.post_params,file_post_name:this.file_post_name,file_size_limit:this.file_size_limit,file_queue_limit:this.file_queue_limit,file_types:this.file_types,file_types_description:this.file_types_description,file_upload_limit:this.file_upload_limit,flash_url:this.flash_url,swfupload_loaded_handler:this.swfUploadLoaded.createDelegate(this),file_dialog_start_handler:this.fileDialogStart.createDelegate(this),file_queued_handler:this.fileQueue.createDelegate(this),file_queue_error_handler:this.fileQueueError.createDelegate(this),file_dialog_complete_handler:this.fileDialogComplete.createDelegate(this),upload_start_handler:this.uploadStart.createDelegate(this),upload_progress_handler:this.uploadProgress.createDelegate(this),upload_error_handler:this.uploadError.createDelegate(this),upload_success_handler:this.uploadSuccess.createDelegate(this),upload_complete_handler:this.uploadComplete.createDelegate(this),debug:this.debug,debug_handler:this.debug?this.debugHandler:Ext.emptyFn});Ext.get(this.suo.movieName).setStyle({position:"absolute",top:0,left:0})},formatProgressBar:function(_v,cellmeta,record){switch(record.data.fileState){case SWFUpload.FILE_STATUS.COMPLETE:if(Ext.isIE){returnValue='<div class="x-progress-wrap" style="height: 18px"><div class="x-progress-inner"><div style="width: 100%;" class="x-progress-bar x-progress-text">100 %';"</div></div></div>"}else{returnValue='<div class="x-progress-wrap" style="height: 18px"><div class="x-progress-inner"><div id="progressBar_'+record.data.id+'" style="width: 100%;" class="x-progress-bar"></div><div id="progressText_'+record.data.id+'" style="width: 100%;" class="x-progress-text x-progress-text-back" />100 %</div>';"</div></div>"}break;default:returnValue='<div class="x-progress-wrap" style="height: 18px"><div class="x-progress-inner"><div id="progressBar_'+record.data.id+'" style="width: 0%;" class="x-progress-bar"></div><div id="progressText_'+record.data.id+'" style="width: 100%;" class="x-progress-text x-progress-text-back" />0 %</div>';"</div></div>";break}return returnValue},debugHandler:function(line){console.log(line)},formatStatus:function(status){return this.strings.status[status]},formatBytes:function(size){if(!size){size=0}var suffix=["B","KB","MB","GB"];var result=size;size=parseInt(size,10);result=size+" "+suffix[0];var loop=0;while(size/1024>1){size=size/1024;loop++}result=Math.round(size)+" "+suffix[loop];return result;if(isNaN(bytes)){return("")}var unit,val;if(bytes<999){unit="B";val=(!bytes&&this.progressRequestCount>=1)?"~":bytes}else{if(bytes<999999){unit="kB";val=Math.round(bytes/1000)}else{if(bytes<999999999){unit="MB";val=Math.round(bytes/100000)/10}else{if(bytes<999999999999){unit="GB";val=Math.round(bytes/100000000)/10}else{unit="TB";val=Math.round(bytes/100000000000)/10}}}}return(val+" "+unit)},swfUploadLoaded:function(){if(this.debug){console.info("SWFUPLOAD LOADED")}this.fireEvent("swfUploadLoaded",this)},fileDialogStart:function(){if(this.debug){console.info("FILE DIALOG START")}this.fireEvent("fileDialogStart",this)},fileQueue:function(file){if(this.debug){console.info("FILE QUEUE")}file.status=0;r=new this.rec(file);r.id=file.id;this.store.add(r);this.fireEvent("fileQueued",this,file)},fileQueueError:function(file,code,message){if(this.debug){console.info("FILE QUEUE ERROR")}switch(code){case -100:var slots;switch(message){case"0":slots=this.strings.error_queue_slots_0;break;case"1":slots=this.strings.error_queue_slots_1;break;default:slots=String.format(this.strings.error_queue_slots_2,message)}Ext.MessageBox.alert(this.strings.text_error,String.format(this.strings.error_queue_exceeded+" "+slots,this.file_queue_limit));break;case -110:Ext.MessageBox.alert(this.strings.text_error,String.format(this.strings.error_size_exceeded,this.formatBytes(this.file_size_limit*1024)));break;case -120:Ext.MessageBox.alert(this.strings.text_error,this.strings.error_zero_byte_file);break;case -130:Ext.MessageBox.alert(this.strings.text_error,this.strings.error_invalid_filetype);break}this.fireEvent("fileQueueError",this,file,code)},fileDialogComplete:function(file_count){if(this.debug){console.info("FILE DIALOG COMPLETE")}if(file_count>0){this.uploadBtn.show()
|
29
|
+
}this.addBtn.show();this.clearBtn.show();this.fireEvent("fileDialogComplete",this,file_count)},uploadStart:function(file){if(this.debug){console.info("UPLOAD START")}this.fireEvent("uploadStart",this,file);return true},progressCount:0,uploadProgress:function(file,bytes_completed,bytes_total){var percent=Math.ceil((bytes_completed/bytes_total)*100);if(percent!=this.progressCount){Ext.getDom("progressBar_"+file.id).style.width=percent+"%";Ext.getDom("progressText_"+file.id).innerHTML=percent+" %";this.progressCount=percent}this.store.getById(file.id).set("status",1);this.fireEvent("uploadProgress",this,file,bytes_completed,bytes_total)},uploadError:function(file,error,code){if(this.debug){console.info("UPLOAD ERROR")}if(code==500){Ext.MessageBox.alert(this.strings.text_error,"File too big");this.fireEvent("fileUploadError",this,file,error,code);return}switch(error){case -200:Ext.MessageBox.alert(this.strings.text_error,this.strings.error_file_not_found);break;case -230:Ext.MessageBox.alert(this.strings.text_error,this.strings.error_security_error);break;case -290:this.store.getById(file.id).set("status",4);this.store.getById(file.id).commit();break}this.fireEvent("fileUploadError",this,file,error,code)},uploadSuccess:function(file,response){if(this.debug){console.info("UPLOAD SUCCESS")}var data=Ext.decode(response);if(data.success){this.store.getById(file.id).data.fileState=SWFUpload.FILE_STATUS.COMPLETE;this.store.getById(file.id).set("status",2)}else{this.store.getById(file.id).set("status",3);this.store.getById(file.id).commit();if(data.msg){Ext.MessageBox.alert(this.strings.text_error,data.msg)}}this.fireEvent("fileUploadSuccess",this,file,data)},uploadComplete:function(file){if(this.debug){console.info("UPLOAD COMPLETE")}if(this.suo.getStats().files_queued&&!this.upload_cancelled){this.suo.startUpload()}else{this.fireEvent("fileUploadComplete",this,file);this.allUploadsComplete()}},allUploadsComplete:function(){this.cancelBtn.hide();this.addBtn.show();this.clearBtn.show();this.fireEvent("allUploadsComplete",this)},addPostParam:function(name,value){if(this.suo){this.suo.settings.post_params[name]=value;this.suo.setPostParams(this.suo.settings.post_params)}else{this.post_params[name]=value}},startUpload:function(){if(this.debug){console.info("START UPLOAD")}this.cancelBtn.show();this.uploadBtn.hide();this.clearBtn.hide();this.upload_cancelled=false;this.fireEvent("startUpload",this);this.suo.startUpload()},stopUpload:function(file){if(this.debug){console.info("STOP UPLOAD")}this.suo.stopUpload();this.upload_cancelled=true;this.getStore().each(function(){if(this.data.status==1){this.set("status",0);this.commit()}});this.cancelBtn.hide();if(this.suo.getStats().files_queued>0){this.uploadBtn.show()}this.addBtn.show();this.clearBtn.show()},removeFiles:function(){if(this.debug){console.info("REMOVE FILES")}var selRecords=this.getSelections();for(var i=0;i<selRecords.length;i++){if(selRecords[i].data.status!=1){this.suo.cancelUpload(selRecords[i].id);this.store.remove(selRecords[i])}}if(this.suo.getStats().files_queued===0){this.uploadBtn.hide()}this.fireEvent("removeFiles",this)},removeAllFiles:function(){if(this.debug){console.info("REMOVE ALL")}var files_left=this.suo.getStats().files_queued;while(files_left>0){this.suo.cancelUpload();files_left=this.suo.getStats().files_queued}this.store.removeAll();this.cancelBtn.hide();this.uploadBtn.hide();this.fireEvent("removeAllFiles",this)}});
|
@@ -0,0 +1,4 @@
|
|
1
|
+
var SWFUpload;if(SWFUpload==undefined){SWFUpload=function(settings){this.initSWFUpload(settings)}}SWFUpload.prototype.initSWFUpload=function(userSettings){try{this.customSettings={};this.settings={};this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings(userSettings);this.loadFlash();this.displayDebugInfo()}catch(ex){delete SWFUpload.instances[this.movieName];throw ex}};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.5.0 2009-12-23 Beta 1";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290,RESIZE:-300};SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};SWFUpload.UPLOAD_TYPE={NORMAL:-1,RESIZED:-2};SWFUpload.BUTTON_ACTION={SELECT_FILE:-100,SELECT_FILES:-110,START_UPLOAD:-120,JAVASCRIPT:-130,NONE:-130};SWFUpload.CURSOR={ARROW:-1,HAND:-2};SWFUpload.WINDOW_MODE={WINDOW:"window",TRANSPARENT:"transparent",OPAQUE:"opaque"};SWFUpload.RESIZE_ENCODING={JPEG:-1,PNG:-2};SWFUpload.completeURL=function(url){try{var path="",indexSlash=-1;if(typeof(url)!=="string"||url.match(/^https?:\/\//i)||url.match(/^\//)||url===""){return url}indexSlash=window.location.pathname.lastIndexOf("/");if(indexSlash<=0){path="/"}else{path=window.location.pathname.substr(0,indexSlash)+"/"}return path+url}catch(ex){return url}};SWFUpload.prototype.initSettings=function(userSettings){this.ensureDefault=function(settingName,defaultValue){var setting=userSettings[settingName];if(setting!=undefined){this.settings[settingName]=setting}else{this.settings[settingName]=defaultValue}};this.ensureDefault("upload_url","");this.ensureDefault("preserve_relative_urls",false);this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("http_success",[]);this.ensureDefault("assume_success_timeout",0);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload.swf");this.ensureDefault("prevent_swf_caching",true);this.ensureDefault("button_image_url","");this.ensureDefault("button_width",1);this.ensureDefault("button_height",1);this.ensureDefault("button_text","");this.ensureDefault("button_text_style","color: #000000; font-size: 16pt;");this.ensureDefault("button_text_top_padding",0);this.ensureDefault("button_text_left_padding",0);this.ensureDefault("button_action",SWFUpload.BUTTON_ACTION.SELECT_FILES);this.ensureDefault("button_disabled",false);this.ensureDefault("button_placeholder_id","");this.ensureDefault("button_placeholder",null);this.ensureDefault("button_cursor",SWFUpload.CURSOR.ARROW);this.ensureDefault("button_window_mode",SWFUpload.WINDOW_MODE.WINDOW);this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("mouse_click_handler",null);this.ensureDefault("mouse_out_handler",null);this.ensureDefault("mouse_over_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;if(!!this.settings.prevent_swf_caching){this.settings.flash_url=this.settings.flash_url+(this.settings.flash_url.indexOf("?")<0?"?":"&")+"preventswfcaching="+new Date().getTime()}if(!this.settings.preserve_relative_urls){this.settings.upload_url=SWFUpload.completeURL(this.settings.upload_url);this.settings.button_image_url=SWFUpload.completeURL(this.settings.button_image_url)}delete this.ensureDefault};SWFUpload.prototype.loadFlash=function(){var targetElement,tempParent,wrapperType;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added"}targetElement=document.getElementById(this.settings.button_placeholder_id)||this.settings.button_placeholder;if(targetElement==undefined){throw"Could not find the placeholder element: "+this.settings.button_placeholder_id}wrapperType=(targetElement.currentStyle&&targetElement.currentStyle.display||window.getComputedStyle&&document.defaultView.getComputedStyle(targetElement,null).getPropertyValue("display"))!=="block"?"span":"div";tempParent=document.createElement(wrapperType);tempParent.innerHTML=this.getFlashHTML();var els=tempParent.getElementsByTagName("object");if(!els||els.length>1||els.length===0){}else{if(els.length===1){this.movieElement=els[0]}}targetElement.parentNode.replaceChild(tempParent.firstChild,targetElement);if(window[this.movieName]==undefined){window[this.movieName]=this.getMovieElement()}};SWFUpload.prototype.getFlashHTML=function(){return['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="',this.settings.button_width,'" height="',this.settings.button_height,'" class="swfupload">','<param name="wmode" value="',this.settings.button_window_mode,'" />','<param name="movie" value="',this.settings.flash_url,'" />','<param name="quality" value="high" />','<param name="allowScriptAccess" value="always" />','<param name="flashvars" value="'+this.getFlashVars()+'" />',"</object>"].join("")};SWFUpload.prototype.getFlashVars=function(){var httpSuccessString,paramString;paramString=this.buildParamString();httpSuccessString=this.settings.http_success.join(",");return["movieName=",encodeURIComponent(this.movieName),"&uploadURL=",encodeURIComponent(this.settings.upload_url),"&useQueryString=",encodeURIComponent(this.settings.use_query_string),"&requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&httpSuccess=",encodeURIComponent(httpSuccessString),"&assumeSuccessTimeout=",encodeURIComponent(this.settings.assume_success_timeout),"&params=",encodeURIComponent(paramString),"&filePostName=",encodeURIComponent(this.settings.file_post_name),"&fileTypes=",encodeURIComponent(this.settings.file_types),"&fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&debugEnabled=",encodeURIComponent(this.settings.debug_enabled),"&buttonImageURL=",encodeURIComponent(this.settings.button_image_url),"&buttonWidth=",encodeURIComponent(this.settings.button_width),"&buttonHeight=",encodeURIComponent(this.settings.button_height),"&buttonText=",encodeURIComponent(this.settings.button_text),"&buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),"&buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),"&buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),"&buttonAction=",encodeURIComponent(this.settings.button_action),"&buttonDisabled=",encodeURIComponent(this.settings.button_disabled),"&buttonCursor=",encodeURIComponent(this.settings.button_cursor)].join("")
|
2
|
+
};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName)}if(this.movieElement===null){throw"Could not find Flash element"}return this.movieElement};SWFUpload.prototype.buildParamString=function(){var name,postParams,paramStringPairs=[];postParams=this.settings.post_params;if(typeof(postParams)==="object"){for(name in postParams){if(postParams.hasOwnProperty(name)){paramStringPairs.push(encodeURIComponent(name.toString())+"="+encodeURIComponent(postParams[name].toString()))}}}return paramStringPairs.join("&")};SWFUpload.prototype.destroy=function(){var movieElement;try{this.cancelUpload(null,false);this.callFlash("StopExternalInterfaceCheck");movieElement=this.cleanUp();if(movieElement){try{movieElement.parentNode.removeChild(movieElement)}catch(ex){}}window[this.movieName]=null;SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];this.movieElement=null;this.settings=null;this.customSettings=null;this.eventQueue=null;this.movieName=null;return true}catch(ex2){return false}};SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n","\t","upload_url: ",this.settings.upload_url,"\n","\t","flash_url: ",this.settings.flash_url,"\n","\t","use_query_string: ",this.settings.use_query_string.toString(),"\n","\t","requeue_on_error: ",this.settings.requeue_on_error.toString(),"\n","\t","http_success: ",this.settings.http_success.join(", "),"\n","\t","assume_success_timeout: ",this.settings.assume_success_timeout,"\n","\t","file_post_name: ",this.settings.file_post_name,"\n","\t","post_params: ",this.settings.post_params.toString(),"\n","\t","file_types: ",this.settings.file_types,"\n","\t","file_types_description: ",this.settings.file_types_description,"\n","\t","file_size_limit: ",this.settings.file_size_limit,"\n","\t","file_upload_limit: ",this.settings.file_upload_limit,"\n","\t","file_queue_limit: ",this.settings.file_queue_limit,"\n","\t","debug: ",this.settings.debug.toString(),"\n","\t","prevent_swf_caching: ",this.settings.prevent_swf_caching.toString(),"\n","\t","button_placeholder_id: ",this.settings.button_placeholder_id.toString(),"\n","\t","button_placeholder: ",(this.settings.button_placeholder?"Set":"Not Set"),"\n","\t","button_image_url: ",this.settings.button_image_url.toString(),"\n","\t","button_width: ",this.settings.button_width.toString(),"\n","\t","button_height: ",this.settings.button_height.toString(),"\n","\t","button_text: ",this.settings.button_text.toString(),"\n","\t","button_text_style: ",this.settings.button_text_style.toString(),"\n","\t","button_text_top_padding: ",this.settings.button_text_top_padding.toString(),"\n","\t","button_text_left_padding: ",this.settings.button_text_left_padding.toString(),"\n","\t","button_action: ",this.settings.button_action.toString(),"\n","\t","button_disabled: ",this.settings.button_disabled.toString(),"\n","\t","custom_settings: ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n","\t","swfupload_loaded_handler assigned: ",(typeof this.settings.swfupload_loaded_handler==="function").toString(),"\n","\t","mouse_click_handler assigned: ",(typeof this.settings.mouse_click_handler==="function").toString(),"\n","\t","mouse_over_handler assigned: ",(typeof this.settings.mouse_over_handler==="function").toString(),"\n","\t","mouse_out_handler assigned: ",(typeof this.settings.mouse_out_handler==="function").toString(),"\n","\t","file_dialog_start_handler assigned: ",(typeof this.settings.file_dialog_start_handler==="function").toString(),"\n","\t","file_queued_handler assigned: ",(typeof this.settings.file_queued_handler==="function").toString(),"\n","\t","file_queue_error_handler assigned: ",(typeof this.settings.file_queue_error_handler==="function").toString(),"\n","\t","upload_start_handler assigned: ",(typeof this.settings.upload_start_handler==="function").toString(),"\n","\t","upload_progress_handler assigned: ",(typeof this.settings.upload_progress_handler==="function").toString(),"\n","\t","upload_error_handler assigned: ",(typeof this.settings.upload_error_handler==="function").toString(),"\n","\t","upload_success_handler assigned: ",(typeof this.settings.upload_success_handler==="function").toString(),"\n","\t","upload_complete_handler assigned: ",(typeof this.settings.upload_complete_handler==="function").toString(),"\n","\t","debug_handler assigned: ",(typeof this.settings.debug_handler==="function").toString(),"\n"].join(""))};SWFUpload.prototype.addSetting=function(name,value,default_value){if(value==undefined){return(this.settings[name]=default_value)}else{return(this.settings[name]=value)}};SWFUpload.prototype.getSetting=function(name){if(this.settings[name]!=undefined){return this.settings[name]}return""};SWFUpload.prototype.callFlash=function(functionName,argumentArray){var movieElement,returnValue,returnString;argumentArray=argumentArray||[];movieElement=this.getMovieElement();try{if(movieElement!=undefined){returnString=movieElement.CallFunction('<invoke name="'+functionName+'" returntype="javascript">'+__flash__argumentsToXML(argumentArray,0)+"</invoke>");returnValue=eval(returnString)}else{this.debug("Can't call flash because the movie wasn't found.")}}catch(ex){this.debug("Exception calling flash function '"+functionName+"': "+ex.message)}if(returnValue!=undefined&&typeof returnValue.post==="object"){returnValue=this.unescapeFilePostParams(returnValue)}return returnValue};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile")};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles")};SWFUpload.prototype.startUpload=function(fileID){this.callFlash("StartUpload",[fileID])};SWFUpload.prototype.startResizedUpload=function(fileID,width,height,encoding,quality){this.callFlash("StartUpload",[fileID,{width:width,height:height,encoding:encoding,quality:quality}])};SWFUpload.prototype.cancelUpload=function(fileID,triggerErrorEvent){if(triggerErrorEvent!==false){triggerErrorEvent=true}this.callFlash("CancelUpload",[fileID,triggerErrorEvent])};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload")};SWFUpload.prototype.requeueUpload=function(indexOrFileID){return this.callFlash("RequeueUpload",[indexOrFileID])};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats")};SWFUpload.prototype.setStats=function(statsObject){this.callFlash("SetStats",[statsObject])};SWFUpload.prototype.getFile=function(fileID){if(typeof(fileID)==="number"){return this.callFlash("GetFileByIndex",[fileID])}else{return this.callFlash("GetFile",[fileID])}};SWFUpload.prototype.getQueueFile=function(fileID){if(typeof(fileID)==="number"){return this.callFlash("GetFileByQueueIndex",[fileID])}else{return this.callFlash("GetFile",[fileID])}};SWFUpload.prototype.addFileParam=function(fileID,name,value){return this.callFlash("AddFileParam",[fileID,name,value])};SWFUpload.prototype.removeFileParam=function(fileID,name){this.callFlash("RemoveFileParam",[fileID,name])};SWFUpload.prototype.setUploadURL=function(url){this.settings.upload_url=url.toString();this.callFlash("SetUploadURL",[url])};SWFUpload.prototype.setPostParams=function(paramsObject){this.settings.post_params=paramsObject;this.callFlash("SetPostParams",[paramsObject])};SWFUpload.prototype.addPostParam=function(name,value){this.settings.post_params[name]=value;this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.removePostParam=function(name){delete this.settings.post_params[name];this.callFlash("SetPostParams",[this.settings.post_params])
|
3
|
+
};SWFUpload.prototype.setFileTypes=function(types,description){this.settings.file_types=types;this.settings.file_types_description=description;this.callFlash("SetFileTypes",[types,description])};SWFUpload.prototype.setFileSizeLimit=function(fileSizeLimit){this.settings.file_size_limit=fileSizeLimit;this.callFlash("SetFileSizeLimit",[fileSizeLimit])};SWFUpload.prototype.setFileUploadLimit=function(fileUploadLimit){this.settings.file_upload_limit=fileUploadLimit;this.callFlash("SetFileUploadLimit",[fileUploadLimit])};SWFUpload.prototype.setFileQueueLimit=function(fileQueueLimit){this.settings.file_queue_limit=fileQueueLimit;this.callFlash("SetFileQueueLimit",[fileQueueLimit])};SWFUpload.prototype.setFilePostName=function(filePostName){this.settings.file_post_name=filePostName;this.callFlash("SetFilePostName",[filePostName])};SWFUpload.prototype.setUseQueryString=function(useQueryString){this.settings.use_query_string=useQueryString;this.callFlash("SetUseQueryString",[useQueryString])};SWFUpload.prototype.setRequeueOnError=function(requeueOnError){this.settings.requeue_on_error=requeueOnError;this.callFlash("SetRequeueOnError",[requeueOnError])};SWFUpload.prototype.setHTTPSuccess=function(http_status_codes){if(typeof http_status_codes==="string"){http_status_codes=http_status_codes.replace(" ","").split(",")}this.settings.http_success=http_status_codes;this.callFlash("SetHTTPSuccess",[http_status_codes])};SWFUpload.prototype.setAssumeSuccessTimeout=function(timeout_seconds){this.settings.assume_success_timeout=timeout_seconds;this.callFlash("SetAssumeSuccessTimeout",[timeout_seconds])};SWFUpload.prototype.setDebugEnabled=function(debugEnabled){this.settings.debug_enabled=debugEnabled;this.callFlash("SetDebugEnabled",[debugEnabled])};SWFUpload.prototype.setButtonImageURL=function(buttonImageURL){if(buttonImageURL==undefined){buttonImageURL=""}this.settings.button_image_url=buttonImageURL;this.callFlash("SetButtonImageURL",[buttonImageURL])};SWFUpload.prototype.setButtonDimensions=function(width,height){this.settings.button_width=width;this.settings.button_height=height;var movie=this.getMovieElement();if(movie!=undefined){movie.style.width=width+"px";movie.style.height=height+"px"}this.callFlash("SetButtonDimensions",[width,height])};SWFUpload.prototype.setButtonText=function(html){this.settings.button_text=html;this.callFlash("SetButtonText",[html])};SWFUpload.prototype.setButtonTextPadding=function(left,top){this.settings.button_text_top_padding=top;this.settings.button_text_left_padding=left;this.callFlash("SetButtonTextPadding",[left,top])};SWFUpload.prototype.setButtonTextStyle=function(css){this.settings.button_text_style=css;this.callFlash("SetButtonTextStyle",[css])};SWFUpload.prototype.setButtonDisabled=function(isDisabled){this.settings.button_disabled=isDisabled;this.callFlash("SetButtonDisabled",[isDisabled])};SWFUpload.prototype.setButtonAction=function(buttonAction){this.settings.button_action=buttonAction;this.callFlash("SetButtonAction",[buttonAction])};SWFUpload.prototype.setButtonCursor=function(cursor){this.settings.button_cursor=cursor;this.callFlash("SetButtonCursor",[cursor])};SWFUpload.prototype.queueEvent=function(handlerName,argumentArray){var self=this;if(argumentArray==undefined){argumentArray=[]}else{if(!(argumentArray instanceof Array)){argumentArray=[argumentArray]}}if(typeof this.settings[handlerName]==="function"){this.eventQueue.push(function(){this.settings[handlerName].apply(this,argumentArray)});setTimeout(function(){self.executeNextEvent()},0)}else{if(this.settings[handlerName]!==null){throw"Event handler "+handlerName+" is unknown or is not a function"}}};SWFUpload.prototype.executeNextEvent=function(){var f=this.eventQueue?this.eventQueue.shift():null;if(typeof(f)==="function"){f.apply(this)}};SWFUpload.prototype.unescapeFilePostParams=function(file){var reg=/[$]([0-9a-f]{4})/i,unescapedPost={},uk,k,match;if(file!=undefined){for(k in file.post){if(file.post.hasOwnProperty(k)){uk=k;while((match=reg.exec(uk))!==null){uk=uk.replace(match[0],String.fromCharCode(parseInt("0x"+match[1],16)))}unescapedPost[uk]=file.post[k]}}file.post=unescapedPost}return file};SWFUpload.prototype.testExternalInterface=function(){try{return this.callFlash("TestExternalInterface")}catch(ex){return false}};SWFUpload.prototype.flashReady=function(){var movieElement=this.getMovieElement();if(!movieElement){this.debug("Flash called back ready but the flash movie can't be found.");return}this.queueEvent("swfupload_loaded_handler")};SWFUpload.prototype.cleanUp=function(){var key,movieElement=this.getMovieElement();try{if(movieElement&&typeof(movieElement.CallFunction)==="unknown"){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(key in movieElement){try{if(typeof(movieElement[key])==="function"){movieElement[key]=null}}catch(ex){}}}}catch(ex1){}window.__flash__removeCallback=function(instance,name){try{if(instance){instance[name]=null}}catch(flashEx){}};return movieElement};SWFUpload.prototype.mouseClick=function(){this.queueEvent("mouse_click_handler")};SWFUpload.prototype.mouseOver=function(){this.queueEvent("mouse_over_handler")};SWFUpload.prototype.mouseOut=function(){this.queueEvent("mouse_out_handler")};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler")};SWFUpload.prototype.fileQueued=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("file_queued_handler",file)};SWFUpload.prototype.fileQueueError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("file_queue_error_handler",[file,errorCode,message])};SWFUpload.prototype.fileDialogComplete=function(numFilesSelected,numFilesQueued,numFilesInQueue){this.queueEvent("file_dialog_complete_handler",[numFilesSelected,numFilesQueued,numFilesInQueue])};SWFUpload.prototype.uploadStart=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("return_upload_start_handler",file)};SWFUpload.prototype.returnUploadStart=function(file){var returnValue;if(typeof this.settings.upload_start_handler==="function"){file=this.unescapeFilePostParams(file);returnValue=this.settings.upload_start_handler.call(this,file)}else{if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function"}}if(returnValue===undefined){returnValue=true}returnValue=!!returnValue;this.callFlash("ReturnUploadStart",[returnValue])};SWFUpload.prototype.uploadProgress=function(file,bytesComplete,bytesTotal){file=this.unescapeFilePostParams(file);this.queueEvent("upload_progress_handler",[file,bytesComplete,bytesTotal])};SWFUpload.prototype.uploadError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("upload_error_handler",[file,errorCode,message])};SWFUpload.prototype.uploadSuccess=function(file,serverData,responseReceived){file=this.unescapeFilePostParams(file);this.queueEvent("upload_success_handler",[file,serverData,responseReceived])};SWFUpload.prototype.uploadComplete=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("upload_complete_handler",file)};SWFUpload.prototype.debug=function(message){this.queueEvent("debug_handler",message)};SWFUpload.prototype.debugMessage=function(message){var exceptionMessage,exceptionValues,key;if(this.settings.debug){exceptionValues=[];if(typeof message==="object"&&typeof message.name==="string"&&typeof message.message==="string"){for(key in message){if(message.hasOwnProperty(key)){exceptionValues.push(key+": "+message[key])}}exceptionMessage=exceptionValues.join("\n")||"";exceptionValues=exceptionMessage.split("\n");exceptionMessage="EXCEPTION: "+exceptionValues.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(exceptionMessage)}else{SWFUpload.Console.writeLine(message)}}};SWFUpload.Console={};SWFUpload.Console.writeLine=function(message){var console,documentForm;try{console=document.getElementById("SWFUpload_Console");if(!console){documentForm=document.createElement("form");
|
4
|
+
document.getElementsByTagName("body")[0].appendChild(documentForm);console=document.createElement("textarea");console.id="SWFUpload_Console";console.style.fontFamily="monospace";console.setAttribute("wrap","off");console.wrap="off";console.style.overflow="auto";console.style.width="700px";console.style.height="350px";console.style.margin="5px";documentForm.appendChild(console)}console.value+=message+"\n";console.scrollTop=console.scrollHeight-console.clientHeight}catch(ex){alert("Exception: "+ex.name+" Message: "+ex.message)}};
|
@@ -2,46 +2,22 @@ a{text-decoration:none;color:#15428b;}
|
|
2
2
|
a:visited{text-decoration:none;color:#15428b;}
|
3
3
|
a:hover{text-decoration:none;color:#3764A0;}
|
4
4
|
h3{padding-bottom:5px;color:#3764A0;}
|
5
|
-
/*Custom
|
6
|
-
|
7
|
-
|
8
|
-
.x-
|
9
|
-
.x-grid3-td-task-title .x-grid3-cell-inner{white-space:normal;}
|
10
|
-
.x-grid3-dirty-cell{background:transparent;}
|
11
|
-
.x-panel-trans{background:transparent;}
|
12
|
-
.x-layout-split-west{background-color:#C4D2E5;cursor:move;}
|
13
|
-
.x-panel-header-text{color:#3764A0;}
|
14
|
-
.x-air #action-panel .x-plain-body{padding-left:3px;}
|
15
|
-
ul.x-tab-strip-top{background:#C4D2E5 none;}
|
16
|
-
#action-panel .x-panel-body li a{text-decoration:none;color:#15428b;}
|
17
|
-
#action-panel .x-plain-body{background-color:#C4D2E5;padding:3px 0 0 5px;}
|
18
|
-
#action-panel .x-panel-body li a:hover{text-decoration:none;color:#3764A0;}
|
19
|
-
#action-panel .x-panel{margin-bottom:3px;margin-right:0;}
|
20
|
-
#action-panel .x-panel-body{border:0 none;}
|
21
|
-
#action-panel .x-panel-body li{margin:3px;}
|
22
|
-
#action-panel .x-panel-body li img{width:16px;height:16px;vertical-align:middle;margin-right:2px;margin-bottom:2px;}
|
5
|
+
/*Custom ExtJS Style*/
|
6
|
+
.x-panel .dynamic{background-color:#FFF;border:1px solid #99BBE8;}
|
7
|
+
.x-panel .dynamic .padding{padding:5px;}
|
8
|
+
.x-layout-split {background-color:#DFE8F6;}
|
23
9
|
/*Some Icons for our admin*/
|
24
|
-
.preview .x-btn-text{background-image:url(../images/
|
25
|
-
.back .x-btn-text{background-image:url(../images/
|
26
|
-
.print .x-btn-text{background-image:url(../images/
|
27
|
-
.remove .x-btn-text{background-image:url(../images/
|
28
|
-
.add .x-btn-text{background-image:url(../images/
|
29
|
-
.edit .x-btn-text{background-image:url(../images/
|
30
|
-
.save .x-btn-text{background-image:url(../images/
|
31
|
-
.duplicate .x-btn-text{background-image:url(../images/
|
32
|
-
.export .x-btn-text{background-image:url(../images/
|
33
|
-
|
34
|
-
|
35
|
-
.down .x-btn-text{background-image:url(../images/backend/arrow_down.png);}
|
36
|
-
.join .x-btn-text{background-image:url(../images/backend/arrow_join.png);}
|
37
|
-
.divide .x-btn-text{background-image:url(../images/backend/arrow_divide.png);}
|
38
|
-
.divide .x-btn-text{background-image:url(../images/backend/arrow_divide.png);}
|
39
|
-
.categories .x-btn-text{background-image:url(../images/backend/categories.gif);}
|
40
|
-
/*Overrite some defaults*/
|
41
|
-
.x-panel-header{background-image:url(../images/backend/bg-hd.png);background-color:#6f839a; text-align:center; color:#343f4b;}
|
42
|
-
.x-panel-noborder .x-panel-header-noborder { border-bottom:none; }
|
43
|
-
.x-html-editor-wrap{border:none;}
|
44
|
-
/*Main Site*/
|
10
|
+
.preview .x-btn-text{background-image:url(../images/admin/preview.gif);}
|
11
|
+
.back .x-btn-text{background-image:url(../images/admin/back.gif);}
|
12
|
+
.print .x-btn-text{background-image:url(../images/admin/print.gif);}
|
13
|
+
.remove .x-btn-text{background-image:url(../images/admin/delete.gif);}
|
14
|
+
.add .x-btn-text{background-image:url(../images/admin/new.gif);}
|
15
|
+
.edit .x-btn-text{background-image:url(../images/admin/edit.gif);}
|
16
|
+
.save .x-btn-text{background-image:url(../images/admin/save.gif);}
|
17
|
+
.duplicate .x-btn-text{background-image:url(../images/admin/duplicate.gif);}
|
18
|
+
.export .x-btn-text{background-image:url(../images/admin/export.gif);}
|
19
|
+
.upload .x-btn-text{background-image:url(../images/admin/up.gif);}
|
20
|
+
/*Admin Styles*/
|
45
21
|
.content{background-color:#FFF;}
|
46
22
|
.label-title{padding:5px 0px 0px 0px;color:#3764A0;border-bottom:1px dotted #C4D2E5;padding-bottom:3px;margin:5px 0px 5px 0px;font-size:1.2em;font-weight:bold;}
|
47
23
|
.label-image{padding:5px 5px 5px 5px;background-color:#DFE8F6;margin:10px 10px 0px 10px;border:1px solid #99BBE8;}
|
@@ -51,8 +27,9 @@ ul.x-tab-strip-top{background:#C4D2E5 none;}
|
|
51
27
|
.column{float:left;width:150px;padding-right:10px;}
|
52
28
|
.small-w{width:10px;}
|
53
29
|
.green{color:green;}
|
30
|
+
/*Main Site*/
|
54
31
|
#ajax-iframe{display:none;}
|
55
|
-
#header{height:39px;border:0 none;background:#1E4176 url(../images/
|
32
|
+
#header{height:39px;border:0 none;background:#1E4176 url(../images/admin/hd-bg.gif) repeat-x 0 0;}
|
56
33
|
#header a{text-decoration:none;color:#FFF;}
|
57
34
|
#header a:hover{color:#99BBE8;}
|
58
35
|
#content-header{background-color:#C4D2E5;padding:5px;color:#3764A0;}
|
@@ -61,6 +38,13 @@ ul.x-tab-strip-top{background:#C4D2E5 none;}
|
|
61
38
|
#logo{float:left;line-height:35px;padding-left:10px;color:#FFF;font-size:1.3em;}
|
62
39
|
#logo img{border:none;}
|
63
40
|
#logout{float:right;line-height:35px;padding-right:10px;}
|
41
|
+
/*Manage Uploads*/
|
42
|
+
.open-window-grid {float:left;}
|
43
|
+
.open-window-grid li{-moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;padding:1px 13px 0px 5px;border:1px solid #A2C6EE;background-color:#E4ECF8;color:#0D3977;margin-right:3px;margin-bottom:3px;position:relative;float:left;line-height:16px;}
|
44
|
+
.open-window-grid li.clean{padding:none;border:none;background-color:transparent;margin:none;}
|
45
|
+
.open-window-grid span.display {position:relative}
|
46
|
+
.open-window-grid a.closebutton {position: absolute; right: 4px; top: 5px; display: block; width: 7px; height: 7px; font-size: 1px; background: url(../images/admin/close.gif)}
|
47
|
+
.open-window-grid a.closebutton:hover {background-position: 7px; }
|
64
48
|
/*Manage Images*/
|
65
49
|
.box-image{padding:5px;border:1px solid #aebfd5;background-color:#DAE7F6;float:left;margin:10px;}
|
66
50
|
.box-image .title{background-color:#C4D2E5;text-align:center;color:#3764A0;margin-bottom:5px;padding:2px 0px 2px 0px;}
|
@@ -73,6 +57,4 @@ ul.x-tab-strip-top{background:#C4D2E5 none;}
|
|
73
57
|
table.items{border:1px solid #99BBE8;border-bottom:none;text-align:center;}
|
74
58
|
table.items th{font-weight:bold;background-color:#BFCFE6;color:#15428B;padding:3px;border-bottom:1px solid #99BBE8;text-align:center;}
|
75
59
|
table.items tr.odd td{background-color:#FFF;padding:3px;border-bottom:1px solid #99BBE8}
|
76
|
-
table.items tr.even td{background-color:#FFF;padding:3px;border-bottom:1px solid #99BBE8}
|
77
|
-
/*Custom Style Here*/
|
78
|
-
.attachment-popup{background-color:#FFF;border-top:1px solid #000;background-image:url(../images/backend/bg-content.png); background-repeat: repeat-x;padding:10px;}
|
60
|
+
table.items tr.even td{background-color:#FFF;padding:3px;border-bottom:1px solid #99BBE8}
|
@@ -4,9 +4,9 @@ img { border:none; }
|
|
4
4
|
h2 { color:#525151; font-size:18px; margin:0px 0px 15px 0px; padding:0; }
|
5
5
|
a { color:#525151; }
|
6
6
|
/*Login Page*/
|
7
|
-
#wrapper { top:0; left:0; background: transparent url('../images/
|
8
|
-
#login-box { margin:0; padding:0px; position:absolute; width:413px; height:478px; background-image: url('../images/
|
9
|
-
#intro-box { margin:0; padding:0px; position:absolute; width:413px; height:478px; background-image: url('../images/
|
7
|
+
#wrapper { top:0; left:0; background: transparent url('../images/admin/background.png') repeat-x scroll center center; height:100%; width:100%; position:absolute; }
|
8
|
+
#login-box { margin:0; padding:0px; position:absolute; width:413px; height:478px; background-image: url('../images/admin/bg-login.png'); top:50%; left:50%; margin-top:-239px; margin-left:-220px; }
|
9
|
+
#intro-box { margin:0; padding:0px; position:absolute; width:413px; height:478px; background-image: url('../images/admin/bg_intro.png'); top:50%; left:50%; margin-top:-239px; margin-left:-220px; }
|
10
10
|
#logo-small { position:absolute; top:10px; left:100%; margin-left:-110px; }
|
11
11
|
#logo-credit { position:absolute; top:10px; left:100%; margin-left:-225px; }
|
12
12
|
#content { text-align:left; margin:150px 20px 0px 100px; }
|
@@ -5,58 +5,59 @@
|
|
5
5
|
*
|
6
6
|
* http://www.lipsiasoft.com
|
7
7
|
*/
|
8
|
-
body
|
9
|
-
table
|
10
|
-
table.form
|
11
|
-
table.form td
|
12
|
-
table.form th
|
13
|
-
th
|
14
|
-
table.padded td
|
15
|
-
tr.alternate
|
16
|
-
h1
|
17
|
-
a
|
18
|
-
a:hover
|
19
|
-
a.black
|
20
|
-
a:hover.black
|
21
|
-
a.white
|
22
|
-
a:hover.white
|
23
|
-
img
|
24
|
-
.blue
|
25
|
-
.fixed
|
26
|
-
.full
|
27
|
-
.half
|
28
|
-
.left
|
29
|
-
.right
|
30
|
-
.clear
|
31
|
-
.align-center
|
32
|
-
.align-left
|
33
|
-
.align-right
|
34
|
-
.align-top
|
35
|
-
.through
|
36
|
-
.small
|
37
|
-
.super-small
|
38
|
-
.big
|
39
|
-
.bold
|
40
|
-
.underline
|
41
|
-
.italic
|
42
|
-
.red
|
43
|
-
.padding-left
|
44
|
-
.padding-right
|
45
|
-
.padding-top
|
46
|
-
.padding-bottom
|
47
|
-
.padding
|
48
|
-
.bordered
|
49
|
-
.border-top
|
50
|
-
.border-bottom
|
51
|
-
.no-space
|
52
|
-
.no-margin-top
|
53
|
-
.no-margin-bottom
|
54
|
-
.margin
|
55
|
-
.margin-
|
56
|
-
.margin-
|
57
|
-
.margin-
|
58
|
-
.
|
59
|
-
.
|
8
|
+
body { font-size:12px; font-family:"Myriad Pro","Myriad Web","Tahoma","Helvetica","Arial",sans-serif; padding:0; margin:0; color:#222; }
|
9
|
+
table { font-size:12px; font-family:"Myriad Pro","Myriad Web","Tahoma","Helvetica","Arial",sans-serif; }
|
10
|
+
table.form { padding:10px; }
|
11
|
+
table.form td { padding:1px; }
|
12
|
+
table.form th { padding:1px; }
|
13
|
+
th { font-weight:bold; }
|
14
|
+
table.padded td { padding:2px; }
|
15
|
+
tr.alternate { background-color:#DDDDDD; }
|
16
|
+
h1 { margin:10px 0px 5px 0px; }
|
17
|
+
a { text-decoration:none; color:#663900; }
|
18
|
+
a:hover { text-decoration:none; color:#CC6600; }
|
19
|
+
a.black { text-decoration:none; color:#222; }
|
20
|
+
a:hover.black { text-decoration:none; color:#663900; }
|
21
|
+
a.white { text-decoration:none; color:#FFF; }
|
22
|
+
a:hover.white { text-decoration:none; color:#663900; }
|
23
|
+
img { border:none; }
|
24
|
+
.blue { color:#3764A0; }
|
25
|
+
.fixed { width:150px; }
|
26
|
+
.full { width:100%; }
|
27
|
+
.half { width:50%; }
|
28
|
+
.left { float:left; }
|
29
|
+
.right { float:right; }
|
30
|
+
.clear { clear:both; }
|
31
|
+
.align-center { text-align:center; }
|
32
|
+
.align-left { text-align:left; }
|
33
|
+
.align-right { text-align:right; }
|
34
|
+
.align-top { vertical-align:top; }
|
35
|
+
.through { text-decoration: line-through;}
|
36
|
+
.small { font-size:0.9em; }
|
37
|
+
.super-small { font-size:0.8em; }
|
38
|
+
.big { font-size:1.1em; }
|
39
|
+
.bold { font-weight:bold; }
|
40
|
+
.underline { border-bottom:1px solid #000;}
|
41
|
+
.italic { font-style: italic; }
|
42
|
+
.red { color:#eb5723; }
|
43
|
+
.padding-left { padding-left:5px; }
|
44
|
+
.padding-right { padding-right:5px; }
|
45
|
+
.padding-top { padding-top:5px; }
|
46
|
+
.padding-bottom { padding-bottom:5px; }
|
47
|
+
.padding { padding:5px; }
|
48
|
+
.bordered { border:1px solid #FF8D35; }
|
49
|
+
.border-top { border-top:1px solid #FF8D35; }
|
50
|
+
.border-bottom { border-bottom:1px solid #FF8D35; }
|
51
|
+
.no-space { font-size:0em; }
|
52
|
+
.no-margin-top { margin-top:0px; }
|
53
|
+
.no-margin-bottom { margin-bottom:0px; }
|
54
|
+
.margin { margin:10px; }
|
55
|
+
.margin-top { margin-top:10px; }
|
56
|
+
.margin-bottom { margin-bottom:10px; }
|
57
|
+
.margin-left { margin-left:10px; }
|
58
|
+
.margin-right { margin-right:10px; }
|
59
|
+
.exception { padding:10px; }
|
60
|
+
.page { height:500px; }
|
60
61
|
/* Default Style for inputs */
|
61
62
|
input,textarea{margin:0;font:normal 12px tahoma,arial,helvetica,sans-serif;width:100%;}
|
62
63
|
input,textarea{padding:1px 3px;background:#fff url(../images/ext/default/form/text-bg.gif) repeat-x 0 0;border:1px solid #B5B8C8;}
|
@@ -6,14 +6,12 @@
|
|
6
6
|
#loading-mask
|
7
7
|
#loading
|
8
8
|
.loading-indicator
|
9
|
-
=image_tag("
|
9
|
+
=image_tag("admin/logo-loader.png") + "Loading..."
|
10
10
|
/ include everything after the loading indicator
|
11
|
-
=javascript_include_tag :prototype, :effects, :dragdrop, :controls, :ext, :locale
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
#logo=link_to options.app_name.titleize, "/"
|
16
|
-
#logout=link_to "Logout #{current_account.email}", url_for(:sessions_destroy)
|
11
|
+
=javascript_include_tag :prototype, :effects, :dragdrop, :controls, :swfupload, :ext, :locale, :admin
|
12
|
+
#header
|
13
|
+
#logo=link_to options.app_name.titleize, url(:index)
|
14
|
+
#logout=link_to "Logout #{current_account.email}", url(:sessions_destroy)
|
17
15
|
|
18
16
|
%iframe{ :id => "ajax-iframe", :name => "ajax-iframe" }
|
19
17
|
%form{ :id => "history-form", :class => "x-hidden" }
|
@@ -1,14 +1,15 @@
|
|
1
|
-
Ext.BLANK_IMAGE_URL = '<%= image_path("ext/default/s.gif") %>';
|
1
|
+
Ext.BLANK_IMAGE_URL = '<%= image_path("ext/default/s.gif") %>';
|
2
|
+
Ext.Updater.defaults.showLoadIndicator = false;
|
2
3
|
Ext.namespace('Admin');
|
3
|
-
Ext.namespace('Admin.util.Format');
|
4
4
|
|
5
|
+
// This is our event manager
|
6
|
+
Admin.events = new Ext.util.Observable();
|
7
|
+
|
8
|
+
// That is the main app
|
5
9
|
Admin.app = function(){
|
6
|
-
// Our pretty simple cache
|
7
|
-
var cache = {};
|
8
|
-
var oldUrl = undefined;
|
9
10
|
return {
|
10
11
|
// Init our app
|
11
|
-
init
|
12
|
+
init: function(){
|
12
13
|
// Cookie provider
|
13
14
|
Ext.state.Manager.setProvider(
|
14
15
|
new Ext.state.CookieProvider({
|
@@ -18,107 +19,116 @@ Admin.app = function(){
|
|
18
19
|
|
19
20
|
// We want save cookies only for grids
|
20
21
|
Ext.override(Ext.Component, { stateful:false });
|
21
|
-
Ext.override(Ext.grid.GridPanel, { stateful:true });
|
22
|
+
// Ext.override(Ext.grid.GridPanel, { stateful:true });
|
22
23
|
Ext.QuickTips.init();
|
23
24
|
|
24
25
|
// Used for direclty load some specific page
|
26
|
+
var loadUrl = undefined;
|
25
27
|
if (window.location.search){
|
26
|
-
|
28
|
+
loadUrl = Ext.urlDecode(window.location.search.substring(1)).load;
|
27
29
|
} else if (window.location.href.split('#')[1]) {
|
28
|
-
|
30
|
+
loadUrl = window.location.href.split('#')[1];
|
29
31
|
}
|
30
32
|
|
31
33
|
// Used for history the browsing
|
32
34
|
Ext.History.init();
|
33
|
-
Ext.History.on('change', function(token){
|
35
|
+
Ext.History.on('change', function(token){ Admin.app.load(token) });
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
+
// Build some events
|
38
|
+
Admin.events.addEvents('itemAdded', 'contentLoaded');
|
37
39
|
|
38
|
-
|
40
|
+
// Our header
|
39
41
|
var header = new Ext.Panel({
|
40
42
|
contentEl: 'header',
|
41
43
|
region: 'north',
|
42
44
|
border: false,
|
43
45
|
bbar: <%= admin_menu %>
|
44
46
|
});
|
45
|
-
<% end %>
|
46
47
|
|
48
|
+
// Our main container
|
47
49
|
this.contentDynamic = new Ext.Panel({
|
48
50
|
id:'dynamic',
|
49
51
|
region:'center',
|
52
|
+
activeItem: 0,
|
50
53
|
border:false,
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
frame: true,
|
55
|
+
bodyCssClass: 'dynamic',
|
56
|
+
buttonAlign: 'left',
|
57
|
+
buttons: [{
|
58
|
+
id:'back',
|
59
|
+
text: Admin.locale.buttons.back,
|
60
|
+
cls: 'x-btn-text-icon back',
|
61
|
+
handler: this.back
|
62
|
+
},'->',{
|
63
|
+
id:'save',
|
64
|
+
text: Admin.locale.buttons.save,
|
65
|
+
hidden: true,
|
66
|
+
cls: 'x-btn-text-icon save'
|
67
|
+
}],
|
68
|
+
layout:'card'
|
54
69
|
});
|
55
70
|
|
71
|
+
// Our viewport
|
56
72
|
this.viewport = new Ext.Viewport({
|
57
73
|
layout:'border',
|
58
|
-
items:
|
74
|
+
items: [header, this.contentDynamic]
|
59
75
|
});
|
60
76
|
|
61
|
-
this.load(loadUrl
|
77
|
+
loadUrl ? this.load(loadUrl) : this.loadPage('<%= url(:dashboard) %>');
|
78
|
+
|
62
79
|
setTimeout(function(){
|
63
80
|
Ext.get('loading').remove();
|
64
81
|
Ext.get('loading-mask').fadeOut({remove:true});
|
65
82
|
}, 250);
|
66
83
|
}, // init
|
67
84
|
|
68
|
-
|
69
|
-
return window.location.search ? Ext.urlDecode(window.location.search.substring(1)).small : false;
|
70
|
-
}, // smalloallProductsGroupingStore
|
71
|
-
|
72
|
-
toolbar: function(){
|
73
|
-
return window.location.search ? Ext.urlDecode(window.location.search.substring(1)).toolbar!="0" : true;
|
74
|
-
}, // hideToolbar
|
75
|
-
|
76
|
-
title: function(){
|
77
|
-
return window.location.search ? Ext.urlDecode(window.location.search.substring(1)).title!="0" : true;
|
78
|
-
}, // hideTite
|
79
|
-
|
80
|
-
load : function(url){
|
85
|
+
load: function(url){
|
81
86
|
var ext = (/[.]/.exec(url)) ? /[^.]+$/.exec(url) : 'html';
|
82
87
|
|
83
|
-
// Now we need to store the url in the history
|
84
|
-
if (!this.smallView()){
|
85
|
-
Ext.History.add(url, true);
|
86
|
-
this.oldUrl = url;
|
87
|
-
}
|
88
88
|
// Now give a reply based on request
|
89
89
|
if (ext.length == 1 && ext[0].toLowerCase() == 'js') {
|
90
|
-
// Clean the html and scripts
|
91
|
-
this.cleanScripts();
|
90
|
+
// Clean the html and scripts
|
91
|
+
this.cleanScripts();
|
92
92
|
this.clean();
|
93
|
-
|
94
|
-
|
95
|
-
var s = document.createElement("script");
|
96
|
-
s.src = url;
|
97
|
-
s.type = 'text/javascript';
|
98
|
-
// Now we can append the child.
|
99
|
-
hd.appendChild(s);
|
93
|
+
Ext.History.add(url, true);
|
94
|
+
Ext.Ajax.request({ url: url, nocache:true });
|
100
95
|
} else if (ext == 'html'){
|
101
|
-
|
102
|
-
this.mask();
|
103
|
-
Ext.Ajax.request({
|
104
|
-
url: url,
|
105
|
-
headers: { 'Accept': 'text/html' },
|
106
|
-
success: function(response) { Admin.app.update(response.responseText) }
|
107
|
-
});
|
96
|
+
this.loadWidget(url);
|
108
97
|
} else {
|
109
98
|
Admin.showAlert(Admin.locale.messages.alert.message);
|
110
99
|
}
|
111
100
|
}, // load
|
112
101
|
|
113
|
-
|
114
|
-
|
115
|
-
|
102
|
+
loadPage: function(url){
|
103
|
+
// Clean the html and scripts
|
104
|
+
this.cleanScripts();
|
105
|
+
this.clean();
|
106
|
+
this.contentDynamic.load({ url: url, scripts: true, callback:this.inspectContent, scope:this, nocache:true });
|
107
|
+
}, // loadPage
|
108
|
+
|
109
|
+
loadWidget: function(url, id){
|
110
|
+
var win = undefined;
|
111
|
+
if (id) { Ext.WindowMgr.each(function(w) { if (w.id == id) { win = w; return false } }, this) };
|
112
|
+
if (win){
|
113
|
+
win.toFront();
|
116
114
|
} else {
|
117
|
-
|
115
|
+
var win = new Admin.window({ id: id });
|
116
|
+
win.show(); win.hide();
|
117
|
+
win.load({
|
118
|
+
url: url,
|
119
|
+
scripts: true,
|
120
|
+
callback: Admin.app.inspectContent,
|
121
|
+
scope: win,
|
122
|
+
nocache: true
|
123
|
+
});
|
118
124
|
}
|
119
|
-
}
|
125
|
+
},
|
126
|
+
|
127
|
+
back: function(){
|
128
|
+
Ext.History.back();
|
129
|
+
}, // back
|
120
130
|
|
121
|
-
update
|
131
|
+
update: function(html){
|
122
132
|
this.cleanScripts();
|
123
133
|
this.clean();
|
124
134
|
var el = this.contentDynamic.body.update(html);
|
@@ -129,201 +139,117 @@ Admin.app = function(){
|
|
129
139
|
Ext.select('head > script').each(function(el){ el.remove(); });
|
130
140
|
}, // cleanScripts
|
131
141
|
|
132
|
-
clean
|
133
|
-
this.
|
134
|
-
this.contentDynamic.items.each(function(
|
142
|
+
clean: function(){
|
143
|
+
this.saveButtons(false);
|
144
|
+
this.contentDynamic.items.each(function(item){ item.destroy });
|
135
145
|
this.contentDynamic.removeAll(true);
|
136
|
-
this.contentDynamic.body.update('');
|
137
|
-
this.contentDynamic.doLayout();
|
146
|
+
this.contentDynamic.body.update('');
|
138
147
|
}, // clean
|
139
148
|
|
140
|
-
|
141
|
-
this.contentDynamic.
|
142
|
-
|
149
|
+
saveButtons: function(show, id){
|
150
|
+
var btns = this.contentDynamic.fbar.items.map;
|
151
|
+
if (show){
|
152
|
+
btns.save.show();
|
153
|
+
btns.save.handler = function(){ Admin.app.submitForm(id) };
|
154
|
+
} else {
|
155
|
+
btns.save.hide();
|
156
|
+
btns.save.handler = undefined;
|
157
|
+
}
|
158
|
+
}, // saveButtons
|
159
|
+
|
160
|
+
addItem: function(item, small){
|
161
|
+
// If we are loading a small item we don't need to add them to our container
|
162
|
+
if (small && small!=''){
|
163
|
+
Admin.events.fireEvent('customItemAdded', item);
|
164
|
+
} else {
|
165
|
+
this.contentDynamic.add(item);
|
166
|
+
this.contentDynamic.layout.setActiveItem(0);
|
167
|
+
this.contentDynamic.doLayout(true, true);
|
168
|
+
}
|
169
|
+
Admin.events.fireEvent('itemAdded', item)
|
143
170
|
}, // addItem
|
144
171
|
|
145
|
-
submitForm
|
146
|
-
|
147
|
-
Admin.
|
148
|
-
|
149
|
-
});
|
150
|
-
Ext.select('form[data-remote=true]').each(function(form){ Ext.Ajax.request({ form: form }) });
|
172
|
+
submitForm: function(id){
|
173
|
+
var form = Ext.fly(id);
|
174
|
+
form.mask(Admin.locale.messages.wait.message);
|
175
|
+
Ext.Ajax.request({ form: form, callback: function(){ Ext.fly(id).unmask() } });
|
151
176
|
}, // submitForms
|
152
177
|
|
153
178
|
setTitle: function(title){
|
154
179
|
this.contentDynamic.setTitle(title);
|
155
|
-
}, //
|
156
|
-
|
157
|
-
inspectContent: function(el, originalHtml){
|
158
|
-
try {
|
159
|
-
|
160
|
-
// Reformat ajax forms
|
161
|
-
el.select('form[data-remote=true]').each(function(form){
|
162
|
-
form.dom.onsubmit = function(){ Admin.app.submitForm(); return false };
|
163
|
-
});
|
164
|
-
|
165
|
-
// Search for tabs in the page
|
166
|
-
var tabs = el.select('div[tabbed=true]');
|
180
|
+
}, // setTitle
|
167
181
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
return { id: tab.id+'-tabbed', contentEl: tab.id, title: tab.title };
|
172
|
-
});
|
182
|
+
inspectContent: function(el, success, response){
|
183
|
+
// Go away if no success
|
184
|
+
if (!success) return;
|
173
185
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
// We need this for IE8
|
181
|
-
var formId = Ext.id(form, 'ajax-form-');
|
182
|
-
|
183
|
-
var tabConfig = {
|
184
|
-
applyTo: formId,
|
185
|
-
activeTab: activeTab,
|
186
|
-
border:false,
|
187
|
-
items: items,
|
188
|
-
deferredRender: false,
|
189
|
-
layoutOnTabChange: true,
|
190
|
-
enableTabScroll: true,
|
191
|
-
defaults: { autoScroll:true, layout:'fit' }
|
192
|
-
};
|
193
|
-
|
194
|
-
if (this.toolbar()){
|
195
|
-
Ext.apply(tabConfig, {
|
196
|
-
bbar: [{
|
197
|
-
text: Admin.locale.buttons.back,
|
198
|
-
cls: 'x-btn-text-icon back',
|
199
|
-
handler: Admin.app.back
|
200
|
-
}, '->',{
|
201
|
-
text: Admin.locale.buttons.save,
|
202
|
-
cls: 'x-btn-text-icon save',
|
203
|
-
handler: Admin.app.submitForm
|
204
|
-
}]
|
205
|
-
});
|
206
|
-
}
|
186
|
+
// Reformat ajax forms
|
187
|
+
el.select('form[data-remote=true]').each(function(form){
|
188
|
+
var id = Ext.id(form, 'ajax-form-');
|
189
|
+
form.dom.onsubmit = function(){ Admin.app.submitForm(id); return false };
|
190
|
+
});
|
207
191
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
// Now we add the tab panel to our main container
|
212
|
-
this.addItem(this.tabPanel);
|
213
|
-
|
214
|
-
// Need to use this because some times we add tabs from inline scripts
|
215
|
-
this.tabPanel.on('add', function(container, tab){ if (tab.id == activeTab) { Admin.app.tabPanel.setActiveTab(activeTab); } });
|
216
|
-
}
|
217
|
-
|
218
|
-
// Now we can load scripts an eval scripts from the original html
|
219
|
-
var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
|
220
|
-
var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
|
221
|
-
var typeRe = /\stype=([\'\"])(.*?)\1/i;
|
222
|
-
|
223
|
-
var match;
|
224
|
-
while(match = re.exec(originalHtml)){
|
225
|
-
var attrs = match[1];
|
226
|
-
var srcMatch = attrs ? attrs.match(srcRe) : false;
|
227
|
-
if(srcMatch && srcMatch[2]){
|
228
|
-
// We append the js into the head so we can easy inspect errors
|
229
|
-
var hd = document.getElementsByTagName("head")[0];
|
230
|
-
var s = document.createElement("script");
|
231
|
-
s.src = srcMatch[2];
|
232
|
-
s.type = 'text/javascript';
|
233
|
-
// Now we can append the child.
|
234
|
-
hd.appendChild(s);
|
235
|
-
}else if(match[2] && match[2].length > 0){
|
236
|
-
if(window.execScript) {
|
237
|
-
window.execScript(match[2]);
|
238
|
-
} else {
|
239
|
-
window.eval(match[2]);
|
240
|
-
}
|
241
|
-
}
|
242
|
-
}
|
192
|
+
// Search for tabs in the page
|
193
|
+
var tabs = el.select('div[tabbed=true]');
|
243
194
|
|
244
|
-
|
245
|
-
|
246
|
-
cache = {};
|
247
|
-
} catch(e){
|
248
|
-
throw this.error(e)
|
249
|
-
}
|
250
|
-
},//inspectContent
|
195
|
+
// We select the first form in the dom
|
196
|
+
var form = el.select('form[data-remote=true]').first();
|
251
197
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
} else {
|
256
|
-
Admin.showAlert(e);
|
257
|
-
}
|
258
|
-
}, // error
|
198
|
+
// We need to parse our title
|
199
|
+
var title = el.select('span[title]').first();
|
200
|
+
if (title) this.setTitle(title.getAttribute("title"));
|
259
201
|
|
260
|
-
|
261
|
-
|
262
|
-
baseCls: 'x-plain',
|
263
|
-
labelAlign: 'top',
|
264
|
-
items: [{
|
265
|
-
xtype:'textarea',
|
266
|
-
anchor: '100% 100%',
|
267
|
-
allowBlank: false,
|
268
|
-
fieldLabel: Admin.locale.help.description,
|
269
|
-
name: 'message'
|
270
|
-
}]
|
271
|
-
});
|
202
|
+
// If we have a form we need some save buttons
|
203
|
+
if (form) this.saveButtons(true, form.id);
|
272
204
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
items
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
modal: true,
|
282
|
-
bodyStyle:'padding:5px;',
|
283
|
-
layout: 'fit'
|
284
|
-
});
|
205
|
+
// Build our tab panel if we have a form and tabs
|
206
|
+
if (tabs.elements.length > 0 && form){
|
207
|
+
// Build Tabs
|
208
|
+
var items = []
|
209
|
+
Ext.each(tabs.elements, function(tab){
|
210
|
+
tab.id = Ext.id('', tab.id +'-tab-');
|
211
|
+
items.push({ id: tab.id + '-tab-id-', contentEl: tab.id, title: tab.title });
|
212
|
+
});
|
285
213
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
Ext.MessageBox.alert(Admin.locale.messages.compliments.title, Admin.locale.help.compliments);
|
296
|
-
},
|
297
|
-
failure: function(form, action) {
|
298
|
-
if (action.result) {
|
299
|
-
Admin.showAlert(action.result.msg);
|
300
|
-
}
|
301
|
-
}
|
214
|
+
// We can build the tabPanel
|
215
|
+
this.tabPanel = new Ext.TabPanel({
|
216
|
+
applyTo: form,
|
217
|
+
activeTab: 0,
|
218
|
+
border:false,
|
219
|
+
items: items,
|
220
|
+
layoutOnTabChange: true,
|
221
|
+
enableTabScroll: true,
|
222
|
+
defaults: { autoScroll:true, layout:'fit' }
|
302
223
|
});
|
303
|
-
}, this);
|
304
224
|
|
305
|
-
|
306
|
-
|
307
|
-
|
225
|
+
this.tabPanel.render();
|
226
|
+
}
|
227
|
+
|
228
|
+
this.fireEvent('contentLoaded');
|
229
|
+
},//inspectContent
|
308
230
|
|
309
|
-
|
310
|
-
|
231
|
+
fireEvent: function(event){
|
232
|
+
Admin.events.fireEvent(event);
|
233
|
+
}, // fireEvent
|
234
|
+
|
235
|
+
error: function(e){
|
236
|
+
(typeof console != 'undefined') ? console.error(e) : Admin.showAlert(e)
|
237
|
+
}, // error
|
238
|
+
|
239
|
+
doLayout: function(){
|
240
|
+
this.contentDynamic.doLayout(true, true);
|
311
241
|
}, //doLayout
|
312
242
|
|
313
|
-
mask
|
314
|
-
if (
|
315
|
-
|
316
|
-
this.contentDynamic.el.mask(text);
|
317
|
-
}
|
243
|
+
mask: function(text){
|
244
|
+
if (text == null || text.length == 0) { text = Ext.LoadMask.prototype.msg; }
|
245
|
+
this.contentDynamic.el.mask(text);
|
318
246
|
}, // mask
|
319
247
|
|
320
|
-
unmask
|
321
|
-
|
322
|
-
this.contentDynamic.el.unmask();
|
323
|
-
}
|
248
|
+
unmask: function(){
|
249
|
+
this.contentDynamic.el.unmask();
|
324
250
|
}, // unmask
|
325
251
|
|
326
|
-
collapseBoxes
|
252
|
+
collapseBoxes: function(current){
|
327
253
|
var el = current.up().down('div.x-box-collapsible');
|
328
254
|
var currentEl = Ext.get(el);
|
329
255
|
currentEl.isDisplayed() ? currentEl.slideOut('t', {duration:.2, useDisplay:true}) : currentEl.slideIn('t', {duration:.2, useDisplay:true});
|
@@ -340,22 +266,22 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
340
266
|
region: "center",
|
341
267
|
viewConfig: { forceFit: true },
|
342
268
|
border: false,
|
343
|
-
bodyBorder: false,
|
344
269
|
buttons: ['add', 'edit', 'remove'],
|
345
270
|
search: true,
|
346
271
|
plugins: [],
|
347
|
-
view: new Ext.grid.GroupingView({ forceFit: true }),
|
348
|
-
sm: new Ext.grid.CheckboxSelectionModel(),
|
349
272
|
column_fields: [],
|
350
273
|
store_fields: [],
|
274
|
+
window: undefined,
|
275
|
+
|
351
276
|
initComponent: function(){
|
352
|
-
|
353
|
-
this.
|
354
|
-
|
277
|
+
// Prepare our View/Cm/Sm
|
278
|
+
this.view = new Ext.grid.GroupingView({ forceFit: true }),
|
279
|
+
this.sm = new Ext.grid.CheckboxSelectionModel(),
|
355
280
|
this.column_fields.unshift(new Ext.grid.CheckboxSelectionModel());
|
356
281
|
this.cm = new Ext.grid.ColumnModel({ columns: this.column_fields });
|
357
282
|
// Toolbar
|
358
283
|
if (this.buttons.length > 0 || this.search){ this.tbar = new Ext.Toolbar() };
|
284
|
+
// Add Buttons
|
359
285
|
Ext.each(this.buttons, function(button){
|
360
286
|
switch(button){
|
361
287
|
case 'add':
|
@@ -392,7 +318,7 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
392
318
|
this.buttons = undefined; // Remove all bbar buttons, we don't want them in the bottom of grid.
|
393
319
|
// Now we need to add some handlers for activate/deactivate buttons
|
394
320
|
this.sm.on('selectionchange', function(){
|
395
|
-
var n = this.
|
321
|
+
var n = this.getSelectionModel().getSelected();
|
396
322
|
var btns = this.getTopToolbar().items.map;
|
397
323
|
if(!n){
|
398
324
|
if (btns.remove){ btns.remove.disable() };
|
@@ -420,31 +346,36 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
420
346
|
id: "id"
|
421
347
|
})
|
422
348
|
});
|
423
|
-
this.store.on('beforeload', function(){
|
424
|
-
this.store.on('load', function(){
|
349
|
+
this.store.on('beforeload', function(){ this.el.mask(); }, this);
|
350
|
+
this.store.on('load', function(){ this.el.unmask(); }, this);
|
425
351
|
// Build bbar
|
426
352
|
this.bbar = new Ext.PagingToolbar({
|
427
353
|
pageSize: 50,
|
428
354
|
displayInfo: true,
|
429
355
|
store: this.store
|
430
356
|
});
|
357
|
+
// Call our superclass
|
431
358
|
Admin.grid.superclass.initComponent.call(this);
|
432
|
-
|
433
|
-
|
359
|
+
// Now we can load our records
|
360
|
+
this.on('render', function(){ this.store.load() }, this);
|
361
|
+
}, // initComponent
|
434
362
|
|
435
363
|
addRecord: function(){
|
436
|
-
Admin.app.
|
437
|
-
},
|
364
|
+
Admin.app.loadWidget(this.baseUrl + '/new');
|
365
|
+
}, // addRecord
|
438
366
|
|
439
367
|
editRecord: function(){
|
440
|
-
|
441
|
-
|
368
|
+
Ext.each(this.getSelectionModel().getSelections(), function(selection){
|
369
|
+
var id = this.baseUrl + '-edit-' + selection.id;
|
370
|
+
Admin.app.loadWidget(this.baseUrl + '/edit/' + selection.id);
|
371
|
+
}, this)
|
372
|
+
}, // editRecord
|
442
373
|
|
443
374
|
removeRecord: function(){
|
444
|
-
Ext.Msg.confirm(Admin.locale.messages.confirm.title, String.format(Admin.locale.messages.confirm.message, this.
|
375
|
+
Ext.Msg.confirm(Admin.locale.messages.confirm.title, String.format(Admin.locale.messages.confirm.message, this.getSelectionModel().getCount()), function(btn, text){
|
445
376
|
if (btn == 'yes'){
|
446
377
|
Admin.app.mask();
|
447
|
-
var records = this.
|
378
|
+
var records = this.getSelectionModel().getSelections();
|
448
379
|
var store = this.store;
|
449
380
|
Ext.Ajax.request({
|
450
381
|
url: this.baseUrl + '/destroy.json',
|
@@ -452,7 +383,6 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
452
383
|
method: 'DELETE',
|
453
384
|
success: function(result, request){
|
454
385
|
var resultValue = Ext.decode(result.responseText);
|
455
|
-
console.log(resultValue.msg);
|
456
386
|
Admin.app.unmask();
|
457
387
|
store.reload();
|
458
388
|
if (!resultValue.success){
|
@@ -467,53 +397,71 @@ Admin.grid = Ext.extend(Ext.grid.GridPanel, {
|
|
467
397
|
});
|
468
398
|
}
|
469
399
|
}, this);
|
470
|
-
}
|
471
|
-
});
|
400
|
+
} // removeRecord
|
401
|
+
}); // Admin.grid
|
472
402
|
|
473
403
|
Admin.window = Ext.extend(Ext.Window, {
|
474
404
|
width: 700,
|
475
|
-
height: 300,
|
476
405
|
layout: 'fit',
|
477
406
|
autoScroll: true,
|
478
|
-
modal: true,
|
479
407
|
maximizable: true,
|
480
408
|
bodyStyle: 'background-color:#FFF',
|
481
409
|
grid: undefined,
|
482
|
-
|
483
|
-
|
484
|
-
iframeId: Ext.id('','iframe-'),
|
410
|
+
item: undefined,
|
411
|
+
|
485
412
|
initComponent: function(){
|
413
|
+
this.addEvents('contentLoaded');
|
414
|
+
this.index = 0;
|
486
415
|
Admin.window.superclass.initComponent.call(this);
|
487
|
-
this.
|
488
|
-
this.
|
416
|
+
this.on('contentLoaded', this.center, this);
|
417
|
+
this.on('contentLoaded', this.show, this);
|
418
|
+
this.adminWindow = true;
|
419
|
+
if (this.item || this.grid) this.add(this.item || this.grid);
|
489
420
|
this.addButton({
|
490
421
|
text: Admin.locale.buttons.close,
|
491
422
|
handler: this[this.closeAction].createDelegate(this, [])
|
492
423
|
});
|
493
424
|
if (this.grid){
|
425
|
+
this.border = false;
|
494
426
|
this.addButton({
|
495
427
|
text: Admin.locale.buttons.select,
|
496
428
|
handler: this.closeWithSelections.createDelegate(this, [])}
|
497
429
|
);
|
498
430
|
}
|
499
|
-
|
431
|
+
}, // initComponent
|
432
|
+
|
433
|
+
addItem: function(item){ // this method is for a compatibility with Admin.app.addItem
|
434
|
+
this.add(item);
|
435
|
+
this.doLayout(true, true);
|
436
|
+
},
|
437
|
+
|
438
|
+
saveButtons: function(show, id){
|
439
|
+
var btns = this.fbar.items.map;
|
440
|
+
if (show){
|
500
441
|
this.addButton({
|
501
442
|
text: Admin.locale.buttons.save,
|
502
|
-
handler:
|
503
|
-
);
|
443
|
+
handler: function(){ Admin.app.submitForm(id) }
|
444
|
+
});
|
504
445
|
}
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
Admin.window.superclass.
|
510
|
-
|
511
|
-
|
512
|
-
|
446
|
+
}, // saveButtons
|
447
|
+
|
448
|
+
show: function(){
|
449
|
+
Ext.WindowMgr.each(function(win) { if (win.adminWindow) this.index++ }, this);
|
450
|
+
Admin.window.superclass.show.call(this);
|
451
|
+
}, // show
|
452
|
+
|
453
|
+
center: function(){
|
454
|
+
var xy = this.el.getAlignToXY(this.container, 'c-c');
|
455
|
+
this.setPagePosition(xy[0]+(this.index*10), xy[1]+(this.index*10));
|
456
|
+
return this;
|
457
|
+
}, // center
|
458
|
+
|
459
|
+
unmask: Ext.emptyFn, // this method is for a compatibility with Admin.app.unmask
|
460
|
+
|
513
461
|
getSelections: function(){
|
514
|
-
return this.
|
462
|
+
return this.grid.getSelectionModel().getSelections();
|
515
463
|
}, // getSelections
|
516
|
-
|
464
|
+
|
517
465
|
closeWithSelections: function(){
|
518
466
|
if (this.getSelections().length > 0){
|
519
467
|
this.fireEvent('selected', this, this.getSelections());
|
@@ -521,35 +469,7 @@ Admin.window = Ext.extend(Ext.Window, {
|
|
521
469
|
} else {
|
522
470
|
Admin.showAlert(Admin.locale.messages.alert.notSelected);
|
523
471
|
}
|
524
|
-
}
|
525
|
-
|
526
|
-
saveForm: function(){
|
527
|
-
this.contentWindow.Admin.app.submitForm();
|
528
|
-
this.fireEvent('saved', this);
|
529
|
-
} // saveForm
|
530
|
-
});
|
531
|
-
|
532
|
-
Admin.comboBox = Ext.extend(Ext.form.ComboBox, {
|
533
|
-
displayField:'title',
|
534
|
-
typeAhead: false,
|
535
|
-
loadingText: 'Searching...',
|
536
|
-
pageSize: 10,
|
537
|
-
autoWidth:true,
|
538
|
-
hideTrigger:true,
|
539
|
-
itemSelector: 'div.search-item',
|
540
|
-
initComponent : function(){
|
541
|
-
Admin.comboBox.superclass.initComponent.call(this);
|
542
|
-
if (this.autoWidth){
|
543
|
-
Admin.app.contentDynamic.on('resize', this.fitContent, this);
|
544
|
-
this.on('render', this.fitContent, this);
|
545
|
-
}
|
546
|
-
}, // initComponent
|
547
|
-
fitContent : function() {
|
548
|
-
this.el.setStyle({display:'none'});
|
549
|
-
var size = this.el.parent().parent().getSize();
|
550
|
-
this.onResize(size.width, size.height);
|
551
|
-
this.el.setStyle({display:'inline'});
|
552
|
-
}
|
472
|
+
} // closeWithSelections
|
553
473
|
});
|
554
474
|
|
555
475
|
Admin.showAlert = function(msg){
|