Browse Source

Pull request #2991: KERNEL-12408:base中eslint的修改

Merge in VISUAL/fineui from ~CHAOS.WANG/fineui:master to master

* commit 'dc79aa76bdc21b6a46b1397baa889bb738c79be7':
  KERNEL-12408:base中eslint的修改
  KERNEL-12408:base中eslint的修改
  KERNEL-12408:base中eslint的修改
  KERNEL-12408:base中eslint的修改
es6
Chaos.Wang 2 years ago
parent
commit
44a327ed93
  1. 3
      .eslintrc
  2. 2
      package.json
  3. 20
      src/base/1.pane.js
  4. 6
      src/base/collection/__test__/collection.test.js
  5. 16
      src/base/collection/collection.js
  6. 32
      src/base/combination/bubble.js
  7. 34
      src/base/combination/combo.js
  8. 14
      src/base/combination/expander.js
  9. 18
      src/base/combination/group.button.js
  10. 16
      src/base/combination/group.combo.js
  11. 14
      src/base/combination/group.virtual.js
  12. 26
      src/base/combination/loader.js
  13. 14
      src/base/combination/navigation.js
  14. 22
      src/base/combination/searcher.js
  15. 22
      src/base/combination/switcher.js
  16. 14
      src/base/combination/tab.js
  17. 4
      src/base/combination/tree.button.js
  18. 6
      src/base/context.js
  19. 6
      src/base/el.js
  20. 2
      src/base/foundation/__test__/message.test.js
  21. 56
      src/base/foundation/message.js
  22. 4
      src/base/grid/__test__/grid.test.js
  23. 18
      src/base/grid/grid.js
  24. 6
      src/base/layer/__test__/layer.popover.test.js
  25. 60
      src/base/layer/layer.drawer.js
  26. 70
      src/base/layer/layer.popover.js
  27. 94
      src/base/layer/layer.popup.js
  28. 34
      src/base/layer/layer.searcher.js
  29. 10
      src/base/list/__test__/listview.test.js
  30. 10
      src/base/list/listview.js
  31. 14
      src/base/list/virtualgrouplist.js
  32. 12
      src/base/list/virtuallist.js
  33. 40
      src/base/pager/pager.js
  34. 18
      src/base/single/1.text.js
  35. 33
      src/base/single/button/button.basic.js
  36. 5
      src/base/single/button/button.node.js
  37. 12
      src/base/single/button/node/__test__/icontexticonnode.test.js
  38. 12
      src/base/single/button/node/__test__/icontextnode.test.js
  39. 12
      src/base/single/button/node/__test__/texticonnode.test.js
  40. 15
      src/base/single/button/node/__test__/textnode.test.js
  41. 15
      src/base/single/button/node/icontexticonnode.js
  42. 13
      src/base/single/button/node/icontextnode.js
  43. 13
      src/base/single/button/node/texticonnode.js
  44. 9
      src/base/single/button/node/textnode.js
  45. 23
      src/base/single/editor/editor.js
  46. 11
      src/base/single/editor/editor.multifile.js
  47. 7
      src/base/single/html/__test__/html.test.js
  48. 24
      src/base/single/html/html.js
  49. 5
      src/base/single/icon/icon.js
  50. 3
      src/base/single/iframe/__test__/iframe.test.js
  51. 7
      src/base/single/iframe/iframe.js
  52. 3
      src/base/single/img/__test__/img.test.js
  53. 7
      src/base/single/img/img.js
  54. 5
      src/base/single/input/checkbox/checkbox.image.js
  55. 11
      src/base/single/input/checkbox/checkbox.js
  56. 37
      src/base/single/input/input.js
  57. 7
      src/base/single/input/radio/radio.image.js
  58. 11
      src/base/single/input/radio/radio.js
  59. 85
      src/base/single/label/abstract.label.js
  60. 7
      src/base/single/label/html.label.js
  61. 10
      src/base/single/label/icon.label.js
  62. 4
      src/base/single/label/label.js
  63. 5
      src/base/single/link/__test__/link.test.js
  64. 8
      src/base/single/link/link.js
  65. 7
      src/base/single/tip/0.tip.js
  66. 19
      src/base/single/tip/tip.toast.js
  67. 3
      src/base/single/trigger/trigger.js
  68. 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-multiline"}] // 多行对象字面量中要求拖尾逗号
"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"],

2
package.json

@ -11,7 +11,7 @@
"@babel/core": "^7.17.4", "@babel/core": "^7.17.4",
"@babel/polyfill": "7.6.0", "@babel/polyfill": "7.6.0",
"@fui/babel-preset-fineui": "^2.0.0", "@fui/babel-preset-fineui": "^2.0.0",
"@fui/eslint-plugin": "1.0.15", "@fui/eslint-plugin": "^1.0.15",
"@types/node": "15.6.1", "@types/node": "15.6.1",
"autoprefixer": "9.6.1", "autoprefixer": "9.6.1",
"babel-loader": "8.0.6", "babel-loader": "8.0.6",

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();

16
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
}); });
@ -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);

32
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) {
@ -261,7 +261,7 @@
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) {

14
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",
}); });
}, },
@ -66,7 +66,7 @@ BI.Expander = BI.inherit(BI.Widget, {
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);
@ -172,7 +172,7 @@ BI.Expander = BI.inherit(BI.Widget, {
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";

18
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],
}); });
}); });
}, },
@ -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";

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

@ -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";

14
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),
}) })
] ],
}); });
}); });
} }
@ -135,10 +135,10 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
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";

26
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,7 +31,7 @@ BI.Loader = BI.inherit(BI.Widget, {
prev: false, prev: false,
next: {}, next: {},
hasPrev: BI.emptyFn, hasPrev: BI.emptyFn,
hasNext: BI.emptyFn hasNext: BI.emptyFn,
}); });
}, },
@ -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,
}]); }]);
}, },
@ -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);

14
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,7 +17,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
}, },
afterCardCreated: BI.emptyFn, afterCardCreated: BI.emptyFn,
afterCardShow: BI.emptyFn afterCardShow: BI.emptyFn,
}); });
}, },
@ -27,12 +27,12 @@ BI.Navigation = BI.inherit(BI.Widget, {
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";

14
src/base/combination/tab.js

@ -9,14 +9,14 @@ 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: [],
}); });
}, },
@ -30,13 +30,13 @@ BI.Tab = BI.inherit(BI.Widget, {
} }
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);

