young 7 years ago
parent
commit
9e7276f979
  1. 162
      bi/base.js
  2. 97
      bi/case.js
  3. 4
      bi/core.css
  4. 358
      bi/core.js
  5. 53
      bi/widget.js
  6. 162
      docs/base.js
  7. 97
      docs/case.js
  8. 4
      docs/core.css
  9. 358
      docs/core.js
  10. 53
      docs/widget.js
  11. 25
      src/base/collection/collection.js
  12. 6
      src/base/combination/combo.js
  13. 10
      src/base/combination/expander.js
  14. 7
      src/base/combination/group.button.js
  15. 5
      src/base/combination/group.combo.js
  16. 4
      src/base/combination/loader.js
  17. 8
      src/base/combination/switcher.js
  18. 25
      src/base/grid/grid.js
  19. 5
      src/base/layer/layer.popup.js
  20. 11
      src/base/single/button/button.basic.js
  21. 6
      src/base/single/button/buttons/button.js
  22. 4
      src/base/single/editor/editor.code.js
  23. 6
      src/base/single/editor/editor.js
  24. 5
      src/base/single/editor/editor.multifile.js
  25. 6
      src/base/single/editor/editor.textarea.js
  26. 4
      src/base/single/input/file.js
  27. 4
      src/base/single/input/input.js
  28. 8
      src/base/table/table.collection.js
  29. 8
      src/base/table/table.grid.js
  30. 5
      src/base/tree/customtree.js
  31. 5
      src/case/button/icon/icon.change.js
  32. 5
      src/case/button/item.multiselect.js
  33. 4
      src/case/colorchooser/colorchooser.js
  34. 4
      src/case/combo/bubblecombo/combo.bubble.js
  35. 5
      src/case/combo/editoriconcheckcombo/combo.editoriconcheck.js
  36. 5
      src/case/combo/iconcombo/combo.icon.js
  37. 5
      src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js
  38. 5
      src/case/combo/textvaluecheckcombo/combo.textvaluechecksmall.js
  39. 5
      src/case/combo/textvaluecombo/combo.textvalue.js
  40. 5
      src/case/combo/textvaluecombo/combo.textvaluesmall.js
  41. 5
      src/case/combo/textvaluedownlistcombo/combo.textvaluedownlist.js
  42. 6
      src/case/editor/editor.search.js
  43. 5
      src/case/editor/editor.state.js
  44. 5
      src/case/editor/editor.state.simple.js
  45. 5
      src/case/editor/editor.text.js
  46. 4
      src/case/segment/segment.js
  47. 7
      src/case/toolbar/toolbar.multiselect.js
  48. 6
      src/case/trigger/trigger.text.js
  49. 6
      src/case/trigger/trigger.text.small.js
  50. 249
      src/core/alias.js
  51. 17
      src/core/func/dom.js
  52. 3
      src/core/proto/date.js
  53. 2
      src/core/view.js
  54. 77
      src/core/widget.js
  55. 6
      src/core/wrapper/layout.js
  56. 2
      src/core/wrapper/layout/layout.card.js
  57. 4
      src/css/core/utils/common.css
  58. 2
      src/less/core/utils/common.less
  59. 4
      src/widget/multiselect/multiselect.loader.js
  60. 4
      src/widget/multiselect/multiselect.popup.view.js
  61. 4
      src/widget/multiselect/multiselect.trigger.js
  62. 4
      src/widget/multiselect/search/multiselect.search.loader.js
  63. 4
      src/widget/multiselect/trigger/editor.multiselect.js
  64. 4
      src/widget/multiselect/trigger/searcher.multiselect.js
  65. 5
      src/widget/multistringlist/multistringlist.js
  66. 4
      src/widget/multitree/multi.tree.combo.js
  67. 4
      src/widget/multitree/multi.tree.popup.js
  68. 4
      src/widget/multitree/trigger/searcher.multi.tree.js
  69. 5
      src/widget/multitreelist/multitreelist.js
  70. 7
      src/widget/numericalinterval/numericalinterval.js

162
bi/base.js

