Browse Source

KERNEL-12408:base中eslint的修改

es6
chaos0156 2 years ago
parent
commit
05de8e3d30
  1. 3
      .eslintrc
  2. 20
      src/base/1.pane.js
  3. 6
      src/base/collection/__test__/collection.test.js
  4. 22
      src/base/collection/collection.js
  5. 36
      src/base/combination/bubble.js
  6. 34
      src/base/combination/combo.js
  7. 18
      src/base/combination/expander.js
  8. 20
      src/base/combination/group.button.js
  9. 18
      src/base/combination/group.combo.js
  10. 16
      src/base/combination/group.virtual.js
  11. 32
      src/base/combination/loader.js
  12. 16
      src/base/combination/navigation.js
  13. 22
      src/base/combination/searcher.js
  14. 22
      src/base/combination/switcher.js
  15. 16
      src/base/combination/tab.js
  16. 4
      src/base/combination/tree.button.js
  17. 6
      src/base/context.js
  18. 6
      src/base/el.js
  19. 2
      src/base/foundation/__test__/message.test.js
  20. 62
      src/base/foundation/message.js
  21. 4
      src/base/grid/__test__/grid.test.js
  22. 24
      src/base/grid/grid.js
  23. 6
      src/base/layer/__test__/layer.popover.test.js
  24. 62
      src/base/layer/layer.drawer.js
  25. 72
      src/base/layer/layer.popover.js
  26. 104
      src/base/layer/layer.popup.js
  27. 34
      src/base/layer/layer.searcher.js
  28. 10
      src/base/list/__test__/listview.test.js
  29. 10
      src/base/list/listview.js
  30. 14
      src/base/list/virtualgrouplist.js
  31. 12
      src/base/list/virtuallist.js
  32. 40
      src/base/pager/pager.js
  33. 24
      src/base/single/1.text.js
  34. 85
      src/base/single/label/abstract.label.js
  35. 7
      src/base/single/label/html.label.js
  36. 10
      src/base/single/label/icon.label.js
  37. 4
      src/base/single/label/label.js
  38. 5
      src/base/single/link/__test__/link.test.js
  39. 8
      src/base/single/link/link.js
  40. 7
      src/base/single/tip/0.tip.js
  41. 19
      src/base/single/tip/tip.toast.js
  42. 3
      src/base/single/trigger/trigger.js
  43. 20
      src/base/tree/customtree.js

3
.eslintrc

@ -31,8 +31,7 @@
"rules": { "rules": {
"no-param-reassign": "off", "no-param-reassign": "off",
"quotes": [2, "double"], "quotes": [2, "double"],
"comma-dangle": ["error", "always"], // 多行对象字面量中要求拖尾逗号 "comma-dangle": ["error", { "arrays": "never", "objects": "always"}], // 多行对象字面量中要求拖尾逗号
"no-empty":["error", { "allowEmptyCatch": true }]
} }
}, { }, {
"files": ["webpack/*.js", "./*.js", "lib/**/*.js", "lib/*.js", "./bin/*.js", "./bin/**/*.js"], "files": ["webpack/*.js", "./*.js", "lib/**/*.js", "lib/*.js", "./bin/*.js", "./bin/**/*.js"],

20
src/base/1.pane.js

@ -15,7 +15,7 @@ BI.Pane = BI.inherit(BI.Widget, {
loadingText: "", loadingText: "",
loadingSize: "small", loadingSize: "small",
overlap: true, overlap: true,
onLoaded: BI.emptyFn onLoaded: BI.emptyFn,
}); });
}, },
@ -32,8 +32,8 @@ BI.Pane = BI.inherit(BI.Widget, {
}, },
cls: "bi-tips", cls: "bi-tips",
text: o.tipText, text: o.tipText,
height: 25 height: 25,
}] }],
}); });
} }
}, },
@ -42,7 +42,7 @@ BI.Pane = BI.inherit(BI.Widget, {
var self = this, o = this.options; var self = this, o = this.options;
var loadingAnimation = BI.createWidget(BI.Providers.getProvider("bi.provider.system").getLoading({ var loadingAnimation = BI.createWidget(BI.Providers.getProvider("bi.provider.system").getLoading({
loadingSize: o.loadingSize, loadingSize: o.loadingSize,
context: this context: this,
})); }));
// pane在同步方式下由items决定tipText的显示与否 // pane在同步方式下由items决定tipText的显示与否
// loading的异步情况下由loaded后对面板的populate的时机决定 // loading的异步情况下由loaded后对面板的populate的时机决定
@ -53,7 +53,7 @@ BI.Pane = BI.inherit(BI.Widget, {
type: "bi.center_adapt", type: "bi.center_adapt",
cls: "loading-container", cls: "loading-container",
items: this._getLoadingTipItems(loadingAnimation), items: this._getLoadingTipItems(loadingAnimation),
element: BI.Layers.make(this.getName() + "-loading", this) element: BI.Layers.make(this.getName() + "-loading", this),
}); });
} }
BI.Layers.show(self.getName() + "-loading"); BI.Layers.show(self.getName() + "-loading");
@ -63,7 +63,7 @@ BI.Pane = BI.inherit(BI.Widget, {
type: "bi.center_adapt", type: "bi.center_adapt",
element: this, element: this,
cls: "loading-container", cls: "loading-container",
items: this._getLoadingTipItems(loadingAnimation) items: this._getLoadingTipItems(loadingAnimation),
}); });
} }
self.fireEvent(BI.Pane.EVENT_LOADING); self.fireEvent(BI.Pane.EVENT_LOADING);
@ -78,12 +78,12 @@ BI.Pane = BI.inherit(BI.Widget, {
var self = this, o = this.options; var self = this, o = this.options;
var loadingTipItems = [{ var loadingTipItems = [{
type: "bi.horizontal_adapt", type: "bi.horizontal_adapt",
items: [loadingTip] items: [loadingTip],
}]; }];
BI.isNotEmptyString(o.loadingText) && loadingTipItems.push({ BI.isNotEmptyString(o.loadingText) && loadingTipItems.push({
type: "bi.text", type: "bi.text",
text: o.loadingText, text: o.loadingText,
tgap: this._getSize(10) tgap: this._getSize(10),
}); });
return [{ return [{
@ -91,7 +91,7 @@ BI.Pane = BI.inherit(BI.Widget, {
ref: function (_ref) { ref: function (_ref) {
self._loading = _ref; self._loading = _ref;
}, },
items: loadingTipItems items: loadingTipItems,
}]; }];
}, },
@ -125,7 +125,7 @@ BI.Pane = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
this.options.items = items || []; this.options.items = items || [];
this.check(); this.check();
} },
}); });
BI.Pane.EVENT_LOADED = "EVENT_LOADED"; BI.Pane.EVENT_LOADED = "EVENT_LOADED";
BI.Pane.EVENT_LOADING = "EVENT_LOADING"; BI.Pane.EVENT_LOADING = "EVENT_LOADING";

6
src/base/collection/__test__/collection.test.js

@ -14,7 +14,7 @@ describe("CollectionTest", function () {
for (var i = 0; i < cellCount; i++) { for (var i = 0; i < cellCount; i++) {
items[i] = { items[i] = {
type: "bi.label", type: "bi.label",
text: i text: i,
}; };
} }
var grid = BI.Test.createWidget({ var grid = BI.Test.createWidget({
@ -27,9 +27,9 @@ describe("CollectionTest", function () {
x: index % 10 * 50, x: index % 10 * 50,
y: Math.floor(index / 10) * 50, y: Math.floor(index / 10) * 50,
width: 50, width: 50,
height: 50 height: 50,
}; };
} },
}); });
// TODO 列表展示类控件不知道该测什么,先标记一下 // TODO 列表展示类控件不知道该测什么,先标记一下
grid.destroy(); grid.destroy();

22
src/base/collection/collection.js

@ -24,7 +24,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
items: [], items: [],
itemFormatter: function (item, index) { itemFormatter: function (item, index) {
return item; return item;
} },
}); });
}, },
@ -38,7 +38,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
self._scrollLock = false; self._scrollLock = false;
}, 1000 / 60); }, 1000 / 60);
this.container = BI._lazyCreateWidget({ this.container = BI._lazyCreateWidget({
type: "bi.absolute" type: "bi.absolute",
}); });
this.element.scroll(function () { this.element.scroll(function () {
if (self._scrollLock === true) { if (self._scrollLock === true) {
@ -49,7 +49,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
self._calculateChildrenToRender(); self._calculateChildrenToRender();
self.fireEvent(BI.CollectionView.EVENT_SCROLL, { self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft, scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop scrollTop: o.scrollTop,
}); });
}); });
// 兼容一下 // 兼容一下
@ -71,7 +71,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
scrollable: scrollable, scrollable: scrollable,
scrolly: scrolly, scrolly: scrolly,
scrollx: scrollx, scrollx: scrollx,
items: [this.container] items: [this.container],
}); });
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) {
self.populate(newValue); self.populate(newValue);
@ -204,18 +204,18 @@ BI.CollectionView = BI.inherit(BI.Widget, {
child = BI._lazyCreateWidget(BI.extend({ child = BI._lazyCreateWidget(BI.extend({
type: "bi.label", type: "bi.label",
width: datum.width, width: datum.width,
height: datum.height height: datum.height,
}, item, { }, item, {
cls: (item.cls || "") + " collection-cell" + (datum.y === 0 ? " first-row" : "") + (datum.x === 0 ? " first-col" : ""), cls: (item.cls || "") + " collection-cell" + (datum.y === 0 ? " first-row" : "") + (datum.x === 0 ? " first-col" : ""),
_left: datum.x, _left: datum.x,
_top: datum.y _top: datum.y,
})); }));
renderedCells.push({ renderedCells.push({
el: child, el: child,
left: datum.x, left: datum.x,
top: datum.y, top: datum.y,
_left: datum.x, _left: datum.x,
_top: datum.y _top: datum.y,
// _width: datum.width, // _width: datum.width,
// _height: datum.height // _height: datum.height
}); });
@ -282,7 +282,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
var minY = BI.max(topBorder); var minY = BI.max(topBorder);
var maxY = BI.min(bottomBorder); var maxY = BI.min(bottomBorder);
this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY, };
} }
}, },
@ -341,7 +341,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.options.overflowX !== !!b) { if (this.options.overflowX !== !!b) {
this.options.overflowX = !!b; this.options.overflowX = !!b;
BI.nextTick(function () { BI.nextTick(function () {
self.element.css({ overflowX: b ? "auto" : "hidden" }); self.element.css({ overflowX: b ? "auto" : "hidden", });
}); });
} }
}, },
@ -351,7 +351,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.options.overflowY !== !!b) { if (this.options.overflowY !== !!b) {
this.options.overflowY = !!b; this.options.overflowY = !!b;
BI.nextTick(function () { BI.nextTick(function () {
self.element.css({ overflowY: b ? "auto" : "hidden" }); self.element.css({ overflowY: b ? "auto" : "hidden", });
}); });
} }
}, },
@ -398,7 +398,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
this.restore(); this.restore();
} }
this._populate(items); this._populate(items);
} },
}); });
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut("bi.collection_view", BI.CollectionView); BI.shortcut("bi.collection_view", BI.CollectionView);

36
src/base/combination/bubble.js

@ -10,14 +10,14 @@
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-popper", baseCls: (conf.baseCls || "") + " bi-popper",
attributes: { attributes: {
tabIndex: -1 tabIndex: -1,
}, },
trigger: "click", // click || hover || click-hover || "" trigger: "click", // click || hover || click-hover || ""
toggle: true, toggle: true,
direction: "", direction: "",
placement: "bottom-start", // top-start/top/top-end/bottom-start/bottom/bottom-end/left-start/left/left-end/right-start/right/right-end placement: "bottom-start", // top-start/top/top-end/bottom-start/bottom/bottom-end/left-start/left/left-end/right-start/right/right-end
logic: { logic: {
dynamic: true dynamic: true,
}, },
container: null, // popupview放置的容器,默认为this.element container: null, // popupview放置的容器,默认为this.element
isDefaultInit: false, isDefaultInit: false,
@ -37,7 +37,7 @@
el: {}, el: {},
popup: {}, popup: {},
comboClass: "bi-combo-popup", comboClass: "bi-combo-popup",
hoverClass: "bi-combo-hover" hoverClass: "bi-combo-hover",
}); });
}, },
@ -82,11 +82,11 @@
}); });
BI.createWidget(BI.extend({ BI.createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
items: [ items: [
{ el: this.combo } { el: this.combo, }
] ],
})))); }))));
o.isDefaultInit && (this._assertPopupView()); o.isDefaultInit && (this._assertPopupView());
}, },
@ -172,7 +172,7 @@
} }
}, BI.EVENT_RESPONSE_TIME, { }, BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
}); });
self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) { self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
debounce(e); debounce(e);
@ -195,7 +195,7 @@
} }
}, BI.EVENT_RESPONSE_TIME, { }, BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
}); });
self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) { self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) {
debounce(e); debounce(e);
@ -226,7 +226,7 @@
_initCombo: function () { _initCombo: function () {
this.combo = BI.createWidget(this.options.el, { this.combo = BI.createWidget(this.options.el, {
value: this.options.value value: this.options.value,
}); });
}, },
@ -236,7 +236,7 @@
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,
value: o.value value: o.value,
}, this); }, this);
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
@ -260,8 +260,8 @@
scrolly: false, scrolly: false,
element: this.options.container || this, element: this.options.container || this,
items: [ items: [
{ el: this.popupView } { el: this.popupView, }
] ],
}); });
this._rendered = true; this._rendered = true;
} }
@ -339,22 +339,22 @@
options: { options: {
offset: function () { offset: function () {
return [o.adjustXOffset, (o.showArrow ? 12 : 0) + (o.adjustYOffset + o.adjustLength)]; return [o.adjustXOffset, (o.showArrow ? 12 : 0) + (o.adjustYOffset + o.adjustLength)];
} },
} },
}]; }];
if (this.options.showArrow) { if (this.options.showArrow) {
modifiers.push({ modifiers.push({
name: "arrow", name: "arrow",
options: { options: {
padding: 4, padding: 4,
element: this.popupView.arrow.element[0] element: this.popupView.arrow.element[0],
} },
}); });
} }
this.popper = BI.Popper.createPopper(this.combo.element[0], this.popupView.element[0], { this.popper = BI.Popper.createPopper(this.combo.element[0], this.popupView.element[0], {
placement: o.placement, placement: o.placement,
strategy: "fixed", strategy: "fixed",
modifiers: modifiers modifiers: modifiers,
}); });
// this.adjustHeight(e); // this.adjustHeight(e);
@ -482,7 +482,7 @@
this.popper && this.popper.destroy(); this.popper && this.popper.destroy();
this.popper = null; this.popper = null;
this.popupView && this.popupView._destroy(); this.popupView && this.popupView._destroy();
} },
}); });
BI.Bubble.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; BI.Bubble.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
BI.Bubble.EVENT_CHANGE = "EVENT_CHANGE"; BI.Bubble.EVENT_CHANGE = "EVENT_CHANGE";