56
src/base/foundation/message.js

@ -44,8 +44,8 @@ BI.Msg = ((function () {
_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,8 +57,8 @@ 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 });
@ -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();

18
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
}); });
@ -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);

60
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:
@ -231,7 +231,7 @@ BI.Drawer = BI.inherit(BI.Widget, {
}, },
destroyed: function () { destroyed: function () {
} },
}); });
BI.shortcut("bi.drawer", BI.Drawer); BI.shortcut("bi.drawer", BI.Drawer);

70
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",
}; };
}, },
@ -226,7 +226,7 @@ BI.Popover = BI.inherit(BI.Widget, {
}, },
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);

94
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,7 +61,7 @@ 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);
@ -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,10 +123,10 @@ 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,
}] }],
}); });
} }
}, },
@ -139,7 +139,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
"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":
@ -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";

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

@ -19,29 +19,29 @@
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)) {
@ -57,12 +57,12 @@
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) {

33
src/base/single/button/button.basic.js

@ -8,6 +8,7 @@
BI.BasicButton = BI.inherit(BI.Single, { BI.BasicButton = BI.inherit(BI.Single, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.BasicButton.superclass._defaultConfig.apply(this, arguments); var conf = BI.BasicButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), _baseCls: (conf._baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer") + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""),
// el: {} // 可以通过el来创建button元素 // el: {} // 可以通过el来创建button元素
@ -24,7 +25,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
trigger: null, trigger: null,
handler: BI.emptyFn, handler: BI.emptyFn,
bubble: null bubble: null,
}); });
}, },
@ -63,11 +64,11 @@ BI.BasicButton = BI.inherit(BI.Single, {
_createShadow: function () { _createShadow: function () {
var self = this, o = this.options; var self = this, o = this.options;
var assertMask = function () { function assertMask() {
if (!self.$mask) { if (!self.$mask) {
self.$mask = BI.createWidget(BI.isObject(o.shadow) ? o.shadow : {}, { self.$mask = BI.createWidget(BI.isObject(o.shadow) ? o.shadow : {}, {
type: "bi.layout", type: "bi.layout",
cls: "bi-button-mask" cls: "bi-button-mask",
}); });
self.$mask.invisible(); self.$mask.invisible();
BI.createWidget({ BI.createWidget({
@ -78,11 +79,11 @@ BI.BasicButton = BI.inherit(BI.Single, {
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0,
}] }],
}); });
} }
}; }
this.element.mouseup(function () { this.element.mouseup(function () {
if (!self._hover && !o.isShadowShowingOnSelected) { if (!self._hover && !o.isShadowShowingOnSelected) {
@ -223,7 +224,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
// 之后的300ms点击无效 // 之后的300ms点击无效
var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
}); });
function ev(e) { function ev(e) {
@ -257,7 +258,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
}, },
el: { el: {
type: "bi.layout", type: "bi.layout",
height: "100%" height: "100%",
}, },
popup: { popup: {
type: "bi.text_bubble_bar_popup_view", type: "bi.text_bubble_bar_popup_view",
@ -272,21 +273,21 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (v) { if (v) {
onClick.apply(self, arguments); onClick.apply(self, arguments);
} }
} },
}] }],
}, },
listeners: [{ listeners: [{
eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW,
action: function () { action: function () {
popup.populate(getBubble()); popup.populate(getBubble());
} },
}] }],
}, },
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
top: 0 top: 0,
}] }],
}); });
} }
if (self.combo.isViewVisible()) { if (self.combo.isViewVisible()) {
@ -294,6 +295,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
} else { } else {
self.combo.showView(); self.combo.showView();
} }
return; return;
} }
onClick.apply(self, arguments); onClick.apply(self, arguments);
@ -304,6 +306,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (BI.isFunction(bubble)) { if (BI.isFunction(bubble)) {
return bubble(); return bubble();
} }
return bubble; return bubble;
} }
}, },
@ -436,7 +439,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
empty: function () { empty: function () {
BI.Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); BI.Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName());
BI.BasicButton.superclass.empty.apply(this, arguments); BI.BasicButton.superclass.empty.apply(this, arguments);
} },
}); });
BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE"; BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";
BI.shortcut("bi.basic_button", BI.BasicButton); BI.shortcut("bi.basic_button", BI.BasicButton);

5
src/base/single/button/button.node.js

@ -9,9 +9,10 @@
BI.NodeButton = BI.inherit(BI.BasicButton, { BI.NodeButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments); var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-node", _baseCls: (conf._baseCls || "") + " bi-node",
open: false open: false,
}); });
}, },
@ -51,6 +52,6 @@ BI.NodeButton = BI.inherit(BI.BasicButton, {
this.setOpened(true); this.setOpened(true);
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this);
} }
} },
}); });
BI.shortcut("bi.node_button", BI.NodeButton); BI.shortcut("bi.node_button", BI.NodeButton);

12
src/base/single/button/node/__test__/icontexticonnode.test.js

@ -4,13 +4,12 @@
*/ */
describe("IconTextIconNodeTest", function () { describe("IconTextIconNodeTest", function () {
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setText", function () { it("setText", function () {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node" type: "bi.icon_text_icon_node",
}); });
iconTextIconNode.setText("AAA"); iconTextIconNode.setText("AAA");
expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA");
@ -34,7 +33,7 @@ describe("IconTextIconNodeTest", function () {
*/ */
it("setValue", function () { it("setValue", function () {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node" type: "bi.icon_text_icon_node",
}); });
iconTextIconNode.setValue("AAA"); iconTextIconNode.setValue("AAA");
expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA");
@ -48,7 +47,7 @@ describe("IconTextIconNodeTest", function () {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
value: "AAA", value: "AAA",
readonly: true readonly: true,
}); });
iconTextIconNode.setValue("BBB"); iconTextIconNode.setValue("BBB");
expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA");
@ -61,7 +60,7 @@ describe("IconTextIconNodeTest", function () {
it("getValue", function () { it("getValue", function () {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
value: "AAA" value: "AAA",
}); });
expect(iconTextIconNode.getValue()).to.equal("AAA"); expect(iconTextIconNode.getValue()).to.equal("AAA");
iconTextIconNode.destroy(); iconTextIconNode.destroy();
@ -91,7 +90,7 @@ describe("IconTextIconNodeTest", function () {
text: "AAA", text: "AAA",
handler: function () { handler: function () {
this.setText("click"); this.setText("click");
} },
}); });
BI.nextTick(function () { BI.nextTick(function () {
iconTextIconNode.element.click(); iconTextIconNode.element.click();
@ -100,5 +99,4 @@ describe("IconTextIconNodeTest", function () {
done(); done();
}); });
}); });
}); });

