SectionSelector.min.js 3.2 KB

1
  1. MWF.xApplication.Forum=MWF.xApplication.Forum||{};MWF.xDesktop.requireApp("Selector","Person",null,false);MWF.xApplication.Forum.SectionSelector=new Class({Extends:MWF.xApplication.Selector.Person,options:{style:"default",count:0,title:"选择列表",values:[],appId:"",formId:"",expand:false},initialize:function(t,e){this.setOptions(e);this.path="/x_component_Selector/$Selector/";this.cssPath="/x_component_Selector/$Selector/"+this.options.style+"/css.wcss";this._loadCss(true);this.container=$(t);this.action=MWF.Actions.get("x_bbs_assemble_control");this.lastPeople="";this.pageCount="13";this.selectedItems=[];this.items=[]},loadSelectItems:function(t){this.action.listCategoryAll(function(t){(t.data||[]).each(function(e){if(e.forumStatus!="停用"){this.action.listSection(e.id,function(t){e.name=e.forumName;e.sectionList=t.data||[];var i=this._newItemCategory(e,this,this.itemAreaNode);e.sectionList.each(function(t){t.name=t.sectionName;var e=this._newItem(t,this,i.children);this.items.push(e)}.bind(this))}.bind(this))}}.bind(this))}.bind(this))},_scrollEvent:function(t){return true},_getChildrenItemIds:function(t){return t.sectionList||[]},_newItemCategory:function(t,e,i,n){return new MWF.xApplication.Forum.SectionSelector.ItemCategory(t,e,i,n)},_listItemByKey:function(t,e,i){return false},_getItem:function(t,e,i,n){},_newItemSelected:function(t,e,i){return new MWF.xApplication.Forum.SectionSelector.ItemSelected(t,e,i)},_listItemByPinyin:function(t,e,i){return false},_newItem:function(t,e,i,n){return new MWF.xApplication.Forum.SectionSelector.Item(t,e,i,n)}});MWF.xApplication.Forum.SectionSelector.Item=new Class({Extends:MWF.xApplication.Selector.Person.Item,_getShowName:function(){return this.data.name},_setIcon:function(){},loadSubItem:function(){return false},checkSelectedSingle:function(){var t=this.selector.options.values.filter(function(t,e){if(typeOf(t)==="object")return this.data.id===t.id||this.data.name===t.name;if(typeOf(t)==="string")return this.data.id===t||this.data.name===t;return false}.bind(this));if(t.length){this.selectedSingle()}},checkSelected:function(){var t=this.selector.selectedItems.filter(function(t,e){return t.data.id===this.data.id||t.data.name===this.data.name}.bind(this));if(t.length){t[0].addItem(this);this.selectedItem=t[0];this.setSelected()}}});MWF.xApplication.Forum.SectionSelector.ItemSelected=new Class({Extends:MWF.xApplication.Selector.Person.ItemSelected,_getShowName:function(){return this.data.name},_setIcon:function(){},check:function(){if(this.selector.items.length){var t=this.selector.items.filter(function(t,e){return t.data.id===this.data.id||t.data.name===this.data.name}.bind(this));this.items=t;if(t.length){t.each(function(t){t.selectedItem=this;t.setSelected()}.bind(this))}}}});MWF.xApplication.Forum.SectionSelector.ItemCategory=new Class({Extends:MWF.xApplication.Selector.Person.ItemCategory,_getShowName:function(){return this.data.name},createNode:function(){this.node=new Element("div",{styles:this.selector.css.selectorItemCategory_department}).inject(this.container)},_setIcon:function(){this.iconNode.setStyle("background-image","url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)")},_hasChild:function(){return this.data.sectionList&&this.data.sectionList.length},check:function(){}});