34
src/base/combination/combo.js

@ -8,7 +8,7 @@
*/ */
BI.Combo = BI.inherit(BI.Bubble, { BI.Combo = BI.inherit(BI.Bubble, {
_const: { _const: {
TRIANGLE_LENGTH: 12 TRIANGLE_LENGTH: 12,
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments);
@ -16,13 +16,13 @@
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: {
tabIndex: -1 tabIndex: -1,
}, },
trigger: "click", // click || hover || click-hover || "" trigger: "click", // click || hover || click-hover || ""
toggle: true, toggle: true,
direction: "bottom", // top||bottom||left||right||top,left||top,right||bottom,left||bottom,right||right,innerRight||right,innerLeft||innerRight||innerLeft direction: "bottom", // top||bottom||left||right||top,left||top,right||bottom,left||bottom,right||right,innerRight||right,innerLeft||innerRight||innerLeft
logic: { logic: {
dynamic: true dynamic: true,
}, },
container: null, // popupview放置的容器,默认为this.element container: null, // popupview放置的容器,默认为this.element
isDefaultInit: false, isDefaultInit: false,
@ -44,7 +44,7 @@
popup: {}, popup: {},
comboClass: "bi-combo-popup", comboClass: "bi-combo-popup",
hoverClass: "bi-combo-hover", hoverClass: "bi-combo-hover",
belowMouse: false belowMouse: false,
}); });
}, },
@ -92,11 +92,11 @@
}); });
BI.createWidget(BI.extend({ BI.createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
items: [ items: [
{ el: this.combo } { el: this.combo, }
] ],
})))); }))));
o.isDefaultInit && (this._assertPopupView()); o.isDefaultInit && (this._assertPopupView());
BI.Resizers.add(this.getName(), BI.bind(function (e) { BI.Resizers.add(this.getName(), BI.bind(function (e) {
@ -113,7 +113,7 @@
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,
value: o.value value: o.value,
}, this); }, this);
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
@ -160,7 +160,7 @@
this._assertPopupViewRender(); this._assertPopupViewRender();
this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW); this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW);
// popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下 // popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下
this.popupView.css({ left: -999999999, top: -99999999 }); this.popupView.css({ left: -999999999, top: -99999999, });
this.popupView.visible(); this.popupView.visible();
BI.each(needHideWhenAnotherComboOpen, function (i, combo) { BI.each(needHideWhenAnotherComboOpen, function (i, combo) {
if (i !== self.getName()) { if (i !== self.getName()) {
@ -197,7 +197,7 @@
offset: function () { offset: function () {
return { return {
left: e.pageX, left: e.pageX,
top: e.pageY top: e.pageY,
}; };
}, },
bounds: function () { bounds: function () {
@ -206,7 +206,7 @@
x: e.offsetX, x: e.offsetX,
y: e.offsetY, y: e.offsetY,
width: 0, width: 0,
height: 24 height: 24,
}; };
}, },
outerWidth: function () { outerWidth: function () {
@ -214,8 +214,8 @@
}, },
outerHeight: function () { outerHeight: function () {
return 24; return 24;
} },
} },
} : this.combo; } : this.combo;
switch (o.direction) { switch (o.direction) {
case "bottom": case "bottom":
@ -297,16 +297,16 @@
offsetStyle: o.offsetStyle, offsetStyle: o.offsetStyle,
adjustXOffset: o.adjustXOffset, adjustXOffset: o.adjustXOffset,
adjustYOffset: o.adjustYOffset, adjustYOffset: o.adjustYOffset,
offset: this.combo.element.offset() offset: this.combo.element.offset(),
}); });
if ("left" in p) { if ("left" in p) {
this.popupView.element.css({ this.popupView.element.css({
left: p.left left: p.left,
}); });
} }
if ("top" in p) { if ("top" in p) {
this.popupView.element.css({ this.popupView.element.css({
top: p.top top: p.top,
}); });
} }
this.position = p; this.position = p;
@ -326,7 +326,7 @@
this.popupView && this.popupView._destroy(); this.popupView && this.popupView._destroy();
delete needHideWhenAnotherComboOpen[this.getName()]; delete needHideWhenAnotherComboOpen[this.getName()];
delete currentOpenedCombos[this.getName()]; delete currentOpenedCombos[this.getName()];
} },
}); });
BI.Combo.closeAll = function () { BI.Combo.closeAll = function () {
BI.each(currentOpenedCombos, function (i, combo) { BI.each(currentOpenedCombos, function (i, combo) {

18
src/base/combination/expander.js

@ -17,7 +17,7 @@ BI.Expander = BI.inherit(BI.Widget, {
el: {}, el: {},
popup: {}, popup: {},
expanderClass: "bi-expander-popup", expanderClass: "bi-expander-popup",
hoverClass: "bi-expander-hover" hoverClass: "bi-expander-hover",
}); });
}, },
@ -65,8 +65,8 @@ BI.Expander = BI.inherit(BI.Widget, {
scrolly: false, scrolly: false,
element: this, element: this,
items: [ items: [
{ el: this.expander } { el: this.expander, }
] ],
}); });
o.isDefaultInit && this._assertPopupView(); o.isDefaultInit && this._assertPopupView();
if (this.expander.isOpened() === true) { if (this.expander.isOpened() === true) {
@ -122,7 +122,7 @@ BI.Expander = BI.inherit(BI.Widget, {
} }
}, BI.EVENT_RESPONSE_TIME, { }, BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
})); }));
} }
break; break;
@ -145,9 +145,9 @@ BI.Expander = BI.inherit(BI.Widget, {
layouts: [{ layouts: [{
type: "bi.vertical", type: "bi.vertical",
hgap: 0, hgap: 0,
vgap: 0 vgap: 0,
}], }],
value: o.value value: o.value,
}, this); }, this);
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -171,8 +171,8 @@ BI.Expander = BI.inherit(BI.Widget, {
scrolly: false, scrolly: false,
element: this, element: this,
items: [ items: [
{ el: this.popupView } { el: this.popupView, }
] ],
}); });
this._rendered = true; this._rendered = true;
} }
@ -271,7 +271,7 @@ BI.Expander = BI.inherit(BI.Widget, {
destroy: function () { destroy: function () {
BI.Expander.superclass.destroy.apply(this, arguments); BI.Expander.superclass.destroy.apply(this, arguments);
} },
}); });
BI.Expander.EVENT_EXPAND = "EVENT_EXPAND"; BI.Expander.EVENT_EXPAND = "EVENT_EXPAND";
BI.Expander.EVENT_COLLAPSE = "EVENT_COLLAPSE"; BI.Expander.EVENT_COLLAPSE = "EVENT_COLLAPSE";

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

@ -15,8 +15,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
layouts: [{ layouts: [{
type: "bi.center", type: "bi.center",
hgap: 0, hgap: 0,
vgap: 0 vgap: 0,
}] }],
}); });
}, },
@ -25,7 +25,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
var behaviors = {}; var behaviors = {};
BI.each(o.behaviors, function (key, rule) { BI.each(o.behaviors, function (key, rule) {
behaviors[key] = BI.BehaviorFactory.createBehavior(key, { behaviors[key] = BI.BehaviorFactory.createBehavior(key, {
rule: rule rule: rule,
}); });
}); });
this.behaviors = behaviors; this.behaviors = behaviors;
@ -43,7 +43,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
_createBtns: function (items) { _createBtns: function (items) {
return BI.createWidgets(BI.createItems(items, { return BI.createWidgets(BI.createItems(items, {
type: "bi.text_button" type: "bi.text_button",
}), this); }), this);
}, },
@ -90,9 +90,9 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
return BI.extend({}, layouts[i], { return BI.extend({}, layouts[i], {
items: [ items: [
BI.extend({}, layouts[i].el, { BI.extend({}, layouts[i].el, {
el: it el: it,
}) })
] ],
}); });
}); });
} }
@ -109,7 +109,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
} }
return BI.extend({}, item, { return BI.extend({}, item, {
el: btns[i] el: btns[i],
}); });
}); });
}, },
@ -203,7 +203,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
items = this._packageItems(items, this._packageBtns(this.buttons)); items = this._packageItems(items, this._packageBtns(this.buttons));
} }
this.layouts = BI.createWidget(BI.extend({ element: this }, this._packageLayout(items))); this.layouts = BI.createWidget(BI.extend({ element: this, }, this._packageLayout(items)));
}, },
setNotSelectedValue: function (v) { setNotSelectedValue: function (v) {
@ -365,14 +365,14 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
destroy: function () { destroy: function () {
BI.ButtonGroup.superclass.destroy.apply(this, arguments); BI.ButtonGroup.superclass.destroy.apply(this, arguments);
this.options.items = []; this.options.items = [];
} },
}); });
BI.extend(BI.ButtonGroup, { BI.extend(BI.ButtonGroup, {
CHOOSE_TYPE_SINGLE: BI.Selection.Single, CHOOSE_TYPE_SINGLE: BI.Selection.Single,
CHOOSE_TYPE_MULTI: BI.Selection.Multi, CHOOSE_TYPE_MULTI: BI.Selection.Multi,
CHOOSE_TYPE_ALL: BI.Selection.All, CHOOSE_TYPE_ALL: BI.Selection.All,
CHOOSE_TYPE_NONE: BI.Selection.None, CHOOSE_TYPE_NONE: BI.Selection.None,
CHOOSE_TYPE_DEFAULT: BI.Selection.Default CHOOSE_TYPE_DEFAULT: BI.Selection.Default,
}); });
BI.ButtonGroup.EVENT_CHANGE = "EVENT_CHANGE"; BI.ButtonGroup.EVENT_CHANGE = "EVENT_CHANGE";

18
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: {
@ -23,10 +23,10 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
type: "bi.button_tree", type: "bi.button_tree",
chooseType: 0, chooseType: 0,
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical",
}] }],
} },
} },
}); });
}, },
@ -71,9 +71,9 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
el: item, el: item,
popup: BI.extend({}, o.popup, { popup: BI.extend({}, o.popup, {
el: BI.extend({ el: BI.extend({
items: children items: children,
}, o.popup.el) }, o.popup.el),
}) }),
}); });
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -89,7 +89,7 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
this.combo.setValue(v); this.combo.setValue(v);
} },
}); });
BI.ComboGroup.EVENT_CHANGE = "EVENT_CHANGE"; BI.ComboGroup.EVENT_CHANGE = "EVENT_CHANGE";

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

@ -6,8 +6,8 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
layouts: [{ layouts: [{
type: "bi.center", type: "bi.center",
hgap: 0, hgap: 0,
vgap: 0 vgap: 0,
}] }],
}); });
}, },
@ -41,10 +41,10 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
if (BI.isKey(map[el.value])) { if (BI.isKey(map[el.value])) {
map[el.value] = _ref; map[el.value] = _ref;
} }
} },
}, el) }, el),
}) })
] ],
}); });
}); });
} }
@ -132,13 +132,13 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
this.options.items = items; this.options.items = items;
items = this._packageBtns(items); items = this._packageBtns(items);
if (!this.layouts) { if (!this.layouts) {
this.layouts = BI.createWidget(BI.extend({ element: this }, this._packageLayout(items))); this.layouts = BI.createWidget(BI.extend({ element: this, }, this._packageLayout(items)));
} else { } else {
this.layouts.populate(items, { this.layouts.populate(items, {
context: this context: this,
}); });
} }
} },
}); });
BI.VirtualGroup.EVENT_CHANGE = "EVENT_CHANGE"; BI.VirtualGroup.EVENT_CHANGE = "EVENT_CHANGE";

32
src/base/combination/loader.js