12
src/base/single/button/node/__test__/icontextnode.test.js

@ -4,13 +4,12 @@
*/ */
describe("IconTextNodeTest", function () { describe("IconTextNodeTest", function () {
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setText", function () { it("setText", function () {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node" type: "bi.icon_text_node",
}); });
iconTextNode.setText("AAA"); iconTextNode.setText("AAA");
expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA");
@ -34,7 +33,7 @@ describe("IconTextNodeTest", function () {
*/ */
it("setValue", function () { it("setValue", function () {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node" type: "bi.icon_text_node",
}); });
iconTextNode.setValue("AAA"); iconTextNode.setValue("AAA");
expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA");
@ -48,7 +47,7 @@ describe("IconTextNodeTest", function () {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
value: "AAA", value: "AAA",
readonly: true readonly: true,
}); });
iconTextNode.setValue("BBB"); iconTextNode.setValue("BBB");
expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA");
@ -61,7 +60,7 @@ describe("IconTextNodeTest", function () {
it("getValue", function () { it("getValue", function () {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
value: "AAA" value: "AAA",
}); });
expect(iconTextNode.getValue()).to.equal("AAA"); expect(iconTextNode.getValue()).to.equal("AAA");
iconTextNode.destroy(); iconTextNode.destroy();
@ -91,7 +90,7 @@ describe("IconTextNodeTest", function () {
text: "AAA", text: "AAA",
handler: function () { handler: function () {
this.setText("click"); this.setText("click");
} },
}); });
BI.nextTick(function () { BI.nextTick(function () {
iconTextNode.element.click(); iconTextNode.element.click();
@ -100,5 +99,4 @@ describe("IconTextNodeTest", function () {
done(); done();
}); });
}); });
}); });

12
src/base/single/button/node/__test__/texticonnode.test.js

@ -4,13 +4,12 @@
*/ */
describe("TextIconNodeTest", function () { describe("TextIconNodeTest", function () {
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setText", function () { it("setText", function () {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node" type: "bi.text_icon_node",
}); });
textIconNode.setText("AAA"); textIconNode.setText("AAA");
expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA");
@ -34,7 +33,7 @@ describe("TextIconNodeTest", function () {
*/ */
it("setValue", function () { it("setValue", function () {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node" type: "bi.text_icon_node",
}); });
textIconNode.setValue("AAA"); textIconNode.setValue("AAA");
expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA");
@ -48,7 +47,7 @@ describe("TextIconNodeTest", function () {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
value: "AAA", value: "AAA",
readonly: true readonly: true,
}); });
textIconNode.setValue("BBB"); textIconNode.setValue("BBB");
expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA");
@ -61,7 +60,7 @@ describe("TextIconNodeTest", function () {
it("getValue", function () { it("getValue", function () {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
value: "AAA" value: "AAA",
}); });
expect(textIconNode.getValue()).to.equal("AAA"); expect(textIconNode.getValue()).to.equal("AAA");
textIconNode.destroy(); textIconNode.destroy();
@ -91,7 +90,7 @@ describe("TextIconNodeTest", function () {
text: "AAA", text: "AAA",
handler: function () { handler: function () {
this.setText("click"); this.setText("click");
} },
}); });
BI.nextTick(function () { BI.nextTick(function () {
textIconNode.element.click(); textIconNode.element.click();
@ -100,5 +99,4 @@ describe("TextIconNodeTest", function () {
done(); done();
}); });
}); });
}); });

15
src/base/single/button/node/__test__/textnode.test.js

@ -4,13 +4,12 @@
*/ */
describe("TextNodeTest", function () { describe("TextNodeTest", function () {
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setText", function () { it("setText", function () {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node" type: "bi.text_node",
}); });
textNode.setText("AAA"); textNode.setText("AAA");
expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); expect(textNode.element.children(".bi-text").text()).to.equal("AAA");
@ -24,7 +23,7 @@ describe("TextNodeTest", function () {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
text: "AAA", text: "AAA",
whiteSpace: "normal" whiteSpace: "normal",
}); });
expect(textNode.getText()).to.equal("AAA"); expect(textNode.getText()).to.equal("AAA");
textNode.destroy(); textNode.destroy();
@ -35,7 +34,7 @@ describe("TextNodeTest", function () {
*/ */
it("setValue", function () { it("setValue", function () {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node" type: "bi.text_node",
}); });
textNode.setValue("AAA"); textNode.setValue("AAA");
expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); expect(textNode.element.children(".bi-text").text()).to.equal("AAA");
@ -49,7 +48,7 @@ describe("TextNodeTest", function () {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
value: "AAA", value: "AAA",
readonly: true readonly: true,
}); });
textNode.setValue("BBB"); textNode.setValue("BBB");
expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); expect(textNode.element.children(".bi-text").text()).to.equal("AAA");
@ -62,7 +61,7 @@ describe("TextNodeTest", function () {
it("getValue", function () { it("getValue", function () {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
value: "AAA" value: "AAA",
}); });
expect(textNode.getValue()).to.equal("AAA"); expect(textNode.getValue()).to.equal("AAA");
textNode.destroy(); textNode.destroy();
@ -92,7 +91,7 @@ describe("TextNodeTest", function () {
text: "AAA", text: "AAA",
handler: function () { handler: function () {
this.setText("click"); this.setText("click");
} },
}); });
BI.nextTick(function () { BI.nextTick(function () {
textNode.element.click(); textNode.element.click();
@ -101,6 +100,4 @@ describe("TextNodeTest", function () {
done(); done();
}); });
}); });
}); });

15
src/base/single/button/node/icontexticonnode.js

