Browse Source

KERNEL-12408:base中eslint的修改

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

3
.eslintrc

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

20
src/base/1.pane.js

@ -15,7 +15,7 @@ BI.Pane = BI.inherit(BI.Widget, {
loadingText: "",
loadingSize: "small",
overlap: true,
onLoaded: BI.emptyFn
onLoaded: BI.emptyFn,
});
},
@ -32,8 +32,8 @@ BI.Pane = BI.inherit(BI.Widget, {
},
cls: "bi-tips",
text: o.tipText,
height: 25
}]
height: 25,
}],
});
}
},
@ -42,7 +42,7 @@ BI.Pane = BI.inherit(BI.Widget, {
var self = this, o = this.options;
var loadingAnimation = BI.createWidget(BI.Providers.getProvider("bi.provider.system").getLoading({
loadingSize: o.loadingSize,
context: this
context: this,
}));
// pane在同步方式下由items决定tipText的显示与否
// loading的异步情况下由loaded后对面板的populate的时机决定
@ -53,7 +53,7 @@ BI.Pane = BI.inherit(BI.Widget, {
type: "bi.center_adapt",
cls: "loading-container",
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");
@ -63,7 +63,7 @@ BI.Pane = BI.inherit(BI.Widget, {
type: "bi.center_adapt",
element: this,
cls: "loading-container",
items: this._getLoadingTipItems(loadingAnimation)
items: this._getLoadingTipItems(loadingAnimation),
});
}
self.fireEvent(BI.Pane.EVENT_LOADING);
@ -78,12 +78,12 @@ BI.Pane = BI.inherit(BI.Widget, {
var self = this, o = this.options;
var loadingTipItems = [{
type: "bi.horizontal_adapt",
items: [loadingTip]
items: [loadingTip],
}];
BI.isNotEmptyString(o.loadingText) && loadingTipItems.push({
type: "bi.text",
text: o.loadingText,
tgap: this._getSize(10)
tgap: this._getSize(10),
});
return [{
@ -91,7 +91,7 @@ BI.Pane = BI.inherit(BI.Widget, {
ref: function (_ref) {
self._loading = _ref;
},
items: loadingTipItems
items: loadingTipItems,
}];
},
@ -125,7 +125,7 @@ BI.Pane = BI.inherit(BI.Widget, {
populate: function (items) {
this.options.items = items || [];
this.check();
}
},
});
BI.Pane.EVENT_LOADED = "EVENT_LOADED";
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++) {
items[i] = {
type: "bi.label",
text: i
text: i,
};
}
var grid = BI.Test.createWidget({
@ -27,9 +27,9 @@ describe("CollectionTest", function () {
x: index % 10 * 50,
y: Math.floor(index / 10) * 50,
width: 50,
height: 50
height: 50,
};
}
},
});
// TODO 列表展示类控件不知道该测什么,先标记一下
grid.destroy();

22
src/base/collection/collection.js

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

36
src/base/combination/bubble.js

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

34
src/base/combination/combo.js

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

18
src/base/combination/expander.js

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

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

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

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

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

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

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

32
src/base/combination/loader.js

@ -14,12 +14,12 @@ BI.Loader = BI.inherit(BI.Widget, {
isDefaultInit: true, // 是否默认初始化数据
logic: {
dynamic: true,
scrolly: true
scrolly: true,
},
// 下面是button_group的属性
el: {
type: "bi.button_group"
type: "bi.button_group",
},
items: [],
@ -31,14 +31,14 @@ BI.Loader = BI.inherit(BI.Widget, {
prev: false,
next: {},
hasPrev: BI.emptyFn,
hasNext: BI.emptyFn
hasNext: BI.emptyFn,
});
},
_prevLoad: function () {
var self = this, o = this.options;
this.prev.setLoading();
o.itemsCreator.apply(this, [{ times: --this.times }, function () {
o.itemsCreator.apply(this, [{ times: --this.times, }, function () {
self.prev.setLoaded();
self.prependItems.apply(self, arguments);
}]);
@ -47,7 +47,7 @@ BI.Loader = BI.inherit(BI.Widget, {
_nextLoad: function () {
var self = this, o = this.options;
this.next.setLoading();
o.itemsCreator.apply(this, [{ times: ++this.times }, function () {
o.itemsCreator.apply(this, [{ times: ++this.times, }, function () {
self.next.setLoaded();
self.addItems.apply(self, arguments);
}]);
@ -61,7 +61,7 @@ BI.Loader = BI.inherit(BI.Widget, {
}
if (o.prev !== false) {
this.prev = BI.createWidget(BI.extend({
type: "bi.loading_bar"
type: "bi.loading_bar",
}, o.prev));
this.prev.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
@ -76,9 +76,9 @@ BI.Loader = BI.inherit(BI.Widget, {
items: o.items,
behaviors: {},
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) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -89,7 +89,7 @@ BI.Loader = BI.inherit(BI.Widget, {
if (o.next !== false) {
this.next = BI.createWidget(BI.extend({
type: "bi.loading_bar"
type: "bi.loading_bar",
}, o.next));
this.next.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
@ -99,11 +99,11 @@ BI.Loader = BI.inherit(BI.Widget, {
}
BI.createWidget(BI.extend({
element: this
element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({
scrolly: true
scrolly: true,
}, 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 () {
@ -125,7 +125,7 @@ BI.Loader = BI.inherit(BI.Widget, {
return !!o.hasPrev.apply(this, [{
times: this.times,
count: this.count
count: this.count,
}]);
},
@ -137,7 +137,7 @@ BI.Loader = BI.inherit(BI.Widget, {
return !!o.hasNext.apply(this, [{
times: this.times,
count: this.count
count: this.count,
}]);
},
@ -170,7 +170,7 @@ BI.Loader = BI.inherit(BI.Widget, {
_populate: function (items) {
var self = this, o = this.options;
if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) {
o.itemsCreator.apply(this, [{ times: 1 }, function () {
o.itemsCreator.apply(this, [{ times: 1, }, function () {
if (arguments.length === 0) {
throw new Error("参数不能为空");
}
@ -259,7 +259,7 @@ BI.Loader = BI.inherit(BI.Widget, {
destroy: function () {
BI.Loader.superclass.destroy.apply(this, arguments);
}
},
});
BI.Loader.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.loader", BI.Loader);

16
src/base/combination/navigation.js

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

22
src/base/combination/searcher.js

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

22
src/base/combination/switcher.js

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

16
src/base/combination/tab.js

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

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

@ -7,7 +7,7 @@
BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
_defaultConfig: function () {
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;
}
},
});
BI.ButtonTree.EVENT_CHANGE = "EVENT_CHANGE";

6
src/base/context.js

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

6
src/base/el.js

@ -9,14 +9,14 @@ BI.EL = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.EL.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-el",
el: {}
el: {},
});
},
render: function () {
var self = this, o = this.options;
this.ele = BI.createWidget(o.el, {
element: this
element: this,
});
this.ele.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -33,6 +33,6 @@ BI.EL = BI.inherit(BI.Widget, {
populate: function () {
this.ele.populate.apply(this, arguments);
}
},
});
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) {
BI.Msg.toast("message", {
autoClose: false
autoClose: false,
});
var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-toast").length).to.equal(1);

62
src/base/foundation/message.js

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

24
src/base/grid/grid.js

@ -27,7 +27,7 @@ BI.GridView = BI.inherit(BI.Widget, {
items: [],
itemFormatter: function (item, row, col) {
return item;
}
},
});
},
@ -41,7 +41,7 @@ BI.GridView = BI.inherit(BI.Widget, {
self._scrollLock = false;
}, 1000 / 60);
this.container = BI._lazyCreateWidget({
type: "bi.absolute"
type: "bi.absolute",
});
this.element.scroll(function () {
if (self._scrollLock === true) {
@ -52,7 +52,7 @@ BI.GridView = BI.inherit(BI.Widget, {
self._calculateChildrenToRender();
self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
scrollTop: o.scrollTop,
});
});
// 兼容一下
@ -74,7 +74,7 @@ BI.GridView = BI.inherit(BI.Widget, {
scrollable: scrollable,
scrolly: scrolly,
scrollx: scrollx,
items: [this.container]
items: [this.container],
});
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) {
self.populate(newValue);
@ -115,7 +115,7 @@ BI.GridView = BI.inherit(BI.Widget, {
_getOverscanIndices: function (cellCount, overscanCellsCount, startIndex, stopIndex) {
return {
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({
type: "bi.label",
width: columnDatum.size,
height: rowDatum.size
height: rowDatum.size,
}, item, {
cls: (item.cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""),
_rowIndex: rowIndex,
_columnIndex: columnIndex,
_left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment
_top: rowDatum.offset + verticalOffsetAdjustment,
}), this);
renderedCells.push({
el: child,
left: columnDatum.offset + horizontalOffsetAdjustment,
top: rowDatum.offset + verticalOffsetAdjustment,
_left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment
_top: rowDatum.offset + verticalOffsetAdjustment,
// _width: columnDatum.size,
// _height: rowDatum.size
});
@ -258,7 +258,7 @@ BI.GridView = BI.inherit(BI.Widget, {
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY };
this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY, };
}
},
@ -333,7 +333,7 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.options.overflowX !== !!b) {
this.options.overflowX = !!b;
BI.nextTick(function () {
self.element.css({ overflowX: b ? "auto" : "hidden" });
self.element.css({ overflowX: b ? "auto" : "hidden", });
});
}
},
@ -343,7 +343,7 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.options.overflowY !== !!b) {
this.options.overflowY = !!b;
BI.nextTick(function () {
self.element.css({ overflowY: b ? "auto" : "hidden" });
self.element.css({ overflowY: b ? "auto" : "hidden", });
});
}
},
@ -398,7 +398,7 @@ BI.GridView = BI.inherit(BI.Widget, {
this.restore();
}
this._populate(items);
}
},
});
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
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",
header: {
type: "bi.label",
text: "这个是header"
text: "这个是header",
},
body: {
type: "bi.label",
text: "这个是body"
}
text: "这个是body",
},
}).open(id);
BI.delay(function () {
expect(BI.Widget._renderEngine.createElement("body").find(".bi-popup-view .bi-z-index-mask").length).to.equal(1);

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

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

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

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

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

@ -5,7 +5,7 @@
*/
BI.PopupView = BI.inherit(BI.Widget, {
_const: {
TRIANGLE_LENGTH: 12
TRIANGLE_LENGTH: 12,
},
_defaultConfig: function (props) {
return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), {
@ -29,7 +29,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
stopEvent: false, // 是否停止mousedown、mouseup事件
stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡
logic: {
dynamic: true
dynamic: true,
},
tool: false, // 自定义工具栏
@ -42,9 +42,9 @@ BI.PopupView = BI.inherit(BI.Widget, {
chooseType: 0,
behaviors: {},
layouts: [{
type: "bi.vertical"
}]
}
type: "bi.vertical",
}],
},
});
},
@ -61,13 +61,13 @@ BI.PopupView = BI.inherit(BI.Widget, {
this.element.css({
"z-index": BI.zIndex_popup,
"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
}).bind({ click: fn });
"max-width": BI.isNumeric(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth,
}).bind({ click: fn, });
this.element.bind("mousewheel", fn);
o.stopPropagation && this.element.bind({ mousedown: fn, mouseup: fn, mouseover: fn });
o.stopEvent && this.element.bind({ mousedown: stop, mouseup: stop, mouseover: stop });
o.stopPropagation && this.element.bind({ mousedown: fn, mouseup: fn, mouseover: fn, });
o.stopEvent && this.element.bind({ mousedown: stop, mouseup: stop, mouseover: stop, });
this.tool = this._createTool();
this.tab = this._createTab();
this.view = this._createView();
@ -81,7 +81,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
});
BI.createWidget(BI.extend({
element: this
element: this,
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
scrolly: false,
lgap: o.lgap,
@ -91,11 +91,11 @@ BI.PopupView = BI.inherit(BI.Widget, {
vgap: o.vgap,
hgap: o.hgap,
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, {
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) {
this.arrow = BI.createWidget({
@ -103,19 +103,19 @@ BI.PopupView = BI.inherit(BI.Widget, {
cls: "bi-bubble-arrow",
items: [{
type: "bi.layout",
cls: "bubble-arrow"
}]
cls: "bubble-arrow",
}],
});
this.arrowWrapper = BI.createWidget({
type: "bi.absolute",
cls: "bi-bubble-arrow-wrapper",
items: [{
el: this.arrow
}]
el: this.arrow,
}],
});
// 因为三角符号的原因位置变大了,需要占位
this.placeholder = BI.createWidget({
type: "bi.layout"
type: "bi.layout",
});
BI.createWidget({
type: "bi.absolute",
@ -123,23 +123,23 @@ BI.PopupView = BI.inherit(BI.Widget, {
items: [{
el: this.arrowWrapper,
left: 0,
top: 0
top: 0,
}, {
el: this.placeholder
}]
el: this.placeholder,
}],
});
}
},
_createView: function () {
var o = this.options;
this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value });
this.button_group = BI.createWidget(o.el, { type: "bi.button_group", value: o.value, });
this.button_group.element.css({
"min-height": BI.isNumeric(o.minHeight) ? (o.minHeight / BI.pixRatio + BI.pixUnit) : o.minHeight,
"padding-top": o.innerVgap / BI.pixRatio + BI.pixUnit,
"padding-bottom": o.innerVgap / 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;
@ -165,7 +165,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
cls: "list-view-tab",
height: 25,
items: o.tabs,
value: o.value
value: o.value,
});
},
@ -182,8 +182,8 @@ BI.PopupView = BI.inherit(BI.Widget, {
items: BI.createItems(o.buttons, {
once: false,
shadow: true,
isShadowShowingOnSelected: true
})
isShadowShowingOnSelected: true,
}),
});
},
@ -217,156 +217,156 @@ BI.PopupView = BI.inherit(BI.Widget, {
direction = "bottom";
style = {
// 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 = {
top: o.tgap + o.vgap,
left: 0,
right: "",
bottom: ""
bottom: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH,
bottom: ""
bottom: "",
};
break;
case "bottom,left":
direction = "bottom";
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 = {
top: o.bgap + o.vgap,
left: "",
right: 0,
bottom: ""
bottom: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: -this._const.TRIANGLE_LENGTH,
bottom: ""
bottom: "",
};
break;
case "top":
case "top,right":
direction = "top";
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 = {
bottom: o.bgap + o.vgap,
left: 0,
right: "",
top: ""
top: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: "",
bottom: -this._const.TRIANGLE_LENGTH
bottom: -this._const.TRIANGLE_LENGTH,
};
break;
case "top,left":
direction = "top";
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 = {
bottom: o.bgap + o.vgap,
right: 0,
left: "",
top: ""
top: "",
};
placeholderStyle = {
left: 0,
right: 0,
height: this._const.TRIANGLE_LENGTH,
top: "",
bottom: -this._const.TRIANGLE_LENGTH
bottom: -this._const.TRIANGLE_LENGTH,
};
break;
case "left":
case "left,bottom":
direction = "left";
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 = {
right: o.rgap + o.hgap,
top: 0,
bottom: "",
left: ""
left: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH,
left: ""
left: "",
};
break;
case "left,top":
direction = "left";
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 = {
right: o.rgap + o.hgap,
bottom: 0,
top: "",
left: ""
left: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
right: -this._const.TRIANGLE_LENGTH,
left: ""
left: "",
};
break;
case "right":
case "right,bottom":
direction = "right";
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 = {
left: o.lgap + o.hgap,
top: 0,
bottom: "",
right: ""
right: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH,
right: ""
right: "",
};
break;
case "right,top":
direction = "right";
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 = {
left: o.lgap + o.hgap,
bottom: 0,
top: "",
right: ""
right: "",
};
placeholderStyle = {
top: 0,
bottom: 0,
width: this._const.TRIANGLE_LENGTH,
left: -this._const.TRIANGLE_LENGTH,
right: ""
right: "",
};
break;
case "right,innerRight":
@ -411,7 +411,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0);
var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVgap;
this.view.resetHeight ? this.view.resetHeight(resetHeight) :
this.view.element.css({ "max-height": resetHeight / BI.pixRatio + BI.pixUnit });
this.view.element.css({ "max-height": resetHeight / BI.pixRatio + BI.pixUnit, });
},
setValue: function (selectedValues) {
@ -421,7 +421,7 @@ BI.PopupView = BI.inherit(BI.Widget, {
getValue: function () {
return this.view.getValue();
}
},
});
BI.PopupView.EVENT_CHANGE = "EVENT_CHANGE";
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: {
redmark: function () {
return true;
}
},
},
items: [],
layouts: [{
type: "bi.vertical"
}]
type: "bi.vertical",
}],
},
searcher: {
type: "bi.button_group",
behaviors: {
redmark: function () {
return true;
}
},
},
items: [],
layouts: [{
type: "bi.vertical"
}]
}
type: "bi.vertical",
}],
},
});
},
@ -51,12 +51,12 @@ BI.SearcherView = BI.inherit(BI.Pane, {
behaviors: {
redmark: function () {
return true;
}
},
},
layouts: [{
type: "bi.vertical"
type: "bi.vertical",
}],
value: o.value
value: o.value,
});
this.matcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -71,8 +71,8 @@ BI.SearcherView = BI.inherit(BI.Pane, {
items: [{
type: "bi.layout",
height: 1,
cls: "searcher-view-spliter bi-background"
}]
cls: "searcher-view-spliter bi-background",
}],
});
this.searcher = BI.createWidget(o.searcher, {
type: "bi.button_group",
@ -80,12 +80,12 @@ BI.SearcherView = BI.inherit(BI.Pane, {
behaviors: {
redmark: function () {
return true;
}
},
},
layouts: [{
type: "bi.vertical"
type: "bi.vertical",
}],
value: o.value
value: o.value,
});
this.searcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -97,7 +97,7 @@ BI.SearcherView = BI.inherit(BI.Pane, {
BI.createWidget({
type: "bi.vertical",
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 () {
return this.matcher.getAllButtons().length > 0;
}
},
});
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({
type: "bi.list_view",
el: {
type: "bi.left"
type: "bi.left",
},
items: BI.map(BI.range(0, 100), function (i, item) {
return BI.extend({}, item, {
type: "bi.label",
width: 200,
height: 200,
text: (i + 1)
text: (i + 1),
});
})
}),
});
a.destroy();
});
@ -38,9 +38,9 @@ describe("ListView && VirtualList", function () {
return BI.extend({}, item, {
type: "bi.label",
height: 30,
text: (i + 1) + "." + item.text
text: (i + 1) + "." + item.text,
});
})
}),
});
a.destroy();
});

