Browse Source

选择框增加expand\collapse事件

unknown 5 năm trước cách đây
mục cha
commit
30bd99fa49

+ 3 - 1
o2web/source/x_component_Selector/Person.js

@@ -27,7 +27,7 @@ MWF.xApplication.Selector.Person = new Class({
         "hasShuttle" : false, //穿梭按钮
         "searchbarInTopNode" : true, //搜索框在标题上还是另起一行
         "hasSelectedSearchbar" : false, //已选是不是有搜索框
-        "noSelectedContainer" : true, //是否有已选项
+        "noSelectedContainer" : false, //是否隐藏右侧已选区域
         "contentUrl" : "", //和默认的页面布局不一样的话,可以传入页面布局HTML URL
         "injectToBody" : false, //当传入HTML URL的时候是否插入到document.body, false的时候插入到this.container
 
@@ -2395,6 +2395,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             if (!this.fx.isRunning()){
                 var display = this.children.getStyle("display");
                 if (display === "none"){
+                    this.selector.fireEvent("expand", [this] );
                     this.children.setStyles({
                         "display": "block",
                         "height": "0px"
@@ -2403,6 +2404,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
                     this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
                     this.isExpand = true;
                 }else{
+                    this.selector.fireEvent("collapse", [this] );
                     if (!this.childrenHeight) this.childrenHeight = this.children.getStyle("height").toFloat();
                     this.fx.start("height", ""+this.childrenHeight+"px", "0px").chain(function(){
                         this.children.setStyles({

+ 4 - 2
o2web/source/x_component_Selector/Unit.js

@@ -232,9 +232,9 @@ MWF.xApplication.Selector.Unit.Item = new Class({
         debugger;
         if( !this.selector.options.expandSubEnable )return;
         this.isExpand = (this.selector.options.expand);
-        if ( this._hasChild() ){
+        if ( this._hasChild() || this.selector.options.expandEmptyCategory ){
             if (this.selector.options.expand){
-                if (this.level===1){
+                if (this.level===1 && this._hasChild() ){
                     this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand);
                     this.loadSubItems();
                 }else{
@@ -246,10 +246,12 @@ MWF.xApplication.Selector.Unit.Item = new Class({
             }
             this.levelNode.addEvent("click", function(e){
                 if (this.isExpand){
+                    this.selector.fireEvent("collapse", [this] );
                     this.children.setStyle("display", "none");
                     this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_collapse);
                     this.isExpand = false;
                 }else{
+                    this.selector.fireEvent("expand", [this] );
                     this.loadSubItems();
                     this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand);
                     this.isExpand = true;

+ 2 - 0
o2web/source/x_component_Selector/UnitWithType.js

@@ -141,10 +141,12 @@ MWF.xApplication.Selector.UnitWithType.Item = new Class({
             }
             this.levelNode.addEvent("click", function(e){
                 if (this.isExpand){
+                    this.selector.fireEvent("collapse", [this] );
                     this.children.setStyle("display", "none");
                     this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_collapse);
                     this.isExpand = false;
                 }else{
+                    this.selector.fireEvent("expand", [this] );
                     this.loadSubItems();
                     this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand);
                     this.isExpand = true;