@ -8,6 +8,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.IconTextIconNode.superclass._defaultConfig.apply(this, arguments); var conf = BI.IconTextIconNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node", baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node",
iconCls1: "close-ha-font", iconCls1: "close-ha-font",
@ -17,7 +18,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
textHgap: 0, textHgap: 0,
textVgap: 0, textVgap: 0,
textLgap: 0, textLgap: 0,
textRgap: 0 textRgap: 0,
}); });
}, },
@ -33,7 +34,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
width: o.leftIconWrapperWidth || o.height, width: o.leftIconWrapperWidth || o.height,
height: o.height, height: o.height,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight iconHeight: o.iconHeight,
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
@ -48,16 +49,16 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height height: o.height,
} },
}, { }, {
type: "bi.icon_label", type: "bi.icon_label",
cls: o.iconCls2, cls: o.iconCls2,
width: o.rightIconWrapperWidth || o.height, width: o.rightIconWrapperWidth || o.height,
height: o.height, height: o.height,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight iconHeight: o.iconHeight,
}] }],
}; };
}, },
@ -92,7 +93,7 @@ BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
getText: function () { getText: function () {
return this.text.getText(); return this.text.getText();
} },
}); });
BI.IconTextIconNode.EVENT_CHANGE = "EVENT_CHANGE"; BI.IconTextIconNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_icon_node", BI.IconTextIconNode); BI.shortcut("bi.icon_text_icon_node", BI.IconTextIconNode);

13
src/base/single/button/node/icontextnode.js

@ -8,6 +8,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.IconTextNode.superclass._defaultConfig.apply(this, arguments); var conf = BI.IconTextNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-node", baseCls: (conf.baseCls || "") + " bi-icon-text-node",
cls: "close-ha-font", cls: "close-ha-font",
@ -16,7 +17,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
textHgap: 0, textHgap: 0,
textVgap: 0, textVgap: 0,
textLgap: 0, textLgap: 0,
textRgap: 0 textRgap: 0,
}); });
}, },
@ -32,7 +33,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
width: o.iconWrapperWidth || o.height, width: o.iconWrapperWidth || o.height,
height: o.height, height: o.height,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight iconHeight: o.iconHeight,
}, { }, {
el: { el: {
type: "bi.label", type: "bi.label",
@ -48,9 +49,9 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height height: o.height,
} },
}] }],
}; };
}, },
@ -85,7 +86,7 @@ BI.IconTextNode = BI.inherit(BI.NodeButton, {
unRedMark: function () { unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
} },
}); });
BI.IconTextNode.EVENT_CHANGE = "EVENT_CHANGE"; BI.IconTextNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_node", BI.IconTextNode); BI.shortcut("bi.icon_text_node", BI.IconTextNode);

13
src/base/single/button/node/texticonnode.js

@ -7,6 +7,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.TextIconNode.superclass._defaultConfig.apply(this, arguments); var conf = BI.TextIconNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-icon-node", baseCls: (conf.baseCls || "") + " bi-text-icon-node",
cls: "close-ha-font", cls: "close-ha-font",
@ -15,7 +16,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, {
textHgap: 0, textHgap: 0,
textVgap: 0, textVgap: 0,
textLgap: 0, textLgap: 0,
textRgap: 0 textRgap: 0,
}); });
}, },
@ -40,16 +41,16 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
height: o.height height: o.height,
} },
}, { }, {
type: "bi.icon_label", type: "bi.icon_label",
cls: o.iconCls, cls: o.iconCls,
width: o.iconWrapperWidth || o.height, width: o.iconWrapperWidth || o.height,
height: o.height, height: o.height,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
iconHeight: o.iconHeight iconHeight: o.iconHeight,
}] }],
}; };
}, },
@ -84,7 +85,7 @@ BI.TextIconNode = BI.inherit(BI.NodeButton, {
unRedMark: function () { unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments); this.text.unRedMark.apply(this.text, arguments);
} },
}); });
BI.TextIconNode.EVENT_CHANGE = "EVENT_CHANGE"; BI.TextIconNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_icon_node", BI.TextIconNode); BI.shortcut("bi.text_icon_node", BI.TextIconNode);

9
src/base/single/button/node/textnode.js

@ -9,6 +9,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.TextNode.superclass._defaultConfig.apply(this, arguments); var conf = BI.TextNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-node", baseCls: (conf.baseCls || "") + " bi-text-node",
textAlign: "left", textAlign: "left",
@ -16,7 +17,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, {
textHgap: 0, textHgap: 0,
textVgap: 0, textVgap: 0,
textLgap: 0, textLgap: 0,
textRgap: 0 textRgap: 0,
}); });
}, },
@ -27,7 +28,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, {
element: this, element: this,
textAlign: o.textAlign, textAlign: o.textAlign,
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight, textHeight: o.whiteSpace === "nowrap" ? o.height : o.textHeight,
height: o.height, height: o.height,
hgap: o.textHgap, hgap: o.textHgap,
vgap: o.textVgap, vgap: o.textVgap,
@ -36,7 +37,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, {
text: o.text, text: o.text,
value: o.value, value: o.value,
keyword: o.keyword, keyword: o.keyword,
py: o.py py: o.py,
}); });
}, },
@ -71,7 +72,7 @@ BI.TextNode = BI.inherit(BI.NodeButton, {
getText: function () { getText: function () {
return this.text.getText(); return this.text.getText();
} },
}); });
BI.TextNode.EVENT_CHANGE = "EVENT_CHANGE"; BI.TextNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_node", BI.TextNode); BI.shortcut("bi.text_node", BI.TextNode);

23
src/base/single/editor/editor.js