@ -881,9 +881,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
return this.options.text;
},
setEnable: function (b) {
BI.BasicButton.superclass.setEnable.apply(this, arguments);
if (!b) {
_setEnable: function (enable) {
BI.BasicButton.superclass._setEnable.apply(this, arguments);
if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
if (!enable) {
if (this.options.shadow) {
this.$mask && this.$mask.setVisible(false);
}
@ -1166,13 +1171,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
},
setEnable: function (b) {
BI.ButtonGroup.superclass.setEnable.apply(this, arguments);
BI.each(this.buttons, function (i, item) {
item.setEnable(b);
});
},
setNotSelectedValue: function (v) {
v = BI.isArray(v) ? v : [v];
BI.each(this.buttons, function (i, item) {
@ -2511,15 +2509,15 @@ BI.Canvas = BI.inherit(BI.Widget, {
}
});
BI.shortcut("bi.canvas", BI.Canvas);/**
* Collection
* CollectionView
*
* Created by GUY on 2016/1/15.
* @class BI.Collection
* @class BI.CollectionView
* @extends BI.Widget
*/
BI.Collection = BI.inherit(BI.Widget, {
BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-collection",
width: 400,
height: 300,
@ -2535,7 +2533,7 @@ BI.Collection = BI.inherit(BI.Widget, {
},
_init: function () {
BI.Collection.superclass._init.apply(this, arguments);
BI.CollectionView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.renderedCells = [];
this.renderedKeys = [];
@ -2554,7 +2552,7 @@ BI.Collection = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender();
self.fireEvent(BI.Collection.EVENT_SCROLL, {
self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
});
@ -2639,7 +2637,7 @@ BI.Collection = BI.inherit(BI.Widget, {
return;
}
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top);
var renderedCells = [], renderedKeys = [];
var renderedCells = [], renderedKeys = [], renderedWidgets = {};
//存储所有的left和top
var lefts = {}, tops = {};
for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
@ -2722,6 +2720,7 @@ BI.Collection = BI.inherit(BI.Widget, {
}
renderedKeys.push(datum.index);
renderedWidgets[i] = child;
}
//已存在的, 需要添加的和需要删除的
var existSet = {}, addSet = {}, deleteArray = [];
@ -2742,13 +2741,17 @@ BI.Collection = BI.inherit(BI.Widget, {
deleteArray.push(i);
});
BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy();
//性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
});
var addedItems = [];
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
@ -2859,8 +2862,8 @@ BI.Collection = BI.inherit(BI.Widget, {
this._populate();
}
});
BI.Collection.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.Collection);/**
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.CollectionView);/**
* @class BI.Combo
* @extends BI.Widget
*/
@ -3187,10 +3190,8 @@ BI.Combo = BI.inherit(BI.Widget, {
this.combo.populate.apply(this.combo, arguments);
},
setEnable: function (arg) {
BI.Combo.superclass.setEnable.apply(this, arguments);
this.combo && this.combo.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
_setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},
@ -3299,7 +3300,7 @@ BI.Expander = BI.inherit(BI.Widget, {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND);
}
if(type === BI.Events.COLLAPSE) {
if (type === BI.Events.COLLAPSE) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_COLLAPSE);
}
@ -3456,11 +3457,9 @@ BI.Expander = BI.inherit(BI.Widget, {
this.expander.populate.apply(this.expander, arguments);
},
setEnable: function (arg) {
BI.Expander.superclass.setEnable.apply(this, arguments);
this.expander && this.expander.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
!arg && this._hideView();
_setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},
setValue: function (v) {
@ -3620,11 +3619,6 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
})
},
setEnable: function (b) {
BI.ComboGroup.superclass.setEnable.apply(this, arguments);
this.combo && this.combo.setEnable(b);
},
getValue: function () {
return this.combo.getValue();
},
@ -3915,10 +3909,6 @@ BI.Loader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (v) {
this.button_group.setEnable(v);
},
doBehavior: function () {
this.button_group.doBehavior.apply(this.button_group, arguments);
},
@ -4624,11 +4614,9 @@ BI.Switcher = BI.inherit(BI.Widget, {
this.switcher.populate.apply(this.switcher, arguments);
},
setEnable: function (arg) {
BI.Switcher.superclass.setEnable.apply(this, arguments);
this.switcher && this.switcher.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
!arg && this._hideView();
_setEnable: function (arg) {
BI.Switcher.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},
setValue: function (v) {
@ -14646,15 +14634,15 @@ $.extend(BI, {
};
}()
});/**
* Grid
* GridView
*
* Created by GUY on 2016/1/11.
* @class BI.Grid
* @class BI.GridView
* @extends BI.Widget
*/
BI.Grid = BI.inherit(BI.Widget, {
BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid-view",
width: 400,
height: 300,
@ -14673,7 +14661,7 @@ BI.Grid = BI.inherit(BI.Widget, {
},
_init: function () {
BI.Grid.superclass._init.apply(this, arguments);
BI.GridView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.renderedCells = [];
this.renderedKeys = [];
@ -14692,7 +14680,7 @@ BI.Grid = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender();
self.fireEvent(BI.Grid.EVENT_SCROLL, {
self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
});
@ -14768,7 +14756,7 @@ BI.Grid = BI.inherit(BI.Widget, {
return;
}
var renderedCells = [], renderedKeys = [];
var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -14819,6 +14807,7 @@ BI.Grid = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key);
renderedWidgets[i] = child;
}
}
//已存在的, 需要添加的和需要删除的
@ -14840,13 +14829,17 @@ BI.Grid = BI.inherit(BI.Widget, {
deleteArray.push(i);
});
BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy();
//性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
});
var addedItems = [];
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
@ -14965,8 +14958,8 @@ BI.Grid = BI.inherit(BI.Widget, {
this._populate();
}
});
BI.Grid.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.Grid);/**
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.GridView);/**
* floatBox弹出层
* @class BI.FloatBox
* @extends BI.Widget
@ -15271,11 +15264,6 @@ BI.PopupView = BI.inherit(BI.Widget, {
this.view.element.css({"max-height": (h - tbHeight - tabHeight - toolHeight - 2) + "px"})
},
setEnable: function (arg) {
BI.PopupView.superclass.setEnable.apply(this, arguments);
this.view && this.view.setEnable(arg);
},
setValue: function (selectedValues) {
this.tab && this.tab.setValue(selectedValues);
this.button_group.setValue(selectedValues);
@ -16082,12 +16070,6 @@ BI.shortcut("bi.image_button", BI.ImageButton);(function ($) {
}
},
setEnable: function (b) {
BI.Button.superclass.setEnable.apply(this, arguments);
// this.text.setEnable(b);
// this.icon && this.icon.setEnable(b);
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
@ -17460,8 +17442,8 @@ BI.CodeEditor = BI.inherit(BI.Single, {
}
},
setEnable: function (b) {
BI.CodeEditor.superclass.setEnable.apply(this, arguments);
_setEnable: function (b) {
BI.CodeEditor.superclass._setEnable.apply(this, arguments);
this.editor.setOption("readOnly", b === true ? false : "nocursor")
},
@ -17832,12 +17814,6 @@ BI.Editor = BI.inherit(BI.Single, {
isValid: function () {
return this.editor.isValid();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
this.watermark && this.watermark.setEnable(b);
}
});
BI.Editor.EVENT_CHANGE = "EVENT_CHANGE";
@ -17940,11 +17916,6 @@ BI.MultifileEditor = BI.inherit(BI.Single, {
reset: function () {
this.file.reset();
},
setEnable: function (enable) {
BI.MultiFile.superclass.setEnable.apply(this, arguments);
this.file.setEnable(enable);
}
});
BI.MultifileEditor.EVENT_CHANGE = "MultifileEditor.EVENT_CHANGE";
@ -18107,12 +18078,6 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
BI.TextAreaEditor.superclass.setValid.apply(this, arguments);
this.content.setValid(b);
this.watermark && this.watermark.setValid(b);
},
setEnable: function (b) {
BI.TextAreaEditor.superclass.setEnable.apply(this, arguments);
this.content.setEnable(b);
this.watermark && this.watermark.setEnable(b);
}
});
BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE";
@ -18847,8 +18812,8 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/**
this.wrap.attachNum = 0;
},
setEnable: function (enable) {
BI.File.superclass.setEnable.apply(this, arguments);
_setEnable: function (enable) {
BI.File.superclass._setEnable.apply(this, arguments);
if (enable === true) {
this.element.attr("disabled", "disabled");
} else {
@ -19120,8 +19085,8 @@ BI.Input = BI.inherit(BI.Single, {
}
},
setEnable: function (b) {
BI.Input.superclass.setEnable.apply(this, [b]);
_setEnable: function (b) {
BI.Input.superclass._setEnable.apply(this, [b]);
this.element[0].disabled = !b;
}
});
@ -28603,7 +28568,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topLeftItems[index];
}
});
this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -28614,7 +28579,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topRightItems[index];
}
});
this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -28625,7 +28590,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomLeftItems[index];
}
});
this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomRightCollection.setScrollTop(scroll.scrollTop);
self.topLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -28637,7 +28602,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomRightItems[index];
}
});
this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomLeftCollection.setScrollTop(scroll.scrollTop);
self.topRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -29386,7 +29351,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter,
});
this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -29396,7 +29361,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter,
});
this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -29406,7 +29371,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter,
});
this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomRightGrid.setScrollTop(scroll.scrollTop);
self.topLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -29417,7 +29382,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter,
});
this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomLeftGrid.setScrollTop(scroll.scrollTop);
self.topRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -32553,11 +32518,6 @@ BI.CustomTree = BI.inherit(BI.Widget, {
this.initTree(this.options.items);
},
setEnable: function (v) {
BI.CustomTree.superclass.setEnable.apply(this, arguments);
this.tree.setEnable(v)
},
_formatItems: function (nodes) {
var self = this, o = this.options;
nodes = BI.Tree.transformToTreeFormat(nodes);

97
bi/case.js

@ -77,11 +77,6 @@ BI.IconChangeButton = BI.inherit(BI.Single, {
this.element.removeClass(o.iconClass).addClass(cls);
o.iconClass = cls;
}
},
setEnable: function (b) {
BI.IconChangeButton.superclass.setEnable.apply(this, arguments);
this.button.setEnable(b);
}
});
BI.IconChangeButton.EVENT_CHANGE = "IconChangeButton.EVENT_CHANGE";
@ -197,11 +192,6 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
}))));
},
setEnable: function (v) {
BI.MultiSelectItem.superclass.setEnable.apply(this, arguments);
this.checkbox.setEnable(v);
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
@ -2373,10 +2363,6 @@ BI.ColorChooser = BI.inherit(BI.Widget, {
return this.combo.isViewVisible();
},
setEnable: function (v) {
this.combo.setEnable(v)
},
setValue: function (color) {
this.combo.setValue(color);
},
@ -3600,10 +3586,6 @@ BI.BubbleCombo = BI.inherit(BI.Widget, {
isViewVisible: function () {
return this.combo.isViewVisible();
},
setEnable: function (v) {
this.combo.setEnable(!!v);
}
});
@ -3799,11 +3781,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
this.editorIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.EditorIconCheckCombo.superclass.setEnable.apply(this, arguments);
this.editorIconCheckCombo.setEnable(v);
},
getValue: function () {
return this.trigger.getValue();
},
@ -4141,11 +4118,6 @@ BI.IconCombo = BI.inherit(BI.Widget, {
this.iconCombo.setValue(v);
},
setEnable: function (v) {
BI.IconCombo.superclass.setEnable.apply(this, arguments);
this.iconCombo.setEnable(v);
},
getValue: function () {
return this.iconCombo.getValue();
},
@ -4431,11 +4403,6 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, {
this.textIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.TextValueCheckCombo.superclass.setEnable.apply(this, arguments);
this.textIconCheckCombo.setEnable(v);
},
setWarningTitle: function (title) {
this.trigger.setWarningTitle(title);
},
@ -4503,11 +4470,6 @@ BI.SmallTextValueCheckCombo = BI.inherit(BI.Widget, {
this.SmallTextIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.SmallTextValueCheckCombo.superclass.setEnable.apply(this, arguments);
this.SmallTextIconCheckCombo.setEnable(v);
},
getValue: function () {
return this.SmallTextIconCheckCombo.getValue();
},
@ -4632,11 +4594,6 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
this.textIconCombo.setValue(v);
},
setEnable: function (v) {
BI.TextValueCombo.superclass.setEnable.apply(this, arguments);
this.textIconCombo.setEnable(v);
},
getValue: function () {
return this.textIconCombo.getValue();
},
@ -4702,11 +4659,6 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, {
this.SmallTextValueCombo.setValue(v);
},
setEnable: function (v) {
BI.SmallTextValueCombo.superclass.setEnable.apply(this, arguments);
this.SmallTextValueCombo.setEnable(v);
},
getValue: function () {
return this.SmallTextValueCombo.getValue();
},
@ -4840,11 +4792,6 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, {
this.trigger.setValue(v.childValue || v.value);
},
setEnable: function (v) {
BI.TextValueDownListCombo.superclass.setEnable.apply(this, arguments);
this.combo.setEnable(v);
},
getValue: function () {
var v = this.combo.getValue()[0];
return [v.childValue || v.value];
@ -5248,12 +5195,6 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
isValid: function () {
return this.editor.isValid();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
this.clear.setEnable(b);
}
});
BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE";
@ -6186,11 +6127,6 @@ BI.StateEditor = BI.inherit(BI.Widget, {
this.editor.setValue(k);
},
setEnable: function (v) {
this.text.setEnable(v);
this.editor.setEnable(v);
},
getValue: function () {
return this.editor.getValue();
},
@ -6464,11 +6400,6 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
this.editor.setValue(k);
},
setEnable: function(v){
this.text.setEnable(v);
this.editor.setEnable(v);
},
getValue: function () {
return this.editor.getValue();
},
@ -6666,11 +6597,6 @@ BI.TextEditor = BI.inherit(BI.Widget, {
getValue: function () {
return this.editor.getValue();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
}
});
BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE";
@ -8714,10 +8640,6 @@ BI.Segment = BI.inherit(BI.Widget, {
this.buttonGroup.setEnabledValue(v);
},
setEnable: function (v) {
this.buttonGroup.setEnable(v);
},
getValue: function () {
return this.buttonGroup.getValue();
}
@ -10452,13 +10374,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
},
setEnable: function (b) {
BI.MultiSelectBar.superclass.setEnable.apply(this, arguments);
this.checkbox.setEnable(b);
this.half.setEnable(b);
this.text.setEnable(b);
}
});
BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE";
@ -11157,12 +11072,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
});
},
setEnable: function (v) {
BI.TextTrigger.superclass.setEnable.apply(this, arguments);
this.trigerButton.setEnable(v);
this.text.setEnable(v);
},
setValue: function (value) {
this.text.setValue(value);
this.text.setTitle(value);
@ -11327,12 +11236,6 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
});
},
setEnable: function (v) {
BI.SmallTextTrigger.superclass.setEnable.apply(this, arguments);
this.trigerButton.setEnable(v);
this.text.setEnable(v);
},
setValue: function (value) {
this.text.setValue(value);
},

4
bi/core.css

@ -3078,8 +3078,8 @@ i {
}
.bi-z-index-mask {
color: #ffffff;
background-color: rgba(26, 26, 26, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d1a1a1a,endColorstr=#4d1a1a1a);
background-color: rgba(26, 26, 26, 0.5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#801a1a1a,endColorstr=#801a1a1a);
}
.bi-list-item:hover,
.bi-list-item.hover {

358
bi/core.js

@ -3042,6 +3042,9 @@ if (!window.BI) {
}
});
})(jQuery);;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
@ -3102,124 +3105,6 @@ if (!window.BI) {
return text;
}
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
function date2Str(date, format) {
if (!date) {
return '';
}
// O(len(format))
var len = format.length, result = '';
if (len > 0) {
var flagch = format.charAt(0), start = 0, str = flagch;
for (var i = 1; i < len; i++) {
var ch = format.charAt(i);
if (flagch !== ch) {
result += compileJFmt({
'char': flagch,
'str': str,
'len': i - start
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
case 'M': //月
if (len > 2) {
str = Date._MN[date.getMonth()];
} else if (len < 2) {
str = date.getMonth() + 1;
} else {
str = String.leftPad(date.getMonth() + 1 + '', 2, '0');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
};
/**
* 数字格式
*/
@ -3262,7 +3147,8 @@ if (!window.BI) {
} else {
return left + '.' + right;
}
};
}
/**
* 处理小数点右边小数部分
* @param tright 右边内容
@ -3306,7 +3192,7 @@ if (!window.BI) {
if (newnum.length > orilen) {
newnum = newnum.substr(1);
} else {
newnum = BI.leftPad(newnum, orilen, '0');
newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false;
}
right = right.replace(/^[0-9]+/, newnum);
@ -3567,7 +3453,7 @@ if (!window.BI) {
return o;
})(jo);
}
};
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
@ -3609,15 +3495,122 @@ if (!window.BI) {
return text;
};
BI.leftPad = function (val, size, ch) {
var result = String(val);
if (!ch) {
ch = " ";
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
BI.date2Str = function (date, format) {
if (!date) {
return '';
}
while (result.length < size) {
result = ch + result;
// O(len(format))
var len = format.length, result = '';
if (len > 0) {
var flagch = format.charAt(0), start = 0, str = flagch;
for (var i = 1; i < len; i++) {
var ch = format.charAt(i);
if (flagch !== ch) {
result += compileJFmt({
'char': flagch,
'str': str,
'len': i - start
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
case 'M': //月
if (len > 2) {
str = Date._MN[date.getMonth()];
} else if (len < 2) {
str = date.getMonth() + 1;
} else {
str = String.leftPad(date.getMonth() + 1 + '', 2, '0');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
return result.toString();
};
BI.object2Number = function (value) {
@ -4432,17 +4425,18 @@ BI.Widget = BI.inherit(BI.OB, {
_initVisualEffects: function () {
var o = this.options;
if (o.invisible) {
this.element.hide();
//用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none");
}
if (o.disabled || o.invalid) {
BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
}, this));
// BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
// }, this));
}
},
@ -4490,6 +4484,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._isMounted = true;
this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
widget._mount && widget._mount();
});
this.mounted && this.mounted();
@ -4497,17 +4492,6 @@ BI.Widget = BI.inherit(BI.OB, {
_mountChildren: null,
_unMount: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.purgeListeners();
this.destroyed && this.destroyed();
},
isMounted: function () {
return this._isMounted;
},
@ -4522,12 +4506,23 @@ BI.Widget = BI.inherit(BI.OB, {
this._initElementHeight();
},
setEnable: function (enable) {
_setEnable: function (enable) {
if (enable === true) {
this.options.disabled = false;
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.options.disabled = true;
}
//递归将所有子组件使能
BI.each(this._children, function (i, child) {
child._setEnable && child._setEnable(enable);
});
},
setEnable: function (enable) {
this._setEnable(enable);
if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
},
@ -4587,7 +4582,7 @@ BI.Widget = BI.inherit(BI.OB, {
},
getWidgetByName: function (name) {
if (!BI.isKey(name) || name == this.getName()) {
if (!BI.isKey(name) || name === this.getName()) {
return this;
}
name = name + "";
@ -4687,6 +4682,21 @@ BI.Widget = BI.inherit(BI.OB, {
this.setVisible(true);
},
__d: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
},
_unMount: function () {
this.__d();
this.purgeListeners();
this.destroyed && this.destroyed();
},
isolate: function () {
if (this._parent) {
this._parent.removeWidget(this);
@ -4702,13 +4712,15 @@ BI.Widget = BI.inherit(BI.OB, {
this.element.empty();
},
_destroy: function () {
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.purgeListeners();
},
destroy: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
@ -5358,7 +5370,7 @@ BI.View = BI.inherit(BI.V, {
BI.each(cardNames, function (i, name) {
delete self._cards[name];
});
this._cardLayouts[key] && this._cardLayouts[key].destroy();
this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this;
},
@ -6007,7 +6019,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */
Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@ -6481,7 +6492,8 @@ Date.parseDateTime = function (str, fmt) {
return new Date(y, m, d, hr, min, sec);
}
return today;
};/*
};
/*
* 给jQuery.Event对象添加的工具方法
*/
$.extend($.Event.prototype, {
@ -11196,7 +11208,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items = newItems;
this._children = newChildren;
BI.each(deleted, function (i, c) {
c.destroy();
c._destroy();
});
},
@ -11221,7 +11233,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} else {
w.element.prependTo(this._getWrapper());
}
del.destroy();
del._destroy();
w._mount();
},
@ -11308,7 +11320,7 @@ BI.Layout = BI.inherit(BI.Widget, {
}
o.items.splice(items.length);
BI.each(deleted, function (i, w) {
w.destroy();
w._destroy();
})
} else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) {
@ -13037,7 +13049,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var child = this._children[cardName];
this._deleteCardByName(cardName);
child && child.destroy();
child && child._destroy();
},
addCardByName: function (cardName, cardItem) {
@ -16272,7 +16284,8 @@ BI.extend(jQuery, {
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + extraHeight;
@ -16320,7 +16333,8 @@ BI.extend(jQuery, {
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight;
@ -16346,7 +16360,8 @@ BI.extend(jQuery, {
getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
if ($.isBottomSpaceEnough(combo, popup, extraHeight)) {
return $.getBottomPosition(combo, popup, extraHeight);
}
@ -16369,7 +16384,8 @@ BI.extend(jQuery, {
getCenterAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var left;
if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) {
left = windowBounds.width - popupBounds.width;
@ -16386,7 +16402,8 @@ BI.extend(jQuery, {
getMiddleAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top;
if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) {
top = windowBounds.height - popupBounds.height;
@ -16582,7 +16599,7 @@ BI.extend(jQuery, {
}
break;
}
if(needAdaptHeight === true) {
if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight));
}
return position;
@ -16613,6 +16630,7 @@ $(function () {
};
}
var t, text, py;
keyword = keyword + "";
keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) {

53
bi/widget.js

@ -10048,10 +10048,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (arg) {
this.button_group.setEnable(arg);
},
resetHeight: function (h) {
this.button_group.resetHeight(h);
},
@ -10138,10 +10134,6 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
this.popupView.populate.apply(this.popupView, arguments);
},
setEnable: function (arg) {
this.popupView.setEnable(arg);
},
resetHeight: function (h) {
this.popupView.resetHeight(h);
},
@ -10291,10 +10283,6 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
this.numberCounter.setValue(ob);
},
setEnable: function (v) {
this.searcher.setEnable(v);
},
getKey: function () {
return this.searcher.getKey();
},
@ -10454,10 +10442,6 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (arg) {
this.button_group.setEnable(arg);
},
resetHeight: function (h) {
this.button_group.resetHeight(h);
},
@ -10703,10 +10687,6 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, {
this.editor.setValue(v);
},
setEnable: function(v){
this.editor.setEnable(v);
},
getValue: function () {
var v = this.editor.getState();
if (BI.isArray(v) && v.length > 0) {
@ -10866,10 +10846,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
return this.searcher.getValue();
},
setEnable: function (v) {
this.editor.setEnable(v);
},
populate: function (items) {
this.searcher.populate.apply(this.searcher, arguments);
}
@ -11267,11 +11243,6 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this.trigger.getSearcher().adjustView();
},
setEnable: function (v) {
this.trigger.setEnable(v);
this.popup.setEnable(v);
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
@ -11649,10 +11620,6 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
this.combo.hideView();
},
setEnable: function (v) {
this.combo.setEnable(v);
},
setValue: function (v) {
this.storeValue.value = v || {};
this.combo.setValue({
@ -11752,10 +11719,6 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, {
return this.tree.hasChecked();
},
setEnable: function (arg) {
this.popupView.setEnable(arg);
},
resetHeight: function (h) {
this.popupView.resetHeight(h);
},
@ -12030,10 +11993,6 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
return this.editor.getValue();
},
setEnable: function(v){
this.editor.setEnable(v);
},
getValue: function () {
return this.searcher.getValue();
},
@ -12200,11 +12159,6 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
this.trigger.getSearcher().adjustView();
},
setEnable: function (v) {
this.trigger.setEnable(v);
this.popup.setEnable(v);
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({
@ -12704,13 +12658,6 @@ BI.NumericalInterval = BI.inherit(BI.Single, {
return this.options.validation === "valid";
},
setEnable: function (b) {
this.smallEditor.setEnable(b);
this.smallCombo.setEnable(b);
this.bigEditor.setEnable(b);
this.bigCombo.setEnable(b);
},
setMinEnable: function (b) {
this.smallEditor.setEnable(b);
},

162
docs/base.js

@ -881,9 +881,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
return this.options.text;
},
setEnable: function (b) {
BI.BasicButton.superclass.setEnable.apply(this, arguments);
if (!b) {
_setEnable: function (enable) {
BI.BasicButton.superclass._setEnable.apply(this, arguments);
if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
if (!enable) {
if (this.options.shadow) {
this.$mask && this.$mask.setVisible(false);
}
@ -1166,13 +1171,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
},
setEnable: function (b) {
BI.ButtonGroup.superclass.setEnable.apply(this, arguments);
BI.each(this.buttons, function (i, item) {
item.setEnable(b);
});
},
setNotSelectedValue: function (v) {
v = BI.isArray(v) ? v : [v];
BI.each(this.buttons, function (i, item) {
@ -2511,15 +2509,15 @@ BI.Canvas = BI.inherit(BI.Widget, {
}
});
BI.shortcut("bi.canvas", BI.Canvas);/**
* Collection
* CollectionView
*
* Created by GUY on 2016/1/15.
* @class BI.Collection
* @class BI.CollectionView
* @extends BI.Widget
*/
BI.Collection = BI.inherit(BI.Widget, {
BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-collection",
width: 400,
height: 300,
@ -2535,7 +2533,7 @@ BI.Collection = BI.inherit(BI.Widget, {
},
_init: function () {
BI.Collection.superclass._init.apply(this, arguments);
BI.CollectionView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.renderedCells = [];
this.renderedKeys = [];
@ -2554,7 +2552,7 @@ BI.Collection = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender();
self.fireEvent(BI.Collection.EVENT_SCROLL, {
self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
});
@ -2639,7 +2637,7 @@ BI.Collection = BI.inherit(BI.Widget, {
return;
}
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top);
var renderedCells = [], renderedKeys = [];
var renderedCells = [], renderedKeys = [], renderedWidgets = {};
//存储所有的left和top
var lefts = {}, tops = {};
for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
@ -2722,6 +2720,7 @@ BI.Collection = BI.inherit(BI.Widget, {
}
renderedKeys.push(datum.index);
renderedWidgets[i] = child;
}
//已存在的, 需要添加的和需要删除的
var existSet = {}, addSet = {}, deleteArray = [];
@ -2742,13 +2741,17 @@ BI.Collection = BI.inherit(BI.Widget, {
deleteArray.push(i);
});
BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy();
//性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
});
var addedItems = [];
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
@ -2859,8 +2862,8 @@ BI.Collection = BI.inherit(BI.Widget, {
this._populate();
}
});
BI.Collection.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.Collection);/**
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.CollectionView);/**
* @class BI.Combo
* @extends BI.Widget
*/
@ -3187,10 +3190,8 @@ BI.Combo = BI.inherit(BI.Widget, {
this.combo.populate.apply(this.combo, arguments);
},
setEnable: function (arg) {
BI.Combo.superclass.setEnable.apply(this, arguments);
this.combo && this.combo.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
_setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},
@ -3299,7 +3300,7 @@ BI.Expander = BI.inherit(BI.Widget, {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND);
}
if(type === BI.Events.COLLAPSE) {
if (type === BI.Events.COLLAPSE) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_COLLAPSE);
}
@ -3456,11 +3457,9 @@ BI.Expander = BI.inherit(BI.Widget, {
this.expander.populate.apply(this.expander, arguments);
},
setEnable: function (arg) {
BI.Expander.superclass.setEnable.apply(this, arguments);
this.expander && this.expander.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
!arg && this._hideView();
_setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},
setValue: function (v) {
@ -3620,11 +3619,6 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
})
},
setEnable: function (b) {
BI.ComboGroup.superclass.setEnable.apply(this, arguments);
this.combo && this.combo.setEnable(b);
},
getValue: function () {
return this.combo.getValue();
},
@ -3915,10 +3909,6 @@ BI.Loader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (v) {
this.button_group.setEnable(v);
},
doBehavior: function () {
this.button_group.doBehavior.apply(this.button_group, arguments);
},
@ -4624,11 +4614,9 @@ BI.Switcher = BI.inherit(BI.Widget, {
this.switcher.populate.apply(this.switcher, arguments);
},
setEnable: function (arg) {
BI.Switcher.superclass.setEnable.apply(this, arguments);
this.switcher && this.switcher.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
!arg && this._hideView();
_setEnable: function (arg) {
BI.Switcher.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},
setValue: function (v) {
@ -14646,15 +14634,15 @@ $.extend(BI, {
};
}()
});/**
* Grid
* GridView
*
* Created by GUY on 2016/1/11.
* @class BI.Grid
* @class BI.GridView
* @extends BI.Widget
*/
BI.Grid = BI.inherit(BI.Widget, {
BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid-view",
width: 400,
height: 300,
@ -14673,7 +14661,7 @@ BI.Grid = BI.inherit(BI.Widget, {
},
_init: function () {
BI.Grid.superclass._init.apply(this, arguments);
BI.GridView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.renderedCells = [];
this.renderedKeys = [];
@ -14692,7 +14680,7 @@ BI.Grid = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender();
self.fireEvent(BI.Grid.EVENT_SCROLL, {
self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
});
@ -14768,7 +14756,7 @@ BI.Grid = BI.inherit(BI.Widget, {
return;
}
var renderedCells = [], renderedKeys = [];
var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -14819,6 +14807,7 @@ BI.Grid = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key);
renderedWidgets[i] = child;
}
}
//已存在的, 需要添加的和需要删除的
@ -14840,13 +14829,17 @@ BI.Grid = BI.inherit(BI.Widget, {
deleteArray.push(i);
});
BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy();
//性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
});
var addedItems = [];
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
@ -14965,8 +14958,8 @@ BI.Grid = BI.inherit(BI.Widget, {
this._populate();
}
});
BI.Grid.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.Grid);/**
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.GridView);/**
* floatBox弹出层
* @class BI.FloatBox
* @extends BI.Widget
@ -15271,11 +15264,6 @@ BI.PopupView = BI.inherit(BI.Widget, {
this.view.element.css({"max-height": (h - tbHeight - tabHeight - toolHeight - 2) + "px"})
},
setEnable: function (arg) {
BI.PopupView.superclass.setEnable.apply(this, arguments);
this.view && this.view.setEnable(arg);
},
setValue: function (selectedValues) {
this.tab && this.tab.setValue(selectedValues);
this.button_group.setValue(selectedValues);
@ -16082,12 +16070,6 @@ BI.shortcut("bi.image_button", BI.ImageButton);(function ($) {
}
},
setEnable: function (b) {
BI.Button.superclass.setEnable.apply(this, arguments);
// this.text.setEnable(b);
// this.icon && this.icon.setEnable(b);
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
@ -17460,8 +17442,8 @@ BI.CodeEditor = BI.inherit(BI.Single, {
}
},
setEnable: function (b) {
BI.CodeEditor.superclass.setEnable.apply(this, arguments);
_setEnable: function (b) {
BI.CodeEditor.superclass._setEnable.apply(this, arguments);
this.editor.setOption("readOnly", b === true ? false : "nocursor")
},
@ -17832,12 +17814,6 @@ BI.Editor = BI.inherit(BI.Single, {
isValid: function () {
return this.editor.isValid();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
this.watermark && this.watermark.setEnable(b);
}
});
BI.Editor.EVENT_CHANGE = "EVENT_CHANGE";
@ -17940,11 +17916,6 @@ BI.MultifileEditor = BI.inherit(BI.Single, {
reset: function () {
this.file.reset();
},
setEnable: function (enable) {
BI.MultiFile.superclass.setEnable.apply(this, arguments);
this.file.setEnable(enable);
}
});
BI.MultifileEditor.EVENT_CHANGE = "MultifileEditor.EVENT_CHANGE";
@ -18107,12 +18078,6 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
BI.TextAreaEditor.superclass.setValid.apply(this, arguments);
this.content.setValid(b);
this.watermark && this.watermark.setValid(b);
},
setEnable: function (b) {
BI.TextAreaEditor.superclass.setEnable.apply(this, arguments);
this.content.setEnable(b);
this.watermark && this.watermark.setEnable(b);
}
});
BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE";
@ -18847,8 +18812,8 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/**
this.wrap.attachNum = 0;
},
setEnable: function (enable) {
BI.File.superclass.setEnable.apply(this, arguments);
_setEnable: function (enable) {
BI.File.superclass._setEnable.apply(this, arguments);
if (enable === true) {
this.element.attr("disabled", "disabled");
} else {
@ -19120,8 +19085,8 @@ BI.Input = BI.inherit(BI.Single, {
}
},
setEnable: function (b) {
BI.Input.superclass.setEnable.apply(this, [b]);
_setEnable: function (b) {
BI.Input.superclass._setEnable.apply(this, [b]);
this.element[0].disabled = !b;
}
});
@ -28603,7 +28568,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topLeftItems[index];
}
});
this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -28614,7 +28579,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topRightItems[index];
}
});
this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -28625,7 +28590,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomLeftItems[index];
}
});
this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomRightCollection.setScrollTop(scroll.scrollTop);
self.topLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -28637,7 +28602,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomRightItems[index];
}
});
this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomLeftCollection.setScrollTop(scroll.scrollTop);
self.topRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -29386,7 +29351,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter,
});
this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -29396,7 +29361,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter,
});
this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -29406,7 +29371,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter,
});
this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomRightGrid.setScrollTop(scroll.scrollTop);
self.topLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -29417,7 +29382,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter,
});
this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomLeftGrid.setScrollTop(scroll.scrollTop);
self.topRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -32553,11 +32518,6 @@ BI.CustomTree = BI.inherit(BI.Widget, {
this.initTree(this.options.items);
},
setEnable: function (v) {
BI.CustomTree.superclass.setEnable.apply(this, arguments);
this.tree.setEnable(v)
},
_formatItems: function (nodes) {
var self = this, o = this.options;
nodes = BI.Tree.transformToTreeFormat(nodes);

97
docs/case.js

@ -77,11 +77,6 @@ BI.IconChangeButton = BI.inherit(BI.Single, {
this.element.removeClass(o.iconClass).addClass(cls);
o.iconClass = cls;
}
},
setEnable: function (b) {
BI.IconChangeButton.superclass.setEnable.apply(this, arguments);
this.button.setEnable(b);
}
});
BI.IconChangeButton.EVENT_CHANGE = "IconChangeButton.EVENT_CHANGE";
@ -197,11 +192,6 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
}))));
},
setEnable: function (v) {
BI.MultiSelectItem.superclass.setEnable.apply(this, arguments);
this.checkbox.setEnable(v);
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
@ -2373,10 +2363,6 @@ BI.ColorChooser = BI.inherit(BI.Widget, {
return this.combo.isViewVisible();
},
setEnable: function (v) {
this.combo.setEnable(v)
},
setValue: function (color) {
this.combo.setValue(color);
},
@ -3600,10 +3586,6 @@ BI.BubbleCombo = BI.inherit(BI.Widget, {
isViewVisible: function () {
return this.combo.isViewVisible();
},
setEnable: function (v) {
this.combo.setEnable(!!v);
}
});
@ -3799,11 +3781,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
this.editorIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.EditorIconCheckCombo.superclass.setEnable.apply(this, arguments);
this.editorIconCheckCombo.setEnable(v);
},
getValue: function () {
return this.trigger.getValue();
},
@ -4141,11 +4118,6 @@ BI.IconCombo = BI.inherit(BI.Widget, {
this.iconCombo.setValue(v);
},
setEnable: function (v) {
BI.IconCombo.superclass.setEnable.apply(this, arguments);
this.iconCombo.setEnable(v);
},
getValue: function () {
return this.iconCombo.getValue();
},
@ -4431,11 +4403,6 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, {
this.textIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.TextValueCheckCombo.superclass.setEnable.apply(this, arguments);
this.textIconCheckCombo.setEnable(v);
},
setWarningTitle: function (title) {
this.trigger.setWarningTitle(title);
},
@ -4503,11 +4470,6 @@ BI.SmallTextValueCheckCombo = BI.inherit(BI.Widget, {
this.SmallTextIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.SmallTextValueCheckCombo.superclass.setEnable.apply(this, arguments);
this.SmallTextIconCheckCombo.setEnable(v);
},
getValue: function () {
return this.SmallTextIconCheckCombo.getValue();
},
@ -4632,11 +4594,6 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
this.textIconCombo.setValue(v);
},
setEnable: function (v) {
BI.TextValueCombo.superclass.setEnable.apply(this, arguments);
this.textIconCombo.setEnable(v);
},
getValue: function () {
return this.textIconCombo.getValue();
},
@ -4702,11 +4659,6 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, {
this.SmallTextValueCombo.setValue(v);
},
setEnable: function (v) {
BI.SmallTextValueCombo.superclass.setEnable.apply(this, arguments);
this.SmallTextValueCombo.setEnable(v);
},
getValue: function () {
return this.SmallTextValueCombo.getValue();
},
@ -4840,11 +4792,6 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, {
this.trigger.setValue(v.childValue || v.value);
},
setEnable: function (v) {
BI.TextValueDownListCombo.superclass.setEnable.apply(this, arguments);
this.combo.setEnable(v);
},
getValue: function () {
var v = this.combo.getValue()[0];
return [v.childValue || v.value];
@ -5248,12 +5195,6 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
isValid: function () {
return this.editor.isValid();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
this.clear.setEnable(b);
}
});
BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE";
@ -6186,11 +6127,6 @@ BI.StateEditor = BI.inherit(BI.Widget, {
this.editor.setValue(k);
},
setEnable: function (v) {
this.text.setEnable(v);
this.editor.setEnable(v);
},
getValue: function () {
return this.editor.getValue();
},
@ -6464,11 +6400,6 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
this.editor.setValue(k);
},
setEnable: function(v){
this.text.setEnable(v);
this.editor.setEnable(v);
},
getValue: function () {
return this.editor.getValue();
},
@ -6666,11 +6597,6 @@ BI.TextEditor = BI.inherit(BI.Widget, {
getValue: function () {
return this.editor.getValue();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
}
});
BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE";
@ -8714,10 +8640,6 @@ BI.Segment = BI.inherit(BI.Widget, {
this.buttonGroup.setEnabledValue(v);
},
setEnable: function (v) {
this.buttonGroup.setEnable(v);
},
getValue: function () {
return this.buttonGroup.getValue();
}
@ -10452,13 +10374,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
},
setEnable: function (b) {
BI.MultiSelectBar.superclass.setEnable.apply(this, arguments);
this.checkbox.setEnable(b);
this.half.setEnable(b);
this.text.setEnable(b);
}
});
BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE";
@ -11157,12 +11072,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
});
},
setEnable: function (v) {
BI.TextTrigger.superclass.setEnable.apply(this, arguments);
this.trigerButton.setEnable(v);
this.text.setEnable(v);
},
setValue: function (value) {
this.text.setValue(value);
this.text.setTitle(value);
@ -11327,12 +11236,6 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
});
},
setEnable: function (v) {
BI.SmallTextTrigger.superclass.setEnable.apply(this, arguments);
this.trigerButton.setEnable(v);
this.text.setEnable(v);
},
setValue: function (value) {
this.text.setValue(value);
},

4
docs/core.css

@ -3078,8 +3078,8 @@ i {
}
.bi-z-index-mask {
color: #ffffff;
background-color: rgba(26, 26, 26, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d1a1a1a,endColorstr=#4d1a1a1a);
background-color: rgba(26, 26, 26, 0.5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#801a1a1a,endColorstr=#801a1a1a);
}
.bi-list-item:hover,
.bi-list-item.hover {

358
docs/core.js

@ -14427,17 +14427,18 @@ BI.Widget = BI.inherit(BI.OB, {
_initVisualEffects: function () {
var o = this.options;
if (o.invisible) {
this.element.hide();
//用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none");
}
if (o.disabled || o.invalid) {
BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
}, this));
// BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
// }, this));
}
},
@ -14485,6 +14486,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._isMounted = true;
this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
widget._mount && widget._mount();
});
this.mounted && this.mounted();
@ -14492,17 +14494,6 @@ BI.Widget = BI.inherit(BI.OB, {
_mountChildren: null,
_unMount: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.purgeListeners();
this.destroyed && this.destroyed();
},
isMounted: function () {
return this._isMounted;
},
@ -14517,12 +14508,23 @@ BI.Widget = BI.inherit(BI.OB, {
this._initElementHeight();
},
setEnable: function (enable) {
_setEnable: function (enable) {
if (enable === true) {
this.options.disabled = false;
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.options.disabled = true;
}
//递归将所有子组件使能
BI.each(this._children, function (i, child) {
child._setEnable && child._setEnable(enable);
});
},
setEnable: function (enable) {
this._setEnable(enable);
if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
},
@ -14582,7 +14584,7 @@ BI.Widget = BI.inherit(BI.OB, {
},
getWidgetByName: function (name) {
if (!BI.isKey(name) || name == this.getName()) {
if (!BI.isKey(name) || name === this.getName()) {
return this;
}
name = name + "";
@ -14682,6 +14684,21 @@ BI.Widget = BI.inherit(BI.OB, {
this.setVisible(true);
},
__d: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
},
_unMount: function () {
this.__d();
this.purgeListeners();
this.destroyed && this.destroyed();
},
isolate: function () {
if (this._parent) {
this._parent.removeWidget(this);
@ -14697,13 +14714,15 @@ BI.Widget = BI.inherit(BI.OB, {
this.element.empty();
},
_destroy: function () {
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.purgeListeners();
},
destroy: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);
@ -15353,7 +15372,7 @@ BI.View = BI.inherit(BI.V, {
BI.each(cardNames, function (i, name) {
delete self._cards[name];
});
this._cardLayouts[key] && this._cardLayouts[key].destroy();
this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this;
},
@ -19581,7 +19600,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items = newItems;
this._children = newChildren;
BI.each(deleted, function (i, c) {
c.destroy();
c._destroy();
});
},
@ -19606,7 +19625,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} else {
w.element.prependTo(this._getWrapper());
}
del.destroy();
del._destroy();
w._mount();
},
@ -19693,7 +19712,7 @@ BI.Layout = BI.inherit(BI.Widget, {
}
o.items.splice(items.length);
BI.each(deleted, function (i, w) {
w.destroy();
w._destroy();
})
} else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) {
@ -19887,6 +19906,9 @@ BI.PopoverSection = BI.inherit(BI.Widget, {
}
});
BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
@ -19947,124 +19969,6 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return text;
}
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
function date2Str(date, format) {
if (!date) {
return '';
}
// O(len(format))
var len = format.length, result = '';
if (len > 0) {
var flagch = format.charAt(0), start = 0, str = flagch;
for (var i = 1; i < len; i++) {
var ch = format.charAt(i);
if (flagch !== ch) {
result += compileJFmt({
'char': flagch,
'str': str,
'len': i - start
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
case 'M': //月
if (len > 2) {
str = Date._MN[date.getMonth()];
} else if (len < 2) {
str = date.getMonth() + 1;
} else {
str = String.leftPad(date.getMonth() + 1 + '', 2, '0');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
};
/**
* 数字格式
*/
@ -20107,7 +20011,8 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
} else {
return left + '.' + right;
}
};
}
/**
* 处理小数点右边小数部分
* @param tright 右边内容
@ -20151,7 +20056,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
if (newnum.length > orilen) {
newnum = newnum.substr(1);
} else {
newnum = BI.leftPad(newnum, orilen, '0');
newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false;
}
right = right.replace(/^[0-9]+/, newnum);
@ -20412,7 +20317,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return o;
})(jo);
}
};
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
@ -20454,15 +20359,122 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return text;
};
BI.leftPad = function (val, size, ch) {
var result = String(val);
if (!ch) {
ch = " ";
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
BI.date2Str = function (date, format) {
if (!date) {
return '';
}
while (result.length < size) {
result = ch + result;
// O(len(format))
var len = format.length, result = '';
if (len > 0) {
var flagch = format.charAt(0), start = 0, str = flagch;
for (var i = 1; i < len; i++) {
var ch = format.charAt(i);
if (flagch !== ch) {
result += compileJFmt({
'char': flagch,
'str': str,
'len': i - start
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
case 'M': //月
if (len > 2) {
str = Date._MN[date.getMonth()];
} else if (len < 2) {
str = date.getMonth() + 1;
} else {
str = String.leftPad(date.getMonth() + 1 + '', 2, '0');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
return result.toString();
};
BI.object2Number = function (value) {
@ -22295,7 +22307,8 @@ BI.extend(jQuery, {
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + extraHeight;
@ -22343,7 +22356,8 @@ BI.extend(jQuery, {
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight;
@ -22369,7 +22383,8 @@ BI.extend(jQuery, {
getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
if ($.isBottomSpaceEnough(combo, popup, extraHeight)) {
return $.getBottomPosition(combo, popup, extraHeight);
}
@ -22392,7 +22407,8 @@ BI.extend(jQuery, {
getCenterAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var left;
if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) {
left = windowBounds.width - popupBounds.width;
@ -22409,7 +22425,8 @@ BI.extend(jQuery, {
getMiddleAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top;
if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) {
top = windowBounds.height - popupBounds.height;
@ -22605,7 +22622,7 @@ BI.extend(jQuery, {
}
break;
}
if(needAdaptHeight === true) {
if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight));
}
return position;
@ -22636,6 +22653,7 @@ $(function () {
};
}
var t, text, py;
keyword = keyword + "";
keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) {
@ -23503,7 +23521,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */
Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@ -23977,7 +23994,8 @@ Date.parseDateTime = function (str, fmt) {
return new Date(y, m, d, hr, min, sec);
}
return today;
};/*
};
/*
* 给jQuery.Event对象添加的工具方法
*/
$.extend($.Event.prototype, {
@ -26545,7 +26563,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var child = this._children[cardName];
this._deleteCardByName(cardName);
child && child.destroy();
child && child._destroy();
},
addCardByName: function (cardName, cardItem) {

53
docs/widget.js

@ -10048,10 +10048,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (arg) {
this.button_group.setEnable(arg);
},
resetHeight: function (h) {
this.button_group.resetHeight(h);
},
@ -10138,10 +10134,6 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
this.popupView.populate.apply(this.popupView, arguments);
},
setEnable: function (arg) {
this.popupView.setEnable(arg);
},
resetHeight: function (h) {
this.popupView.resetHeight(h);
},
@ -10291,10 +10283,6 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
this.numberCounter.setValue(ob);
},
setEnable: function (v) {
this.searcher.setEnable(v);
},
getKey: function () {
return this.searcher.getKey();
},
@ -10454,10 +10442,6 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (arg) {
this.button_group.setEnable(arg);
},
resetHeight: function (h) {
this.button_group.resetHeight(h);
},
@ -10703,10 +10687,6 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, {
this.editor.setValue(v);
},
setEnable: function(v){
this.editor.setEnable(v);
},
getValue: function () {
var v = this.editor.getState();
if (BI.isArray(v) && v.length > 0) {
@ -10866,10 +10846,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
return this.searcher.getValue();
},
setEnable: function (v) {
this.editor.setEnable(v);
},
populate: function (items) {
this.searcher.populate.apply(this.searcher, arguments);
}
@ -11267,11 +11243,6 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this.trigger.getSearcher().adjustView();
},
setEnable: function (v) {
this.trigger.setEnable(v);
this.popup.setEnable(v);
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
@ -11649,10 +11620,6 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
this.combo.hideView();
},
setEnable: function (v) {
this.combo.setEnable(v);
},
setValue: function (v) {
this.storeValue.value = v || {};
this.combo.setValue({
@ -11752,10 +11719,6 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, {
return this.tree.hasChecked();
},
setEnable: function (arg) {
this.popupView.setEnable(arg);
},
resetHeight: function (h) {
this.popupView.resetHeight(h);
},
@ -12030,10 +11993,6 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
return this.editor.getValue();
},
setEnable: function(v){
this.editor.setEnable(v);
},
getValue: function () {
return this.searcher.getValue();
},
@ -12200,11 +12159,6 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
this.trigger.getSearcher().adjustView();
},
setEnable: function (v) {
this.trigger.setEnable(v);
this.popup.setEnable(v);
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({
@ -12704,13 +12658,6 @@ BI.NumericalInterval = BI.inherit(BI.Single, {
return this.options.validation === "valid";
},
setEnable: function (b) {
this.smallEditor.setEnable(b);
this.smallCombo.setEnable(b);
this.bigEditor.setEnable(b);
this.bigCombo.setEnable(b);
},
setMinEnable: function (b) {
this.smallEditor.setEnable(b);
},

25
src/base/collection/collection.js

@ -1,13 +1,13 @@
/**
* Collection
* CollectionView
*
* Created by GUY on 2016/1/15.
* @class BI.Collection
* @class BI.CollectionView
* @extends BI.Widget
*/
BI.Collection = BI.inherit(BI.Widget, {
BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-collection",
width: 400,
height: 300,
@ -23,7 +23,7 @@ BI.Collection = BI.inherit(BI.Widget, {
},
_init: function () {
BI.Collection.superclass._init.apply(this, arguments);
BI.CollectionView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.renderedCells = [];
this.renderedKeys = [];
@ -42,7 +42,7 @@ BI.Collection = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender();
self.fireEvent(BI.Collection.EVENT_SCROLL, {
self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
});
@ -127,7 +127,7 @@ BI.Collection = BI.inherit(BI.Widget, {
return;
}
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top);
var renderedCells = [], renderedKeys = [];
var renderedCells = [], renderedKeys = [], renderedWidgets = {};
//存储所有的left和top
var lefts = {}, tops = {};
for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
@ -210,6 +210,7 @@ BI.Collection = BI.inherit(BI.Widget, {
}
renderedKeys.push(datum.index);
renderedWidgets[i] = child;
}
//已存在的, 需要添加的和需要删除的
var existSet = {}, addSet = {}, deleteArray = [];
@ -230,13 +231,17 @@ BI.Collection = BI.inherit(BI.Widget, {
deleteArray.push(i);
});
BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy();
//性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
});
var addedItems = [];
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
@ -347,5 +352,5 @@ BI.Collection = BI.inherit(BI.Widget, {
this._populate();
}
});
BI.Collection.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.Collection);
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.CollectionView);

6
src/base/combination/combo.js

@ -325,10 +325,8 @@ BI.Combo = BI.inherit(BI.Widget, {
this.combo.populate.apply(this.combo, arguments);
},
setEnable: function (arg) {
BI.Combo.superclass.setEnable.apply(this, arguments);
this.combo && this.combo.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
_setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},

10
src/base/combination/expander.js

@ -39,7 +39,7 @@ BI.Expander = BI.inherit(BI.Widget, {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND);
}
if(type === BI.Events.COLLAPSE) {
if (type === BI.Events.COLLAPSE) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_COLLAPSE);
}
@ -196,11 +196,9 @@ BI.Expander = BI.inherit(BI.Widget, {
this.expander.populate.apply(this.expander, arguments);
},
setEnable: function (arg) {
BI.Expander.superclass.setEnable.apply(this, arguments);
this.expander && this.expander.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
!arg && this._hideView();
_setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},
setValue: function (v) {

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

@ -189,13 +189,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
},
setEnable: function (b) {
BI.ButtonGroup.superclass.setEnable.apply(this, arguments);
BI.each(this.buttons, function (i, item) {
item.setEnable(b);
});
},
setNotSelectedValue: function (v) {
v = BI.isArray(v) ? v : [v];
BI.each(this.buttons, function (i, item) {

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

@ -83,11 +83,6 @@ BI.ComboGroup = BI.inherit(BI.Widget, {
})
},
setEnable: function (b) {
BI.ComboGroup.superclass.setEnable.apply(this, arguments);
this.combo && this.combo.setEnable(b);
},
getValue: function () {
return this.combo.getValue();
},

4
src/base/combination/loader.js

@ -195,10 +195,6 @@ BI.Loader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (v) {
this.button_group.setEnable(v);
},
doBehavior: function () {
this.button_group.doBehavior.apply(this.button_group, arguments);
},

8
src/base/combination/switcher.js

@ -186,11 +186,9 @@ BI.Switcher = BI.inherit(BI.Widget, {
this.switcher.populate.apply(this.switcher, arguments);
},
setEnable: function (arg) {
BI.Switcher.superclass.setEnable.apply(this, arguments);
this.switcher && this.switcher.setEnable(arg);
this.popupView && this.popupView.setEnable(arg);
!arg && this._hideView();
_setEnable: function (arg) {
BI.Switcher.superclass._setEnable.apply(this, arguments);
!arg && this.isViewVisible() && this._hideView();
},
setValue: function (v) {

25
src/base/grid/grid.js

@ -1,13 +1,13 @@
/**
* Grid
* GridView
*
* Created by GUY on 2016/1/11.
* @class BI.Grid
* @class BI.GridView
* @extends BI.Widget
*/
BI.Grid = BI.inherit(BI.Widget, {
BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), {
return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid-view",
width: 400,
height: 300,
@ -26,7 +26,7 @@ BI.Grid = BI.inherit(BI.Widget, {
},
_init: function () {
BI.Grid.superclass._init.apply(this, arguments);
BI.GridView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.renderedCells = [];
this.renderedKeys = [];
@ -45,7 +45,7 @@ BI.Grid = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender();
self.fireEvent(BI.Grid.EVENT_SCROLL, {
self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
});
@ -121,7 +121,7 @@ BI.Grid = BI.inherit(BI.Widget, {
return;
}
var renderedCells = [], renderedKeys = [];
var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -172,6 +172,7 @@ BI.Grid = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key);
renderedWidgets[i] = child;
}
}
//已存在的, 需要添加的和需要删除的
@ -193,13 +194,17 @@ BI.Grid = BI.inherit(BI.Widget, {
deleteArray.push(i);
});
BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy();
//性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
});
var addedItems = [];
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
@ -318,5 +323,5 @@ BI.Grid = BI.inherit(BI.Widget, {
this._populate();
}
});
BI.Grid.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.Grid);
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.GridView);

5
src/base/layer/layer.popup.js

@ -158,11 +158,6 @@ BI.PopupView = BI.inherit(BI.Widget, {
this.view.element.css({"max-height": (h - tbHeight - tabHeight - toolHeight - 2) + "px"})
},
setEnable: function (arg) {
BI.PopupView.superclass.setEnable.apply(this, arguments);
this.view && this.view.setEnable(arg);
},
setValue: function (selectedValues) {
this.tab && this.tab.setValue(selectedValues);
this.button_group.setValue(selectedValues);

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

@ -298,9 +298,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
return this.options.text;
},
setEnable: function (b) {
BI.BasicButton.superclass.setEnable.apply(this, arguments);
if (!b) {
_setEnable: function (enable) {
BI.BasicButton.superclass._setEnable.apply(this, arguments);
if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
if (!enable) {
if (this.options.shadow) {
this.$mask && this.$mask.setVisible(false);
}

6
src/base/single/button/buttons/button.js

@ -119,12 +119,6 @@
}
},
setEnable: function (b) {
BI.Button.superclass.setEnable.apply(this, arguments);
// this.text.setEnable(b);
// this.icon && this.icon.setEnable(b);
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},

4
src/base/single/editor/editor.code.js

@ -76,8 +76,8 @@ BI.CodeEditor = BI.inherit(BI.Single, {
}
},
setEnable: function (b) {
BI.CodeEditor.superclass.setEnable.apply(this, arguments);
_setEnable: function (b) {
BI.CodeEditor.superclass._setEnable.apply(this, arguments);
this.editor.setOption("readOnly", b === true ? false : "nocursor")
},

6
src/base/single/editor/editor.js

@ -303,12 +303,6 @@ BI.Editor = BI.inherit(BI.Single, {
isValid: function () {
return this.editor.isValid();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
this.watermark && this.watermark.setEnable(b);
}
});
BI.Editor.EVENT_CHANGE = "EVENT_CHANGE";

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

@ -79,11 +79,6 @@ BI.MultifileEditor = BI.inherit(BI.Single, {
reset: function () {
this.file.reset();
},
setEnable: function (enable) {
BI.MultiFile.superclass.setEnable.apply(this, arguments);
this.file.setEnable(enable);
}
});
BI.MultifileEditor.EVENT_CHANGE = "MultifileEditor.EVENT_CHANGE";

6
src/base/single/editor/editor.textarea.js

@ -153,12 +153,6 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
BI.TextAreaEditor.superclass.setValid.apply(this, arguments);
this.content.setValid(b);
this.watermark && this.watermark.setValid(b);
},
setEnable: function (b) {
BI.TextAreaEditor.superclass.setEnable.apply(this, arguments);
this.content.setEnable(b);
this.watermark && this.watermark.setEnable(b);
}
});
BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE";

4
src/base/single/input/file.js

@ -601,8 +601,8 @@
this.wrap.attachNum = 0;
},
setEnable: function (enable) {
BI.File.superclass.setEnable.apply(this, arguments);
_setEnable: function (enable) {
BI.File.superclass._setEnable.apply(this, arguments);
if (enable === true) {
this.element.attr("disabled", "disabled");
} else {

4
src/base/single/input/input.js

@ -256,8 +256,8 @@ BI.Input = BI.inherit(BI.Single, {
}
},
setEnable: function (b) {
BI.Input.superclass.setEnable.apply(this, [b]);
_setEnable: function (b) {
BI.Input.superclass._setEnable.apply(this, [b]);
this.element[0].disabled = !b;
}
});

8
src/base/table/table.collection.js

@ -34,7 +34,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topLeftItems[index];
}
});
this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -45,7 +45,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topRightItems[index];
}
});
this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -56,7 +56,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomLeftItems[index];
}
});
this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomRightCollection.setScrollTop(scroll.scrollTop);
self.topLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -68,7 +68,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomRightItems[index];
}
});
this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) {
this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) {
self.bottomLeftCollection.setScrollTop(scroll.scrollTop);
self.topRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();

8
src/base/table/table.grid.js

@ -39,7 +39,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter,
});
this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -49,7 +49,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter,
});
this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -59,7 +59,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter,
});
this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomRightGrid.setScrollTop(scroll.scrollTop);
self.topLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();
@ -70,7 +70,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter,
});
this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) {
this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) {
self.bottomLeftGrid.setScrollTop(scroll.scrollTop);
self.topRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar();

5
src/base/tree/customtree.js

@ -35,11 +35,6 @@ BI.CustomTree = BI.inherit(BI.Widget, {
this.initTree(this.options.items);
},
setEnable: function (v) {
BI.CustomTree.superclass.setEnable.apply(this, arguments);
this.tree.setEnable(v)
},
_formatItems: function (nodes) {
var self = this, o = this.options;
nodes = BI.Tree.transformToTreeFormat(nodes);

5
src/case/button/icon/icon.change.js

@ -77,11 +77,6 @@ BI.IconChangeButton = BI.inherit(BI.Single, {
this.element.removeClass(o.iconClass).addClass(cls);
o.iconClass = cls;
}
},
setEnable: function (b) {
BI.IconChangeButton.superclass.setEnable.apply(this, arguments);
this.button.setEnable(b);
}
});
BI.IconChangeButton.EVENT_CHANGE = "IconChangeButton.EVENT_CHANGE";

5
src/case/button/item.multiselect.js

@ -50,11 +50,6 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
}))));
},
setEnable: function (v) {
BI.MultiSelectItem.superclass.setEnable.apply(this, arguments);
this.checkbox.setEnable(v);
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},