10
src/base/list/listview.js

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

14
src/base/list/virtualgrouplist.js

@ -17,7 +17,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
el: {},
itemFormatter: function (item, index) {
return item;
}
},
};
},
@ -34,7 +34,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
},
}, {
type: "bi.virtual_group",
height: o.rowHeight * o.items.length,
@ -43,15 +43,15 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
},
layouts: [BI.extend({
type: "bi.vertical",
scrolly: false
}, o.el)]
scrolly: false,
}, o.el)],
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
},
}],
element: this
element: this,
};
},
@ -178,7 +178,7 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, {
populate: function (items) {
this._populate(items);
}
},
});
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: [],
itemFormatter: function (item, index) {
return item;
}
},
};
},
@ -33,19 +33,19 @@ BI.VirtualList = BI.inherit(BI.Widget, {
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
},
}, {
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
},
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
}]
},
}],
};
},
@ -203,7 +203,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
destroyed: function () {
this.cache = {};
this.renderedIndex = -1;
}
},
});
BI.shortcut("bi.virtual_list", BI.VirtualList);

40
src/base/pager/pager.js

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

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

@ -19,50 +19,50 @@
tgap: 0,
bgap: 0,
py: "",
highLight: false
highLight: false,
},
render: function () {
var self = this, o = this.options;
if (o.hgap + o.lgap > 0) {
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) {
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) {
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) {
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)) {
this.element.css({ lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height });
this.element.css({ lineHeight: BI.isNumber(o.height) ? (o.height / BI.pixRatio + BI.pixUnit) : o.height, });
}
if (BI.isWidthOrHeight(o.lineHeight)) {
this.element.css({ lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight });
this.element.css({ lineHeight: BI.isNumber(o.lineHeight) ? (o.lineHeight / BI.pixRatio + BI.pixUnit) : o.lineHeight, });
}
if (BI.isWidthOrHeight(o.maxWidth)) {
this.element.css({ maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth });
this.element.css({ maxWidth: BI.isNumber(o.maxWidth) ? (o.maxWidth / BI.pixRatio + BI.pixUnit) : o.maxWidth, });
}
this.element.css({
textAlign: o.textAlign,
whiteSpace: this._getTextWrap(),
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) {
this.text = BI.createWidget({
type: "bi.layout",
tagName: "span"
tagName: "span",
});
this.text.element.click(function (e) {
o.handler.call(self, self.getValue(), self, e);
@ -70,7 +70,7 @@
BI.createWidget({
type: "bi.default",
element: this,
items: [this.text]
items: [this.text],
});
} else {
this.text = this;
@ -154,7 +154,7 @@
BI.Text.superclass.setText.apply(this, arguments);
this.options.text = text;
this._doRedMark(this.options.keyword);
}
},
});
var formatters = [];
BI.Text.addTextFormatter = function (formatter) {

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

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

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

@ -5,11 +5,12 @@
BI.HtmlLabel = BI.inherit(BI.AbstractLabel, {
props: {
baseCls: "bi-html-label"
baseCls: "bi-html-label",
},
_createJson: function () {
var o = this.options;
return {
type: "bi.html",
textAlign: o.textAlign,
@ -17,9 +18,9 @@ BI.HtmlLabel = BI.inherit(BI.AbstractLabel, {
lineHeight: o.textHeight,
text: o.text,
value: o.value,
handler: o.handler
handler: o.handler,
};
}
},
});
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 () {
var o = this.options;
this.element.css({
textAlign: "center"
textAlign: "center",
});
this.icon = BI.createWidget({
type: "bi.icon",
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)) {
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,
tgap: o.tgap,
bgap: o.bgap,
items: [this.icon]
items: [this.icon],
});
} else {
this.element.css("lineHeight", "1");
@ -52,9 +52,9 @@ BI.IconLabel = BI.inherit(BI.Single, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
items: [this.icon]
items: [this.icon],
});
}
}
},
});
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: {
baseCls: "bi-label",
py: "",
keyword: ""
keyword: "",
},
doRedMark: function () {
@ -16,7 +16,7 @@ BI.Label = BI.inherit(BI.AbstractLabel, {
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
}
},
});
BI.shortcut("bi.label", BI.Label);

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