@ -38,7 +38,7 @@ BI.Editor = BI.inherit(BI.Single, {
watermark: o.watermark, watermark: o.watermark,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
allowBlank: o.allowBlank allowBlank: o.allowBlank,
})); }));
this.editor.element.css({ this.editor.element.css({
width: "100%", width: "100%",
@ -46,7 +46,7 @@ BI.Editor = BI.inherit(BI.Single, {
border: "none", border: "none",
outline: "none", outline: "none",
padding: "0", padding: "0",
margin: "0" margin: "0",
}); });
var items = [{ var items = [{
@ -60,19 +60,19 @@ BI.Editor = BI.inherit(BI.Single, {
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0 bottom: 0,
}] }],
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
right: o.hgap + o.rgap, right: o.hgap + o.rgap,
top: o.vgap + o.tgap, top: o.vgap + o.tgap,
bottom: o.vgap + o.bgap bottom: o.vgap + o.bgap,
}]; }];
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: items items: items,
}); });
this.setWaterMark(this.options.watermark); this.setWaterMark(this.options.watermark);
@ -159,6 +159,7 @@ BI.Editor = BI.inherit(BI.Single, {
}); });
this.element.click(function (e) { this.element.click(function (e) {
e.stopPropagation(); e.stopPropagation();
return false; return false;
}); });
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
@ -194,7 +195,7 @@ BI.Editor = BI.inherit(BI.Single, {
height: o.height - 2 * o.vgap - o.tgap, height: o.height - 2 * o.vgap - o.tgap,
hgap: 2, hgap: 2,
whiteSpace: "nowrap", whiteSpace: "nowrap",
textAlign: "left" textAlign: "left",
}); });
this.watermark.element.bind({ this.watermark.element.bind({
mousedown: function (e) { mousedown: function (e) {
@ -204,7 +205,7 @@ BI.Editor = BI.inherit(BI.Single, {
self.editor.isEditing() && self.editor.blur(); self.editor.isEditing() && self.editor.blur();
} }
e.stopEvent(); e.stopEvent();
} },
}); });
this.watermark.element.bind("click", function (e) { this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) { if (self.isEnabled()) {
@ -240,7 +241,6 @@ BI.Editor = BI.inherit(BI.Single, {
}, },
setWaterMark: function (v) { setWaterMark: function (v) {
this.options.watermark = v; this.options.watermark = v;
if (BI.isNull(this.watermark)) { if (BI.isNull(this.watermark)) {
@ -269,7 +269,7 @@ BI.Editor = BI.inherit(BI.Single, {
} }
if (!this.disabledError && BI.isKey(errorText)) { if (!this.disabledError && BI.isKey(errorText)) {
BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, { BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, {
adjustYOffset: o.simple ? 1 : 2 adjustYOffset: o.simple ? 1 : 2,
}); });
this._checkToolTip(); this._checkToolTip();
} }
@ -332,6 +332,7 @@ BI.Editor = BI.inherit(BI.Single, {
if (!this.isValid()) { if (!this.isValid()) {
return BI.trim(this.editor.getLastValidValue()); return BI.trim(this.editor.getLastValidValue());
} }
return BI.trim(this.editor.getValue()); return BI.trim(this.editor.getValue());
}, },
@ -345,7 +346,7 @@ BI.Editor = BI.inherit(BI.Single, {
destroyed: function () { destroyed: function () {
BI.Bubbles.remove(this.getName()); BI.Bubbles.remove(this.getName());
} },
}); });
BI.Editor.EVENT_CHANGE = "EVENT_CHANGE"; BI.Editor.EVENT_CHANGE = "EVENT_CHANGE";
BI.Editor.EVENT_FOCUS = "EVENT_FOCUS"; BI.Editor.EVENT_FOCUS = "EVENT_FOCUS";

11
src/base/single/editor/editor.multifile.js

@ -9,12 +9,13 @@
BI.MultifileEditor = BI.inherit(BI.Widget, { BI.MultifileEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.MultifileEditor.superclass._defaultConfig.apply(this, arguments); var conf = BI.MultifileEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-multifile-editor", baseCls: (conf.baseCls || "") + " bi-multifile-editor",
multiple: false, multiple: false,
maxSize: -1, // 1024 * 1024 maxSize: -1, // 1024 * 1024
accept: "", accept: "",
url: "" url: "",
}); });
}, },
@ -57,13 +58,13 @@ BI.MultifileEditor = BI.inherit(BI.Widget, {
el: { el: {
type: "bi.adaptive", type: "bi.adaptive",
scrollable: false, scrollable: false,
items: [this.file] items: [this.file],
}, },
top: 0, top: 0,
right: 0, right: 0,
left: 0, left: 0,
bottom: 0 bottom: 0,
}] }],
}); });
}, },
@ -104,7 +105,7 @@ BI.MultifileEditor = BI.inherit(BI.Widget, {
reset: function () { reset: function () {
this._reset(); this._reset();
} },
}); });
BI.MultifileEditor.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultifileEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultifileEditor.EVENT_UPLOADSTART = "EVENT_UPLOADSTART"; BI.MultifileEditor.EVENT_UPLOADSTART = "EVENT_UPLOADSTART";

7
src/base/single/html/__test__/html.test.js

@ -5,14 +5,13 @@
*/ */
describe("HtmlTest", function () { describe("HtmlTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("html_h1", function () { it("html_h1", function () {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.html", type: "bi.html",
text: "<h1>在bi.html标签中使用html原生标签</h1>" text: "<h1>在bi.html标签中使用html原生标签</h1>",
}); });
expect(a.element.find("h1").length).to.equal(1); expect(a.element.find("h1").length).to.equal(1);
a.destroy(); a.destroy();
@ -32,10 +31,10 @@ describe("HtmlTest", function () {
highLight: true, highLight: true,
hgap: 10, hgap: 10,
vgap: 10, vgap: 10,
handler: BI.emptyFn handler: BI.emptyFn,
}); });
a.setValue("DDDDD"); a.setValue("DDDDD");
a.setStyle({"background-color": "red"}); a.setStyle({ "background-color": "red" });
expect(a.text.element.css("background-color")).to.equal("rgb(255, 0, 0)"); expect(a.text.element.css("background-color")).to.equal("rgb(255, 0, 0)");
a.destroy(); a.destroy();
}); });

24
src/base/single/html/html.js