4
src/case/colorchooser/colorchooser.js

@ -70,10 +70,6 @@ BI.ColorChooser = BI.inherit(BI.Widget, {
return this.combo.isViewVisible();
},
setEnable: function (v) {
this.combo.setEnable(v)
},
setValue: function (color) {
this.combo.setValue(color);
},

4
src/case/combo/bubblecombo/combo.bubble.js

@ -201,10 +201,6 @@ BI.BubbleCombo = BI.inherit(BI.Widget, {
isViewVisible: function () {
return this.combo.isViewVisible();
},
setEnable: function (v) {
this.combo.setEnable(!!v);
}
});

5
src/case/combo/editoriconcheckcombo/combo.editoriconcheck.js

@ -62,11 +62,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
this.editorIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.EditorIconCheckCombo.superclass.setEnable.apply(this, arguments);
this.editorIconCheckCombo.setEnable(v);
},
getValue: function () {
return this.trigger.getValue();
},

5
src/case/combo/iconcombo/combo.icon.js

@ -81,11 +81,6 @@ BI.IconCombo = BI.inherit(BI.Widget, {
this.iconCombo.setValue(v);
},
setEnable: function (v) {
BI.IconCombo.superclass.setEnable.apply(this, arguments);
this.iconCombo.setEnable(v);
},
getValue: function () {
return this.iconCombo.getValue();
},

5
src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js

@ -56,11 +56,6 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, {
this.textIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.TextValueCheckCombo.superclass.setEnable.apply(this, arguments);
this.textIconCheckCombo.setEnable(v);
},
setWarningTitle: function (title) {
this.trigger.setWarningTitle(title);
},

5
src/case/combo/textvaluecheckcombo/combo.textvaluechecksmall.js

@ -51,11 +51,6 @@ BI.SmallTextValueCheckCombo = BI.inherit(BI.Widget, {
this.SmallTextIconCheckCombo.setValue(v);
},
setEnable: function (v) {
BI.SmallTextValueCheckCombo.superclass.setEnable.apply(this, arguments);
this.SmallTextIconCheckCombo.setEnable(v);
},
getValue: function () {
return this.SmallTextIconCheckCombo.getValue();
},

5
src/case/combo/textvaluecombo/combo.textvalue.js

@ -53,11 +53,6 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
this.textIconCombo.setValue(v);
},
setEnable: function (v) {
BI.TextValueCombo.superclass.setEnable.apply(this, arguments);
this.textIconCombo.setEnable(v);
},
getValue: function () {
return this.textIconCombo.getValue();
},

5
src/case/combo/textvaluecombo/combo.textvaluesmall.js

@ -53,11 +53,6 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, {
this.SmallTextValueCombo.setValue(v);
},
setEnable: function (v) {
BI.SmallTextValueCombo.superclass.setEnable.apply(this, arguments);
this.SmallTextValueCombo.setEnable(v);
},
getValue: function () {
return this.SmallTextValueCombo.getValue();
},

5
src/case/combo/textvaluedownlistcombo/combo.textvaluedownlist.js

@ -64,11 +64,6 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, {
this.trigger.setValue(v.childValue || v.value);
},
setEnable: function (v) {
BI.TextValueDownListCombo.superclass.setEnable.apply(this, arguments);
this.combo.setEnable(v);
},
getValue: function () {
var v = this.combo.getValue()[0];
return [v.childValue || v.value];

6
src/case/editor/editor.search.js

@ -168,12 +168,6 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
isValid: function () {
return this.editor.isValid();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
this.clear.setEnable(b);
}
});
BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE";

