Browse Source

KERNEL-12408 chore: base/combination中eslint修改

es6
chaos0156 2 years ago
parent
commit
d728980489
  1. 12
      src/base/collection/collection.js
  2. 14
      src/base/combination/bubble.js
  3. 8
      src/base/combination/combo.js
  4. 6
      src/base/combination/expander.js
  5. 24
      src/base/combination/group.button.js
  6. 2
      src/base/combination/group.combo.js
  7. 7
      src/base/combination/group.virtual.js
  8. 10
      src/base/combination/loader.js
  9. 5
      src/base/combination/navigation.js
  10. 12
      src/base/combination/searcher.js
  11. 2
      src/base/combination/switcher.js
  12. 2
      src/base/combination/tab.js
  13. 25
      src/base/combination/tree.button.js

12
src/base/collection/collection.js

@ -101,10 +101,10 @@ BI.CollectionView = BI.inherit(BI.Widget, {
for (var index = 0, len = o.items.length; index < len; index++) { for (var index = 0, len = o.items.length; index < len; index++) {
var cellMetadatum = o.cellSizeAndPositionGetter(index); var cellMetadatum = o.cellSizeAndPositionGetter(index);
if (cellMetadatum.height === null || isNaN(cellMetadatum.height) || if (BI.isNull(cellMetadatum.height) || isNaN(cellMetadatum.height) ||
cellMetadatum.width === null || isNaN(cellMetadatum.width) || BI.isNull(cellMetadatum.width) || isNaN(cellMetadatum.width) ||
cellMetadatum.x === null || isNaN(cellMetadatum.x) || BI.isNull(cellMetadatum.x) || isNaN(cellMetadatum.x) ||
cellMetadatum.y === null || isNaN(cellMetadatum.y)) { BI.isNull(cellMetadatum.y) || isNaN(cellMetadatum.y)) {
throw Error(); throw Error();
} }
@ -170,12 +170,12 @@ BI.CollectionView = BI.inherit(BI.Widget, {
// 存储上下左右四个边界 // 存储上下左右四个边界
var leftBorder = {}, rightBorder = {}, topBorder = {}, bottomBorder = {}; var leftBorder = {}, rightBorder = {}, topBorder = {}, bottomBorder = {};
function assertMinBorder(border, offset) { function assertMinBorder(border, offset) {
if (border[offset] === null) { if (BI.isNull(border[offset])) {
border[offset] = Number.MAX_VALUE; border[offset] = Number.MAX_VALUE;
} }
} }
function assertMaxBorder(border, offset) { function assertMaxBorder(border, offset) {
if (border[offset] === null) { if (BI.isNull(border[offset])) {
border[offset] = 0; border[offset] = 0;
} }
} }

14
src/base/combination/bubble.js

@ -6,6 +6,7 @@
BI.Bubble = BI.inherit(BI.Widget, { BI.Bubble = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Bubble.superclass._defaultConfig.apply(this, arguments); var conf = BI.Bubble.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-popper", baseCls: (conf.baseCls || "") + " bi-popper",
attributes: { attributes: {
@ -36,7 +37,7 @@
el: {}, el: {},
popup: {}, popup: {},
comboClass: "bi-combo-popup", comboClass: "bi-combo-popup",
hoverClass: "bi-combo-hover", hoverClass: "bi-combo-hover"
}); });
}, },
@ -104,14 +105,14 @@
_initPullDownAction: function () { _initPullDownAction: function () {
var self = this, o = this.options; var self = this, o = this.options;
var evs = (this.options.trigger || "").split(","); var evs = (this.options.trigger || "").split(",");
var st = function (e) { function st (e) {
if (o.stopEvent) { if (o.stopEvent) {
e.stopEvent(); e.stopEvent();
} }
if (o.stopPropagation) { if (o.stopPropagation) {
e.stopPropagation(); e.stopPropagation();
} }
}; }
var enterPopup = false; var enterPopup = false;
@ -217,6 +218,8 @@
} }
}); });
break; break;
default:
break;
} }
}); });
}, },
@ -229,7 +232,7 @@
_assertPopupView: function () { _assertPopupView: function () {
var self = this, o = this.options; var self = this, o = this.options;
if (this.popupView == null) { if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, { this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, {
type: "bi.bubble_popup_view", type: "bi.bubble_popup_view",
showArrow: o.showArrow, showArrow: o.showArrow,
@ -286,6 +289,7 @@
return; return;
} }
this._hideView(e); this._hideView(e);
return true; return true;
}, },
@ -319,7 +323,7 @@
}, },
_popupView: function (e) { _popupView: function (e) {
var self = this, o = this.options; var o = this.options;
this._assertPopupViewRender(); this._assertPopupViewRender();
this.fireEvent(BI.Bubble.EVENT_BEFORE_POPUPVIEW); this.fireEvent(BI.Bubble.EVENT_BEFORE_POPUPVIEW);
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下 // popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下

8
src/base/combination/combo.js

@ -1,6 +1,7 @@
!(function () { !(function () {
var needHideWhenAnotherComboOpen = {}; var needHideWhenAnotherComboOpen = {};
var currentOpenedCombos = {}; var currentOpenedCombos = {};
/** /**
* @class BI.Combo * @class BI.Combo
* @extends BI.Widget * @extends BI.Widget
@ -11,6 +12,7 @@
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""), baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""),
attributes: { attributes: {
@ -107,7 +109,7 @@
_assertPopupView: function () { _assertPopupView: function () {
var self = this, o = this.options; var self = this, o = this.options;
if (this.popupView == null) { if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, { this.popupView = BI.createWidget(BI.isFunction(this.options.popup) ? this.options.popup() : this.options.popup, {
type: "bi.popup_view", type: "bi.popup_view",
showArrow: o.showArrow, showArrow: o.showArrow,
@ -280,10 +282,12 @@
delete p.adaptHeight; delete p.adaptHeight;
p.dir = "right"; p.dir = "right";
break; break;
default:
break;
} }
if ("adaptHeight" in p) { if ("adaptHeight" in p) {
this.resetListHeight(p["adaptHeight"]); this.resetListHeight(p.adaptHeight);
} }
var width = this.combo.element.outerWidth(); var width = this.combo.element.outerWidth();
var height = this.combo.element.outerHeight(); var height = this.combo.element.outerHeight();

6
src/base/combination/expander.js

@ -126,6 +126,8 @@ BI.Expander = BI.inherit(BI.Widget, {
})); }));
} }
break; break;
default:
break;
} }
}); });
}, },
@ -136,7 +138,7 @@ BI.Expander = BI.inherit(BI.Widget, {
_assertPopupView: function () { _assertPopupView: function () {
var self = this, o = this.options; var self = this, o = this.options;
if (this.popupView == null) { if (BI.isNull(this.popupView)) {
this.popupView = BI.createWidget(this.options.popup, { this.popupView = BI.createWidget(this.options.popup, {
type: "bi.button_group", type: "bi.button_group",
cls: "expander-popup", cls: "expander-popup",
@ -255,6 +257,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (this.expander.options.id === id) { if (this.expander.options.id === id) {
return this.expander; return this.expander;
} }
return this.popupView && this.popupView.getNodeById(id); return this.popupView && this.popupView.getNodeById(id);
}, },
@ -262,6 +265,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (this.expander.getValue() === value) { if (this.expander.getValue() === value) {
return this.expander; return this.expander;
} }
return this.popupView && this.popupView.getNodeByValue(value); return this.popupView && this.popupView.getNodeByValue(value);
}, },

24
src/base/combination/group.button.js

@ -42,7 +42,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}, },
_createBtns: function (items) { _createBtns: function (items) {
var o = this.options;
return BI.createWidgets(BI.createItems(items, { return BI.createWidgets(BI.createItems(items, {
type: "bi.text_button" type: "bi.text_button"
}), this); }), this);
@ -66,6 +65,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
case BI.ButtonGroup.CHOOSE_TYPE_NONE: case BI.ButtonGroup.CHOOSE_TYPE_NONE:
self.setValue([]); self.setValue([]);
break; break;
default:
break;
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
@ -84,7 +85,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
_packageBtns: function (btns) { _packageBtns: function (btns) {
var o = this.options; var o = this.options;
var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts]; var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts];
for (var i = layouts.length - 1; i > 0; i--) { for (let i = layouts.length - 1; i > 0; i--) {
btns = BI.map(btns, function (k, it) { btns = BI.map(btns, function (k, it) {
return BI.extend({}, layouts[i], { return BI.extend({}, layouts[i], {
items: [ items: [
@ -95,15 +96,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}); });
}); });
} }
return btns; return btns;
}, },
_packageSimpleItems: function (btns) { _packageSimpleItems: function (btns) {
var o = this.options; var o = this.options;
return BI.map(o.items, function (i, item) { return BI.map(o.items, function (i, item) {
if (BI.stripEL(item) === item) { if (BI.stripEL(item) === item) {
return btns[i]; return btns[i];
} }
return BI.extend({}, item, { return BI.extend({}, item, {
el: btns[i] el: btns[i]
}); });
@ -122,12 +126,14 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
lay = BI.formatEL(lay.items[0]).el; lay = BI.formatEL(lay.items[0]).el;
} }
lay.items = items; lay.items = items;
return layout; return layout;
}, },
// 如果是一个简单的layout // 如果是一个简单的layout
_isSimpleLayout: function () { _isSimpleLayout: function () {
var o = this.options; var o = this.options;
return BI.isArray(o.layouts) ? (o.layouts.length === 1 && !BI.isArray(o.items[0])) : true; return BI.isArray(o.layouts) ? (o.layouts.length === 1 && !BI.isArray(o.items[0])) : true;
}, },
@ -140,12 +146,12 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}, },
prependItems: function (items) { prependItems: function (items) {
var o = this.options;
var btns = this._btnsCreator.apply(this, arguments); var btns = this._btnsCreator.apply(this, arguments);
this.buttons = BI.concat(btns, this.buttons); this.buttons = BI.concat(btns, this.buttons);
if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) { if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) {
this.layouts.prependItems(btns); this.layouts.prependItems(btns);
return; return;
} }
@ -154,13 +160,13 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
}, },
addItems: function (items) { addItems: function (items) {
var o = this.options;
var btns = this._btnsCreator.apply(this, arguments); var btns = this._btnsCreator.apply(this, arguments);
this.buttons = BI.concat(this.buttons, btns); this.buttons = BI.concat(this.buttons, btns);
// 如果是一个简单的layout // 如果是一个简单的layout
if (this._isSimpleLayout() && this.layouts && this.layouts.addItems) { if (this._isSimpleLayout() && this.layouts && this.layouts.addItems) {
this.layouts.addItems(btns); this.layouts.addItems(btns);
return; return;
} }
@ -257,6 +263,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
v.push(item.getValue()); v.push(item.getValue());
} }
}); });
return v; return v;
}, },
@ -267,6 +274,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
v.push(item.getValue()); v.push(item.getValue());
} }
}); });
return v; return v;
}, },
@ -285,6 +293,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
btns.push(item); btns.push(item);
} }
}); });
return btns; return btns;
}, },
@ -295,6 +304,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
btns.push(item); btns.push(item);
} }
}); });
return btns; return btns;
}, },
@ -303,9 +313,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) { BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.getValue() === value) { if (item.isEnabled() && item.getValue() === value) {
index = i; index = i;
return true; return true;
} }
}); });
return index; return index;
}, },
@ -314,9 +326,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) { BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.options.id === id) { if (item.isEnabled() && item.options.id === id) {
node = item; node = item;
return true; return true;
} }
}); });
return node; return node;
}, },
@ -325,9 +339,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
BI.any(this.buttons, function (i, item) { BI.any(this.buttons, function (i, item) {
if (item.isEnabled() && item.getValue() === value) { if (item.isEnabled() && item.getValue() === value) {
node = item; node = item;
return true; return true;
} }
}); });
return node; return node;
}, },

2
src/base/combination/group.combo.js

@ -15,7 +15,7 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
el: {type: "bi.text_button", text: "", value: ""}, el: { type: "bi.text_button", text: "", value: "" },
items: [], items: [],
popup: { popup: {

7
src/base/combination/group.virtual.js

@ -29,9 +29,10 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
var o = this.options; var o = this.options;
var map = this.buttonMap = {}; var map = this.buttonMap = {};
var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts]; var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts];
for (var i = layouts.length - 1; i > 0; i--) { for (let i = layouts.length - 1; i > 0; i--) {
items = BI.map(items, function (k, it) { items = BI.map(items, function (k, it) {
var el = BI.stripEL(it); var el = BI.stripEL(it);
return BI.extend({}, layouts[i], { return BI.extend({}, layouts[i], {
items: [ items: [
BI.extend({}, layouts[i].el, { BI.extend({}, layouts[i].el, {
@ -47,6 +48,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
}); });
}); });
} }
return items; return items;
}, },
@ -60,6 +62,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
lay = BI.formatEL(lay.items[0]).el; lay = BI.formatEL(lay.items[0]).el;
} }
lay.items = items; lay.items = items;
return layout; return layout;
}, },
@ -93,6 +96,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
} }
} }
}); });
return v; return v;
}, },
@ -119,6 +123,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
} }
} }
}); });
return v; return v;
}, },

10
src/base/combination/loader.js

@ -38,7 +38,7 @@ BI.Loader = BI.inherit(BI.Widget, {
_prevLoad: function () { _prevLoad: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.prev.setLoading(); this.prev.setLoading();
o.itemsCreator.apply(this, [{times: --this.times}, function () { o.itemsCreator.apply(this, [{ times: --this.times }, function () {
self.prev.setLoaded(); self.prev.setLoaded();
self.prependItems.apply(self, arguments); self.prependItems.apply(self, arguments);
}]); }]);
@ -47,7 +47,7 @@ BI.Loader = BI.inherit(BI.Widget, {
_nextLoad: function () { _nextLoad: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.next.setLoading(); this.next.setLoading();
o.itemsCreator.apply(this, [{times: ++this.times}, function () { o.itemsCreator.apply(this, [{ times: ++this.times }, function () {
self.next.setLoaded(); self.next.setLoaded();
self.addItems.apply(self, arguments); self.addItems.apply(self, arguments);
}]); }]);
@ -122,6 +122,7 @@ BI.Loader = BI.inherit(BI.Widget, {
if (BI.isNumber(o.count)) { if (BI.isNumber(o.count)) {
return this.count < o.count; return this.count < o.count;
} }
return !!o.hasPrev.apply(this, [{ return !!o.hasPrev.apply(this, [{
times: this.times, times: this.times,
count: this.count count: this.count
@ -133,6 +134,7 @@ BI.Loader = BI.inherit(BI.Widget, {
if (BI.isNumber(o.count)) { if (BI.isNumber(o.count)) {
return this.count < o.count; return this.count < o.count;
} }
return !!o.hasNext.apply(this, [{ return !!o.hasNext.apply(this, [{
times: this.times, times: this.times,
count: this.count count: this.count
@ -168,13 +170,14 @@ BI.Loader = BI.inherit(BI.Widget, {
_populate: function (items) { _populate: function (items) {
var self = this, o = this.options; var self = this, o = this.options;
if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) { if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) {
o.itemsCreator.apply(this, [{times: 1}, function () { o.itemsCreator.apply(this, [{ times: 1 }, function () {
if (arguments.length === 0) { if (arguments.length === 0) {
throw new Error("参数不能为空"); throw new Error("参数不能为空");
} }
self.populate.apply(self, arguments); self.populate.apply(self, arguments);
o.onLoaded(); o.onLoaded();
}]); }]);
return false; return false;
} }
this.options.items = items; this.options.items = items;
@ -195,6 +198,7 @@ BI.Loader = BI.inherit(BI.Widget, {
this.prev.invisible(); this.prev.invisible();
} }
} }
return true; return true;
}, },

5
src/base/combination/navigation.js

@ -23,7 +23,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"}); this.tab = BI.createWidget(this.options.tab, { type: "bi.button_group" });
this.cardMap = {}; this.cardMap = {};
this.showIndex = 0; this.showIndex = 0;
this.layout = BI.createWidget({ this.layout = BI.createWidget({
@ -45,6 +45,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
cardCreator: function (v) { cardCreator: function (v) {
var card = o.cardCreator(v); var card = o.cardCreator(v);
self.cardMap[v] = card; self.cardMap[v] = card;
return card; return card;
}, },
afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardCreated: BI.bind(this.afterCardCreated, this),
@ -54,7 +55,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
if (BI.isFunction(o.showIndex)) { if (BI.isFunction(o.showIndex)) {
this.__watch(o.showIndex, function (context, newValue) { this.__watch(o.showIndex, function (context, newValue) {
self.setSelect(newValue); self.setSelect(newValue);
}) });
} }
}, },

12
src/base/combination/searcher.js

@ -82,6 +82,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
self._pauseSearch(); self._pauseSearch();
} }
break; break;
default:
break;
} }
}); });
}, },
@ -109,6 +111,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
values.push(obj.getValue()); values.push(obj.getValue());
o.adapter && o.adapter.setValue(values); o.adapter && o.adapter.setValue(values);
break; break;
default:
break;
} }
} }
self.fireEvent(BI.Searcher.EVENT_CHANGE, value, obj); self.fireEvent(BI.Searcher.EVENT_CHANGE, value, obj);
@ -140,7 +144,6 @@ BI.Searcher = BI.inherit(BI.Widget, {
}, },
_pauseSearch: function () { _pauseSearch: function () {
var o = this.options, name = this.getName();
this._stop = true; this._stop = true;
BI.nextTick(function (name) { BI.nextTick(function (name) {
BI.Maskers.hide(name); BI.Maskers.hide(name);
@ -153,7 +156,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
}, },
_stopSearch: function () { _stopSearch: function () {
var o = this.options, name = this.getName(); var name = this.getName();
this._stop = true; this._stop = true;
BI.Maskers.hide(name); BI.Maskers.hide(name);
if (this._isSearching === true) { if (this._isSearching === true) {
@ -175,6 +178,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
this.popupView.populate(find, match, keyword); this.popupView.populate(find, match, keyword);
o.isAutoSync && o.adapter && o.adapter.getValue && this.popupView.setValue(o.adapter.getValue()); o.isAutoSync && o.adapter && o.adapter.getValue && this.popupView.setValue(o.adapter.getValue());
self.fireEvent(BI.Searcher.EVENT_SEARCHING); self.fireEvent(BI.Searcher.EVENT_SEARCHING);
return; return;
} }
this.popupView.loading && this.popupView.loading(); this.popupView.loading && this.popupView.loading();
@ -203,6 +207,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
if (BI.isEmptyString(res[res.length - 1])) { if (BI.isEmptyString(res[res.length - 1])) {
res = res.slice(0, res.length - 1); res = res.slice(0, res.length - 1);
} }
return BI.isNull(res) ? "" : res[res.length - 1]; return BI.isNull(res) ? "" : res[res.length - 1];
} }
}, },
@ -246,6 +251,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
hasMatched: function () { hasMatched: function () {
this._assertPopupView(); this._assertPopupView();
return this.popupView.hasMatched(); return this.popupView.hasMatched();
}, },
@ -288,8 +294,8 @@ BI.Searcher = BI.inherit(BI.Widget, {
if (BI.isNull(this.popupView)) { if (BI.isNull(this.popupView)) {
return o.popup.value; return o.popup.value;
} }
return this.popupView.getValue();
return this.popupView.getValue();
}, },
populate: function (result, searchResult, keyword) { populate: function (result, searchResult, keyword) {

2
src/base/combination/switcher.js

@ -265,6 +265,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
if (this.switcher.attr("id") === id) { if (this.switcher.attr("id") === id) {
return this.switcher; return this.switcher;
} }
return this.popupView && this.popupView.getNodeById(id); return this.popupView && this.popupView.getNodeById(id);
}, },
@ -272,6 +273,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
if (this.switcher.getValue() === value) { if (this.switcher.getValue() === value) {
return this.switcher; return this.switcher;
} }
return this.popupView && this.popupView.getNodeByValue(value); return this.popupView && this.popupView.getNodeByValue(value);
}, },

2
src/base/combination/tab.js

@ -112,7 +112,7 @@ BI.Tab = BI.inherit(BI.Widget, {
}, },
removeTab: function (cardname) { removeTab: function (cardname) {
var self = this, o = this.options; var self = this;
BI.any(this.cardMap, function (name, card) { BI.any(this.cardMap, function (name, card) {
if (BI.isEqual(name, (cardname + ""))) { if (BI.isEqual(name, (cardname + ""))) {
self.layout.deleteCardByName(name); self.layout.deleteCardByName(name);

25
src/base/combination/tree.button.js

@ -16,6 +16,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (!BI.isFunction(item.setSelected)) { if (!BI.isFunction(item.setSelected)) {
item.setNotSelectedValue(v); item.setNotSelectedValue(v);
return; return;
} }
if (BI.deepContains(v, item.getValue())) { if (BI.deepContains(v, item.getValue())) {
@ -31,6 +32,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (BI.isFunction(item.setEnabledValue)) { if (BI.isFunction(item.setEnabledValue)) {
item.setEnabledValue(v); item.setEnabledValue(v);
return; return;
} }
if (BI.deepContains(v, item.getValue())) { if (BI.deepContains(v, item.getValue())) {
@ -46,6 +48,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (!BI.isFunction(item.setSelected)) { if (!BI.isFunction(item.setSelected)) {
item.setValue(v); item.setValue(v);
return; return;
} }
if (BI.deepContains(v, item.getValue())) { if (BI.deepContains(v, item.getValue())) {
@ -61,12 +64,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
v = BI.concat(v, item.getNotSelectedValue()); v = BI.concat(v, item.getNotSelectedValue());
return; return;
} }
if (item.isEnabled() && item.isSelected && !item.isSelected()) { if (item.isEnabled() && item.isSelected && !item.isSelected()) {
v.push(item.getValue()); v.push(item.getValue());
} }
}); });
return v; return v;
}, },
@ -75,12 +80,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
v = BI.concat(v, item.getValue()); v = BI.concat(v, item.getValue());
return; return;
} }
if (item.isEnabled() && item.isSelected && item.isSelected()) { if (item.isEnabled() && item.isSelected && item.isSelected()) {
v.push(item.getValue()); v.push(item.getValue());
} }
}); });
return v; return v;
}, },
@ -89,12 +96,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
btns = btns.concat(item.getSelectedButtons()); btns = btns.concat(item.getSelectedButtons());
return; return;
} }
if (item.isSelected && item.isSelected()) { if (item.isSelected && item.isSelected()) {
btns.push(item); btns.push(item);
} }
}); });
return btns; return btns;
}, },
@ -103,12 +112,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
btns = btns.concat(item.getNotSelectedButtons()); btns = btns.concat(item.getNotSelectedButtons());
return; return;
} }
if (item.isSelected && !item.isSelected()) { if (item.isSelected && !item.isSelected()) {
btns.push(item); btns.push(item);
} }
}); });
return btns; return btns;
}, },
@ -118,12 +129,14 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.each(this.buttons, function (i, item) { BI.each(this.buttons, function (i, item) {
if (item.isEnabled() && !BI.isFunction(item.setSelected)) { if (item.isEnabled() && !BI.isFunction(item.setSelected)) {
leaves = leaves.concat(item.getAllLeaves()); leaves = leaves.concat(item.getAllLeaves());
return; return;
} }
if (item.isEnabled()) { if (item.isEnabled()) {
leaves.push(item); leaves.push(item);
} }
}); });
return leaves; return leaves;
}, },
@ -133,9 +146,11 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
var vs = item.getValue(); var vs = item.getValue();
if (item.isEnabled() && (vs === value || BI.contains(vs, value))) { if (item.isEnabled() && (vs === value || BI.contains(vs, value))) {
index = i; index = i;
return true; return true;
} }
}); });
return index; return index;
}, },
@ -145,14 +160,17 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
if (item.isEnabled()) { if (item.isEnabled()) {
if (item.attr("id") === id) { if (item.attr("id") === id) {
node = item; node = item;
return true; return true;
} else if (BI.isFunction(item.getNodeById)) { } else if (BI.isFunction(item.getNodeById)) {
if (node = item.getNodeById(id)) { node = item.getNodeById(id);
if (node) {
return true; return true;
} }
} }
} }
}); });
return node; return node;
}, },
@ -161,15 +179,18 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
BI.any(this.buttons, function (i, item) { BI.any(this.buttons, function (i, item) {
if (item.isEnabled()) { if (item.isEnabled()) {
if (BI.isFunction(item.getNodeByValue)) { if (BI.isFunction(item.getNodeByValue)) {
if (node = item.getNodeByValue(value)) { node = item.getNodeByValue(value);
if (node) {
return true; return true;
} }
} else if (item.attr("value") === value) { } else if (item.attr("value") === value) {
node = item; node = item;
return true; return true;
} }
} }
}); });
return node; return node;
} }
}); });

Loading…
Cancel
Save