@ -25,43 +25,43 @@ BI.Html = BI.inherit(BI.Single, {
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.isNumber(o.height)) { if (BI.isNumber(o.height)) {
this.element.css({lineHeight: o.height / BI.pixRatio + BI.pixUnit}); this.element.css({ lineHeight: o.height / BI.pixRatio + BI.pixUnit });
} }
if (BI.isNumber(o.lineHeight)) { if (BI.isNumber(o.lineHeight)) {
this.element.css({lineHeight: o.lineHeight / BI.pixRatio + BI.pixUnit}); this.element.css({ lineHeight: o.lineHeight / BI.pixRatio + BI.pixUnit });
} }
if (BI.isWidthOrHeight(o.maxWidth)) { if (BI.isWidthOrHeight(o.maxWidth)) {
this.element.css({maxWidth: o.maxWidth}); this.element.css({ maxWidth: o.maxWidth });
} }
this.element.css({ this.element.css({
textAlign: o.textAlign, textAlign: o.textAlign,
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
textOverflow: o.whiteSpace === 'nowrap' ? "ellipsis" : "", textOverflow: o.whiteSpace === "nowrap" ? "ellipsis" : "",
overflow: o.whiteSpace === "nowrap" ? "" : "auto" overflow: o.whiteSpace === "nowrap" ? "" : "auto",
}); });
if (o.handler) { if (o.handler) {
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.layout", type: "bi.layout",
tagName: "span" tagName: "span",
}); });
this.text.element.click(function () { this.text.element.click(function () {
o.handler(self.getValue()); o.handler(self.getValue());
@ -69,7 +69,7 @@ BI.Html = BI.inherit(BI.Single, {
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;
@ -108,7 +108,7 @@ BI.Html = BI.inherit(BI.Single, {
BI.Html.superclass.setText.apply(this, arguments); BI.Html.superclass.setText.apply(this, arguments);
this.options.text = text; this.options.text = text;
this.text.element.html(text); this.text.element.html(text);
} },
}); });
BI.shortcut("bi.html", BI.Html); BI.shortcut("bi.html", BI.Html);

5
src/base/single/icon/icon.js

@ -6,9 +6,10 @@
BI.Icon = BI.inherit(BI.Single, { BI.Icon = BI.inherit(BI.Single, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Icon.superclass._defaultConfig.apply(this, arguments); var conf = BI.Icon.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
tagName: "i", tagName: "i",
baseCls: (conf.baseCls || "") + " x-icon b-font horizon-center display-block" baseCls: (conf.baseCls || "") + " x-icon b-font horizon-center display-block",
}); });
}, },
@ -16,6 +17,6 @@ BI.Icon = BI.inherit(BI.Single, {
if (BI.isIE9Below && BI.isIE9Below()) { if (BI.isIE9Below && BI.isIE9Below()) {
this.element.addClass("hack"); this.element.addClass("hack");
} }
} },
}); });
BI.shortcut("bi.icon", BI.Icon); BI.shortcut("bi.icon", BI.Icon);

3
src/base/single/iframe/__test__/iframe.test.js

@ -5,13 +5,12 @@
*/ */
describe("IframeTest", function () { describe("IframeTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("directionPager", function () { it("directionPager", function () {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.iframe" type: "bi.iframe",
}); });
a.setSrc("http://www.baidu.com"); a.setSrc("http://www.baidu.com");
a.setName("testIFrame"); a.setName("testIFrame");

7
src/base/single/iframe/iframe.js

@ -7,6 +7,7 @@
BI.Iframe = BI.inherit(BI.Single, { BI.Iframe = BI.inherit(BI.Single, {
_defaultConfig: function (config) { _defaultConfig: function (config) {
var conf = BI.Iframe.superclass._defaultConfig.apply(this, arguments); var conf = BI.Iframe.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
tagName: "iframe", tagName: "iframe",
baseCls: (conf.baseCls || "") + " bi-iframe", baseCls: (conf.baseCls || "") + " bi-iframe",
@ -14,7 +15,7 @@ BI.Iframe = BI.inherit(BI.Single, {
name: "", name: "",
attributes: {}, attributes: {},
width: "100%", width: "100%",
height: "100%" height: "100%",
}); });
}, },
@ -31,7 +32,7 @@ BI.Iframe = BI.inherit(BI.Single, {
this.options.attributes = BI.extend({ this.options.attributes = BI.extend({
frameborder: 0, frameborder: 0,
src: o.src, src: o.src,
name: o.name name: o.name,
}, this.options.attributes); }, this.options.attributes);
}, },
@ -51,7 +52,7 @@ BI.Iframe = BI.inherit(BI.Single, {
getName: function () { getName: function () {
return this.options.name; return this.options.name;
} },
}); });
BI.shortcut("bi.iframe", BI.Iframe); BI.shortcut("bi.iframe", BI.Iframe);

3
src/base/single/img/__test__/img.test.js

@ -5,7 +5,6 @@
*/ */
describe("ImgTest", function () { describe("ImgTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
@ -13,7 +12,7 @@ describe("ImgTest", function () {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.img", type: "bi.img",
iconWidth: 36, iconWidth: 36,
iconHeight: 36 iconHeight: 36,
}); });
a.setSrc("test.png"); a.setSrc("test.png");
expect(a.element.attr("src")).to.equal("test.png"); expect(a.element.attr("src")).to.equal("test.png");

7
src/base/single/img/img.js

@ -9,13 +9,14 @@
BI.Img = BI.inherit(BI.Single, { BI.Img = BI.inherit(BI.Single, {
_defaultConfig: function (config) { _defaultConfig: function (config) {
var conf = BI.Img.superclass._defaultConfig.apply(this, arguments); var conf = BI.Img.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
tagName: "img", tagName: "img",
baseCls: (conf.baseCls || "") + " bi-img display-block", baseCls: (conf.baseCls || "") + " bi-img display-block",
src: "", src: "",
attributes: config.src ? { src: config.src } : {}, attributes: config.src ? { src: config.src } : {},
width: "100%", width: "100%",
height: "100%" height: "100%",
}); });
}, },
@ -23,7 +24,7 @@ BI.Img = BI.inherit(BI.Single, {
BI.Img.superclass._initProps.apply(this, arguments); BI.Img.superclass._initProps.apply(this, arguments);
var o = this.options; var o = this.options;
this.options.attributes = BI.extend({ this.options.attributes = BI.extend({
src: o.src src: o.src,
}, this.options.attributes); }, this.options.attributes);
}, },
@ -34,7 +35,7 @@ BI.Img = BI.inherit(BI.Single, {
getSrc: function () { getSrc: function () {
return this.options.src; return this.options.src;
} },
}); });
BI.shortcut("bi.img", BI.Img); BI.shortcut("bi.img", BI.Img);