5
src/case/editor/editor.state.js

@ -201,11 +201,6 @@ BI.StateEditor = BI.inherit(BI.Widget, {
this.editor.setValue(k);
},
setEnable: function (v) {
this.text.setEnable(v);
this.editor.setEnable(v);
},
getValue: function () {
return this.editor.getValue();
},

5
src/case/editor/editor.state.simple.js

@ -199,11 +199,6 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
this.editor.setValue(k);
},
setEnable: function(v){
this.text.setEnable(v);
this.editor.setEnable(v);
},
getValue: function () {
return this.editor.getValue();
},

5
src/case/editor/editor.text.js

@ -141,11 +141,6 @@ BI.TextEditor = BI.inherit(BI.Widget, {
getValue: function () {
return this.editor.getValue();
},
setEnable: function (b) {
BI.Editor.superclass.setEnable.apply(this, arguments);
this.editor && this.editor.setEnable(b);
}
});
BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE";

4
src/case/segment/segment.js

@ -46,10 +46,6 @@ BI.Segment = BI.inherit(BI.Widget, {
this.buttonGroup.setEnabledValue(v);
},
setEnable: function (v) {
this.buttonGroup.setEnable(v);
},
getValue: function () {
return this.buttonGroup.getValue();
}

7
src/case/toolbar/toolbar.multiselect.js

@ -121,13 +121,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
this.setSelected(isAllChecked);
!isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
},
setEnable: function (b) {
BI.MultiSelectBar.superclass.setEnable.apply(this, arguments);
this.checkbox.setEnable(b);
this.half.setEnable(b);
this.text.setEnable(b);
}
});
BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE";