@ -14,12 +14,12 @@ BI.Loader = BI.inherit(BI.Widget, {
isDefaultInit: true, // 是否默认初始化数据 isDefaultInit: true, // 是否默认初始化数据
logic: { logic: {
dynamic: true, dynamic: true,
scrolly: true scrolly: true,
}, },
// 下面是button_group的属性 // 下面是button_group的属性
el: { el: {
type: "bi.button_group" type: "bi.button_group",
}, },
items: [], items: [],
@ -31,14 +31,14 @@ BI.Loader = BI.inherit(BI.Widget, {
prev: false, prev: false,
next: {}, next: {},
hasPrev: BI.emptyFn, hasPrev: BI.emptyFn,
hasNext: BI.emptyFn hasNext: BI.emptyFn,
}); });
}, },
_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);
}]); }]);
@ -61,7 +61,7 @@ BI.Loader = BI.inherit(BI.Widget, {
} }
if (o.prev !== false) { if (o.prev !== false) {
this.prev = BI.createWidget(BI.extend({ this.prev = BI.createWidget(BI.extend({
type: "bi.loading_bar" type: "bi.loading_bar",
}, o.prev)); }, o.prev));
this.prev.on(BI.Controller.EVENT_CHANGE, function (type) { this.prev.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
@ -76,9 +76,9 @@ BI.Loader = BI.inherit(BI.Widget, {
items: o.items, items: o.items,
behaviors: {}, behaviors: {},
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical",
}], }],
value: o.value value: o.value,
}); });
this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -89,7 +89,7 @@ BI.Loader = BI.inherit(BI.Widget, {
if (o.next !== false) { if (o.next !== false) {
this.next = BI.createWidget(BI.extend({ this.next = BI.createWidget(BI.extend({
type: "bi.loading_bar" type: "bi.loading_bar",
}, o.next)); }, o.next));
this.next.on(BI.Controller.EVENT_CHANGE, function (type) { this.next.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
@ -99,11 +99,11 @@ BI.Loader = BI.inherit(BI.Widget, {
} }
BI.createWidget(BI.extend({ BI.createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({
scrolly: true scrolly: true,
}, o.logic, { }, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.prev, this.button_group, this.next) items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.prev, this.button_group, this.next),
})))); }))));
o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () { o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () {
@ -125,7 +125,7 @@ BI.Loader = BI.inherit(BI.Widget, {
return !!o.hasPrev.apply(this, [{ return !!o.hasPrev.apply(this, [{
times: this.times, times: this.times,
count: this.count count: this.count,
}]); }]);
}, },
@ -137,7 +137,7 @@ BI.Loader = BI.inherit(BI.Widget, {
return !!o.hasNext.apply(this, [{ return !!o.hasNext.apply(this, [{
times: this.times, times: this.times,
count: this.count count: this.count,
}]); }]);
}, },
@ -170,7 +170,7 @@ 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("参数不能为空");
} }
@ -259,7 +259,7 @@ BI.Loader = BI.inherit(BI.Widget, {
destroy: function () { destroy: function () {
BI.Loader.superclass.destroy.apply(this, arguments); BI.Loader.superclass.destroy.apply(this, arguments);
} },
}); });
BI.Loader.EVENT_CHANGE = "EVENT_CHANGE"; BI.Loader.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.loader", BI.Loader); BI.shortcut("bi.loader", BI.Loader);

16
src/base/combination/navigation.js

@ -7,7 +7,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
return BI.extend(BI.Navigation.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.Navigation.superclass._defaultConfig.apply(this, arguments), {
direction: "bottom", // top, bottom, left, right, custom direction: "bottom", // top, bottom, left, right, custom
logic: { logic: {
dynamic: false dynamic: false,
}, },
single: false, single: false,
showIndex: false, showIndex: false,
@ -17,22 +17,22 @@ BI.Navigation = BI.inherit(BI.Widget, {
}, },
afterCardCreated: BI.emptyFn, afterCardCreated: BI.emptyFn,
afterCardShow: BI.emptyFn afterCardShow: BI.emptyFn,
}); });
}, },
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({
type: "bi.card" type: "bi.card",
}); });
BI.createWidget(BI.extend({ BI.createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout) items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout),
})))); }))));
@ -49,7 +49,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
return card; return card;
}, },
afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardCreated: BI.bind(this.afterCardCreated, this),
afterCardShow: BI.bind(this.afterCardShow, this) afterCardShow: BI.bind(this.afterCardShow, this),
}); });
if (BI.isFunction(o.showIndex)) { if (BI.isFunction(o.showIndex)) {
@ -162,7 +162,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
destroy: function () { destroy: function () {
BI.Navigation.superclass.destroy.apply(this, arguments); BI.Navigation.superclass.destroy.apply(this, arguments);
} },
}); });
BI.Navigation.EVENT_CHANGE = "EVENT_CHANGE"; BI.Navigation.EVENT_CHANGE = "EVENT_CHANGE";

22
src/base/combination/searcher.js

@ -28,17 +28,17 @@ BI.Searcher = BI.inherit(BI.Widget, {
}, },
el: { el: {
type: "bi.search_editor" type: "bi.search_editor",
}, },
popup: { popup: {
type: "bi.searcher_view" type: "bi.searcher_view",
}, },
adapter: null, adapter: null,
masker: { // masker层 masker: { // masker层
offset: {} offset: {},
} },
}); });
}, },
@ -46,7 +46,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget(o.el, { this.editor = BI.createWidget(o.el, {
type: "bi.search_editor" type: "bi.search_editor",
}); });
BI.createWidget({ BI.createWidget({
@ -58,13 +58,13 @@ BI.Searcher = BI.inherit(BI.Widget, {
bgap: o.bgap, bgap: o.bgap,
vgap: o.vgap, vgap: o.vgap,
hgap: o.hgap, hgap: o.hgap,
items: [this.editor] items: [this.editor],
}); });
o.isDefaultInit && (this._assertPopupView()); o.isDefaultInit && (this._assertPopupView());
var search = BI.debounce(BI.bind(this._search, this), BI.EVENT_RESPONSE_TIME, { var search = BI.debounce(BI.bind(this._search, this), BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
}); });
this.editor.on(BI.Controller.EVENT_CHANGE, function (type) { this.editor.on(BI.Controller.EVENT_CHANGE, function (type) {
switch (type) { switch (type) {
@ -93,7 +93,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
if ((o.masker && !BI.Maskers.has(this.getName())) || (o.masker === false && !this.popupView)) { if ((o.masker && !BI.Maskers.has(this.getName())) || (o.masker === false && !this.popupView)) {
this.popupView = BI.createWidget(o.popup, { this.popupView = BI.createWidget(o.popup, {
type: "bi.searcher_view", type: "bi.searcher_view",
chooseType: o.chooseType chooseType: o.chooseType,
}); });
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -125,7 +125,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
if (o.masker && !BI.Maskers.has(this.getName())) { if (o.masker && !BI.Maskers.has(this.getName())) {
BI.Maskers.create(this.getName(), o.adapter, BI.extend({ BI.Maskers.create(this.getName(), o.adapter, BI.extend({
container: this, container: this,
render: this.popupView render: this.popupView,
}, o.masker), this); }, o.masker), this);
} }
}, },
@ -185,7 +185,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
o.onSearch({ o.onSearch({
times: 1, times: 1,
keyword: keyword, keyword: keyword,
selectedValues: o.adapter && o.adapter.getValue() selectedValues: o.adapter && o.adapter.getValue(),
}, function (searchResult, matchResult) { }, function (searchResult, matchResult) {
if (!self._stop && keyword === self.editor.getValue()) { if (!self._stop && keyword === self.editor.getValue()) {
var args = [].slice.call(arguments); var args = [].slice.call(arguments);
@ -325,7 +325,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
setWaterMark: function (v) { setWaterMark: function (v) {
this.editor.setWaterMark(v); this.editor.setWaterMark(v);
} },
}); });
BI.Searcher.EVENT_CHANGE = "EVENT_CHANGE"; BI.Searcher.EVENT_CHANGE = "EVENT_CHANGE";
BI.Searcher.EVENT_START = "EVENT_START"; BI.Searcher.EVENT_START = "EVENT_START";

22
src/base/combination/switcher.js

@ -18,7 +18,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
adapter: null, adapter: null,
masker: {}, masker: {},
switcherClass: "bi-switcher-popup", switcherClass: "bi-switcher-popup",
hoverClass: "bi-switcher-hover" hoverClass: "bi-switcher-hover",
}); });
}, },
@ -65,8 +65,8 @@ BI.Switcher = BI.inherit(BI.Widget, {
scrolly: false, scrolly: false,
element: this, element: this,
items: [ items: [
{ el: this.switcher } { el: this.switcher, }
] ],
}); });
o.isDefaultInit && (this._assertPopupView()); o.isDefaultInit && (this._assertPopupView());
}, },
@ -119,7 +119,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
} }
}, BI.EVENT_RESPONSE_TIME, { }, BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
})); }));
} }
break; break;
@ -129,7 +129,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
_initSwitcher: function () { _initSwitcher: function () {
this.switcher = BI.createWidget(this.options.el, { this.switcher = BI.createWidget(this.options.el, {
value: this.options.value value: this.options.value,
}); });
}, },
@ -138,14 +138,14 @@ BI.Switcher = BI.inherit(BI.Widget, {
if (!this._created) { if (!this._created) {
this.popupView = BI.createWidget(o.popup, { this.popupView = BI.createWidget(o.popup, {
type: "bi.button_group", type: "bi.button_group",
element: o.adapter && BI.Maskers.create(this.getName(), o.adapter, BI.extend({ container: this }, o.masker)), element: o.adapter && BI.Maskers.create(this.getName(), o.adapter, BI.extend({ container: this, }, o.masker)),
cls: "switcher-popup", cls: "switcher-popup",
layouts: [{ layouts: [{
type: "bi.vertical", type: "bi.vertical",
hgap: 0, hgap: 0,
vgap: 0 vgap: 0,
}], }],
value: o.value value: o.value,
}, this); }, this);
this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -159,8 +159,8 @@ BI.Switcher = BI.inherit(BI.Widget, {
scrolly: false, scrolly: false,
element: this, element: this,
items: [ items: [
{ el: this.popupView } { el: this.popupView, }
] ],
}); });
} }
this._created = true; this._created = true;
@ -279,7 +279,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
empty: function () { empty: function () {
this.popupView && this.popupView.empty(); this.popupView && this.popupView.empty();
} },
}); });
BI.Switcher.EVENT_EXPAND = "EVENT_EXPAND"; BI.Switcher.EVENT_EXPAND = "EVENT_EXPAND";
BI.Switcher.EVENT_COLLAPSE = "EVENT_COLLAPSE"; BI.Switcher.EVENT_COLLAPSE = "EVENT_COLLAPSE";

16
src/base/combination/tab.js

@ -9,34 +9,34 @@ BI.Tab = BI.inherit(BI.Widget, {
direction: "top", // top, bottom, left, right, custom direction: "top", // top, bottom, left, right, custom
single: false, // 是不是单页面 single: false, // 是不是单页面
logic: { logic: {
dynamic: false dynamic: false,
}, },
showIndex: false, showIndex: false,
tab: false, tab: false,
cardCreator: function (v) { cardCreator: function (v) {
return BI.createWidget(); return BI.createWidget();
}, },
keepAlives: [] keepAlives: [],
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
if (BI.isObject(o.tab)) { if (BI.isObject(o.tab)) {
this.tab = BI.createWidget(this.options.tab, { type: "bi.button_group" }); this.tab = BI.createWidget(this.options.tab, { type: "bi.button_group", });
this.tab.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.tab.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
} }
this.cardMap = {}; this.cardMap = {};
this.layout = BI.createWidget({ this.layout = BI.createWidget({
type: "bi.card" type: "bi.card",
}); });
BI.createWidget(BI.extend({ BI.createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout) items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout),
})))); }))));
var listener = new BI.ShowListener({ var listener = new BI.ShowListener({
@ -51,7 +51,7 @@ BI.Tab = BI.inherit(BI.Widget, {
afterCardShow: function (v) { afterCardShow: function (v) {
self._deleteOtherCards(v); self._deleteOtherCards(v);
self.curr = v; self.curr = v;
} },
}); });
listener.on(BI.ShowListener.EVENT_CHANGE, function (value) { listener.on(BI.ShowListener.EVENT_CHANGE, function (value) {
self.fireEvent(BI.Tab.EVENT_CHANGE, value, self); self.fireEvent(BI.Tab.EVENT_CHANGE, value, self);
@ -170,7 +170,7 @@ BI.Tab = BI.inherit(BI.Widget, {
destroy: function () { destroy: function () {
this.cardMap = {}; this.cardMap = {};
BI.Tab.superclass.destroy.apply(this, arguments); BI.Tab.superclass.destroy.apply(this, arguments);
} },
}); });
BI.Tab.EVENT_CHANGE = "EVENT_CHANGE"; BI.Tab.EVENT_CHANGE = "EVENT_CHANGE";

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

@ -7,7 +7,7 @@
BI.ButtonTree = BI.inherit(BI.ButtonGroup, { BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.ButtonTree.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.ButtonTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-button-tree" baseCls: "bi-button-tree",
}); });
}, },
@ -192,7 +192,7 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
}); });
return node; return node;
} },
}); });
BI.ButtonTree.EVENT_CHANGE = "EVENT_CHANGE"; BI.ButtonTree.EVENT_CHANGE = "EVENT_CHANGE";

6
src/base/context.js

@ -10,13 +10,13 @@ BI.Context = BI.inherit(BI.Widget, {
context: "", context: "",
watch: {}, watch: {},
el: {}, el: {},
items: [] items: [],
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.context = BI.createWidget(o.items[0] || o.el, { this.context = BI.createWidget(o.items[0] || o.el, {
element: this element: this,
}); });
this.context.on(BI.Controller.EVENT_CHANGE, function () { this.context.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -40,6 +40,6 @@ BI.Context = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this.context.populate.apply(this, arguments); this.context.populate.apply(this, arguments);
} },
}); });
BI.shortcut("bi.context", BI.Context); BI.shortcut("bi.context", BI.Context);

6
src/base/el.js

@ -9,14 +9,14 @@ BI.EL = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.EL.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.EL.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-el", baseCls: "bi-el",
el: {} el: {},
}); });
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this.ele = BI.createWidget(o.el, { this.ele = BI.createWidget(o.el, {
element: this element: this,
}); });
this.ele.on(BI.Controller.EVENT_CHANGE, function () { this.ele.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -33,6 +33,6 @@ BI.EL = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this.ele.populate.apply(this, arguments); this.ele.populate.apply(this, arguments);
} },
}); });
BI.shortcut("bi.el", BI.EL); BI.shortcut("bi.el", BI.EL);

2
src/base/foundation/__test__/message.test.js