5
src/base/single/input/checkbox/checkbox.image.js

@ -6,6 +6,7 @@
BI.ImageCheckbox = BI.inherit(BI.IconButton, { BI.ImageCheckbox = BI.inherit(BI.IconButton, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.ImageCheckbox.superclass._defaultConfig.apply(this, arguments); var conf = BI.ImageCheckbox.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-image-checkbox check-box-icon", baseCls: (conf.baseCls || "") + " bi-image-checkbox check-box-icon",
selected: false, selected: false,
@ -13,9 +14,9 @@ BI.ImageCheckbox = BI.inherit(BI.IconButton, {
width: 16, width: 16,
height: 16, height: 16,
iconWidth: 16, iconWidth: 16,
iconHeight: 16 iconHeight: 16,
}); });
} },
}); });
BI.ImageCheckbox.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE; BI.ImageCheckbox.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE;

11
src/base/single/input/checkbox/checkbox.js

@ -12,11 +12,12 @@ BI.Checkbox = BI.inherit(BI.BasicButton, {
width: 14, width: 14,
height: 14, height: 14,
iconWidth: 14, iconWidth: 14,
iconHeight: 14 iconHeight: 14,
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [{ items: [{
@ -26,8 +27,8 @@ BI.Checkbox = BI.inherit(BI.BasicButton, {
}, },
cls: "checkbox-content", cls: "checkbox-content",
width: o.iconWidth, width: o.iconWidth,
height: o.iconHeight height: o.iconHeight,
}] }],
}; };
}, },
@ -42,7 +43,7 @@ BI.Checkbox = BI.inherit(BI.BasicButton, {
doClick: function () { doClick: function () {
BI.Checkbox.superclass.doClick.apply(this, arguments); BI.Checkbox.superclass.doClick.apply(this, arguments);
if(this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.Checkbox.EVENT_CHANGE); this.fireEvent(BI.Checkbox.EVENT_CHANGE);
} }
}, },
@ -54,7 +55,7 @@ BI.Checkbox = BI.inherit(BI.BasicButton, {
} else { } else {
this.checkbox.element.removeClass("bi-high-light-background"); this.checkbox.element.removeClass("bi-high-light-background");
} }
} },
}); });
BI.Checkbox.EVENT_CHANGE = "EVENT_CHANGE"; BI.Checkbox.EVENT_CHANGE = "EVENT_CHANGE";

37
src/base/single/input/input.js

