Ext.BLANK_IMAGE_URL='/lotus/scripts/ext/resources/images/default/s.gif';if((typeof Range!=="undefined")&&!Range.prototype.createContextualFragment) {Range.prototype.createContextualFragment=function(html) {var frag=document.createDocumentFragment(),div=document.createElement("div");frag.appendChild(div);div.outerHTML=html;return frag;};} if(!window.console){window.console={log:function(){}};} Ext.ux.clone=function(o){if(!o||'object'!==typeof o){return o;} var c='function'===typeof o.pop?[]:{};var p,v;for(p in o){if(o.hasOwnProperty(p)){v=o[p];if(v&&'object'===typeof v){c[p]=Ext.ux.clone(v);} else{c[p]=v;}}} return c;};Ext.ux.isEmpty=function(v,allowBlank){if(Ext.type(v)==='object'){var i=0;for(var key in v){i++;} if(i===0)return true;else return false;} if(Ext.type(v)==='array'){return v.length==0?true:false;} return v===null||v===undefined||(!allowBlank?v==='':false);} Ext.override(Ext.tree.TreeLoader,{getParams:function(node){var buf={},bp=this.baseParams;for(var key in bp){if(typeof bp[key]!="function"){buf[encodeURIComponent(key)]=encodeURIComponent(bp[key]);}} buf["node"]=encodeURIComponent(node.id);return buf;}});Ext.override(Ext.Window,{maximize:function(){if(!this.maximized){this.expand(false);this.restoreSize=this.getSize();this.restorePos=this.getPosition(true);if(this.maximizable){this.tools.maximize.hide();this.tools.restore.show();} this.maximized=true;this.el.disableShadow();if(this.dd){this.dd.lock();} if(this.collapsible){this.tools.toggle.hide();} this.el.addClass('x-window-maximized');this.container.addClass('x-window-maximized-ct');var s=Ext.getDoc().getScroll();this.setPosition(s.left,s.top);this.fitContainer();this.fireEvent('maximize',this);}}});Ext.override(Ext.grid.GridView,{layout:function(){if(!this.mainBody){return;} var g=this.grid;var c=g.getGridEl();var csize=c.getSize(true);var vw=csize.width;if(vw<20||csize.height<20){return;} if(g.autoHeight){this.scroller.dom.style.overflow='visible';this.scroller.dom.style.position='static';}else{this.el.setSize(csize.width,csize.height);var hdHeight=this.mainHd.getHeight();var vh=csize.height-(hdHeight);this.scroller.setSize(vw,vh);if(this.innerHd){this.innerHd.style.width=(vw)+'px';}} if(this.forceFit){if(this.lastViewWidth!=vw){this.fitColumns(false,false);this.lastViewWidth=vw;}}else{this.autoExpand();this.syncHeaderScroll();} this.onLayout(vw,vh);}});Ext.override(Ext.grid.GridView,{onColumnSplitterMoved:function(i,w){this.userResized=true;var cm=this.grid.colModel;var oldw=cm.getColumnWidth(i);var dw=oldw-w;cm.setColumnWidth(i,w,true);if(this.forceFit){this.updateColumnWidth(i,w);while(dw!=0&&i");if(this.displayInfo){this.displayEl=this.addText({text:' '});} this.add("-");this.first=this.addButton({tooltip:this.firstText,iconCls:"x-tbar-page-first",disabled:true,handler:this.onClick.createDelegate(this,["first"])});this.prev=this.addButton({tooltip:this.prevText,iconCls:"x-tbar-page-prev",disabled:true,handler:this.onClick.createDelegate(this,["prev"])});this.addSeparator();this.add(this.beforePageText);this.field=Ext.get(this.addDom({tag:"input",type:"text",size:"3",value:"1",cls:"x-tbar-page-number"}).el);this.field.on("keydown",this.onPagingKeydown,this);this.field.on("focus",function(){this.dom.select();});this.afterTextEl=this.addText(String.format(this.afterPageText,1));this.field.setHeight(18);this.addSeparator();this.next=this.addButton({tooltip:this.nextText,iconCls:"x-tbar-page-next",disabled:true,handler:this.onClick.createDelegate(this,["next"])});this.last=this.addButton({tooltip:this.lastText,iconCls:"x-tbar-page-last",disabled:true,handler:this.onClick.createDelegate(this,["last"])});this.loading=this.addButton({tooltip:this.refreshText,iconCls:"x-tbar-loading",handler:this.onClick.createDelegate(this,["refresh"]),hidden:true});if(this.dsLoaded){this.onLoad.apply(this,this.dsLoaded);}},updateInfo:function(){if(this.displayEl){var count=this.store.getCount();var msg=count==0?this.emptyMsg:String.format(this.displayMsg,this.cursor+1,this.cursor+count,this.store.getTotalCount());Ext.get(this.displayEl.getEl()).update(msg);}}});Ext.namespace("Lotus.ui");Lotus.ui.UISettingPlugin=function(config){Ext.apply(this,config)};Lotus.ui.UISettingPlugin.prototype={init:function(component){component.stateful=true;component.addEvents('stateload');Ext.apply(component,{saveState:function(){if(this.stateProvider){var state=this.getState();if(this.fireEvent('beforestatesave',this,this.stateProvider)!==false){this.stateProvider.set(this.stateId||this.id,state);this.fireEvent('statesave',this,state);}}},initState:function(config){if(this.stateProvider){var state=this.stateProvider.get(this.stateId||this.id,this);if(state){if(this.fireEvent('beforestaterestore',this,state)!==false){this.applyState(state);this.fireEvent('staterestore',this,state);}} else{this.on('stateload',this.initState,this,{single:true});}}},restoreState:function(config){if(!this.stateProvider)return;var state=this.stateProvider.get(this.stateId||this.id);if(state){this.applyState(state);}}});}};Lotus.ui.UISettingGridPlugin=Ext.extend(Lotus.ui.UISettingPlugin,{init:function(grid){if(this.unregisterHiddenchange){Ext.apply(grid,{initStateEvents:function(){Ext.grid.GridPanel.superclass.initStateEvents.call(this);}});} Lotus.ui.UISettingGridPlugin.superclass.init.apply(this,arguments);grid.addEvents('pagesizechanged');Ext.apply(grid,{getState:function() {var s=Ext.grid.GridPanel.prototype.getState.call(this);if(this.getTopToolbar()&&this.getTopToolbar().pageSize) {s.pageSize=this.getTopToolbar().pageSize;} return s;},applyState:function(state) {Ext.grid.GridPanel.prototype.applyState.call(this,state);if(state.pageSize) {sizeChanged=false;if(this.getTopToolbar()&&this.getTopToolbar().pageSize!=state.pageSize) {this.getTopToolbar().pageSize=state.pageSize;sizeChanged=true};if(this.getBottomToolbar()&&this.getBottomToolbar().pageSize!=state.pageSize) {this.getBottomToolbar().pageSize=state.pageSize;sizeChanged=true};if(sizeChanged)this.fireEvent('pagesizechanged',state);} if(!state.sort) {this.store.sortInfo=null;} this.getColumnModel().totalWidth=null;this.getView().lastViewWidth=null;this.getView().refresh(true);}});}});Lotus.ui.TreeEditorCancelEvPlugin=function(){this.init=function(editor){editor.addEvents('editcanceled');Ext.apply(editor,{beforeNodeClick:function(node,e){clearTimeout(this.autoEditTimer);if(this.tree.getSelectionModel().isSelected(node)){e.stopEvent();return this.triggerEdit(node);}else{if(this.allowBlur!==true){this.cancelEdit();}}},onBlur:function(){if(this.allowBlur!==true&&this.editing) {this.cancelEdit();}},cancelEdit:function(remainVisible){if(this.editing){this.setValue(this.startValue);this.fireEvent('editcanceled',this);if(remainVisible!==true){this.hide();}}}});}};Lotus.ui.Components={items:{},add:function(component){this.items[component.getId()]=component;}};Lotus.ui.Component=function(id) {this.id=id;this.objectClass="Lotus.ui.Component";this.registerEvents(["ajaxResponse"]);} Lotus.ui.Component.prototype={events:[],ajaxParams:{},defaultAjaxParams:{},handlers:{},ajaxMethod:"POST",ajaxEntryPoint:null,defaultHandlerAjaxParams:{},defaultAjaxParams:{},options:{},init:function(){Lotus.ui.Components.add(this);},setAjaxEntryPoint:function(url){this.ajaxEntryPoint=url;},getAjaxEntryPoint:function(){return this.ajaxEntryPoint;},setAjaxParams:function(params){if(Ext.ux.isEmpty(this.defaultAjaxParams)){this.defaultAjaxParams=Ext.ux.clone(params);} this.ajaxParams=params;},resetAjaxParams:function(){this.setAjaxParams(this.defaultAjaxParams);},getAjaxParams:function(){return Ext.ux.clone(this.ajaxParams);},setHandlers:function(handlers){for(var remoteHandler in handlers){this.defaultHandlerAjaxParams[remoteHandler]=Ext.ux.clone(handlers[remoteHandler].params);} this.handlers=handlers;},getHandlerFor:function(remoteHandler){if(!this.handlers[remoteHandler]){throw("Remote handler for '"+remoteHandler+"' not found");} var url=typeof this.handlers[remoteHandler].url=='undefined'?this.getAjaxEntryPoint():this.handlers[remoteHandler].url;return url;},getHandlerAjaxParams:function(remoteHandler){if(!this.handlers[remoteHandler]){throw("Remote handler for '"+remoteHandler+"' not found");} var extraParams=typeof this.handlers[remoteHandler].params=='undefined'?{}:this.handlers[remoteHandler].params;return Ext.ux.clone(extraParams);},setHandlerAjaxParams:function(remoteHandler,params,replace){params=params||{};if(typeof replace=='undefined')replace=false;if(replace===true)this.handlers[remoteHandler].params=params;else if(replace===false)Ext.apply(this.handlers[remoteHandler].params,params);},resetHandlerAjaxParams:function(remoteHandler){this.setHandlerAjaxParams(remoteHandler,this.defaultHandlerAjaxParams[remoteHandler],true);},setAjaxMethod:function(method){this.ajaxMethod=method;},getAjaxMethod:function(){return this.ajaxMethod;},setOptions:function(options){Ext.apply(this.options,options);},setOption:function(option,value) {this.options[option]=value;},getOption:function(option){return this.options[option];},getWidget:function(){},getId:function(){return this.id;},ajaxRequest:function(url,handleSuccess,handleFailure,params,crossdomain){params=params||{};if(typeof handleSuccess!='function') {} if(typeof handleFailure!='function') {} var reqOpt={method:this.ajaxMethod,url:url,success:this.handleResponse,failure:handleFailure,scope:this,argument:{handlerSuccess:handleSuccess,handlerFailure:handleFailure},params:Ext.applyIf(params,this.getAjaxParams())} if(crossdomain){tmpForm=Ext.getBody().createChild({tag:"form",method:"post"});Ext.Ajax.request(Ext.apply(reqOpt,{isUpload:true,form:tmpForm}));tmpForm.remove.defer(2000,tmpForm);}else{Ext.Ajax.request(reqOpt);}},handleResponse:function(response,request){var argument=response.argument;var json=response.responseText;var objResponse=json.length?eval("("+json+")"):{status:"error",errmsg:"Server response timed out."};var request_params=Ext.util.JSON.decode(request.params.request);if(!this.fireEvent("ajaxResponse",response,request,this))return false;if(objResponse.status=='ok'){argument.handlerSuccess.createDelegate(this,[objResponse,request_params])();}else{argument.handlerFailure.createDelegate(this,[objResponse,request_params])();}},confirmBox:function(title,message,callback){Ext.Msg.confirm(title,message,callback,this);},assign:function(event,func,scope){this.assignEventHandler(event,func,scope);},assignEventHandler:function(event,func,scope){this["on"+event]=func.createDelegate(scope);},fireEvent:function(eventName,arg1,arg2,arg3,arg4,arg5){var event="on"+eventName;if(this.events.indexOf(eventName)!=-1){return this[event](arg1,arg2,arg3,arg4,arg5);}else{throw("Event handler for '"+eventName+"' not implemented");}},registerEvents:function(events){for(var i=0;i3){ret["status"]=false;ret["msg"]="You can only create 3 levels of folders. Please choose a higher-level folder.";return ret;}else{return ret;}} var level=0;if(node.hasChildNodes()){++level;if(level+destParent.getDepth()>2){ret["status"]=false;ret["msg"]="You can only create 3 levels of folders. Please choose a higher-level folder.";return ret;} for(var i=0;i2){ret["status"]=false;ret["msg"]="You can only create 3 levels of folders. Please choose a higher-level folder.";return ret;}}}} return ret;},addNewNode:function(){var selectedNode=this.getSelectedTreeNode();if(selectedNode==null||selectedNode==''){Ext.Msg.show({title:'Error',msg:'Please select the folder in which you want the new folder to be added. To add a top-level folder, select "Folders."',buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR});return;}else{if(selectedNode.getDepth()>2){Ext.MessageBox.alert("Error",'You can only create 3 levels of folders. Please choose a higher-level folder.');return;} if(selectedNode.text=='Unfiled'){Ext.MessageBox.alert("Error","You cannot create a new folder under the 'Unfiled' folder."+" Please choose another folder.");return;}} if(!this.getOption("new_folder_label_by_ajax")||!this.getHandlerFor('folderAutoname')) {return this.addNewNodeAction(this.getOption("new_folder_label"));} this.tree.fireEvent('beforeAutonameCall');this.ajaxRequest(this.getHandlerFor("folderAutoname"),this.requestFldNameSuccess,this.requestFldNameError,this.getHandlerAjaxParams('folderAutoname'));},requestFldNameSuccess:function(response){this.tree.fireEvent('endAutonameCall');return this.addNewNodeAction(response.response.folder_autoname,true);},requestFldNameError:function(){this.tree.fireEvent('endAutonameCall');return this.addNewNodeAction(this.getOption("new_folder_label"));},addNewNodeAction:function(node_name,is_ajax_autoname){this.tree.getRootNode().expand();var selectedNode=this.getSelectedTreeNode();var node=selectedNode.appendChild(new Ext.tree.TreeNode({text:node_name,cls:'show-as-folder',id:'_newnode',allowDrag:this.getOption("allow_move"),'is_ajax_autoname':is_ajax_autoname}));this.tree.getSelectionModel().select(node);this.editor.editNode=node;this.editor.startEdit(node.ui.textNode);this.setCurrentEditedNode(node);},actionEditStart:function(editor,node,value) {this.tree.getTopToolbar().disable();},actionEditCanceled:function() {var editedNode=this.editor.editNode;if(editedNode.id==='_newnode'&&editedNode.getOwnerTree())editedNode.remove();editedNode.attributes.canceled=true;},actionAdd:function(editor,value,startvalue){if(value!=null&&typeof(value)!='undefined'&&value.indexOf('"')!=-1){Ext.MessageBox.alert("Error","Please do not use Double Quotes(\") in the Folder Name.");return false;} var editedNode=this.editor.editNode;var existingFolders=[];var parentNodeName=null;var parentNode=null;if(editedNode.id!="_newnode"){parentNode=this.selectedNode.parentNode;if(parentNode){existingFolders=parentNode.childNodes;}}else{existingFolders=this.selectedNode.childNodes;parentNode=this.selectedNode;if(existingFolders!=null&&typeof(existingFolders)!='undefined'&&value!='New Folder'){for(var i=0;i',value);},renderStoreName:function(value,p,record){return String.format('{0}',value,record.data.url);},renderDate:function(value){if(value==null||typeof(value)=='undefined'||value=='')return'';var pstTime=value.getTime()+(value.getTimezoneOffset()*60000)-(7*3600000);value=new Date(pstTime);return value?Ext.util.Format.date(value,'M d, Y')+' PDT':'';},renderDateTime:function(value){if(value==null||typeof(value)=='undefined'||value=='')return'';var pstTime=value.getTime()+(value.getTimezoneOffset()*60000)-(7*3600000);value=new Date(pstTime);return value?Ext.util.Format.date(value,'M d, Y, h:i a')+' PDT':'';}};Lotus.ui.Grid=Ext.extend(Lotus.ui.Component,{grid:null,reader:null,recordDef:{},dataRecord:null,store:null,cmDef:[],cm:null,selModel:null,toolbarExtraItems:[],gridPlugins:[],defaultStoreHandler:'get',bottomPagingToolbar:null,topPagingToolbar:null,editable:false,options:{width:800,height:600,items_per_page:10,delete_confirmation:"Are you sure you want to delete selected items?",record_id:"id",no_rows_text:"No items to display.",autoHeight:true,layout:'fit',enableHdMenu:true},getStoreLoadingParams:function(){return{params:{start:0,limit:this.getOption("items_per_page")}};},setRecordDef:function(recordDef){this.recordDef=recordDef;},setColumnModelDef:function(cmDef){this.cmDef=cmDef;},setSelectionModel:function(selModel){this.selModel=selModel;},setToolbarExtraItems:function(items){this.toolbarExtraItems=items;},setGridPlugins:function(plugins){if(!Ext.isArray(plugins)) {plugins=[plugins];} for(var ind=0;ind0)this.loadingForms--;if(this.loadingForms===0){this.enableActions();}},onFormBeforeLoad:function(form){this.loadingForms++;},onloadFailure:function(response){Ext.Msg.alert("Get preferences",response.errmsg);}}) Lotus.ui.PreferencesItem=Ext.extend(Lotus.ui.Component,{item:null,formPanel:null,footerButtons:[],options:{title:"Untitled Form",footer:false,header:true,button_align:"center",collapsed:false},setContent:function(item){this.item=item;},init:function(){var cfg={anchor:"100%",autoHeight:true,collapsible:true,titleCollapse:true,collapsed:this.getOption("collapsed"),title:this.getOption("title"),footer:this.getOption("footer"),header:this.getOption("header"),buttonAlign:this.getOption("button_align")};if(this.getOption("baseCls")){cfg.baseCls=this.getOption("baseCls");} if(this.footerButtons.length){Ext.apply(cfg,{footer:true,buttons:this.footerButtons});} this.formPanel=new Lotus.ui.CollapsibleRoundedPanel(cfg);this.formPanel.add(this.item.getWidget());Lotus.ui.PreferencesItem.superclass.init.call(this);},setFooterButtons:function(buttons){this.footerButtons=buttons;},setTitle:function(title){this.setOption("title",title);},getWidget:function(){return this.formPanel;},getForm:function(){return this.item.getForm();},getItem:function(){return this.item;}});Lotus.ui.Form=Ext.extend(Lotus.ui.Component,{events:["beforeSetValues","loadSuccess","loadError","beforeLoad","beforeSave","saveSuccess","saveFailure"],form:null,loaded:false,options:{auto_load:false},setContentById:function(formId){this.form=new Ext.form.BasicForm(formId);},setContentByUrl:function(url){},init:function(){this.convertForm();if(this.getOption("auto_load")){if(!this.getHandlerFor("get")){throw("Lotus.ui.Form: Handler 'get' not defined");} this.loadData();} Lotus.ui.Form.superclass.init.call(this);},convertForm:function(formId){this.form.getEl().select("input").each(function(item){this.convertInput(this.form,item);return;},this);this.form.getEl().select("textarea").each(function(item){this.convertTextarea(this.form,item);},this);this.form.getEl().select("select").each(function(item){this.convertSelect(this.form,item);},this);},convertTextarea:function(form,item){var elem=Ext.get(item);if(!elem)return;var field=new Ext.form.Field({inputType:elem.dom.type,applyTo:elem.dom,name:elem.dom.name});form.add(field);},convertSubmit:function(form,elem){var but=new Ext.Button({applyTo:elem.dom,text:elem.dom.value,handler:function(){},scope:this});but.on('click',elem.dom.onclick);but.validate=function(){return true;};elem.remove();form.add(but);},convertInput:function(form,item){var dummy=new Ext.form.Field();var elem=Ext.get(item);if(!elem)return;var field=null,but=null;if(elem.dom.type=="submit"||elem.dom.type=="button"){this.convertSubmit(form,elem);return;} if(elem.dom.type=="radio"||elem.dom.type=="checkbox"){if(!elem.dom.id)elem.dom.id=dummy.getId();var checkboxCfg={applyTo:elem.dom,name:elem.dom.name,id:elem.dom.id,checked:elem.dom.checked,disabled:elem.dom.disabled,listeners:{"beforerender":{fn:function(radio){radio.onRender=function(ct,position){Ext.form.Checkbox.superclass.onRender.call(this,ct,position);if(this.inputValue!==undefined){this.el.dom.value=this.inputValue;} this.wrap=this.el.wrap({cls:"x-form-check-wrap",tag:"span"});if(this.boxLabel){this.wrap.createChild({tag:'label',htmlFor:this.el.id,cls:'x-form-cb-label',html:this.boxLabel});} if(this.checked){this.setValue(true);}else{this.checked=this.el.dom.checked;}}}}}};switch(elem.dom.type){case"radio":field=new Ext.form.Radio(checkboxCfg);break;case"checkbox":field=new Ext.form.Checkbox(checkboxCfg);break;} form.add(field);return;} var field=new Ext.form.Field({inputType:elem.dom.type,applyTo:elem.dom,name:elem.dom.name,itemCls:"lotus-form-field"});form.add(field);},convertSelect:function(form,item){var elem=Ext.get(item);if(!elem)return;var comboParams=Ext.util.JSON.decode(elem.getAttributeNS(null,"request"))||{};Ext.applyIf(comboParams,this.getAjaxParams());var store=elem.getAttributeNS(null,"optionsdatasource")?new Ext.data.JsonStore({url:elem.getAttributeNS(null,"optionsdatasource"),root:'response.items',fields:['key','value'],baseParams:comboParams}):undefined;if(store)store.reload();var _object={transform:elem.dom,id:typeof elem.dom.id=='undefined'?elem.dom.name:elem.dom.id,allowDomMove:false,inputType:elem.dom.type,store:store,name:elem.dom.name,valueField:'value',displayField:'key',typeAhead:false,triggerAction:'all',lazyInit:false,forceSelection:true,hideLabel:false,defaultAutoCreate:{tag:"input",type:"text",size:"24",autocomplete:"off",style:"visibility: visible"},editable:false};if(elem.dom.getAttribute('width')!=null) {_object['width']=parseInt(elem.dom.getAttribute('width'));_object['minListWidth']=40;} var field=new Ext.form.ComboBox(_object);if(typeof elem.dom.onchange!='undefined'&&elem.dom.onchange!==null&&elem.dom.onchange!=''){field.on('select',elem.dom.onchange);} form.add(field);return field;},getWidget:function(){return new Ext.Component(this.form.getEl());},getForm:function(){return this.form;},getFormEl:function(elName){var field=this.form.findField(elName);return field;},loadData:function(){this.fireEvent("beforeLoad",this);this.ajaxRequest(this.getHandlerFor("get"),function(response){this.fireEvent("beforeSetValues",this,response);this.form.setValues(response.response);this.fireEvent("loadSuccess",this);},function(response){this.fireEvent("loadError",this);},this.getHandlerAjaxParams("get"));},saveData:function(){if(!this.fireEvent("beforeSave"))return false;var formValues={};Ext.apply(formValues,this.getForm().getValues());this.ajaxRequest(this.getHandlerFor("submit"),this.actionSaveSuccess,this.actionSaveError,Ext.apply(this.getHandlerAjaxParams("submit"),{form:formValues}));},actionSaveSuccess:function(response){if(!this.fireEvent("saveSuccess",this,response))return;Ext.Msg.alert("Save","Form save: success");},actionSaveError:function(response){if(!this.fireEvent("saveFailure",this,response))return;Ext.Msg.alert("Save","Form save: failure");}});Lotus.ui.Dashboard=Ext.extend(Lotus.ui.Component,{items:null,panel:null,options:{columns:2},setItems:function(items){this.items=items;},addItem:function(item){this.items.push(item);},removeItem:function(item){this.items.remove(item);},initColumns:function(){var colSize=1/this.getOption("columns");var columnDef=[];var startIndex=0;var announcementsWidget=null;var setAnnouncementsWidget=true;var alertsWidget=null;var setAlertsWidget=true;for(var i=0;i1){Ext.MessageBox.alert("Error",err2);return false;} return true;},init:function(){Ext.applyIf(this.options,{subgrid_record_id:"subgridId"});this.rowExpander=new Lotus.SubgridRowExpander({no_subgrid_row_text:this.getOption('no_subgrid_row_text'),recordCfg:this.subgridRecordDef,cmCfg:this.subgridCmDef,readerCfg:{totalProperty:"response.results",root:"response.rows",id:this.getOption("subgrid_record_id")},proxyCfg:{url:this.getHandlerFor("subgrid_get"),method:this.getAjaxMethod()},storeRowParams:this.subgridAjaxRowParams,storeBaseParams:Ext.apply(Ext.ux.clone(this.ajaxParams),Ext.apply(this.subgridAjaxParams,this.getHandlerAjaxParams("subgrid_get"))),masterGridDataColumn:this.masterGridDataColumn});this.rowExpander.setLazyLoadStore(this.lazyLoadStore);this.rowExpander.setBindSelectionWithParent(this.bindSelectionWithParent);this.rowExpander.setSubgridSelModelType(this.subgridSelModelType);this.setGridPlugins(this.rowExpander);this.initGrid();if(!this.getOption("stateful")){this.refresh();} Lotus.ui.Grid.superclass.init.call(this);},setSubgridCmDef:function(cmDef){this.subgridCmDef=cmDef;},setSubgridRecordDef:function(recordDef){this.subgridRecordDef=recordDef;},setSubgridSelModelType:function(selModel){this.subgridSelModelType=selModel;},setSubgridAjaxRowParams:function(params){this.subgridAjaxRowParams=params;},setSubgridAjaxParams:function(params){Ext.apply(this.subgridAjaxParams,params);},setMasterGridDataColumn:function(column){this.masterGridDataColumn=column;},getSubgridSelectionIds:function(returnAllIfNoneSeleted){var ids=[];if(typeof returnAllIfNoneSeleted=='undefined'||returnAllIfNoneSeleted==null){returnAllIfNoneSeleted=false;} for(var i=0;i{dottedName}':'
{dottedName}
';this.view=new Ext.DataView({cls:"lotus-ihost-view",itemSelector:'div.thumb-wrap',style:'overflow:auto',multiSelect:true,plugins:new Ext.DataView.DragSelector({dragSafe:true,extendSelection:!this.getOption("enable_drag")===true}),store:this.store,tpl:new Ext.XTemplate('','
','
',thumbPartTpl,'
','
','
')});this.panel=this.initPanel();this.view.on("render",function(){this.mask=new Ext.LoadMask(this.view.getEl(),{store:this.store});if(!this.getOption('lazy_load')){var extraParams={start:0,limit:this.getOption("items_per_page")};extraParams=Ext.apply(this.getAjaxParams(),Ext.apply(this.getHandlerAjaxParams("get"),extraParams));this.ajaxRequest(this.getHandlerFor("get"),this.getImageDataSuccess,this.getImageDataFailure,extraParams);} if(this.getOption("enable_drag")){var drgzone=new ImageDragZone(this.view,{ddgroup:"ihost-images"});} if(this.getOption("enable_drop")){var drpzone=new Ext.dd.DropTarget(this.view.getEl(),{ddgroup:"ihost-images"});drpzone._linkedEl=this;drpzone.notifyDrop=function(source,e,data){var target=Ext.get(e.getTarget());if(!target.hasClass("thumb-wrap")){target=target.up(".thumb-wrap");} if(target===null){this._linkedEl.updateNodes(data.nodesData,null,null);}else{var point=e.getXY();var box=target.getBox();if(point[0]>box.x+box.width/2){this._linkedEl.updateNodes(data.nodesData,target,"after");} else{this._linkedEl.updateNodes(data.nodesData,target,"before");}} return true;};}},this);Lotus.ui.ImagesPanel.superclass.init.call(this);},updateNodes:function(nodesSource,nodeDestination,position){var json={source:[]};var nodes=nodesSource;for(var i=0;i0){var thumbDom=this.panel.getEl().select("div.thumb-wrap:first").first();var thumbHeight=thumbDom?Ext.fly(thumbDom).getBox().height+Ext.fly(thumbDom).getPadding("tb"):100;ht=Math.ceil(num/5)*thumbHeight+25;} this.panel.body.setHeight(ht);},initDataStore:function(){return new Ext.data.JsonStore({url:this.getHandlerFor("get"),totalProperty:"images.count",root:"images.data",id:this.getOption("record_id"),fields:this.dataFields});},initPanel:function(){this.dataList.images={};this.dataList.images.count=0;this.dataList.images.data=[];this.zoomDataList.images={};this.zoomDataList.images.count=0;this.zoomDataList.images.data=[];var panelItems=new Array();if(this.enableZoom){this.initTypeDD();panelItems.push(this.typeDd);} panelItems.push(this.view);return new Ext.Panel({header:false,region:'center',margins:'1 1 1 0',style:'overflow:auto',bbar:this.initPagerToolbar("bottom",null,this.bbarItems),items:panelItems,width:550,height:this.getOption("height")});},initTypeDD:function(){this.typeDd=new Ext.form.ComboBox({xtype:'combo',store:[['0','Standard'],['4','Zoomstream']],width:225,selectOnFocus:true,editable:false,triggerAction:'all',listeners:{"select":{fn:this.refresh,scope:this}},name:'imageType',value:'',inputValue:'1',fieldLabel:'Image Type',hideLabel:false,labelSeparator:':'});this.typeDd.setValue('0');},setData:function(data){this.dataList=data;},setZoomData:function(data){this.zoomDataList=data;},getData:function(){return this.dataList;},getZoomData:function(){return this.zoomDataList;},setBrowserWindow:function(win){this.browserWindow=win;},deleteNodes:function(nodes){if(!this.fireEvent("beforeDelete",this,nodes))return;if(nodes.length<=0){return;} var currentDataList={};if(this.enableZoom&&this.typeDd.getValue()=='4'){currentDataList=this.zoomDataList;}else{currentDataList=this.dataList;} if(!currentDataList||!currentDataList.images||!currentDataList.images.data){return;} var dataRows=currentDataList.images.data;if(dataRows.length<=0){return;} var newDataRows=new Array();for(var i=0;ilimit){var errMsg="Maximum limit of "+limit+" images has been exceeded. You already have "+currLen+" images attached. Please remove some images and try again";Ext.MessageBox.alert("Error",errMsg);return false;} return true;},checkForRepeatedImages:function(records){var currentDataList={};if(this.enableZoom&&this.typeDd.getValue()=='4'){currentDataList=this.zoomDataList;}else{currentDataList=this.dataList;} var duplicateUrl=false;for(var p=0;p0){nodes=sortNodes;} var newDataRows=new Array();if(nodeDestination==null){for(var i=0;i=start&&i{msg}"),textBox:null,options:{enable_zoom:false,folders_id_column:"id",folders_name_column:"text"},setOptions:function(options){this.options=options;this.options.folders_id_column="id";this.options.folders_name_column="text";},setCurrentFolder:function(fid){this.currentFolder=parseInt(fid)?fid:null;},events:['uploadFailure','uploadSuccess','folderCreateSuccess','folderCreateFailure'],findFormField:function(baseId){if(!this.getForm())return undefined;return this.getForm().findField(this.generateFieldId(baseId));},generateFieldId:function(baseId){return this.id+"-"+baseId;},init:function(){var formFields=[{xtype:'fileuploadfield',anchor:'100%',allowedExtensions:['gif','png','jpg','jpeg'],id:this.generateFieldId("file"),emptyText:'Select an image',fieldLabel:'Image Location',allowBlank:false,name:'file',listeners:{fileselected:{fn:function(field,value){this.findFormField("image_name").setValue(this.extractFileName(value));this.textBox.body.update("");},scope:this}}}];formFields.push({xtype:'textfield',name:'image_name',id:this.generateFieldId('image_name'),fieldLabel:'Image Name',allowBlank:true});if(!this.getOption("enable_zoom")){formFields.push({xtype:"combo",name:"fid",id:this.generateFieldId("fid"),hiddenName:"fid",fieldLabel:"Upload to folder",emptyText:'Unfiled',editable:false,forceSelection:true,triggerAction:'all',store:new Ext.data.Store({url:this.getHandlerFor("getFolders"),baseParams:Ext.apply(this.getAjaxParams(),this.getHandlerAjaxParams("getFolders")),reader:new Ext.data.JsonReader({root:'data',id:this.getOption("folders_id_column")},[{name:'fid',mapping:this.getOption("folders_id_column")},{name:'name',mapping:this.getOption("folders_name_column")}]),listeners:{load:{fn:function(){if(this.currentFolder){this.findFormField("fid").setValue(this.currentFolder);}},scope:this}}}),mode:'local',valueField:'fid',displayField:'name',listeners:{render:function(){this.store.load();}}});formFields.push({xtype:'textfieldwithbutton',name:'new_folder',width:230,id:this.generateFieldId('new_folder'),fieldLabel:"Create new folder",buttonText:"Create",buttonCfg:{handler:function(){var field=this.findFormField("new_folder");if(field.getValue().length){this.createNewFolder();}else{field.markInvalid();}},scope:this}});formFields.push({xtype:'textfield',name:'caption',fieldLabel:'Caption',id:this.generateFieldId('caption'),allowBlank:true});};formFields.push({xtype:'hidden',name:'cat',value:this.getOption("enable_zoom")?'zoom':'ihost'});this.uploadForm=new Ext.FormPanel({fileUpload:true,method:'POST',url:this.getHandlerFor("submit"),height:200,width:380,labelWidth:130,items:formFields});this.textBox=new Ext.Panel({height:30,layout:'fit'});this.win=new Ext.Window({cls:'lotus-ihost-window',title:this.getOption("enable_zoom")?"Upload Zoomstream Images":"Upload Standard Images",border:true,autoHeight:true,width:400,plain:true,items:this.formPanel,header:true,resizable:false,closable:true,constrain:true,items:[this.uploadForm,this.textBox],buttons:[{text:"Upload",handler:function(){if(!this.getForm().isValid())return;this.getForm().doAction(new Lotus.FormSubmitAction(this.getForm(),{waitMsg:'Uploading your image...',failure:function(form,action){this.fireEvent("uploadFailure",action,form);this.textBox.body.update(this.msgTpl.applyTemplate({msg:""}));Ext.Msg.show({title:'Error',msg:action.result.errors.errmsg,buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR});},success:function(form,action){this.textBox.body.update(this.msgTpl.applyTemplate({msg:"Upload successful! Upload another image?"}));this.fireEvent("uploadSuccess",action,form);},params:this.getHandlerAjaxParams("submit"),scope:this}));},scope:this},{text:"Cancel",handler:function(){this.win.close();},scope:this}]});},show:function(){if(this.win) this.win.show();},getWidget:function(){return this.win;},getFormPanel:function(){return this.uploadForm;},getForm:function(){return this.uploadForm.getForm();},getCreateFolderParams:function(folderName){if(typeof(folderName)!='undefined'||folderName!=null) return Ext.apply({fname:folderName},this.getHandlerAjaxParams("createFolder"));else return Ext.apply(this.getHandlerAjaxParams("createFolder"));},createNewFolder:function(){var value=this.findFormField('new_folder').getValue();this.ajaxRequest(this.getHandlerFor("createFolder"),this.createNewFolderSuccess,this.createNewFolderError,this.getCreateFolderParams(value));},createNewFolderSuccess:function(response,send){this.currentFolder=response.response.fid;this.findFormField("new_folder").reset();this.findFormField("fid").store.load();this.fireEvent("folderCreateSuccess",response,send);},createNewFolderError:function(response){this.fireEvent("folderCreateFailure",response);Ext.Msg.show({title:'Error',msg:response.errmsg?response.errmsg:'Unknown error creating folder, please try again.',buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR});},extractFileName:function(path) {var filename='';if(path.indexOf('/')>-1) filename=path.substring(path.lastIndexOf('/')+1,path.length);else filename=path.substring(path.lastIndexOf('\\')+1,path.length);return filename;}});Lotus.ui.IhostPanel=Ext.extend(Lotus.ui.Component,{layout:null,treePanel:null,imagesPanel:null,win:null,browserListDataFields:[],mainListDataFields:[],treeHandlers:{},treeOptions:{},listHandlers:{},listOptions:{},mainListHandlers:{},mainListOptions:{},useLocalPanel:false,enableZoom:false,mainList:null,uploaderHandlers:{},uploaderOptions:{},useCustomMainList:false,customMainList:null,uploader:null,initBrowseWindow:function(){this.imagesPanel=new Lotus.ui.ImagesPanel("ihost-images-panel");this.imagesPanel.useLocalPanel=this.useLocalPanel;this.imagesPanel.setAjaxEntryPoint(this.getAjaxEntryPoint());this.imagesPanel.setHandlers(this.listHandlers);this.imagesPanel.setOptions(Ext.apply(this.listOptions,{enable_drag:false,enable_drop:false}));if(!this.enableZoom){this.imagesPanel.setAjaxParams(this.getAjaxParams());}else{if(this.mainList.typeDd.getValue()=='4') this.imagesPanel.setAjaxParams(Ext.apply(this.getAjaxParams(),{cat:'zoom'}));} this.imagesPanel.setLinkedImagesPanel(this.mainList);this.imagesPanel.setDataFields(this.browserListDataFields);var topToolbar=[];if(!this.enableZoom||this.mainList.typeDd.getValue()=='0'){topToolbar.push({xtype:"button",text:"Upload >",handler:function(){this.showUploader();},scope:this});} var attachButtonCfg={xtype:"button",text:"Attach Selected",handler:function(){if(this.linkedImagesPanel){var records=this.getView().getSelectedRecords();if(records.length){if(this.useLocalPanel){if(this.linkedImagesPanel.checkAgainstMaxLimit(records.length)&&this.linkedImagesPanel.checkForRepeatedImages(records)){this.linkedImagesPanel.updateNodes(records,null,null);}}else{this.linkedImagesPanel.updateNodes(records,null,null);}}}},scope:this.imagesPanel};topToolbar.push(attachButtonCfg);topToolbar.push("->");topToolbar.push({xtype:"textfield",name:"keyword",id:"keyword"});topToolbar.push({xtype:"button",text:"Search",handler:function(){var searchText=Ext.getCmp('keyword').getValue();if(searchText!=null&&searchText!=""){this.search({'searchText':searchText});}else return;},scope:this.imagesPanel});this.imagesPanel.setTopToolbarExtraItems(topToolbar);this.imagesPanel.setBottomToolbarExtraItems([Ext.apply({"style":{"margin-left":"200px"}},attachButtonCfg)]);this.imagesPanel.init();if(!this.enableZoom||this.mainList.typeDd.getValue()=='0'){this.treePanel=new Lotus.ui.FolderTree("ihost-tree-comp");this.treePanel.setAjaxEntryPoint(this.getAjaxEntryPoint());this.treePanel.setHandlers(this.treeHandlers);this.treePanel.setOptions(Ext.apply(this.treeOptions,{allow_delete:false,allow_create:false}));this.treePanel.setAjaxParams(this.getAjaxParams());this.treePanel.init();this.treePanel.getWidget().on("click",function(node){this.imagesPanel.refresh({fid:node.id})},this);var leftPanel=new Ext.Panel({region:'west',split:true,collapsible:true,collapseMode:'mini',width:200,minWidth:150,border:false,cls:'lotus-left-panel',autoScroll:true,items:[this.treePanel.getWidget()]});this.layout=new Ext.Panel({layout:'border',width:850,height:400,items:[leftPanel,this.imagesPanel.getWidget()]});}else if(this.enableZoom&&this.mainList.typeDd.getValue()=='4'){this.layout=new Ext.Panel({layout:'border',width:650,height:400,items:[this.imagesPanel.getWidget()]});} this.win=new Ext.Window({cls:'lotus-ihost-window',border:false,autoHeight:true,plain:true,items:this.formPanel,header:true,resizable:true,closable:true,constrain:true,items:this.layout});this.win.show();this.win.setWidth(this.layout.getInnerWidth()+10);this.win.setHeight(this.layout.getInnerHeight());if(this.enableZoom){if(this.mainList.typeDd.getValue()=='0'){this.win.setTitle('Standard Images')}else if(this.mainList.typeDd.getValue()=='4'){this.win.setTitle('Zoomstream Images');}} if(this.useLocalPanel){this.mainList.setBrowserWindow(this.win);} this.win.on("close",function(){if(this.uploader&&this.uploader.getWidget()){this.uploader.getWidget().close();}},this);},showUploader:function(){if(this.enableZoom&&this.mainList.typeDd.getValue()=='4')return;if(this.uploader){if(this.uploader.getWidget().isVisible()){this.uploader.getWidget().toFront();return;}} this.uploader=new Lotus.ui.ImageUploader(this.id+"-image-uploader");this.uploader.setHandlers(this.uploaderHandlers);this.uploader.setOptions(Ext.applyIf({enable_zoom:this.enableZoom&&this.mainList.typeDd.getValue()=='4'},this.uploaderOptions));if(this.treePanel.getSelectedTreeNode()){this.uploader.setCurrentFolder(this.treePanel.getSelectedTreeNode().id);} else{this.uploader.setCurrentFolder(null);} this.uploader.setAjaxParams(this.getAjaxParams());this.uploader.assign("uploadSuccess",function(response,form){var folderId=this.uploader.findFormField("fid").getValue();this.imagesPanel.refresh({fid:folderId});if(folderId) this.treePanel.getWidget().getSelectionModel().select(this.treePanel.getWidget().getNodeById(folderId));else this.treePanel.getWidget().getSelectionModel().clearSelections();this.uploader.findFormField("file").reset();this.uploader.findFormField("image_name").reset();this.uploader.findFormField("caption").reset();},this);this.uploader.assign("folderCreateSuccess",function(){this.treePanel.refresh();},this);this.uploader.init();this.uploader.show();},init:function(){if(this.useCustomMainList==true&&this.customMainList){this.mainList=this.customMainList;}else if(this.useLocalPanel){this.mainList=new Lotus.ui.ImagesLocalPanel("ihost-attached-local-panel");this.mainList.enableZoom=this.enableZoom;}else{this.mainList=new Lotus.ui.ImagesPanel("ihost-attached-panel");} this.mainList.setOptions(Ext.apply(this.mainListOptions));this.mainList.setAjaxEntryPoint(this.getAjaxEntryPoint());this.mainList.setHandlers(this.mainListHandlers);this.mainList.setAjaxParams(this.getAjaxParams());this.mainList.setBottomToolbarExtraItems([{text:"Remove",handler:function(){this.mainList.deleteSelectedNodes();},scope:this},{text:"Add Images",handler:function(){this.initBrowseWindow()},scope:this}]);this.mainList.setTopToolbarExtraItems([]);this.mainList.setDataFields(this.mainListDataFields);this.mainList.init();Lotus.ui.IhostPanel.superclass.init.call(this);},setMainListDataFields:function(fields){this.mainListDataFields=fields;},setBrowserListDataFields:function(fields){this.browserListDataFields=fields;},setTreeHandlers:function(handlers){this.treeHandlers=handlers;},setTreeOptions:function(options){this.treeOptions=options;},setBrowserListHandlers:function(handlers){this.listHandlers=handlers;},setBrowserListOptions:function(options){this.listOptions=options;},setMainListHandlers:function(handlers){this.mainListHandlers=handlers;},setMainListOptions:function(options){this.mainListOptions=options;},setUploaderHandlers:function(handlers){this.uploaderHandlers=handlers;},setUploaderOptions:function(options){this.uploaderOptions=options;},getWidget:function(){return this.mainList.getWidget();},setMainListData:function(data){if(this.mainList){return this.mainList.setData(data);}else{return false;}},setZoomListData:function(data){if(this.mainList){return this.mainList.setZoomData(data);}else{return false;}},loadMainListData:function(data){this.setMainListData(data) return this.mainList.refresh();},getMainListData:function(){return this.mainList.getData();},getZoomListData:function(){return this.mainList.getZoomData();},getTree:function(){return this.treePanel;},getBrowser:function(){return this.imagesPanel;},setCustomMainList:function(customMainList){this.customMainList=customMainList;},setUseCustomMainList:function(useCustomMainList){this.useCustomMainList=useCustomMainList;}});Lotus.ui.SearchWidget=Ext.extend(Lotus.ui.Form,{_name:'sw_',_title:'Search Widget',data:null,rows_visible:1,rows_top:0,rows_maximum:4,cols_delete_base:0,cols_attributes_base:1,cols_subjects_base:2,cols_predicates_base:3,cols_complements_base:4,searchPanel:null,_deps:{},_data:{},_width:900,options:{should_convert:false,auto_load:true},setName:function(value){this._name=value;},setTitle:function(value){this._title=value;},setWidth:function(val){this._width=val;},setDeps:function(value){if(typeof value!='object'){return;} this._deps=value;},loadDeps:function(){this.ajaxRequest(this.getHandlerFor("getDeps"),function(response){this.setDeps(response.response);this._depsReady=true;this._calls_ready();},function(response){if(typeof this._loadErrors=='undefined'){this._loadErrors=[];} this._depsReady=true;this._loadErrors.push('Widget dependencies could not be loaded.');this._calls_ready();},this.getHandlerAjaxParams("getDeps"));},loadData:function(){this.fireEvent("beforeLoad",this);this.ajaxRequest(this.getHandlerFor("get"),function(response){this._data=response.response;this._dataReady=true;this._calls_ready();},function(response){if(typeof this._loadErrors=='undefined'){this._loadErrors=[];} this._dataReady=true;this._loadErrors.push('Widget data could not be loaded.');this._calls_ready();},this.getHandlerAjaxParams("get"));},saveData:function(){if(!this.fireEvent("beforeSave"))return false;var formValues=this.getFormData();this.ajaxRequest(this.getHandlerFor("submit"),this.actionSaveSuccess,this.actionSaveError,Ext.apply(this.getHandlerAjaxParams("submit"),{form:formValues}));},getFormData:function(){var formValues={};for(var i in this._formElements){if(Ext.isArray(this._formElements[i])){formValues[i]={};for(var k=0;kItems to which  '});var operatorLabel2=new Ext.form.Label({html:'  of these conditions apply:'});var operatorPanel=new Ext.form.ComboBox({id:this._name+'_search_operator_combo',name:this._name+'-operator',labelAlign:'left',store:store,value:value,mode:'local',width:70,hideLabel:false,editable:false,forceSelection:true,selectOnFocus:true,triggerAction:'all'});if(typeof this.searchOperator=='undefined'||this.searchOperator===null){this.searchOperator=new Ext.Panel({id:this._name+'_search_operaror',width:this._width-20,layout:'table',layoutConfig:{columns:3},items:[operatorLabel,operatorPanel,operatorLabel2]});} items.push(this.searchOperator);this.addToForm(operatorPanel);}else{var operatorValue=new Ext.form.Hidden({name:this._name+'-operator',value:value});items.push(operatorValue);this.addToForm(operatorValue);} if(typeof this.searchPanel=='undefined'||this.searchPanel===null){this.searchPanel=new Ext.Panel({id:this._name+'_search_form',width:this._width-10});} items.push(this.searchPanel);if(typeof this._post_search_panel=='object'){items.push(this._post_search_panel);} var searchPanel=new Ext.Panel({id:this._name+'_search_widget',title:this._title,bodyStyle:'padding: 5px 5px 5px',width:this._width,labelAlign:'top',frame:true,layout:'form',items:items});this.rows_visible=this.isPrefillValue(0)?this._data.rows.length:this._deps.rows_visible;this.rows_maximum=this._deps.rows_maximum;var linkPanel=new Ext.Panel({autoHeight:true,autoScroll:false,autoWidth:true,bodyBorder:false,footer:false,header:false,id:this._name+'add_new_line',layout:'column',shadow:false});linkPanel.addButton({text:'add condition',cls:"search-panel-button",handler:function(){if(this.rows_visible'));return;} this._on_calls_ready();}},initAll:function(){this._clearPanel();this.form=new Ext.form.BasicForm();this.fireEvent('formCreated');this._initPanel();this._initRows();this.searchPanel.doLayout();this.fireEvent('endLayout');},_initRows:function(){this._populating=true;for(var i=0;i=this.cols_complements_base){return true;}} return false;},this);for(var i=0;i0){db=new Ext.Button({id:(this._name+'-del-row-'+index),cls:'lotus-btn-options',icon:'/lts/void.gif'});db.on({'click':{fn:function(link){var index=this._extractRow(link.id);if(index>0){this.spDelRow(index);}},scope:this}});} else{db=new Ext.form.Label({html:' '});} rowPanel.insert(this.cols_delete_base,{id:this.spId(index,'col',this.cols_delete_base),layout:"table",columnWidth:.05,items:[db]});this.searchPanel.insert(pos,rowPanel);subjectsCombo.fireEvent('select',subjectsCombo);},spDelRow:function(index){var items=this._formElements;for(var i in items){if(this._matchRow(i,index)){this.removeFromForm(i);}} this.searchPanel.remove(this.spId(index));this.rows_visible--;}});if(typeof(loadScripts)!='undefined'){loadScripts();} Lotus.ui.BubbleToolTip=function(obj){if(typeof(obj)=='undefined'||obj==null){obj={};} if(typeof(obj.bubbleInfo)=='undefined'||obj.bubbleInfo==null){obj.bubbleInfo={};} this.bubbleInfo=obj.bubbleInfo;var html='
'+this.bubbleInfo.bubbleMessage+'
Don\'t show this again
=ay){if(this.bubbleInfo.vAlign=="A"){y=ay-h-5;} else if(this.bubbleInfo.vAlign=="B"){y=ay+30;}} if(x<=ax&&(x+w)>=ax){if(this.bubbleInfo.hAlign=="L"){x=ax-10;} else if(this.bubbleInfo.hAlign=="R"){x=(ax+aw+5)-w;} else if(this.bubbleInfo.hAlign=="C"){x=(ax-(w/2)+(aw/2));}} return{x:x,y:y};},refresh:function(){this.initTarget();this.show();},getTargetWH:function(){var targetEl=Ext.get(this.bubbleInfo.targetElId);var wh=[0,0];if(typeof(targetEl)!='undefined'&&targetEl!=null){wh[0]=targetEl.getSize().width;wh[1]=targetEl.getSize().height;} return wh;},show:function(){var targetEl=Ext.get(this.bubbleInfo.targetElId);if(typeof(targetEl)!='undefined'&&targetEl!=null&&targetEl.isDisplayed()){Lotus.ui.BubbleToolTip.superclass.show.call(this);}},getTargetXY:function(){var targetEl=Ext.get(this.bubbleInfo.targetElId);var xy=[0,0];if(typeof(targetEl)!='undefined'&&targetEl!=null){xy[0]=targetEl.getLeft();xy[1]=targetEl.getTop();} return xy;}});Lotus.ui.CategoryTree=Ext.extend(Lotus.ui.Component,{categoriesChanged:false,currentEditedNode:null,tree:null,win:null,propWin:null,isLoaded:false,events:['beforeSave','saveSuccess','saveFailure','beforeLoad','loadSuccess','loadFailure','addNode','deleteNode','editNode','moveSuccess','moveFailure'],nodeMenu:new Ext.util.MixedCollection(),options:{title:"Category editor",renderAsPanel:false,renderTo:null,crossdomain:true,width:390,height:350,storeMapping:{categories:"categories",subcategories:"subcategories"},frame:false,header:false},getNodeBaseAttrs:function(){return{singleClickExpand:false,iconCls:'x-tree-node-categories',listeners:{dblclick:this.onNodeDblClick,beforemove:this.onNodeBeforeMove,move:this.onNodeMove,scope:this}}},onNodeDblClick:function(node,e){if(e.getTarget()!=node.getUI().getTextEl())return;this.showEditCategoryWindow(node,node.parentNode,"edit");},onNodeMove:function(tree,node,oldParent,newParent,index){if(newParent.getDepth()>=1){} this.fireEvent("moveSuccess",this,tree,node,oldParent,newParent);},onNodeBeforeMove:function(tree,node,oldParent,newParent,index){var response=this.checkValidNodeMovement(node,oldParent,newParent);if(!response.status){Ext.Msg.show({title:'Error',msg:response.msg,buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR});return false;}},checkValidNodeMovement:function(node,sourceParent,destParent){var ret={"status":true,"msg":""};if(sourceParent!=destParent){if(this.checkNodeExists(node,destParent)){ret["status"]=false;ret["msg"]="Category already exists";}} return ret;},checkNodeExists:function(node,destNode){for(var i=0;iTry again?',buttons:Ext.Msg.OKCANCEL,fn:function(a){if(a=='cancel'){tree.opList=[];tree.getTree().root.reload();}else{tree.saveCategoryTree();} if(this.win&&typeof this.win.close=='function')this.win.close();},icon:Ext.MessageBox.ERROR,scope:this});this.fireEvent("saveFailure",this,response,request);},onMenuAddCategory:function(){if(!this.addCategory(this.getSelectedNode())){Ext.Msg.show({title:'Error',msg:'You can\'t have more than 2 levels.',buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR});}},addCategory:function(node){node=node||this.tree.getRootNode();this.showEditCategoryWindow(null,node,"add");return true;},getSelectedNode:function(){return this.tree.getSelectionModel().getSelectedNode();},serializeCategoryTree:function(node){var i=0;var sLevel=[];var serializedTree=[];while(typeof(node.item(i))!='undefined'){var cNode=node.item(i);var sNode={};var parentId=cNode.parentNode.id;if(parentId=="source"){parentId="-1";} sNode['id']=cNode.attributes.id;sNode['name']=Ext.util.Format.htmlDecode(cNode.attributes.text);sNode['parentId']=parentId;sNode['index']=node.indexOf(cNode)+1;sNode['mature']=cNode.attributes.mature;sNode['Image']=cNode.attributes.Image;if(cNode.hasChildNodes()){sNode[this.getOption("storeMapping").subcategories]=this.serializeCategoryTree(cNode);} if(node.getDepth()==0){serializedTree.push(sNode);} sLevel.push(sNode);i++;} if(node.getDepth()==0){var obj={};obj[this.getOption("storeMapping").categories]=serializedTree;return obj;} else return sLevel;},onMenuDeleteCategory:function(){if((n=this.getSelectedNode())!=null) this.deleteCategoryConfirm(n);},deleteCategoryConfirm:function(node){if(node==null)return;if(node.id=='source'){Ext.Msg.show({title:'Error',msg:'You can\'t delete the root.',buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR});return;} Ext.Msg.show({title:'Confirmation',msg:'Are you sure you want to delete \''+node.text+'\' ?
(Note: Deleting a category does NOT delete the contained items, which will be moved to this category\'s parent).',buttons:Ext.Msg.YESNO,cls:"x-window-wz",fn:function(answer){if(answer=='yes'){node.remove();this.fireEvent("deleteNode",this,node);}},animEl:'elId',icon:Ext.MessageBox.QUESTION,scope:this});},onMenuEditCategory:function(){var node=this.getSelectedNode();if(!this.editCategory(node)){Ext.Msg.show({title:'Error',msg:'Select a category first.',buttons:Ext.Msg.OK,icon:Ext.MessageBox.ERROR});return;}},editCategory:function(node){if(node==null) return false;this.showEditCategoryWindow(node,node.parentNode,"edit");return true;}});Lotus.ui.CategoryTreePlus=Ext.extend(Lotus.ui.CategoryTree,{activeNodes:new Ext.util.MixedCollection(),getTbarCfg:function(){return null},getBbarCfg:function(){return null},getMenuButtonsCfg:function(nodeType){nodeType=nodeType||"categ";var btnCfg=[{text:"New Subcategory",cls:"xblueBtn",disabledClass:"xblueBtndis",handler:function(but){this.addCategory(this.tree.getNodeById(but.nodeId));},scope:this},{text:"Move",cls:"xblueBtn",disabledClass:"xblueBtndis",handler:function(but){this.showMoveMenu(this.tree.getNodeById(but.nodeId));},scope:this},{text:"Edit",cls:"xblueBtn",disabledClass:"xblueBtndis",handler:function(btn){this.editCategory(this.tree.getNodeById(btn.nodeId));},scope:this},{text:"Delete",handler:function(btn){this.deleteCategoryConfirm(this.tree.getNodeById(btn.nodeId));},cls:"xblueBtn",disabledClass:"xblueBtndis",scope:this}];switch(nodeType){case'root':Ext.apply(btnCfg[0],{text:"New Category",cls:"xblueBtn",disabled:false});Ext.apply(btnCfg[1],{disabled:true});Ext.apply(btnCfg[2],{disabled:true});Ext.apply(btnCfg[3],{disabled:true});break;} return btnCfg;},init:function(){Lotus.ui.CategoryTreePlus.superclass.init.call(this);this.win.getEl().on("mousedown",function(e){var divR=this.win.getEl().getRight();var ulR=Ext.fly(this.tree.getRootNode().getUI().getEl()).getRight();if(divR-ulR<3)return;if(e.getPageX()>=ulR&&e.getPageX()<=divR){this.removeAllNodeMenus();}},this);var tree=this;tree.opList=[];tree.serializeNode=function(cNode,parentId){sNode={};if(parentId=="source"){parentId="-1";} sNode['id']=cNode.attributes.id;sNode['index']=cNode.parentNode.indexOf(cNode)+1;sNode['name']=Ext.util.Format.htmlDecode(cNode.attributes.text);sNode['parentId']=parentId;sNode['mature']=cNode.attributes.mature;sNode['Image']=cNode.attributes.Image;sNode['MetaKeywords']=cNode.attributes.MetaKeywords?cNode.attributes.MetaKeywords:'';sNode['MetaDescription']=cNode.attributes.MetaDescription?cNode.attributes.MetaDescription:'';sNode['Image']=cNode.attributes.Image?cNode.attributes.Image:'';sNode['HeaderImage']=cNode.attributes.HeaderImage?cNode.attributes.HeaderImage:'';return sNode;} tree.getChildIds=function(node,ids){if(!ids) var ids=[];ids.push(node.attributes.id);for(var i=0;i=2)node.setMenuButtons(this.getMenuButtonsCfg("subcateg"));else node.setMenuButtons(this.getMenuButtonsCfg("categ"));},onDestroyNodeMenu:function(node){this.activeNodes.removeKey(node.id);},onShowNodeMenu:function(menu,node){if(this.activeNodes.getCount())this.removeAllNodeMenus();this.activeNodes.add(node.id,node);},onNodeOver:function(node){if(node!=this.getTree().getRootNode()){this.getTree().getRootNode().getUI().destroyNodeMenu();}},getTreeJSON:function(node,excludeNode){var i=0;var sLevel=[];var serializedTree=[];while(typeof(node.item(i))!='undefined'){var cNode=node.item(i);if(cNode.id!=excludeNode.id){var sNode={};var parentId=cNode.parentNode.id;if(parentId=="source"){parentId="-1";} sNode['id']=cNode.attributes.id;sNode['text']=cNode.attributes.text;sNode['iconCls']="x-tree-node-categories";if(cNode.hasChildNodes()){sNode['leaf']=false;sNode["children"]=this.getTreeJSON(cNode,excludeNode);}else sNode['leaf']=true;if(node.getDepth()==0){serializedTree.push(sNode);} sLevel.push(sNode);} i++;} if(node.getDepth()==0) return serializedTree;else return sLevel;}});Ext.override(Ext.form.TextArea,{onKeyUp:function(e){if(!e.isNavKeyPress()||e.getKey()==e.ENTER){this.autoSize();} Ext.form.TextArea.superclass.onKeyUp.call(this,e);}});