@ -23,7 +23,7 @@ describe("MessageTest", function () {
*/ */
it("toast_hand_close", function (done) { it("toast_hand_close", function (done) {
BI.Msg.toast("message", { BI.Msg.toast("message", {
autoClose: false autoClose: false,
}); });
var body = BI.Widget._renderEngine.createElement("body"); var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-toast").length).to.equal(1); expect(body.find(".bi-toast").length).to.equal(1);

62
src/base/foundation/message.js

@ -21,7 +21,7 @@ BI.Msg = ((function () {
// BI.Msg.prompt(title, message, value, callback, min_width); // BI.Msg.prompt(title, message, value, callback, min_width);
}, },
toast: function (message, options, context) { toast: function (message, options, context) {
BI.isString(options) && (options = { level: options }); BI.isString(options) && (options = { level: options, });
options = options || {}; options = options || {};
context = context || BI.Widget._renderEngine.createElement("body"); context = context || BI.Widget._renderEngine.createElement("body");
var level = options.level || "common"; var level = options.level || "common";
@ -40,12 +40,12 @@ BI.Msg = ((function () {
BI.remove(toastStack, toast.element); BI.remove(toastStack, toast.element);
var _height = BI.SIZE_CONSANTS.TOAST_TOP; var _height = BI.SIZE_CONSANTS.TOAST_TOP;
BI.each(toastStack, function (i, element) { BI.each(toastStack, function (i, element) {
element.css({ "top": _height }); element.css({ "top": _height, });
_height += element.outerHeight() + 10; _height += element.outerHeight() + 10;
}); });
callback(); callback();
} },
}] }],
}); });
var height = BI.SIZE_CONSANTS.TOAST_TOP; var height = BI.SIZE_CONSANTS.TOAST_TOP;
BI.each(toastStack, function (i, element) { BI.each(toastStack, function (i, element) {
@ -57,11 +57,11 @@ BI.Msg = ((function () {
items: [{ items: [{
el: toast, el: toast,
left: "50%", left: "50%",
top: height top: height,
}] }],
}); });
toastStack.push(toast.element); toastStack.push(toast.element);
toast.element.css({ "margin-left": -1 * toast.element.outerWidth() / 2 }); toast.element.css({ "margin-left": -1 * toast.element.outerWidth() / 2, });
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () { autoClose && BI.delay(function () {
@ -82,7 +82,7 @@ BI.Msg = ((function () {
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
opacity: 0.5 opacity: 0.5,
}).appendTo("body")); }).appendTo("body"));
$pop = BI.Widget._renderEngine.createElement("<div class=\"bi-message-depend\">").css({ $pop = BI.Widget._renderEngine.createElement("<div class=\"bi-message-depend\">").css({
position: "absolute", position: "absolute",
@ -90,7 +90,7 @@ BI.Msg = ((function () {
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
bottom: 0 bottom: 0,
}).appendTo("body"); }).appendTo("body");
function close () { function close () {
messageShows[messageShows.length - 1].destroy(); messageShows[messageShows.length - 1].destroy();
@ -112,8 +112,8 @@ BI.Msg = ((function () {
if (BI.isFunction(callback)) { if (BI.isFunction(callback)) {
callback.apply(null, [false]); callback.apply(null, [false]);
} }
} },
} },
}); });
} }
controlItems.push({ controlItems.push({
@ -125,8 +125,8 @@ BI.Msg = ((function () {
if (BI.isFunction(callback)) { if (BI.isFunction(callback)) {
callback.apply(null, [true]); callback.apply(null, [true]);
} }
} },
} },
}); });
var conf = { var conf = {
element: $pop, element: $pop,
@ -135,7 +135,7 @@ BI.Msg = ((function () {
{ {
type: "bi.border", type: "bi.border",
attributes: { attributes: {
tabIndex: 1 tabIndex: 1,
}, },
mounted: function () { mounted: function () {
this.element.keyup(function (e) { this.element.keyup(function (e) {
@ -173,8 +173,8 @@ BI.Msg = ((function () {
text: title || BI.i18nText("BI-Basic_Prompt"), text: title || BI.i18nText("BI-Basic_Prompt"),
textAlign: "left", textAlign: "left",
hgap: 20, hgap: 20,
height: 40 height: 40,
} },
}, },
east: { east: {
el: { el: {
@ -186,13 +186,13 @@ BI.Msg = ((function () {
if (BI.isFunction(callback)) { if (BI.isFunction(callback)) {
callback.apply(null, [false]); callback.apply(null, [false]);
} }
}
}, },
width: 56
}
}
}, },
height: 40 width: 56,
},
},
},
height: 40,
}, },
center: { center: {
el: BI.isPlainObject(message) ? message : { el: BI.isPlainObject(message) ? message : {
@ -200,8 +200,8 @@ BI.Msg = ((function () {
vgap: 10, vgap: 10,
hgap: 20, hgap: 20,
whiteSpace: "normal", whiteSpace: "normal",
text: message text: message,
} },
}, },
south: { south: {
el: { el: {
@ -210,25 +210,25 @@ BI.Msg = ((function () {
el: { el: {
type: "bi.right_vertical_adapt", type: "bi.right_vertical_adapt",
lgap: 10, lgap: 10,
items: controlItems items: controlItems,
}, },
top: 0, top: 0,
left: 20, left: 20,
right: 20, right: 20,
bottom: 0 bottom: 0,
}] }],
}, },
height: 44 height: 44,
} },
}, },
width: 450, width: 450,
height: 200 height: 200,
} }
] ],
}; };
messageShows[messageShows.length] = BI.createWidget(conf); messageShows[messageShows.length] = BI.createWidget(conf);
} },
}; };
})()); })());

4
src/base/grid/__test__/grid.test.js

@ -15,7 +15,7 @@ describe("GridTest", function () {
for (var j = 0; j < columnCount; j++) { for (var j = 0; j < columnCount; j++) {
items[i][j] = { items[i][j] = {
type: "bi.label", type: "bi.label",
text: i + "-" + j text: i + "-" + j,
}; };
} }
} }
@ -32,7 +32,7 @@ describe("GridTest", function () {
}, },
columnWidthGetter: function () { columnWidthGetter: function () {
return 100; return 100;
} },
}); });
// TODO 性能展示类控件,不知道要测啥,标记一下 // TODO 性能展示类控件,不知道要测啥,标记一下
grid.destroy(); grid.destroy();

24
src/base/grid/grid.js

@ -27,7 +27,7 @@ BI.GridView = BI.inherit(BI.Widget, {
items: [], items: [],
itemFormatter: function (item, row, col) { itemFormatter: function (item, row, col) {
return item; return item;
} },
}); });
}, },
@ -41,7 +41,7 @@ BI.GridView = BI.inherit(BI.Widget, {
self._scrollLock = false; self._scrollLock = false;
}, 1000 / 60); }, 1000 / 60);
this.container = BI._lazyCreateWidget({ this.container = BI._lazyCreateWidget({
type: "bi.absolute" type: "bi.absolute",
}); });
this.element.scroll(function () { this.element.scroll(function () {
if (self._scrollLock === true) { if (self._scrollLock === true) {
@ -52,7 +52,7 @@ BI.GridView = BI.inherit(BI.Widget, {
self._calculateChildrenToRender(); self._calculateChildrenToRender();
self.fireEvent(BI.GridView.EVENT_SCROLL, { self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft, scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop scrollTop: o.scrollTop,
}); });
}); });
// 兼容一下 // 兼容一下
@ -74,7 +74,7 @@ BI.GridView = BI.inherit(BI.Widget, {
scrollable: scrollable, scrollable: scrollable,
scrolly: scrolly, scrolly: scrolly,
scrollx: scrollx, scrollx: scrollx,
items: [this.container] items: [this.container],
}); });
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) {
self.populate(newValue); self.populate(newValue);
@ -115,7 +115,7 @@ BI.GridView = BI.inherit(BI.Widget, {
_getOverscanIndices: function (cellCount, overscanCellsCount, startIndex, stopIndex) { _getOverscanIndices: function (cellCount, overscanCellsCount, startIndex, stopIndex) {
return { return {
overscanStartIndex: Math.max(0, startIndex - overscanCellsCount), overscanStartIndex: Math.max(0, startIndex - overscanCellsCount),
overscanStopIndex: Math.min(cellCount - 1, stopIndex + overscanCellsCount) overscanStopIndex: Math.min(cellCount - 1, stopIndex + overscanCellsCount),
}; };
}, },
@ -197,20 +197,20 @@ BI.GridView = BI.inherit(BI.Widget, {
child = BI._lazyCreateWidget(BI.extend({ child = BI._lazyCreateWidget(BI.extend({
type: "bi.label", type: "bi.label",
width: columnDatum.size, width: columnDatum.size,
height: rowDatum.size height: rowDatum.size,
}, item, { }, item, {
cls: (item.cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""), cls: (item.cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""),
_rowIndex: rowIndex, _rowIndex: rowIndex,
_columnIndex: columnIndex, _columnIndex: columnIndex,
_left: columnDatum.offset + horizontalOffsetAdjustment, _left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment _top: rowDatum.offset + verticalOffsetAdjustment,
}), this); }), this);
renderedCells.push({ renderedCells.push({
el: child, el: child,
left: columnDatum.offset + horizontalOffsetAdjustment, left: columnDatum.offset + horizontalOffsetAdjustment,
top: rowDatum.offset + verticalOffsetAdjustment, top: rowDatum.offset + verticalOffsetAdjustment,
_left: columnDatum.offset + horizontalOffsetAdjustment, _left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment _top: rowDatum.offset + verticalOffsetAdjustment,
// _width: columnDatum.size, // _width: columnDatum.size,
// _height: rowDatum.size // _height: rowDatum.size
}); });
@ -258,7 +258,7 @@ BI.GridView = BI.inherit(BI.Widget, {
this.container.attr("items", renderedCells); this.container.attr("items", renderedCells);
this.renderedCells = renderedCells; this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys; this.renderedKeys = renderedKeys;
this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY, };
} }
}, },
@ -333,7 +333,7 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.options.overflowX !== !!b) { if (this.options.overflowX !== !!b) {
this.options.overflowX = !!b; this.options.overflowX = !!b;
BI.nextTick(function () { BI.nextTick(function () {
self.element.css({ overflowX: b ? "auto" : "hidden" }); self.element.css({ overflowX: b ? "auto" : "hidden", });
}); });
} }
}, },
@ -343,7 +343,7 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.options.overflowY !== !!b) { if (this.options.overflowY !== !!b) {
this.options.overflowY = !!b; this.options.overflowY = !!b;
BI.nextTick(function () { BI.nextTick(function () {
self.element.css({ overflowY: b ? "auto" : "hidden" }); self.element.css({ overflowY: b ? "auto" : "hidden", });
}); });
} }
}, },
@ -398,7 +398,7 @@ BI.GridView = BI.inherit(BI.Widget, {
this.restore(); this.restore();
} }
this._populate(items); this._populate(items);
} },
}); });
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut("bi.grid_view", BI.GridView); BI.shortcut("bi.grid_view", BI.GridView);

6
src/base/layer/__test__/layer.popover.test.js