6
src/case/trigger/trigger.text.js

@ -48,12 +48,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
});
},
setEnable: function (v) {
BI.TextTrigger.superclass.setEnable.apply(this, arguments);
this.trigerButton.setEnable(v);
this.text.setEnable(v);
},
setValue: function (value) {
this.text.setValue(value);
this.text.setTitle(value);

6
src/case/trigger/trigger.text.small.js

@ -47,12 +47,6 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
});
},
setEnable: function (v) {
BI.SmallTextTrigger.superclass.setEnable.apply(this, arguments);
this.trigerButton.setEnable(v);
this.text.setEnable(v);
},
setValue: function (value) {
this.text.setValue(value);
},

249
src/core/alias.js

@ -1,4 +1,7 @@
;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
@ -59,124 +62,6 @@
return text;
}
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
function date2Str(date, format) {
if (!date) {
return '';
}
// O(len(format))
var len = format.length, result = '';
if (len > 0) {
var flagch = format.charAt(0), start = 0, str = flagch;
for (var i = 1; i < len; i++) {
var ch = format.charAt(i);
if (flagch !== ch) {
result += compileJFmt({
'char': flagch,
'str': str,
'len': i - start
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
case 'M': //月
if (len > 2) {
str = Date._MN[date.getMonth()];
} else if (len < 2) {
str = date.getMonth() + 1;
} else {
str = String.leftPad(date.getMonth() + 1 + '', 2, '0');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
};
/**
* 数字格式
*/
@ -219,7 +104,8 @@
} else {
return left + '.' + right;
}
};
}
/**
* 处理小数点右边小数部分
* @param tright 右边内容
@ -263,7 +149,7 @@
if (newnum.length > orilen) {
newnum = newnum.substr(1);
} else {
newnum = BI.leftPad(newnum, orilen, '0');
newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false;
}
right = right.replace(/^[0-9]+/, newnum);
@ -524,7 +410,7 @@
return o;
})(jo);
}
};
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
@ -566,15 +452,122 @@
return text;
};
BI.leftPad = function (val, size, ch) {
var result = String(val);
if (!ch) {
ch = " ";
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
BI.date2Str = function (date, format) {
if (!date) {
return '';
}
while (result.length < size) {
result = ch + result;
// O(len(format))
var len = format.length, result = '';
if (len > 0) {
var flagch = format.charAt(0), start = 0, str = flagch;
for (var i = 1; i < len; i++) {
var ch = format.charAt(i);
if (flagch !== ch) {
result += compileJFmt({
'char': flagch,
'str': str,
'len': i - start
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
case 'M': //月
if (len > 2) {
str = Date._MN[date.getMonth()];
} else if (len < 2) {
str = date.getMonth() + 1;
} else {
str = String.leftPad(date.getMonth() + 1 + '', 2, '0');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
return result.toString();
};
BI.object2Number = function (value) {

17
src/core/func/dom.js

@ -267,7 +267,8 @@ BI.extend(jQuery, {
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + extraHeight;
@ -315,7 +316,8 @@ BI.extend(jQuery, {
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top, adaptHeight;
if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) {
top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight;
@ -341,7 +343,8 @@ BI.extend(jQuery, {
getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
if ($.isBottomSpaceEnough(combo, popup, extraHeight)) {
return $.getBottomPosition(combo, popup, extraHeight);
}
@ -364,7 +367,8 @@ BI.extend(jQuery, {
getCenterAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var left;
if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) {
left = windowBounds.width - popupBounds.width;
@ -381,7 +385,8 @@ BI.extend(jQuery, {
getMiddleAdaptPosition: function (combo, popup) {
var comboOffset = combo.element.offset();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds();
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(),
windowBounds = $("body").bounds();
var top;
if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) {
top = windowBounds.height - popupBounds.height;
@ -577,7 +582,7 @@ BI.extend(jQuery, {
}
break;
}
if(needAdaptHeight === true) {
if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight));
}
return position;

3
src/core/proto/date.js

@ -55,7 +55,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */
Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@ -529,4 +528,4 @@ Date.parseDateTime = function (str, fmt) {
return new Date(y, m, d, hr, min, sec);
}
return today;
};
};

2
src/core/view.js

@ -168,7 +168,7 @@ BI.View = BI.inherit(BI.V, {
BI.each(cardNames, function (i, name) {
delete self._cards[name];
});
this._cardLayouts[key] && this._cardLayouts[key].destroy();
this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this;
},

77
src/core/widget.js

@ -105,17 +105,18 @@ BI.Widget = BI.inherit(BI.OB, {
_initVisualEffects: function () {
var o = this.options;
if (o.invisible) {
this.element.hide();
//用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none");
}
if (o.disabled || o.invalid) {
BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
}, this));
// BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
// }, this));
}
},
@ -163,6 +164,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._isMounted = true;
this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
widget._mount && widget._mount();
});
this.mounted && this.mounted();
@ -170,17 +172,6 @@ BI.Widget = BI.inherit(BI.OB, {
_mountChildren: null,
_unMount: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.purgeListeners();
this.destroyed && this.destroyed();
},
isMounted: function () {
return this._isMounted;
},
@ -195,12 +186,23 @@ BI.Widget = BI.inherit(BI.OB, {
this._initElementHeight();
},
setEnable: function (enable) {
_setEnable: function (enable) {
if (enable === true) {
this.options.disabled = false;
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.options.disabled = true;
}
//递归将所有子组件使能
BI.each(this._children, function (i, child) {
child._setEnable && child._setEnable(enable);
});
},
setEnable: function (enable) {
this._setEnable(enable);
if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
},
@ -260,7 +262,7 @@ BI.Widget = BI.inherit(BI.OB, {
},
getWidgetByName: function (name) {
if (!BI.isKey(name) || name == this.getName()) {
if (!BI.isKey(name) || name === this.getName()) {
return this;
}
name = name + "";
@ -360,6 +362,21 @@ BI.Widget = BI.inherit(BI.OB, {
this.setVisible(true);
},
__d: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
},
_unMount: function () {
this.__d();
this.purgeListeners();
this.destroyed && this.destroyed();
},
isolate: function () {
if (this._parent) {
this._parent.removeWidget(this);
@ -375,13 +392,15 @@ BI.Widget = BI.inherit(BI.OB, {
this.element.empty();
},
_destroy: function () {
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.purgeListeners();
},
destroy: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.fireEvent(BI.Events.DESTROY);

6
src/core/wrapper/layout.js

@ -252,7 +252,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items = newItems;
this._children = newChildren;
BI.each(deleted, function (i, c) {
c.destroy();
c._destroy();
});
},
@ -277,7 +277,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} else {
w.element.prependTo(this._getWrapper());
}
del.destroy();
del._destroy();
w._mount();
},
@ -364,7 +364,7 @@ BI.Layout = BI.inherit(BI.Widget, {
}
o.items.splice(items.length);
BI.each(deleted, function (i, w) {
w.destroy();
w._destroy();
})
} else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) {

2
src/core/wrapper/layout/layout.card.js

@ -91,7 +91,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var child = this._children[cardName];
this._deleteCardByName(cardName);
child && child.destroy();
child && child._destroy();
},
addCardByName: function (cardName, cardItem) {

4
src/css/core/utils/common.css

@ -125,8 +125,8 @@
}
.bi-z-index-mask {
color: #ffffff;
background-color: rgba(26, 26, 26, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d1a1a1a,endColorstr=#4d1a1a1a);
background-color: rgba(26, 26, 26, 0.5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#801a1a1a,endColorstr=#801a1a1a);
}
.bi-list-item:hover,
.bi-list-item.hover {

2
src/less/core/utils/common.less

@ -175,7 +175,7 @@
.bi-z-index-mask {
color: @color-bi-background-default;
.background-color(@color-bi-background-black, 30%);
.background-color(@color-bi-background-black, 50%);
}
//只有背景变化

4
src/widget/multiselect/multiselect.loader.js

@ -155,10 +155,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (arg) {
this.button_group.setEnable(arg);
},
resetHeight: function (h) {
this.button_group.resetHeight(h);
},

4
src/widget/multiselect/multiselect.popup.view.js

@ -74,10 +74,6 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
this.popupView.populate.apply(this.popupView, arguments);
},
setEnable: function (arg) {
this.popupView.setEnable(arg);
},
resetHeight: function (h) {
this.popupView.resetHeight(h);
},

4
src/widget/multiselect/multiselect.trigger.js

@ -133,10 +133,6 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
this.numberCounter.setValue(ob);
},
setEnable: function (v) {
this.searcher.setEnable(v);
},
getKey: function () {
return this.searcher.getKey();
},

4
src/widget/multiselect/search/multiselect.search.loader.js

@ -139,10 +139,6 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
this.button_group.populate.apply(this.button_group, arguments);
},
setEnable: function (arg) {
this.button_group.setEnable(arg);
},
resetHeight: function (h) {
this.button_group.resetHeight(h);
},

4
src/widget/multiselect/trigger/editor.multiselect.js

@ -56,10 +56,6 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, {
this.editor.setValue(v);
},
setEnable: function(v){
this.editor.setEnable(v);
},
getValue: function () {
var v = this.editor.getState();
if (BI.isArray(v) && v.length > 0) {

4
src/widget/multiselect/trigger/searcher.multiselect.js

@ -134,10 +134,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
return this.searcher.getValue();
},
setEnable: function (v) {
this.editor.setEnable(v);
},
populate: function (items) {
this.searcher.populate.apply(this.searcher, arguments);
}

5
src/widget/multistringlist/multistringlist.js

@ -287,11 +287,6 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this.trigger.getSearcher().adjustView();
},
setEnable: function (v) {
this.trigger.setEnable(v);
this.popup.setEnable(v);
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);

4
src/widget/multitree/multi.tree.combo.js

@ -236,10 +236,6 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
this.combo.hideView();
},
setEnable: function (v) {
this.combo.setEnable(v);
},
setValue: function (v) {
this.storeValue.value = v || {};
this.combo.setValue({

4
src/widget/multitree/multi.tree.popup.js

@ -79,10 +79,6 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, {
return this.tree.hasChecked();
},
setEnable: function (arg) {
this.popupView.setEnable(arg);
},
resetHeight: function (h) {
this.popupView.resetHeight(h);
},

4
src/widget/multitree/trigger/searcher.multi.tree.js

@ -119,10 +119,6 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
return this.editor.getValue();
},
setEnable: function(v){
this.editor.setEnable(v);
},
getValue: function () {
return this.searcher.getValue();
},

5
src/widget/multitreelist/multitreelist.js

@ -150,11 +150,6 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
this.trigger.getSearcher().adjustView();
},
setEnable: function (v) {
this.trigger.setEnable(v);
this.popup.setEnable(v);
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({

7
src/widget/numericalinterval/numericalinterval.js

@ -430,13 +430,6 @@ BI.NumericalInterval = BI.inherit(BI.Single, {
return this.options.validation === "valid";
},
setEnable: function (b) {
this.smallEditor.setEnable(b);
this.smallCombo.setEnable(b);
this.bigEditor.setEnable(b);
this.bigCombo.setEnable(b);
},
setMinEnable: function (b) {
this.smallEditor.setEnable(b);
},

Loading…
Cancel
Save