@ -5,15 +5,14 @@
*/
describe("LinkTest", function () {
/**
* test_author_windy
*/
it("link", function () {
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();
});
});

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

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

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

@ -9,14 +9,15 @@
BI.Tip = BI.inherit(BI.Single, {
_defaultConfig: function () {
var conf = BI.Tip.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-tip",
zIndex: BI.zIndex_tip
zIndex: BI.zIndex_tip,
});
},
_init: function () {
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;
this.element.css({
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);
var fn = function (e) {
function fn(e) {
e.stopPropagation();
e.stopEvent();
return false;
};
}
this.element.bind({
click: fn,
mousedown: fn,
@ -46,7 +47,7 @@ BI.Toast = BI.inherit(BI.Tip, {
mouseover: fn,
mouseenter: fn,
mouseleave: fn,
mousemove: fn
mousemove: fn,
});
var cls;
switch (o.level) {
@ -68,9 +69,9 @@ BI.Toast = BI.inherit(BI.Tip, {
break;
}
var hasCloseIcon = function () {
function hasCloseIcon() {
return o.closable === true || (o.closable === null && o.autoClose === false);
};
}
var items = [{
type: "bi.icon_label",
cls: cls + " toast-icon",
@ -81,7 +82,7 @@ BI.Toast = BI.inherit(BI.Tip, {
whiteSpace: "normal",
text: o.text,
textHeight: o.textHeight,
textAlign: "left"
textAlign: "left",
},
}];
@ -106,13 +107,13 @@ BI.Toast = BI.inherit(BI.Tip, {
hgap: o.hgap,
vgap: o.vgap,
innerHgap: o.innerHgap,
columnSize: columnSize
columnSize: columnSize,
};
},
beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY);
}
},
});
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast);

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

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

Loading…
Cancel
Save