@ -16,12 +16,12 @@ describe("PopoverTest", function () {
size: "normal", size: "normal",
header: { header: {
type: "bi.label", type: "bi.label",
text: "这个是header" text: "这个是header",
}, },
body: { body: {
type: "bi.label", type: "bi.label",
text: "这个是body" text: "这个是body",
} },
}).open(id); }).open(id);
BI.delay(function () { BI.delay(function () {
expect(BI.Widget._renderEngine.createElement("body").find(".bi-popup-view .bi-z-index-mask").length).to.equal(1); expect(BI.Widget._renderEngine.createElement("body").find(".bi-popup-view .bi-z-index-mask").length).to.equal(1);

62
src/base/layer/layer.drawer.js

@ -7,7 +7,7 @@ BI.Drawer = BI.inherit(BI.Widget, {
SIZE: { SIZE: {
SMALL: "small", SMALL: "small",
NORMAL: "normal", NORMAL: "normal",
BIG: "big" BIG: "big",
}, },
props: { props: {
baseCls: "bi-drawer bi-card", baseCls: "bi-drawer bi-card",
@ -19,7 +19,7 @@ BI.Drawer = BI.inherit(BI.Widget, {
closable: true, // BI-40839 是否显示右上角的关闭按钮 closable: true, // BI-40839 是否显示右上角的关闭按钮
bodyHgap: 20, bodyHgap: 20,
bodyTgap: 10, bodyTgap: 10,
bodyBgap: 10 bodyBgap: 10,
}, },
render: function () { render: function () {
@ -33,20 +33,20 @@ BI.Drawer = BI.inherit(BI.Widget, {
type: "bi.absolute", type: "bi.absolute",
items: [{ items: [{
el: BI.isPlainObject(o.header) ? BI.extend({}, o.header, { el: BI.isPlainObject(o.header) ? BI.extend({}, o.header, {
extraCls: "bi-font-bold" extraCls: "bi-font-bold",
}) : { }) : {
type: "bi.label", type: "bi.label",
cls: "bi-font-bold", cls: "bi-font-bold",
height: o.headerHeight, height: o.headerHeight,
text: o.header, text: o.header,
title: o.header, title: o.header,
textAlign: "left" textAlign: "left",
}, },
left: 20, left: 20,
top: 0, top: 0,
right: 0, right: 0,
bottom: 0 bottom: 0,
}] }],
}, { }, {
el: o.closable ? { el: o.closable ? {
type: "bi.icon_button", type: "bi.icon_button",
@ -54,15 +54,15 @@ BI.Drawer = BI.inherit(BI.Widget, {
height: o.headerHeight, height: o.headerHeight,
handler: function () { handler: function () {
self.close(); self.close();
} },
} : { } : {
type: "bi.layout" type: "bi.layout",
}, },
width: 56 width: 56,
}], }],
height: o.headerHeight height: o.headerHeight,
}, },
height: o.headerHeight height: o.headerHeight,
}, { }, {
el: { el: {
type: "bi.vertical", type: "bi.vertical",
@ -72,17 +72,17 @@ BI.Drawer = BI.inherit(BI.Widget, {
self.body = this; self.body = this;
}, },
items: [{ items: [{
el: o.body el: o.body,
}] }],
}, },
hgap: o.bodyHgap, hgap: o.bodyHgap,
tgap: o.bodyTgap, tgap: o.bodyTgap,
bgap: o.bodyBgap bgap: o.bodyBgap,
}]; }];
return BI.extend({ return BI.extend({
type: "bi.vtape", type: "bi.vtape",
items: items items: items,
}, this._getSuitableSize()); }, this._getSuitableSize());
}, },
@ -103,12 +103,12 @@ BI.Drawer = BI.inherit(BI.Widget, {
} }
if (o.placement === "top" || o.placement === "bottom") { if (o.placement === "top" || o.placement === "bottom") {
return { return {
height: o.height || size height: o.height || size,
}; };
} }
if (o.placement === "left" || o.placement === "right") { if (o.placement === "left" || o.placement === "right") {
return { return {
width: o.width || size width: o.width || size,
}; };
} }
}, },
@ -120,28 +120,28 @@ BI.Drawer = BI.inherit(BI.Widget, {
self.element.css({ self.element.css({
top: 0, top: 0,
left: "100%", left: "100%",
bottom: 0 bottom: 0,
}); });
break; break;
case "left": case "left":
self.element.css({ self.element.css({
top: 0, top: 0,
right: "100%", right: "100%",
bottom: 0 bottom: 0,
}); });
break; break;
case "top": case "top":
self.element.css({ self.element.css({
left: 0, left: 0,
right: 0, right: 0,
bottom: "100%" bottom: "100%",
}); });
break; break;
case "bottom": case "bottom":
self.element.css({ self.element.css({
left: 0, left: 0,
right: 0, right: 0,
top: "100%" top: "100%",
}); });
break; break;
default: default:
@ -156,22 +156,22 @@ BI.Drawer = BI.inherit(BI.Widget, {
switch (o.placement) { switch (o.placement) {
case "right": case "right":
self.element.css({ self.element.css({
left: "calc(100% - " + size.width + "px)" left: "calc(100% - " + size.width + "px)",
}); });
break; break;
case "left": case "left":
self.element.css({ self.element.css({
right: "calc(100% - " + size.width + "px)" right: "calc(100% - " + size.width + "px)",
}); });
break; break;
case "top": case "top":
self.element.css({ self.element.css({
bottom: "calc(100% - " + size.height + "px)" bottom: "calc(100% - " + size.height + "px)",
}); });
break; break;
case "bottom": case "bottom":
self.element.css({ self.element.css({
top: "calc(100% - " + size.height + "px)" top: "calc(100% - " + size.height + "px)",
}); });
break; break;
default: default:
@ -187,22 +187,22 @@ BI.Drawer = BI.inherit(BI.Widget, {
switch (o.placement) { switch (o.placement) {
case "right": case "right":
self.element.css({ self.element.css({
left: "100%" left: "100%",
}); });
break; break;
case "left": case "left":
self.element.css({ self.element.css({
right: "100%" right: "100%",
}); });
break; break;
case "top": case "top":
self.element.css({ self.element.css({
bottom: "100%" bottom: "100%",
}); });
break; break;
case "bottom": case "bottom":
self.element.css({ self.element.css({
top: "100%" top: "100%",
}); });
break; break;
default: default:
@ -227,11 +227,11 @@ BI.Drawer = BI.inherit(BI.Widget, {
}, },
setZindex: function (zindex) { setZindex: function (zindex) {
this.element.css({ "z-index": zindex }); this.element.css({ "z-index": zindex, });
}, },
destroyed: function () { destroyed: function () {
} },
}); });
BI.shortcut("bi.drawer", BI.Drawer); BI.shortcut("bi.drawer", BI.Drawer);

72
src/base/layer/layer.popover.js

@ -8,9 +8,9 @@ BI.Popover = BI.inherit(BI.Widget, {
SIZE: { SIZE: {
SMALL: "small", SMALL: "small",
NORMAL: "normal", NORMAL: "normal",
BIG: "big" BIG: "big",
}, },
MAX_HEIGHT: 600 MAX_HEIGHT: 600,
}, },
props: function () { props: function () {
@ -18,7 +18,7 @@ BI.Popover = BI.inherit(BI.Widget, {
baseCls: "bi-popover bi-card bi-border-radius", baseCls: "bi-popover bi-card bi-border-radius",
size: "normal", // small, normal, big size: "normal", // small, normal, big
logic: { logic: {
dynamic: false dynamic: false,
}, },
header: null, header: null,
headerHeight: 40, headerHeight: 40,
@ -27,7 +27,7 @@ BI.Popover = BI.inherit(BI.Widget, {
footerHeight: 44, footerHeight: 44,
closable: true, // BI-40839 是否显示右上角的关闭按钮 closable: true, // BI-40839 是否显示右上角的关闭按钮
bodyHgap: BI.SIZE_CONSANTS.H_GAP_SIZE, bodyHgap: BI.SIZE_CONSANTS.H_GAP_SIZE,
bodyTgap: BI.SIZE_CONSANTS.V_GAP_SIZE bodyTgap: BI.SIZE_CONSANTS.V_GAP_SIZE,
}; };
}, },
@ -45,11 +45,11 @@ BI.Popover = BI.inherit(BI.Widget, {
self.startY += deltaY; self.startY += deltaY;
self.element.css({ self.element.css({
left: BI.clamp(self.startX, 0, W - self.element.width()) + "px", left: BI.clamp(self.startX, 0, W - self.element.width()) + "px",
top: BI.clamp(self.startY, 0, H - self.element.height()) + "px" top: BI.clamp(self.startY, 0, H - self.element.height()) + "px",
}); });
// BI-12134 没有什么特别好的方法 // BI-12134 没有什么特别好的方法
BI.Resizers._resize({ BI.Resizers._resize({
target: self.element[0] target: self.element[0],
}); });
}, function () { }, function () {
self.tracker.releaseMouseMoves(); self.tracker.releaseMouseMoves();
@ -66,21 +66,21 @@ BI.Popover = BI.inherit(BI.Widget, {
}, },
items: [{ items: [{
el: BI.isPlainObject(o.header) ? BI.extend({}, o.header, { el: BI.isPlainObject(o.header) ? BI.extend({}, o.header, {
extraCls: "bi-font-bold" extraCls: "bi-font-bold",
}) : { }) : {
type: "bi.label", type: "bi.label",
cls: "bi-font-bold", cls: "bi-font-bold",
height: o.headerHeight, height: o.headerHeight,
text: o.header, text: o.header,
title: o.header, title: o.header,
textAlign: "left" textAlign: "left",
}, },
top: 0, top: 0,
bottom: 0, bottom: 0,
left: BI.SIZE_CONSANTS.H_GAP_SIZE, left: BI.SIZE_CONSANTS.H_GAP_SIZE,
right: o.closable ? 0 : BI.SIZE_CONSANTS.H_GAP_SIZE right: o.closable ? 0 : BI.SIZE_CONSANTS.H_GAP_SIZE,
}] }],
} },
}, o.closable ? { }, o.closable ? {
el: { el: {
type: "bi.icon_button", type: "bi.icon_button",
@ -88,13 +88,13 @@ BI.Popover = BI.inherit(BI.Widget, {
height: o.headerHeight, height: o.headerHeight,
handler: function () { handler: function () {
self.close(); self.close();
}
}, },
width: 56 },
width: 56,
} : null], } : null],
height: o.headerHeight height: o.headerHeight,
}, },
height: o.headerHeight height: o.headerHeight,
}, o.logic.dynamic ? { }, o.logic.dynamic ? {
el: { el: {
type: "bi.vertical", type: "bi.vertical",
@ -105,14 +105,14 @@ BI.Popover = BI.inherit(BI.Widget, {
}, },
css: { css: {
"max-height": this._getSuitableBodyHeight(c.MAX_HEIGHT - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap), "max-height": this._getSuitableBodyHeight(c.MAX_HEIGHT - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap),
"min-height": this._getSuitableBodyHeight(size.height - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap) "min-height": this._getSuitableBodyHeight(size.height - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap),
}, },
items: [{ items: [{
el: o.body el: o.body,
}], }],
hgap: o.bodyHgap, hgap: o.bodyHgap,
tgap: o.bodyTgap tgap: o.bodyTgap,
} },
} : { } : {
el: { el: {
type: "bi.absolute", type: "bi.absolute",
@ -121,9 +121,9 @@ BI.Popover = BI.inherit(BI.Widget, {
left: o.bodyHgap, left: o.bodyHgap,
top: o.bodyTgap, top: o.bodyTgap,
right: o.bodyHgap, right: o.bodyHgap,
bottom: 0 bottom: 0,
}] }],
} },
}]; }];
if (o.footer) { if (o.footer) {
items.push({ items.push({
@ -134,23 +134,23 @@ BI.Popover = BI.inherit(BI.Widget, {
left: BI.SIZE_CONSANTS.H_GAP_SIZE, left: BI.SIZE_CONSANTS.H_GAP_SIZE,
top: 0, top: 0,
right: BI.SIZE_CONSANTS.H_GAP_SIZE, right: BI.SIZE_CONSANTS.H_GAP_SIZE,
bottom: 0 bottom: 0,
}], }],
height: o.footerHeight height: o.footerHeight,
}, },
height: o.footerHeight height: o.footerHeight,
}); });
} }
return BI.extend({ return BI.extend({
items: items, items: items,
width: this._getSuitableWidth(size.width) width: this._getSuitableWidth(size.width),
}, o.logic.dynamic ? { }, o.logic.dynamic ? {
type: "bi.vertical", type: "bi.vertical",
scrolly: false scrolly: false,
} : { } : {
type: "bi.vtape", type: "bi.vtape",
height: this._getSuitableHeight(size.height) height: this._getSuitableHeight(size.height),
}); });
}, },
@ -203,7 +203,7 @@ BI.Popover = BI.inherit(BI.Widget, {
return { return {
width: o.width || size.width, width: o.width || size.width,
height: o.height || size.height, height: o.height || size.height,
type: size.type || "default" type: size.type || "default",
}; };
}, },
@ -222,11 +222,11 @@ BI.Popover = BI.inherit(BI.Widget, {
}, },
setZindex: function (zindex) { setZindex: function (zindex) {
this.element.css({ "z-index": zindex }); this.element.css({ "z-index": zindex, });
}, },
destroyed: function () { destroyed: function () {
} },
}); });
BI.shortcut("bi.popover", BI.Popover); BI.shortcut("bi.popover", BI.Popover);
@ -234,7 +234,7 @@ BI.shortcut("bi.popover", BI.Popover);
BI.BarPopover = BI.inherit(BI.Popover, { BI.BarPopover = BI.inherit(BI.Popover, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.BarPopover.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.BarPopover.superclass._defaultConfig.apply(this, arguments), {
btns: [BI.i18nText("BI-Basic_OK"), BI.i18nText("BI-Basic_Cancel")] btns: [BI.i18nText("BI-Basic_OK"), BI.i18nText("BI-Basic_Cancel")],
}); });
}, },
@ -252,7 +252,7 @@ BI.BarPopover = BI.inherit(BI.Popover, {
handler: function (v) { handler: function (v) {
self.fireEvent(BI.Popover.EVENT_CANCEL, v); self.fireEvent(BI.Popover.EVENT_CANCEL, v);
self.close(v); self.close(v);
} },
}, { }, {
type: "bi.button", type: "bi.button",
text: this.options.btns[0], text: this.options.btns[0],
@ -261,10 +261,10 @@ BI.BarPopover = BI.inherit(BI.Popover, {
handler: function (v) { handler: function (v) {
self.fireEvent(BI.Popover.EVENT_CONFIRM, v); self.fireEvent(BI.Popover.EVENT_CONFIRM, v);
self.close(v); self.close(v);
} },
}] }],
}); });
} },
}); });
BI.shortcut("bi.bar_popover", BI.BarPopover); BI.shortcut("bi.bar_popover", BI.BarPopover);

104
src/base/layer/layer.popup.js

