guy 8 years ago
parent
commit
07ff967a0d
  1. 75
      bi/base.js
  2. 32
      bi/widget.js
  3. 75
      docs/base.js
  4. 32
      docs/widget.js
  5. 13
      src/base/combination/combo.js
  6. 25
      src/base/combination/expander.js
  7. 2
      src/base/combination/switcher.js
  8. 22
      src/base/tree/asynctree.js
  9. 8
      src/base/tree/parttree.js
  10. 5
      src/base/tree/treeview.js
  11. 32
      src/widget/multiselecttree/multiselecttree.js

75
bi/base.js

@ -1742,7 +1742,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this._buildTree(map, path);
return;
}
var storeValues = BI.deepClone(this.selectedValues);
var storeValues = BI.deepClone(this.options.paras.selectedValues);
var treeNode = this._getTree(storeValues, path);
this._addTreeNode(map, parent, this._getNodeValue(node), treeNode);
},
@ -1952,8 +1952,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.selectedValues = BI.deepClone(value) || {};
this.options.paras.selectedValues = BI.deepClone(value || {});
},
updateValue: function (values, param) {
@ -2105,7 +2104,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
if (treeNode.checked === true) {
} else {
var tNode = treeNode;
var pNode = this._getTree(this.selectedValues, parentValues);
var pNode = this._getTree(this.options.paras.selectedValues, parentValues);
if (BI.isNotNull(pNode[name])) {
delete pNode[name];
}
@ -2113,7 +2112,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
parentValues = parentValues.slice(0, parentValues.length - 1);
tNode = tNode.getParentNode();
if (tNode != null) {
pNode = this._getTree(this.selectedValues, parentValues);
pNode = this._getTree(this.options.paras.selectedValues, parentValues);
name = this._getNodeValue(tNode);
delete pNode[name];
}
@ -2127,10 +2126,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var self = this, o = this.options;
var parentValues = treeNode.parentValues || self._getParentValues(treeNode);
var op = BI.extend({}, o.paras, {
"id": treeNode.id,
"times": 1,
"parentValues": parentValues.concat(this._getNodeValue(treeNode)),
"checkState": treeNode.getCheckStatus()
id: treeNode.id,
times: 1,
parentValues: parentValues.concat(this._getNodeValue(treeNode)),
checkState: treeNode.getCheckStatus()
});
var complete = function (d) {
var nodes = d.items || [];
@ -2178,7 +2177,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
},
hasChecked: function () {
return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
return !BI.isEmpty(this.options.paras.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
},
getValue: function () {
@ -2187,20 +2186,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return BI.deepClone(this.selectedValues);
return BI.deepClone(this.options.paras.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
if (BI.isEmpty(this.options.paras.selectedValues)) {
return checkedValues;
}
return this._join(checkedValues, this.selectedValues);
return this._join(checkedValues, this.options.paras.selectedValues);
},
//生成树方法
stroke: function (config) {
delete this.options.keyword;
BI.extend(this.options.paras, config);
//取消选中时使用
this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {};
var setting = this._configSetting();
this._initTree(setting);
}
@ -2253,7 +2250,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
//如果选中的值中不存在该值不处理
var t = this.selectedValues;
var t = this.options.paras.selectedValues;
var p = parentValues.concat(name);
for (var i = 0, len = p.length; i < len; i++) {
t = t[p[i]];
@ -2266,11 +2263,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
}
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues
}), function (new_values) {
self.selectedValues = new_values;
self.options.paras.selectedValues = new_values;
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
});
}
@ -2367,9 +2363,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
delete o.paras.keyword;
BI.extend(o.paras, config);
delete o.paras.lastSearchValue;
//取消选中时使用
this.selectedValues = BI.deepClone(o.paras.selectedValues) || {};
//delete this.options.paras.selectedValues;
var setting = this._configSetting();
this._initTree(setting, o.paras.keyword);
}
@ -2920,7 +2913,7 @@ BI.Combo = BI.inherit(BI.Widget, {
this._initCombo();
this._initPullDownAction();
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
@ -2938,12 +2931,12 @@ BI.Combo = BI.inherit(BI.Widget, {
});
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.addClass(o.hoverClass);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.removeClass(o.hoverClass);
}
});
@ -2990,14 +2983,14 @@ BI.Combo = BI.inherit(BI.Widget, {
switch (ev) {
case "hover":
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled() && o.toggle === true) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
@ -3007,7 +3000,7 @@ BI.Combo = BI.inherit(BI.Widget, {
case "click":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -3220,6 +3213,7 @@ BI.Combo = BI.inherit(BI.Widget, {
_setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView();
},
@ -3317,13 +3311,13 @@ BI.Expander = BI.inherit(BI.Widget, {
this._initExpander();
this._initPullDownAction();
this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
if (type === BI.Events.COLLAPSE) {
self._hideView();
}
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
if (type === BI.Events.COLLAPSE) {
self._hideView();
}
if (type === BI.Events.EXPAND) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND);
@ -3339,11 +3333,11 @@ BI.Expander = BI.inherit(BI.Widget, {
});
this.element.hover(function () {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.addClass(o.hoverClass);
}
}, function () {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.removeClass(o.hoverClass);
}
});
@ -3379,13 +3373,13 @@ BI.Expander = BI.inherit(BI.Widget, {
switch (e) {
case "hover":
self.element[e](function (e) {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander);
self.fireEvent(BI.Expander.EVENT_EXPAND);
}
}, function () {
if (self.isEnabled() && self.expander.isEnabled() && o.toggle) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid() && o.toggle) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander);
self.fireEvent(BI.Expander.EVENT_COLLAPSE);
@ -3396,7 +3390,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (e) {
self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) {
if (self.expander.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
o.toggle ? self._toggle() : self._popupView();
if (self.isExpanded()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander);
@ -3487,6 +3481,7 @@ BI.Expander = BI.inherit(BI.Widget, {
_setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView();
},
@ -4484,7 +4479,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
this._initSwitcher();
this._initPullDownAction();
this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}

32
bi/widget.js

@ -11322,34 +11322,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
itemsCreator: o.itemsCreator
});
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
if (self.trigger.isSearching()) {
if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
}
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
});
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
//搜索中的时候用的是parttree,同adapter中的synctree不一样
this.searcherPane = BI.createWidget({
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
return self.searcher.getKeyword();
},
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
op.keyword = self.searcher.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({
this.searcher = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
keyword: self.searcher.getKeyword()
});
},
adapter: this.adapter,
@ -11359,15 +11361,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setSelectedValue(self.storeValue.value);
// self.storeValue = {value: self.adapter.getValue()};
// self.searcherPane.setSelectedValue(self.storeValue.value);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setSelectedValue(self.storeValue.value);
// self.adapter.setSelectedValue(self.storeValue.value);
BI.nextTick(function () {
self.adapter.populate();
});
@ -11375,11 +11377,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
}
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}
}, {
@ -11394,7 +11397,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
type: "bi.vtape",
element: this,
items: [{
el: this.trigger,
el: this.searcher,
height: 30
}, {
el: this.adapter,
@ -11432,7 +11435,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
setSelectedValue: function (v) {
this.storeValue.value = v || {};
this.adapter.setSelectedValue(v);
this.trigger.setValue({
this.searcherPane.setSelectedValue(v);
this.searcher.setValue({
value: v || {}
});
},
@ -11444,7 +11448,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
stopSearch: function () {
this.trigger.stopSearch();
this.searcher.stopSearch();
},
updateValue: function (v) {
@ -11456,7 +11460,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
populate: function () {
this.trigger.populate.apply(this.trigger, arguments);
this.searcher.populate.apply(this.searcher, arguments);
this.adapter.populate.apply(this.adapter, arguments);
}
});

75
docs/base.js

@ -1742,7 +1742,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this._buildTree(map, path);
return;
}
var storeValues = BI.deepClone(this.selectedValues);
var storeValues = BI.deepClone(this.options.paras.selectedValues);
var treeNode = this._getTree(storeValues, path);
this._addTreeNode(map, parent, this._getNodeValue(node), treeNode);
},
@ -1952,8 +1952,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.selectedValues = BI.deepClone(value) || {};
this.options.paras.selectedValues = BI.deepClone(value || {});
},
updateValue: function (values, param) {
@ -2105,7 +2104,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
if (treeNode.checked === true) {
} else {
var tNode = treeNode;
var pNode = this._getTree(this.selectedValues, parentValues);
var pNode = this._getTree(this.options.paras.selectedValues, parentValues);
if (BI.isNotNull(pNode[name])) {
delete pNode[name];
}
@ -2113,7 +2112,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
parentValues = parentValues.slice(0, parentValues.length - 1);
tNode = tNode.getParentNode();
if (tNode != null) {
pNode = this._getTree(this.selectedValues, parentValues);
pNode = this._getTree(this.options.paras.selectedValues, parentValues);
name = this._getNodeValue(tNode);
delete pNode[name];
}
@ -2127,10 +2126,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var self = this, o = this.options;
var parentValues = treeNode.parentValues || self._getParentValues(treeNode);
var op = BI.extend({}, o.paras, {
"id": treeNode.id,
"times": 1,
"parentValues": parentValues.concat(this._getNodeValue(treeNode)),
"checkState": treeNode.getCheckStatus()
id: treeNode.id,
times: 1,
parentValues: parentValues.concat(this._getNodeValue(treeNode)),
checkState: treeNode.getCheckStatus()
});
var complete = function (d) {
var nodes = d.items || [];
@ -2178,7 +2177,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
},
hasChecked: function () {
return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
return !BI.isEmpty(this.options.paras.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
},
getValue: function () {
@ -2187,20 +2186,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return BI.deepClone(this.selectedValues);
return BI.deepClone(this.options.paras.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
if (BI.isEmpty(this.options.paras.selectedValues)) {
return checkedValues;
}
return this._join(checkedValues, this.selectedValues);
return this._join(checkedValues, this.options.paras.selectedValues);
},
//生成树方法
stroke: function (config) {
delete this.options.keyword;
BI.extend(this.options.paras, config);
//取消选中时使用
this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {};
var setting = this._configSetting();
this._initTree(setting);
}
@ -2253,7 +2250,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
//如果选中的值中不存在该值不处理
var t = this.selectedValues;
var t = this.options.paras.selectedValues;
var p = parentValues.concat(name);
for (var i = 0, len = p.length; i < len; i++) {
t = t[p[i]];
@ -2266,11 +2263,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
}
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues
}), function (new_values) {
self.selectedValues = new_values;
self.options.paras.selectedValues = new_values;
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
});
}
@ -2367,9 +2363,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
delete o.paras.keyword;
BI.extend(o.paras, config);
delete o.paras.lastSearchValue;
//取消选中时使用
this.selectedValues = BI.deepClone(o.paras.selectedValues) || {};
//delete this.options.paras.selectedValues;
var setting = this._configSetting();
this._initTree(setting, o.paras.keyword);
}
@ -2920,7 +2913,7 @@ BI.Combo = BI.inherit(BI.Widget, {
this._initCombo();
this._initPullDownAction();
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
@ -2938,12 +2931,12 @@ BI.Combo = BI.inherit(BI.Widget, {
});
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.addClass(o.hoverClass);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.removeClass(o.hoverClass);
}
});
@ -2990,14 +2983,14 @@ BI.Combo = BI.inherit(BI.Widget, {
switch (ev) {
case "hover":
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled() && o.toggle === true) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
@ -3007,7 +3000,7 @@ BI.Combo = BI.inherit(BI.Widget, {
case "click":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -3220,6 +3213,7 @@ BI.Combo = BI.inherit(BI.Widget, {
_setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView();
},
@ -3317,13 +3311,13 @@ BI.Expander = BI.inherit(BI.Widget, {
this._initExpander();
this._initPullDownAction();
this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
if (type === BI.Events.COLLAPSE) {
self._hideView();
}
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
if (type === BI.Events.COLLAPSE) {
self._hideView();
}
if (type === BI.Events.EXPAND) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND);
@ -3339,11 +3333,11 @@ BI.Expander = BI.inherit(BI.Widget, {
});
this.element.hover(function () {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.addClass(o.hoverClass);
}
}, function () {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.removeClass(o.hoverClass);
}
});
@ -3379,13 +3373,13 @@ BI.Expander = BI.inherit(BI.Widget, {
switch (e) {
case "hover":
self.element[e](function (e) {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander);
self.fireEvent(BI.Expander.EVENT_EXPAND);
}
}, function () {
if (self.isEnabled() && self.expander.isEnabled() && o.toggle) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid() && o.toggle) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander);
self.fireEvent(BI.Expander.EVENT_COLLAPSE);
@ -3396,7 +3390,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (e) {
self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) {
if (self.expander.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
o.toggle ? self._toggle() : self._popupView();
if (self.isExpanded()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander);
@ -3487,6 +3481,7 @@ BI.Expander = BI.inherit(BI.Widget, {
_setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView();
},
@ -4484,7 +4479,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
this._initSwitcher();
this._initPullDownAction();
this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}

32
docs/widget.js

@ -11322,34 +11322,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
itemsCreator: o.itemsCreator
});
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
if (self.trigger.isSearching()) {
if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
}
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
});
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
//搜索中的时候用的是parttree,同adapter中的synctree不一样
this.searcherPane = BI.createWidget({
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
return self.searcher.getKeyword();
},
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
op.keyword = self.searcher.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({
this.searcher = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
keyword: self.searcher.getKeyword()
});
},
adapter: this.adapter,
@ -11359,15 +11361,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setSelectedValue(self.storeValue.value);
// self.storeValue = {value: self.adapter.getValue()};
// self.searcherPane.setSelectedValue(self.storeValue.value);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setSelectedValue(self.storeValue.value);
// self.adapter.setSelectedValue(self.storeValue.value);
BI.nextTick(function () {
self.adapter.populate();
});
@ -11375,11 +11377,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
}
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}
}, {
@ -11394,7 +11397,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
type: "bi.vtape",
element: this,
items: [{
el: this.trigger,
el: this.searcher,
height: 30
}, {
el: this.adapter,
@ -11432,7 +11435,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
setSelectedValue: function (v) {
this.storeValue.value = v || {};
this.adapter.setSelectedValue(v);
this.trigger.setValue({
this.searcherPane.setSelectedValue(v);
this.searcher.setValue({
value: v || {}
});
},
@ -11444,7 +11448,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
stopSearch: function () {
this.trigger.stopSearch();
this.searcher.stopSearch();
},
updateValue: function (v) {
@ -11456,7 +11460,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
populate: function () {
this.trigger.populate.apply(this.trigger, arguments);
this.searcher.populate.apply(this.searcher, arguments);
this.adapter.populate.apply(this.adapter, arguments);
}
});

13
src/base/combination/combo.js

@ -34,7 +34,7 @@ BI.Combo = BI.inherit(BI.Widget, {
this._initCombo();
this._initPullDownAction();
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
@ -52,12 +52,12 @@ BI.Combo = BI.inherit(BI.Widget, {
});
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.addClass(o.hoverClass);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.removeClass(o.hoverClass);
}
});
@ -104,14 +104,14 @@ BI.Combo = BI.inherit(BI.Widget, {
switch (ev) {
case "hover":
self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND);
}
});
self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled() && o.toggle === true) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE);
@ -121,7 +121,7 @@ BI.Combo = BI.inherit(BI.Widget, {
case "click":
var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.combo.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -334,6 +334,7 @@ BI.Combo = BI.inherit(BI.Widget, {
_setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView();
},

25
src/base/combination/expander.js

@ -28,13 +28,13 @@ BI.Expander = BI.inherit(BI.Widget, {
this._initExpander();
this._initPullDownAction();
this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
if (type === BI.Events.COLLAPSE) {
self._hideView();
}
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}
if (type === BI.Events.COLLAPSE) {
self._hideView();
}
if (type === BI.Events.EXPAND) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND);
@ -50,11 +50,11 @@ BI.Expander = BI.inherit(BI.Widget, {
});
this.element.hover(function () {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.addClass(o.hoverClass);
}
}, function () {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.removeClass(o.hoverClass);
}
});
@ -90,13 +90,13 @@ BI.Expander = BI.inherit(BI.Widget, {
switch (e) {
case "hover":
self.element[e](function (e) {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander);
self.fireEvent(BI.Expander.EVENT_EXPAND);
}
}, function () {
if (self.isEnabled() && self.expander.isEnabled() && o.toggle) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid() && o.toggle) {
self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander);
self.fireEvent(BI.Expander.EVENT_COLLAPSE);
@ -107,7 +107,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (e) {
self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) {
if (self.expander.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.expander.isEnabled()) {
if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
o.toggle ? self._toggle() : self._popupView();
if (self.isExpanded()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander);
@ -198,6 +198,7 @@ BI.Expander = BI.inherit(BI.Widget, {
_setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView();
},

2
src/base/combination/switcher.js

@ -28,7 +28,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
this._initSwitcher();
this._initPullDownAction();
this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) {
if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) {
self._popupView();
}

22
src/base/tree/asynctree.js

@ -105,7 +105,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
if (treeNode.checked === true) {
} else {
var tNode = treeNode;
var pNode = this._getTree(this.selectedValues, parentValues);
var pNode = this._getTree(this.options.paras.selectedValues, parentValues);
if (BI.isNotNull(pNode[name])) {
delete pNode[name];
}
@ -113,7 +113,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
parentValues = parentValues.slice(0, parentValues.length - 1);
tNode = tNode.getParentNode();
if (tNode != null) {
pNode = this._getTree(this.selectedValues, parentValues);
pNode = this._getTree(this.options.paras.selectedValues, parentValues);
name = this._getNodeValue(tNode);
delete pNode[name];
}
@ -127,10 +127,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var self = this, o = this.options;
var parentValues = treeNode.parentValues || self._getParentValues(treeNode);
var op = BI.extend({}, o.paras, {
"id": treeNode.id,
"times": 1,
"parentValues": parentValues.concat(this._getNodeValue(treeNode)),
"checkState": treeNode.getCheckStatus()
id: treeNode.id,
times: 1,
parentValues: parentValues.concat(this._getNodeValue(treeNode)),
checkState: treeNode.getCheckStatus()
});
var complete = function (d) {
var nodes = d.items || [];
@ -178,7 +178,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
},
hasChecked: function () {
return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
return !BI.isEmpty(this.options.paras.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
},
getValue: function () {
@ -187,20 +187,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return BI.deepClone(this.selectedValues);
return BI.deepClone(this.options.paras.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
if (BI.isEmpty(this.options.paras.selectedValues)) {
return checkedValues;
}
return this._join(checkedValues, this.selectedValues);
return this._join(checkedValues, this.options.paras.selectedValues);
},
//生成树方法
stroke: function (config) {
delete this.options.keyword;
BI.extend(this.options.paras, config);
//取消选中时使用
this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {};
var setting = this._configSetting();
this._initTree(setting);
}

8
src/base/tree/parttree.js

@ -45,7 +45,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
//如果选中的值中不存在该值不处理
var t = this.selectedValues;
var t = this.options.paras.selectedValues;
var p = parentValues.concat(name);
for (var i = 0, len = p.length; i < len; i++) {
t = t[p[i]];
@ -58,11 +58,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
}
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues
}), function (new_values) {
self.selectedValues = new_values;
self.options.paras.selectedValues = new_values;
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
});
}
@ -159,9 +158,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
delete o.paras.keyword;
BI.extend(o.paras, config);
delete o.paras.lastSearchValue;
//取消选中时使用
this.selectedValues = BI.deepClone(o.paras.selectedValues) || {};
//delete this.options.paras.selectedValues;
var setting = this._configSetting();
this._initTree(setting, o.paras.keyword);
}

5
src/base/tree/treeview.js

@ -241,7 +241,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this._buildTree(map, path);
return;
}
var storeValues = BI.deepClone(this.selectedValues);
var storeValues = BI.deepClone(this.options.paras.selectedValues);
var treeNode = this._getTree(storeValues, path);
this._addTreeNode(map, parent, this._getNodeValue(node), treeNode);
},
@ -451,8 +451,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.selectedValues = BI.deepClone(value) || {};
this.options.paras.selectedValues = BI.deepClone(value || {});
},
updateValue: function (values, param) {

32
src/widget/multiselecttree/multiselecttree.js

@ -19,34 +19,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
itemsCreator: o.itemsCreator
});
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
if (self.trigger.isSearching()) {
if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
}
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
});
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
//搜索中的时候用的是parttree,同adapter中的synctree不一样
this.searcherPane = BI.createWidget({
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
return self.searcher.getKeyword();
},
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
op.keyword = self.searcher.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({
this.searcher = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
keyword: self.searcher.getKeyword()
});
},
adapter: this.adapter,
@ -56,15 +58,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setSelectedValue(self.storeValue.value);
// self.storeValue = {value: self.adapter.getValue()};
// self.searcherPane.setSelectedValue(self.storeValue.value);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setSelectedValue(self.storeValue.value);
// self.adapter.setSelectedValue(self.storeValue.value);
BI.nextTick(function () {
self.adapter.populate();
});
@ -72,11 +74,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
}
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}
}, {
@ -91,7 +94,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
type: "bi.vtape",
element: this,
items: [{
el: this.trigger,
el: this.searcher,
height: 30
}, {
el: this.adapter,
@ -129,7 +132,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
setSelectedValue: function (v) {
this.storeValue.value = v || {};
this.adapter.setSelectedValue(v);
this.trigger.setValue({
this.searcherPane.setSelectedValue(v);
this.searcher.setValue({
value: v || {}
});
},
@ -141,7 +145,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
stopSearch: function () {
this.trigger.stopSearch();
this.searcher.stopSearch();
},
updateValue: function (v) {
@ -153,7 +157,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
populate: function () {
this.trigger.populate.apply(this.trigger, arguments);
this.searcher.populate.apply(this.searcher, arguments);
this.adapter.populate.apply(this.adapter, arguments);
}
});

Loading…
Cancel
Save