@ -7,12 +7,13 @@
BI.Input = BI.inherit(BI.Single, { BI.Input = BI.inherit(BI.Single, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Input.superclass._defaultConfig.apply(this, arguments); var conf = BI.Input.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-input display-block overflow-dot", baseCls: (conf.baseCls || "") + " bi-input display-block overflow-dot",
tagName: "input", tagName: "input",
validationChecker: BI.emptyFn, validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn, // 按确定键能否退出编辑 quitChecker: BI.emptyFn, // 按确定键能否退出编辑
allowBlank: false allowBlank: false,
}); });
}, },
@ -27,15 +28,15 @@ BI.Input = BI.inherit(BI.Single, {
}, BI.EVENT_RESPONSE_TIME); }, BI.EVENT_RESPONSE_TIME);
var _clk = BI.debounce(BI.bind(this._click, this), BI.EVENT_RESPONSE_TIME, { var _clk = BI.debounce(BI.bind(this._click, this), BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
}); });
this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, { this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
}); });
this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false,
}); });
this.element this.element
.keydown(function (e) { .keydown(function (e) {
@ -86,7 +87,7 @@ BI.Input = BI.inherit(BI.Single, {
this.element.addClass("bi-input-focus"); this.element.addClass("bi-input-focus");
this._checkValidationOnValueChange(); this._checkValidationOnValueChange();
this._isEditing = true; this._isEditing = true;
if (this.getValue() == "") { if (this.getValue() === "") {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(BI.Input.EVENT_EMPTY); this.fireEvent(BI.Input.EVENT_EMPTY);
} }
@ -139,7 +140,7 @@ BI.Input = BI.inherit(BI.Single, {
this._checkValidationOnValueChange(); this._checkValidationOnValueChange();
} }
if (this.isValid() && BI.trim(this.getValue()) !== "") { if (this.isValid() && BI.trim(this.getValue()) !== "") {
if (BI.trim(this.getValue()) !== this._lastValue && (!this._start || this._lastValue == null || this._lastValue === "") if (BI.trim(this.getValue()) !== this._lastValue && (!this._start || BI.isNull(this._lastValue) || this._lastValue === "")
|| (this._pause === true && !/(\s|\u00A0)$/.test(this.getValue()))) { || (this._pause === true && !/(\s|\u00A0)$/.test(this.getValue()))) {
this._start = true; this._start = true;
this._pause = false; this._pause = false;
@ -147,7 +148,7 @@ BI.Input = BI.inherit(BI.Single, {
this.fireEvent(BI.Input.EVENT_START); this.fireEvent(BI.Input.EVENT_START);
} }
} }
if (keyCode == BI.KeyCode.ENTER) { if (BI.isEqual(keyCode, BI.KeyCode.ENTER)) {
if (this.isValid() || this.options.quitChecker.apply(this, [BI.trim(this.getValue())]) !== false) { if (this.isValid() || this.options.quitChecker.apply(this, [BI.trim(this.getValue())]) !== false) {
this.blur(); this.blur();
this.fireEvent(BI.Input.EVENT_ENTER); this.fireEvent(BI.Input.EVENT_ENTER);
@ -155,20 +156,20 @@ BI.Input = BI.inherit(BI.Single, {
this.fireEvent(BI.Input.EVENT_RESTRICT); this.fireEvent(BI.Input.EVENT_RESTRICT);
} }
} }
if (keyCode == BI.KeyCode.SPACE) { if (BI.isEqual(keyCode, BI.KeyCode.SPACE)) {
this.fireEvent(BI.Input.EVENT_SPACE); this.fireEvent(BI.Input.EVENT_SPACE);
} }
if (keyCode == BI.KeyCode.BACKSPACE && this._lastValue == "") { if (BI.isEqual(keyCode, BI.KeyCode.BACKSPACE) && this._lastValue === "") {
this.fireEvent(BI.Input.EVENT_REMOVE); this.fireEvent(BI.Input.EVENT_REMOVE);
} }
if (keyCode == BI.KeyCode.BACKSPACE || keyCode == BI.KeyCode.DELETE) { if (BI.isEqual(keyCode, BI.KeyCode.BACKSPACE) || BI.isEqual(keyCode, BI.KeyCode.DELETE)) {
this.fireEvent(BI.Input.EVENT_BACKSPACE); this.fireEvent(BI.Input.EVENT_BACKSPACE);
} }
this.fireEvent(BI.Input.EVENT_KEY_DOWN, arguments); this.fireEvent(BI.Input.EVENT_KEY_DOWN, arguments);
// _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务
var lastValue = this._lastValue; var lastValue = this._lastValue;
if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) {
this._valueChange(); this._valueChange();
} }
if (BI.isEndWithBlank(this.getValue())) { if (BI.isEndWithBlank(this.getValue())) {
@ -185,7 +186,7 @@ BI.Input = BI.inherit(BI.Single, {
// 初始状态 // 初始状态
_defaultState: function () { _defaultState: function () {
if (this.getValue() == "") { if (this.getValue() === "") {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(BI.Input.EVENT_EMPTY); this.fireEvent(BI.Input.EVENT_EMPTY);
} }
@ -199,7 +200,7 @@ BI.Input = BI.inherit(BI.Single, {
this.fireEvent(BI.Input.EVENT_CHANGE); this.fireEvent(BI.Input.EVENT_CHANGE);
this._lastSubmitValue = BI.trim(this.getValue()); this._lastSubmitValue = BI.trim(this.getValue());
} }
if (this.getValue() == "") { if (this.getValue() === "") {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(BI.Input.EVENT_EMPTY); this.fireEvent(BI.Input.EVENT_EMPTY);
} }
@ -209,14 +210,16 @@ BI.Input = BI.inherit(BI.Single, {
_checkValidationOnValueChange: function (callback) { _checkValidationOnValueChange: function (callback) {
var self = this, o = this.options; var self = this, o = this.options;
var v = this.getValue(); var v = this.getValue();
if (o.allowBlank === true && BI.trim(v) == "") { if (o.allowBlank === true && BI.trim(v) === "") {
this.setValid(true); this.setValid(true);
callback && callback(); callback && callback();
return; return;
} }
if (BI.trim(v) == "") { if (BI.trim(v) === "") {
this.setValid(false); this.setValid(false);
callback && callback(); callback && callback();
return; return;
} }
var checker = o.validationChecker.apply(this, [BI.trim(v)]); var checker = o.validationChecker.apply(this, [BI.trim(v)]);
@ -224,7 +227,7 @@ BI.Input = BI.inherit(BI.Single, {
checker.then(function (validate) { checker.then(function (validate) {
self.setValid(validate !== false); self.setValid(validate !== false);
callback && callback(); callback && callback();
}) });
} else { } else {
this.setValid(checker !== false); this.setValid(checker !== false);
callback && callback(); callback && callback();
@ -306,7 +309,7 @@ BI.Input = BI.inherit(BI.Single, {
_setEnable: function (b) { _setEnable: function (b) {
BI.Input.superclass._setEnable.apply(this, [b]); BI.Input.superclass._setEnable.apply(this, [b]);
this.element[0].disabled = !b; this.element[0].disabled = !b;
} },
}); });
BI.Input.EVENT_CHANGE = "EVENT_CHANGE"; BI.Input.EVENT_CHANGE = "EVENT_CHANGE";

7
src/base/single/input/radio/radio.image.js

@ -6,6 +6,7 @@
BI.ImageRadio = BI.inherit(BI.IconButton, { BI.ImageRadio = BI.inherit(BI.IconButton, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.ImageRadio.superclass._defaultConfig.apply(this, arguments); var conf = BI.ImageRadio.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-radio radio-icon", baseCls: (conf.baseCls || "") + " bi-radio radio-icon",
selected: false, selected: false,
@ -13,16 +14,16 @@ BI.ImageRadio = BI.inherit(BI.IconButton, {
width: 16, width: 16,
height: 16, height: 16,
iconWidth: 16, iconWidth: 16,
iconHeight: 16 iconHeight: 16,
}); });
}, },
doClick: function () { doClick: function () {
BI.ImageRadio.superclass.doClick.apply(this, arguments); BI.ImageRadio.superclass.doClick.apply(this, arguments);
if(this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.ImageRadio.EVENT_CHANGE); this.fireEvent(BI.ImageRadio.EVENT_CHANGE);
} }
} },
}); });
BI.ImageRadio.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE; BI.ImageRadio.EVENT_CHANGE = BI.IconButton.EVENT_CHANGE;

11
src/base/single/input/radio/radio.js

@ -12,11 +12,12 @@ BI.Radio = BI.inherit(BI.BasicButton, {
width: 14, width: 14,
height: 14, height: 14,
iconWidth: 14, iconWidth: 14,
iconHeight: 14 iconHeight: 14,
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [{ items: [{
@ -26,8 +27,8 @@ BI.Radio = BI.inherit(BI.BasicButton, {
self.radio = _ref; self.radio = _ref;
}, },
width: o.iconWidth, width: o.iconWidth,
height: o.iconHeight height: o.iconHeight,
}] }],
}; };
}, },
@ -42,7 +43,7 @@ BI.Radio = BI.inherit(BI.BasicButton, {
doClick: function () { doClick: function () {
BI.Radio.superclass.doClick.apply(this, arguments); BI.Radio.superclass.doClick.apply(this, arguments);
if(this.isValid()) { if (this.isValid()) {
this.fireEvent(BI.Radio.EVENT_CHANGE); this.fireEvent(BI.Radio.EVENT_CHANGE);
} }
}, },
@ -54,7 +55,7 @@ BI.Radio = BI.inherit(BI.BasicButton, {
} else { } else {
this.radio.element.removeClass("bi-high-light-background"); this.radio.element.removeClass("bi-high-light-background");
} }
} },
}); });
BI.Radio.EVENT_CHANGE = "EVENT_CHANGE"; BI.Radio.EVENT_CHANGE = "EVENT_CHANGE";

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