@ -5,7 +5,7 @@
*/ */
BI.PopupView = BI.inherit(BI.Widget, { BI.PopupView = BI.inherit(BI.Widget, {
_const: { _const: {
TRIANGLE_LENGTH: 12 TRIANGLE_LENGTH: 12,
}, },
_defaultConfig: function (props) { _defaultConfig: function (props) {
return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), {
@ -29,7 +29,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
stopEvent: false, // 是否停止mousedown、mouseup事件 stopEvent: false, // 是否停止mousedown、mouseup事件
stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡 stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡
logic: { logic: {
dynamic: true dynamic: true,
}, },
tool: false, // 自定义工具栏 tool: false, // 自定义工具栏
@ -42,9 +42,9 @@ BI.PopupView = BI.inherit(BI.Widget, {
chooseType: 0, chooseType: 0,
behaviors: {}, behaviors: {},
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical",
}] }],
} },
}); });
}, },
@ -61,13 +61,13 @@ BI.PopupView = BI.inherit(BI.Widget, {
this.element.css({ this.element.css({
"z-index": BI.zIndex_popup, "z-index": BI.zIndex_popup,
"min-width": BI.isNumeric(o.minWidth) ? (o.minWidth / BI.pixRatio + BI.pixUnit) : o.minWidth, "min-width": BI.isNumeric(o.minWidth) ? (o.minWidth / BI.pixRatio + BI.pixUnit) : o.minWidth,
"max-width": BI.isNumeric(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth "max-width": BI.isNumeric(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth,
}).bind({ click: fn }); }).bind({ click: fn, });
this.element.bind("mousewheel", fn); this.element.bind("mousewheel", fn);
o.stopPropagation && this.element.bind({ mousedown: fn, mouseup: fn, mouseover: fn }); o.stopPropagation && this.element.bind({ mousedown: fn, mouseup: fn, mouseover: fn, });
o.stopEvent && this.element.bind({ mousedown: stop, mouseup: stop, mouseover: stop }); o.stopEvent && this.element.bind({ mousedown: stop, mouseup: stop, mouseover: stop, });
this.tool = this._createTool(); this.tool = this._createTool();
this.tab = this._createTab(); this.tab = this._createTab();
this.view = this._createView(); this.view = this._createView();
@ -81,7 +81,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
}); });
BI.createWidget(BI.extend({ BI.createWidget(BI.extend({
element: this element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
scrolly: false, scrolly: false,
lgap: o.lgap, lgap: o.lgap,
@ -91,11 +91,11 @@ BI.PopupView = BI.inherit(BI.Widget, {
vgap: o.vgap, vgap: o.vgap,
hgap: o.hgap, hgap: o.hgap,
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, BI.extend({ items: BI.LogicFactory.createLogicItemsByDirection(o.direction, BI.extend({
cls: "list-view-outer bi-card list-view-shadow" + (o.primary ? " bi-primary" : "") cls: "list-view-outer bi-card list-view-shadow" + (o.primary ? " bi-primary" : ""),
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tool, this.tab, this.view, this.toolbar) items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tool, this.tab, this.view, this.toolbar),
}))) })))
) ),
})))); }))));
if (o.showArrow) { if (o.showArrow) {
this.arrow = BI.createWidget({ this.arrow = BI.createWidget({
@ -103,19 +103,19 @@ BI.PopupView = BI.inherit(BI.Widget, {
cls: "bi-bubble-arrow", cls: "bi-bubble-arrow",
items: [{ items: [{
type: "bi.layout", type: "bi.layout",
cls: "bubble-arrow" cls: "bubble-arrow",
}] }],
}); });
this.arrowWrapper = BI.createWidget({ this.arrowWrapper = BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
cls: "bi-bubble-arrow-wrapper", cls: "bi-bubble-arrow-wrapper",
items: [{ items: [{
el: this.arrow el: this.arrow,
}] }],
}); });
// 因为三角符号的原因位置变大了,需要占位 // 因为三角符号的原因位置变大了,需要占位
this.placeholder = BI.createWidget({ this.placeholder = BI.createWidget({
type: "bi.layout" type: "bi.layout",
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -123,23 +123,23 @@ BI.PopupView = BI.inherit(BI.Widget, {
items: [{ items: [{
el: this.arrowWrapper, el: this.arrowWrapper,
left: 0, left: 0,
top: 0 top: 0,
}, { }, {
el: this.placeholder el: this.placeholder,
}] }],
}); });
} }
}, },
_createView: function () { _createView: function () {
var o = this.options; var o = this.options;
this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value }); this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value, });
this.button_group.element.css({ this.button_group.element.css({
"min-height": BI.isNumeric(o.minHeight) ? (o.minHeight / BI.pixRatio + BI.pixUnit) : o.minHeight, "min-height": BI.isNumeric(o.minHeight) ? (o.minHeight / BI.pixRatio + BI.pixUnit) : o.minHeight,
"padding-top": o.innerVgap / BI.pixRatio + BI.pixUnit, "padding-top": o.innerVgap / BI.pixRatio + BI.pixUnit,
"padding-bottom": o.innerVgap / BI.pixRatio + BI.pixUnit, "padding-bottom": o.innerVgap / BI.pixRatio + BI.pixUnit,
"padding-left": o.innerHgap / BI.pixRatio + BI.pixUnit, "padding-left": o.innerHgap / BI.pixRatio + BI.pixUnit,
"padding-right": o.innerHgap / BI.pixRatio + BI.pixUnit "padding-right": o.innerHgap / BI.pixRatio + BI.pixUnit,
}); });
return this.button_group; return this.button_group;
@ -165,7 +165,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
cls: "list-view-tab", cls: "list-view-tab",
height: 25, height: 25,
items: o.tabs, items: o.tabs,
value: o.value value: o.value,
}); });
}, },
@ -182,8 +182,8 @@ BI.PopupView = BI.inherit(BI.Widget, {
items: BI.createItems(o.buttons, { items: BI.createItems(o.buttons, {
once: false, once: false,
shadow: true, shadow: true,
isShadowShowingOnSelected: true isShadowShowingOnSelected: true,
}) }),
}); });
}, },
@ -217,156 +217,156 @@ BI.PopupView = BI.inherit(BI.Widget, {
direction = "bottom"; direction = "bottom";
style = { style = {
// 5表示留出一定的空间 // 5表示留出一定的空间
left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft) left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft),
}; };
wrapperStyle = { wrapperStyle = {
top: o.tgap + o.vgap, top: o.tgap + o.vgap,
left: 0, left: 0,
right: "", right: "",
bottom: "" bottom: "",
}; };
placeholderStyle = { placeholderStyle = {
left: 0, left: 0,
right: 0, right: 0,
height: this._const.TRIANGLE_LENGTH, height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH, top: -this._const.TRIANGLE_LENGTH,
bottom: "" bottom: "",
}; };
break; break;
case "bottom,left": case "bottom,left":
direction = "bottom"; direction = "bottom";
style = { style = {
right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight) right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight),
}; };
wrapperStyle = { wrapperStyle = {
top: o.bgap + o.vgap, top: o.bgap + o.vgap,
left: "", left: "",
right: 0, right: 0,
bottom: "" bottom: "",
}; };
placeholderStyle = { placeholderStyle = {
left: 0, left: 0,
right: 0, right: 0,
height: this._const.TRIANGLE_LENGTH, height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH, top: -this._const.TRIANGLE_LENGTH,
bottom: "" bottom: "",
}; };
break; break;
case "top": case "top":
case "top,right": case "top,right":
direction = "top"; direction = "top";
style = { style = {
left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft) left: BI.clamp(((middle ? popupWidth : position.width) - adjustXOffset) / 2 - 8, minLeft, maxLeft),
}; };
wrapperStyle = { wrapperStyle = {
bottom: o.bgap + o.vgap, bottom: o.bgap + o.vgap,
left: 0, left: 0,
right: "", right: "",
top: "" top: "",
}; };
placeholderStyle = { placeholderStyle = {
left: 0, left: 0,
right: 0, right: 0,
height: this._const.TRIANGLE_LENGTH, height: this._const.TRIANGLE_LENGTH,
top: "", top: "",
bottom: -this._const.TRIANGLE_LENGTH bottom: -this._const.TRIANGLE_LENGTH,
}; };
break; break;
case "top,left": case "top,left":
direction = "top"; direction = "top";
style = { style = {
right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight) right: BI.clamp(((middle ? popupWidth : position.width) + adjustXOffset) / 2 - 8, minRight, maxRight),
}; };
wrapperStyle = { wrapperStyle = {
bottom: o.bgap + o.vgap, bottom: o.bgap + o.vgap,
right: 0, right: 0,
left: "", left: "",
top: "" top: "",
}; };
placeholderStyle = { placeholderStyle = {
left: 0, left: 0,
right: 0, right: 0,
height: this._const.TRIANGLE_LENGTH, height: this._const.TRIANGLE_LENGTH,
top: "", top: "",
bottom: -this._const.TRIANGLE_LENGTH bottom: -this._const.TRIANGLE_LENGTH,
}; };
break; break;
case "left": case "left":
case "left,bottom": case "left,bottom":
direction = "left"; direction = "left";
style = { style = {
top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop) top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop),
}; };
wrapperStyle = { wrapperStyle = {
right: o.rgap + o.hgap, right: o.rgap + o.hgap,
top: 0, top: 0,
bottom: "", bottom: "",
left: "" left: "",
}; };
placeholderStyle = { placeholderStyle = {
top: 0, top: 0,
bottom: 0, bottom: 0,
width: this._const.TRIANGLE_LENGTH, width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH, right: -this._const.TRIANGLE_LENGTH,
left: "" left: "",
}; };
break; break;
case "left,top": case "left,top":
direction = "left"; direction = "left";
style = { style = {
bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom) bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom),
}; };
wrapperStyle = { wrapperStyle = {
right: o.rgap + o.hgap, right: o.rgap + o.hgap,
bottom: 0, bottom: 0,
top: "", top: "",
left: "" left: "",
}; };
placeholderStyle = { placeholderStyle = {
top: 0, top: 0,
bottom: 0, bottom: 0,
width: this._const.TRIANGLE_LENGTH, width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH, right: -this._const.TRIANGLE_LENGTH,
left: "" left: "",
}; };
break; break;
case "right": case "right":
case "right,bottom": case "right,bottom":
direction = "right"; direction = "right";
style = { style = {
top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop) top: BI.clamp(((middle ? popupHeight : position.height) - adjustYOffset) / 2 - 8, minTop, maxTop),
}; };
wrapperStyle = { wrapperStyle = {
left: o.lgap + o.hgap, left: o.lgap + o.hgap,
top: 0, top: 0,
bottom: "", bottom: "",
right: "" right: "",
}; };
placeholderStyle = { placeholderStyle = {
top: 0, top: 0,
bottom: 0, bottom: 0,
width: this._const.TRIANGLE_LENGTH, width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH, left: -this._const.TRIANGLE_LENGTH,
right: "" right: "",
}; };
break; break;
case "right,top": case "right,top":
direction = "right"; direction = "right";
style = { style = {
bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom) bottom: BI.clamp(((middle ? popupHeight : position.height) + adjustYOffset) / 2 - 8, minBottom, maxBottom),
}; };
wrapperStyle = { wrapperStyle = {
left: o.lgap + o.hgap, left: o.lgap + o.hgap,
bottom: 0, bottom: 0,
top: "", top: "",
right: "" right: "",
}; };
placeholderStyle = { placeholderStyle = {
top: 0, top: 0,
bottom: 0, bottom: 0,
width: this._const.TRIANGLE_LENGTH, width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH, left: -this._const.TRIANGLE_LENGTH,
right: "" right: "",
}; };
break; break;
case "right,innerRight": case "right,innerRight":
@ -411,7 +411,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0); toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0);
var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap; var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap;
this.view.resetHeight ? this.view.resetHeight(resetHeight) : this.view.resetHeight ? this.view.resetHeight(resetHeight) :
this.view.element.css({ "max-height": resetHeight / BI.pixRatio + BI.pixUnit }); this.view.element.css({ "max-height": resetHeight / BI.pixRatio + BI.pixUnit, });
}, },
setValue: function (selectedValues) { setValue: function (selectedValues) {
@ -421,7 +421,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
getValue: function () { getValue: function () {
return this.view.getValue(); return this.view.getValue();
} },
}); });
BI.PopupView.EVENT_CHANGE = "EVENT_CHANGE"; BI.PopupView.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.popup_view", BI.PopupView); BI.shortcut("bi.popup_view", BI.PopupView);

34
src/base/layer/layer.searcher.js

@ -20,25 +20,25 @@ BI.SearcherView = BI.inherit(BI.Pane, {
behaviors: { behaviors: {
redmark: function () { redmark: function () {
return true; return true;
} },
}, },
items: [], items: [],
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical",
}] }],
}, },
searcher: { searcher: {
type: "bi.button_group", type: "bi.button_group",
behaviors: { behaviors: {
redmark: function () { redmark: function () {
return true; return true;
} },
}, },
items: [], items: [],
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical",
}] }],
} },
}); });
}, },
@ -51,12 +51,12 @@ BI.SearcherView = BI.inherit(BI.Pane, {
behaviors: { behaviors: {
redmark: function () { redmark: function () {
return true; return true;
} },
}, },
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical",
}], }],
value: o.value value: o.value,
}); });
this.matcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) { this.matcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -71,8 +71,8 @@ BI.SearcherView = BI.inherit(BI.Pane, {
items: [{ items: [{
type: "bi.layout", type: "bi.layout",
height: 1, height: 1,
cls: "searcher-view-spliter bi-background" cls: "searcher-view-spliter bi-background",
}] }],
}); });
this.searcher = BI.createWidget(o.searcher, { this.searcher = BI.createWidget(o.searcher, {
type: "bi.button_group", type: "bi.button_group",
@ -80,12 +80,12 @@ BI.SearcherView = BI.inherit(BI.Pane, {
behaviors: { behaviors: {
redmark: function () { redmark: function () {
return true; return true;
} },
}, },
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical",
}], }],
value: o.value value: o.value,
}); });
this.searcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) { this.searcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -97,7 +97,7 @@ BI.SearcherView = BI.inherit(BI.Pane, {
BI.createWidget({ BI.createWidget({
type: "bi.vertical", type: "bi.vertical",
element: this, element: this,
items: [this.matcher, this.spliter, this.searcher] items: [this.matcher, this.spliter, this.searcher],
}); });
}, },
@ -134,7 +134,7 @@ BI.SearcherView = BI.inherit(BI.Pane, {
hasMatched: function () { hasMatched: function () {
return this.matcher.getAllButtons().length > 0; return this.matcher.getAllButtons().length > 0;
} },
}); });
BI.SearcherView.EVENT_CHANGE = "EVENT_CHANGE"; BI.SearcherView.EVENT_CHANGE = "EVENT_CHANGE";

10
src/base/list/__test__/listview.test.js

@ -13,16 +13,16 @@ describe("ListView && VirtualList", function () {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.list_view", type: "bi.list_view",
el: { el: {
type: "bi.left" type: "bi.left",
}, },
items: BI.map(BI.range(0, 100), function (i, item) { items: BI.map(BI.range(0, 100), function (i, item) {
return BI.extend({}, item, { return BI.extend({}, item, {
type: "bi.label", type: "bi.label",
width: 200, width: 200,
height: 200, height: 200,
text: (i + 1) text: (i + 1),
}); });
}) }),
}); });
a.destroy(); a.destroy();
}); });
@ -38,9 +38,9 @@ describe("ListView && VirtualList", function () {
return BI.extend({}, item, { return BI.extend({}, item, {
type: "bi.label", type: "bi.label",
height: 30, height: 30,
text: (i + 1) + "." + item.text text: (i + 1) + "." + item.text,
}); });
}) }),
}); });
a.destroy(); a.destroy();
}); });

10
src/base/list/listview.js

@ -16,7 +16,7 @@ BI.ListView = BI.inherit(BI.Widget, {
items: [], items: [],
itemFormatter: function (item, index) { itemFormatter: function (item, index) {
return item; return item;
} },
}; };
}, },
@ -35,9 +35,9 @@ BI.ListView = BI.inherit(BI.Widget, {
scrolly: false, scrolly: false,
ref: function (_ref) { ref: function (_ref) {
self.container = _ref; self.container = _ref;
} },
}, o.el)], }, o.el)],
element: this element: this,
}; };
}, },
@ -85,7 +85,7 @@ BI.ListView = BI.inherit(BI.Widget, {
this.cache[cnt] = { this.cache[cnt] = {
index: index, index: index,
scrollTop: lastHeight, scrollTop: lastHeight,
height: addedHeight height: addedHeight,
}; };
this.renderedIndex = cnt; this.renderedIndex = cnt;
cnt++; cnt++;
@ -127,7 +127,7 @@ BI.ListView = BI.inherit(BI.Widget, {
destroyed: function () { destroyed: function () {
this.restore(); this.restore();
} },
}); });
BI.shortcut("bi.list_view", BI.ListView); BI.shortcut("bi.list_view", BI.ListView);

14
src/base/list/virtualgrouplist.js

@ -17,7 +17,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
el: {}, el: {},
itemFormatter: function (item, index) { itemFormatter: function (item, index) {
return item; return item;
} },
}; };
}, },
@ -34,7 +34,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
type: "bi.layout", type: "bi.layout",
ref: function () { ref: function () {
self.topBlank = this; self.topBlank = this;
} },
}, { }, {
type: "bi.virtual_group", type: "bi.virtual_group",
height: o.rowHeight * o.items.length, height: o.rowHeight * o.items.length,
@ -43,15 +43,15 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
}, },
layouts: [BI.extend({ layouts: [BI.extend({
type: "bi.vertical", type: "bi.vertical",
scrolly: false scrolly: false,
}, o.el)] }, o.el)],
}, { }, {
type: "bi.layout", type: "bi.layout",
ref: function () { ref: function () {
self.bottomBlank = this; self.bottomBlank = this;
} },
}], }],
element: this element: this,
}; };
}, },
@ -178,7 +178,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
this._populate(items); this._populate(items);
} },
}); });
BI.shortcut("bi.virtual_group_list", BI.VirtualGroupList); BI.shortcut("bi.virtual_group_list", BI.VirtualGroupList);

12
src/base/list/virtuallist.js

@ -15,7 +15,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
items: [], items: [],
itemFormatter: function (item, index) { itemFormatter: function (item, index) {
return item; return item;
} },
}; };
}, },
@ -33,19 +33,19 @@ BI.VirtualList = BI.inherit(BI.Widget, {
type: "bi.layout", type: "bi.layout",
ref: function () { ref: function () {
self.topBlank = this; self.topBlank = this;
} },
}, { }, {
type: "bi.vertical", type: "bi.vertical",
scrolly: false, scrolly: false,
ref: function () { ref: function () {
self.container = this; self.container = this;
} },
}, { }, {
type: "bi.layout", type: "bi.layout",
ref: function () { ref: function () {
self.bottomBlank = this; self.bottomBlank = this;
} },
}] }],
}; };
}, },
@ -203,7 +203,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
destroyed: function () { destroyed: function () {
this.cache = {}; this.cache = {};
this.renderedIndex = -1; this.renderedIndex = -1;
} },
}); });
BI.shortcut("bi.virtual_list", BI.VirtualList); BI.shortcut("bi.virtual_list", BI.VirtualList);

40
src/base/pager/pager.js

@ -13,7 +13,7 @@ BI.Pager = BI.inherit(BI.Widget, {
layouts: [{ layouts: [{
type: "bi.horizontal", type: "bi.horizontal",
hgap: 10, hgap: 10,
vgap: 0 vgap: 0,
}], }],
dynamicShow: true, // 是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态 dynamicShow: true, // 是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态
@ -36,7 +36,7 @@ BI.Pager = BI.inherit(BI.Widget, {
return 1; return 1;
}, },
hasPrev: BI.emptyFn, // pages不可用时有效 hasPrev: BI.emptyFn, // pages不可用时有效
hasNext: BI.emptyFn // pages不可用时有效 hasNext: BI.emptyFn, // pages不可用时有效
}); });
}, },
@ -78,13 +78,13 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push({ view.push({
text: prev, text: prev,
value: "prev", value: "prev",
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false),
}); });
} else { } else {
view.push({ view.push({
el: BI.extend({ el: BI.extend({
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false),
}, prev) }, prev),
}); });
} }
} }
@ -94,13 +94,13 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push({ view.push({
text: first, text: first,
value: "first", value: "first",
disabled: !(dict.index > 1 && groups !== 0) disabled: !(dict.index > 1 && groups !== 0),
}); });
if (dict.index > 1 && groups !== 0 && groups !== pages - 1) { if (dict.index > 1 && groups !== 0 && groups !== pages - 1) {
view.push({ view.push({
type: "bi.label", type: "bi.label",
cls: "page-ellipsis", cls: "page-ellipsis",
text: "\u2026" text: "\u2026",
}); });
} }
} }
@ -126,12 +126,12 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push({ view.push({
text: s, text: s,
value: s, value: s,
selected: true selected: true,
}); });
} else { } else {
view.push({ view.push({
text: s, text: s,
value: s value: s,
}); });
} }
} }
@ -142,13 +142,13 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push({ view.push({
type: "bi.label", type: "bi.label",
cls: "page-ellipsis", cls: "page-ellipsis",
text: "\u2026" text: "\u2026",
}); });
} }
view.push({ view.push({
text: last, text: last,
value: "last", value: "last",
disabled: !(pages > groups && dict.end < pages && groups !== 0) disabled: !(pages > groups && dict.end < pages && groups !== 0),
}); });
} }
@ -158,20 +158,20 @@ BI.Pager = BI.inherit(BI.Widget, {
view.push((function () { view.push((function () {
if (BI.isKey(next)) { if (BI.isKey(next)) {
if (pages === false) { if (pages === false) {
return { text: next, value: "next", disabled: o.hasNext(curr) === false }; return { text: next, value: "next", disabled: o.hasNext(curr) === false, };
} }
return (dict.flow && curr === pages) return (dict.flow && curr === pages)
? ?
{ text: next, value: "next", disabled: true } { text: next, value: "next", disabled: true, }
: :
{ text: next, value: "next", disabled: !(curr !== pages && next || dict.flow) }; { text: next, value: "next", disabled: !(curr !== pages && next || dict.flow), };
} }
return { return {
el: BI.extend({ el: BI.extend({
disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow),
}, next) }, next),
}; };
}())); }()));
} }
@ -184,13 +184,13 @@ BI.Pager = BI.inherit(BI.Widget, {
cls: "bi-list-item-select bi-border-radius", cls: "bi-list-item-select bi-border-radius",
height: 23, height: 23,
hgap: v.el ? 0 : 10, hgap: v.el ? 0 : 10,
stopPropagation: true stopPropagation: true,
}, BI.stripEL(v)); }, BI.stripEL(v));
return BI.formatEL(v); return BI.formatEL(v);
}), }),
behaviors: o.behaviors, behaviors: o.behaviors,
layouts: o.layouts layouts: o.layouts,
}); });
this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
// if (self._lock === true) { // if (self._lock === true) {
@ -219,7 +219,7 @@ BI.Pager = BI.inherit(BI.Widget, {
} }
o.jump.apply(self, [{ o.jump.apply(self, [{
pages: pages, pages: pages,
curr: self.currPage curr: self.currPage,
}]); }]);
self._populate(); self._populate();
self.fireEvent(BI.Pager.EVENT_CHANGE, obj); self.fireEvent(BI.Pager.EVENT_CHANGE, obj);
@ -292,7 +292,7 @@ BI.Pager = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this._populate(); this._populate();
} },
}); });
BI.Pager.EVENT_CHANGE = "EVENT_CHANGE"; BI.Pager.EVENT_CHANGE = "EVENT_CHANGE";
BI.Pager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE"; BI.Pager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE";

24
src/base/single/1.text.js

@ -19,50 +19,50 @@
tgap: 0, tgap: 0,
bgap: 0, bgap: 0,
py: "", py: "",
highLight: false highLight: false,
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
if (o.hgap + o.lgap > 0) { if (o.hgap + o.lgap > 0) {
this.element.css({ this.element.css({
"padding-left": (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit "padding-left": (o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit,
}); });
} }
if (o.hgap + o.rgap > 0) { if (o.hgap + o.rgap > 0) {
this.element.css({ this.element.css({
"padding-right": (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit "padding-right": (o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit,
}); });
} }
if (o.vgap + o.tgap > 0) { if (o.vgap + o.tgap > 0) {
this.element.css({ this.element.css({
"padding-top": (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit "padding-top": (o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit,
}); });
} }
if (o.vgap + o.bgap > 0) { if (o.vgap + o.bgap > 0) {
this.element.css({ this.element.css({
"padding-bottom": (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit "padding-bottom": (o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit,
}); });
} }
if (BI.isWidthOrHeight(o.height)) { if (BI.isWidthOrHeight(o.height)) {
this.element.css({ lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height }); this.element.css({ lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height, });
} }
if (BI.isWidthOrHeight(o.lineHeight)) { if (BI.isWidthOrHeight(o.lineHeight)) {
this.element.css({ lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight }); this.element.css({ lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight, });
} }
if (BI.isWidthOrHeight(o.maxWidth)) { if (BI.isWidthOrHeight(o.maxWidth)) {
this.element.css({ maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth }); this.element.css({ maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth, });
} }
this.element.css({ this.element.css({
textAlign: o.textAlign, textAlign: o.textAlign,
whiteSpace: this._getTextWrap(), whiteSpace: this._getTextWrap(),
textOverflow: o.whiteSpace === "nowrap" ? "ellipsis" : "", textOverflow: o.whiteSpace === "nowrap" ? "ellipsis" : "",
overflow: o.whiteSpace === "nowrap" ? "" : (BI.isWidthOrHeight(o.height) ? "auto" : "") overflow: o.whiteSpace === "nowrap" ? "" : (BI.isWidthOrHeight(o.height) ? "auto" : ""),
}); });
if (o.handler && o.handler !== BI.emptyFn) { if (o.handler && o.handler !== BI.emptyFn) {
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.layout", type: "bi.layout",
tagName: "span" tagName: "span",
}); });
this.text.element.click(function (e) { this.text.element.click(function (e) {
o.handler.call(self, self.getValue(), self, e); o.handler.call(self, self.getValue(), self, e);
@ -70,7 +70,7 @@
BI.createWidget({ BI.createWidget({
type: "bi.default", type: "bi.default",
element: this, element: this,
items: [this.text] items: [this.text],
}); });
} else { } else {
this.text = this; this.text = this;
@ -154,7 +154,7 @@
BI.Text.superclass.setText.apply(this, arguments); BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text; this.options.text = text;
this._doRedMark(this.options.keyword); this._doRedMark(this.options.keyword);
} },
}); });
var formatters = []; var formatters = [];
BI.Text.addTextFormatter = function (formatter) { BI.Text.addTextFormatter = function (formatter) {

85
src/base/single/label/abstract.label.js

@ -6,6 +6,7 @@
_defaultConfig: function (props) { _defaultConfig: function (props) {
var conf = BI.AbstractLabel.superclass._defaultConfig.apply(this, arguments); var conf = BI.AbstractLabel.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
textAlign: "center", textAlign: "center",
whiteSpace: "nowrap", // normal or nowrap whiteSpace: "nowrap", // normal or nowrap
@ -36,11 +37,13 @@
if (BI.isFunction(text)) { if (BI.isFunction(text)) {
return text(); return text();
} }
return text; return text;
}, },
_createJson: function () { _createJson: function () {
var o = this.options; var o = this.options;
return { return {
type: "bi.text", type: "bi.text",
textAlign: o.textAlign, textAlign: o.textAlign,
@ -52,7 +55,7 @@
py: o.py, py: o.py,
keyword: o.keyword, keyword: o.keyword,
highLight: o.highLight, highLight: o.highLight,
handler: o.handler handler: o.handler,
}; };
}, },
@ -80,10 +83,11 @@
element: this, element: this,
items: [ items: [
{ {
el: (this.text = BI.createWidget(json)) el: (this.text = BI.createWidget(json)),
} }
] ],
}); });
return; return;
} }
BI.createWidget({ // 1.2 BI.createWidget({ // 1.2
@ -93,10 +97,11 @@
element: this, element: this,
items: [ items: [
{ {
el: (this.text = BI.createWidget(json)) el: (this.text = BI.createWidget(json)),
} }
] ],
}); });
return; return;
} }
if (o.whiteSpace === "normal") { // 1.3 if (o.whiteSpace === "normal") { // 1.3
@ -106,7 +111,7 @@
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
}); });
this.text = BI.createWidget(json); this.text = BI.createWidget(json);
BI.createWidget({ BI.createWidget({
@ -114,13 +119,14 @@
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1 columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
scrollable: o.whiteSpace === "normal", scrollable: o.whiteSpace === "normal",
element: this, element: this,
items: [this.text] items: [this.text],
}); });
return; return;
} }
if (BI.isNumber(o.height) && o.height > 0) { // 1.4 if (BI.isNumber(o.height) && o.height > 0) { // 1.4
this.element.css({ this.element.css({
"line-height": o.height / BI.pixRatio + BI.pixUnit "line-height": o.height / BI.pixRatio + BI.pixUnit,
}); });
json.textAlign = o.textAlign; json.textAlign = o.textAlign;
delete json.maxWidth; delete json.maxWidth;
@ -131,8 +137,9 @@
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
})); }));
return; return;
} }
BI.extend(json, { // 1.5 BI.extend(json, { // 1.5
@ -142,7 +149,7 @@
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
maxWidth: "100%" maxWidth: "100%",
}); });
this.text = BI.createWidget(json); this.text = BI.createWidget(json);
BI.createWidget({ BI.createWidget({
@ -150,8 +157,9 @@
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1 columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
scrollable: o.whiteSpace === "normal", scrollable: o.whiteSpace === "normal",
element: this, element: this,
items: [this.text] items: [this.text],
}); });
return; return;
} }
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { // 1.6 if (BI.isNumber(o.textWidth) && o.textWidth > 0) { // 1.6
@ -163,10 +171,11 @@
element: this, element: this,
items: [ items: [
{ {
el: (this.text = BI.createWidget(json)) el: (this.text = BI.createWidget(json)),
} }
] ],
}); });
return; return;
} }
if (o.whiteSpace === "normal") { // 1.7 if (o.whiteSpace === "normal") { // 1.7
@ -176,7 +185,7 @@
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
}); });
this.text = BI.createWidget(json); this.text = BI.createWidget(json);
BI.createWidget({ BI.createWidget({
@ -184,13 +193,14 @@
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1 columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
scrollable: true, scrollable: true,
element: this, element: this,
items: [this.text] items: [this.text],
}); });
return; return;
} }
if (BI.isNumber(o.height) && o.height > 0) { // 1.8 if (BI.isNumber(o.height) && o.height > 0) { // 1.8
this.element.css({ this.element.css({
"line-height": o.height / BI.pixRatio + BI.pixUnit "line-height": o.height / BI.pixRatio + BI.pixUnit,
}); });
json.textAlign = o.textAlign; json.textAlign = o.textAlign;
delete json.maxWidth; delete json.maxWidth;
@ -201,8 +211,9 @@
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
})); }));
return; return;
} }
this.text = BI.createWidget(BI.extend(json, { this.text = BI.createWidget(BI.extend(json, {
@ -211,13 +222,13 @@
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
})); }));
BI.createWidget({ BI.createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1 columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
element: this, element: this,
items: [this.text] items: [this.text],
}); });
}, },
@ -238,10 +249,11 @@
element: this, element: this,
items: [ items: [
{ {
el: (this.text = BI.createWidget(json)) el: (this.text = BI.createWidget(json)),
} }
] ],
}); });
return; return;
} }
BI.createWidget({ // 2.2 BI.createWidget({ // 2.2
@ -258,16 +270,17 @@
element: this, element: this,
items: [ items: [
{ {
el: (this.text = BI.createWidget(json)) el: (this.text = BI.createWidget(json)),
} }
] ],
}); });
return; return;
} }
if (BI.isNumber(o.height) && o.height > 0) { // 2.3 if (BI.isNumber(o.height) && o.height > 0) { // 2.3
if (o.whiteSpace !== "normal") { if (o.whiteSpace !== "normal") {
this.element.css({ this.element.css({
"line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit "line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit,
}); });
} }
delete json.maxWidth; delete json.maxWidth;
@ -278,8 +291,9 @@
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
})); }));
return; return;
} }
json.maxWidth = o.width - 2 * o.hgap - o.lgap - o.rgap; json.maxWidth = o.width - 2 * o.hgap - o.lgap - o.rgap;
@ -296,9 +310,10 @@
bgap: o.bgap, bgap: o.bgap,
element: this, element: this,
items: [{ items: [{
el: (this.text = BI.createWidget(json)) el: (this.text = BI.createWidget(json)),
}] }],
}); });
return; return;
} }
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
@ -317,16 +332,17 @@
element: this, element: this,
items: [ items: [
{ {
el: (this.text = BI.createWidget(json)) el: (this.text = BI.createWidget(json)),
} }
] ],
}); });
return; return;
} }
if (BI.isNumber(o.height) && o.height > 0) { if (BI.isNumber(o.height) && o.height > 0) {
if (o.whiteSpace !== "normal") { if (o.whiteSpace !== "normal") {
this.element.css({ this.element.css({
"line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit "line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit,
}); });
} }
delete json.maxWidth; delete json.maxWidth;
@ -337,8 +353,9 @@
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
})); }));
return; return;
} }
this.text = BI.createWidget(BI.extend(json, { this.text = BI.createWidget(BI.extend(json, {
@ -347,7 +364,7 @@
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap bgap: o.bgap,
})); }));
BI.createWidget({ BI.createWidget({
type: adaptLayout, type: adaptLayout,
@ -355,7 +372,7 @@
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1 columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
element: this, element: this,
scrollable: o.whiteSpace === "normal", scrollable: o.whiteSpace === "normal",
items: [this.text] items: [this.text],
}); });
}, },
@ -394,6 +411,6 @@
this.options.text = v; this.options.text = v;
this.text.setValue(v); this.text.setValue(v);
} }
} },
}); });
}()); }());

7
src/base/single/label/html.label.js

@ -5,11 +5,12 @@
BI.HtmlLabel = BI.inherit(BI.AbstractLabel, { BI.HtmlLabel = BI.inherit(BI.AbstractLabel, {
props: { props: {
baseCls: "bi-html-label" baseCls: "bi-html-label",
}, },
_createJson: function () { _createJson: function () {
var o = this.options; var o = this.options;
return { return {
type: "bi.html", type: "bi.html",
textAlign: o.textAlign, textAlign: o.textAlign,
@ -17,9 +18,9 @@ BI.HtmlLabel = BI.inherit(BI.AbstractLabel, {
lineHeight: o.textHeight, lineHeight: o.textHeight,
text: o.text, text: o.text,
value: o.value, value: o.value,
handler: o.handler handler: o.handler,
}; };
} },
}); });
BI.shortcut("bi.html_label", BI.HtmlLabel); BI.shortcut("bi.html_label", BI.HtmlLabel);

10
src/base/single/label/icon.label.js

@ -21,12 +21,12 @@ BI.IconLabel = BI.inherit(BI.Single, {
render: function () { render: function () {
var o = this.options; var o = this.options;
this.element.css({ this.element.css({
textAlign: "center" textAlign: "center",
}); });
this.icon = BI.createWidget({ this.icon = BI.createWidget({
type: "bi.icon", type: "bi.icon",
width: o.iconWidth, width: o.iconWidth,
height: o.iconHeight height: o.iconHeight,
}); });
if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) { if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) {
this.element.css("lineHeight", (o.lineHeight || o.height) / BI.pixRatio + BI.pixUnit); this.element.css("lineHeight", (o.lineHeight || o.height) / BI.pixRatio + BI.pixUnit);
@ -39,7 +39,7 @@ BI.IconLabel = BI.inherit(BI.Single, {
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
items: [this.icon] items: [this.icon],
}); });
} else { } else {
this.element.css("lineHeight", "1"); this.element.css("lineHeight", "1");
@ -52,9 +52,9 @@ BI.IconLabel = BI.inherit(BI.Single, {
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
items: [this.icon] items: [this.icon],
}); });
} }
} },
}); });
BI.shortcut("bi.icon_label", BI.IconLabel); BI.shortcut("bi.icon_label", BI.IconLabel);

4
src/base/single/label/label.js

@ -7,7 +7,7 @@ BI.Label = BI.inherit(BI.AbstractLabel, {
props: { props: {
baseCls: "bi-label", baseCls: "bi-label",
py: "", py: "",
keyword: "" keyword: "",
}, },
doRedMark: function () { doRedMark: function () {
@ -16,7 +16,7 @@ BI.Label = BI.inherit(BI.AbstractLabel, {
unRedMark: function () { unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
} },
}); });
BI.shortcut("bi.label", BI.Label); BI.shortcut("bi.label", BI.Label);

5
src/base/single/link/__test__/link.test.js

@ -5,15 +5,14 @@
*/ */
describe("LinkTest", function () { describe("LinkTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("link", function () { it("link", function () {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.link" type: "bi.link",
}); });
expect(a.element.is('a')).to.equal(true); expect(a.element.is("a")).to.equal(true);
a.destroy(); a.destroy();
}); });
}); });

8
src/base/single/link/link.js

@ -6,16 +6,18 @@
BI.Link = BI.inherit(BI.Label, { BI.Link = BI.inherit(BI.Label, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Link.superclass._defaultConfig.apply(this, arguments); var conf = BI.Link.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-link display-block", baseCls: (conf.baseCls || "") + " bi-link display-block",
tagName: "a", tagName: "a",
href: "", href: "",
target: "_blank" target: "_blank",
}); });
}, },
_createJson: function () { _createJson: function () {
var o = this.options; var o = this.options;
return { return {
type: "bi.a", type: "bi.a",
textAlign: o.textAlign, textAlign: o.textAlign,
@ -26,9 +28,9 @@ BI.Link = BI.inherit(BI.Label, {
value: o.value, value: o.value,
py: o.py, py: o.py,
href: o.href, href: o.href,
target: o.target target: o.target,
}; };
} },
}); });
BI.shortcut("bi.link", BI.Link); BI.shortcut("bi.link", BI.Link);

7
src/base/single/tip/0.tip.js

@ -9,14 +9,15 @@
BI.Tip = BI.inherit(BI.Single, { BI.Tip = BI.inherit(BI.Single, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Tip.superclass._defaultConfig.apply(this, arguments); var conf = BI.Tip.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-tip", _baseCls: (conf._baseCls || "") + " bi-tip",
zIndex: BI.zIndex_tip zIndex: BI.zIndex_tip,
}); });
}, },
_init: function () { _init: function () {
BI.Tip.superclass._init.apply(this, arguments); BI.Tip.superclass._init.apply(this, arguments);
this.element.css({zIndex: this.options.zIndex}); this.element.css({ zIndex: this.options.zIndex, });
} },
}); });

19
src/base/single/tip/tip.toast.js

@ -31,14 +31,15 @@ BI.Toast = BI.inherit(BI.Tip, {
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.element.css({ this.element.css({
minWidth: (o.closable ? c.closableMinWidth : c.minWidth) / BI.pixRatio + BI.pixUnit, minWidth: (o.closable ? c.closableMinWidth : c.minWidth) / BI.pixRatio + BI.pixUnit,
maxWidth: (o.closable ? c.closableMaxWidth : c.maxWidth) / BI.pixRatio + BI.pixUnit maxWidth: (o.closable ? c.closableMaxWidth : c.maxWidth) / BI.pixRatio + BI.pixUnit,
}); });
this.element.addClass("toast-" + o.level); this.element.addClass("toast-" + o.level);
var fn = function (e) { function fn(e) {
e.stopPropagation(); e.stopPropagation();
e.stopEvent(); e.stopEvent();
return false; return false;
}; }
this.element.bind({ this.element.bind({
click: fn, click: fn,
mousedown: fn, mousedown: fn,
@ -46,7 +47,7 @@ BI.Toast = BI.inherit(BI.Tip, {
mouseover: fn, mouseover: fn,
mouseenter: fn, mouseenter: fn,
mouseleave: fn, mouseleave: fn,
mousemove: fn mousemove: fn,
}); });
var cls; var cls;
switch (o.level) { switch (o.level) {
@ -68,9 +69,9 @@ BI.Toast = BI.inherit(BI.Tip, {
break; break;
} }
var hasCloseIcon = function () { function hasCloseIcon() {
return o.closable === true || (o.closable === null && o.autoClose === false); return o.closable === true || (o.closable === null && o.autoClose === false);
}; }
var items = [{ var items = [{
type: "bi.icon_label", type: "bi.icon_label",
cls: cls + " toast-icon", cls: cls + " toast-icon",
@ -81,7 +82,7 @@ BI.Toast = BI.inherit(BI.Tip, {
whiteSpace: "normal", whiteSpace: "normal",
text: o.text, text: o.text,
textHeight: o.textHeight, textHeight: o.textHeight,
textAlign: "left" textAlign: "left",
}, },
}]; }];
@ -106,13 +107,13 @@ BI.Toast = BI.inherit(BI.Tip, {
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
innerHgap: o.innerHgap, innerHgap: o.innerHgap,
columnSize: columnSize columnSize: columnSize,
}; };
}, },
beforeDestroy: function () { beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY); this.fireEvent(BI.Toast.EVENT_DESTORY);
} },
}); });
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY"; BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast); BI.shortcut("bi.toast", BI.Toast);

3
src/base/single/trigger/trigger.js

@ -7,9 +7,10 @@
BI.Trigger = BI.inherit(BI.Single, { BI.Trigger = BI.inherit(BI.Single, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Trigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.Trigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-trigger cursor-pointer", _baseCls: (conf._baseCls || "") + " bi-trigger cursor-pointer",
height: 24 height: 24,
}); });
}, },

20
src/base/tree/customtree.js

@ -13,8 +13,8 @@ BI.CustomTree = BI.inherit(BI.Widget, {
expander: { expander: {
el: {}, el: {},
popup: { popup: {
type: "bi.custom_tree" type: "bi.custom_tree",
} },
}, },
items: [], items: [],
@ -24,9 +24,9 @@ BI.CustomTree = BI.inherit(BI.Widget, {
type: "bi.button_tree", type: "bi.button_tree",
chooseType: 0, chooseType: 0,
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical",
}] }],
} },
}); });
}, },
@ -45,12 +45,12 @@ BI.CustomTree = BI.inherit(BI.Widget, {
var item = BI.extend({ var item = BI.extend({
type: "bi.expander", type: "bi.expander",
el: { el: {
value: node.value value: node.value,
}, },
popup: { type: "bi.custom_tree" } popup: { type: "bi.custom_tree", },
}, BI.deepClone(o.expander), { }, BI.deepClone(o.expander), {
id: node.id, id: node.id,
pId: node.pId pId: node.pId,
}); });
var el = BI.stripEL(node); var el = BI.stripEL(node);
if (!BI.isWidget(el)) { if (!BI.isWidget(el)) {
@ -94,7 +94,7 @@ BI.CustomTree = BI.inherit(BI.Widget, {
callback.apply(null, args); callback.apply(null, args);
}]); }]);
}, },
value: o.value value: o.value,
}); });
this.tree.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { this.tree.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -143,7 +143,7 @@ BI.CustomTree = BI.inherit(BI.Widget, {
empty: function () { empty: function () {
this.tree.empty(); this.tree.empty();
} },
}); });
BI.CustomTree.EVENT_CHANGE = "EVENT_CHANGE"; BI.CustomTree.EVENT_CHANGE = "EVENT_CHANGE";

Loading…
Cancel
Save