Browse Source

Merge pull request #10 in ~GUY/fineui from ~WINDY/fineui:2.0 to 2.0

* commit 'aee0d19bd3b334f62e077ab03b682d348e02752e':
  update
es6
windy 8 years ago
parent
commit
61c60f8458
  1. 12
      dist/base.js
  2. 47
      dist/core.js
  3. 4652
      dist/widget.js
  4. 1
      src/base/base.js
  5. 8
      src/base/combination/group.virtual.js
  6. 3
      src/base/combination/tab.js
  7. 118
      src/component/allvaluechooser/combo.allvaluechooser.js
  8. 6
      src/core/controller/controller.broadcast.js
  9. 10
      src/core/widget.js
  10. 31
      src/core/wrapper/layout.js
  11. 219
      src/widget/dynamicgrouptab/dynamicgroup.tab.buttongroup.js
  12. 437
      src/widget/intervalslider/intervalslider.js
  13. 222
      src/widget/intervalslider/model.accuratecalculation.js
  14. 59
      src/widget/move2group/button.add.move2group.js
  15. 136
      src/widget/move2group/combo.move2group.js
  16. 85
      src/widget/move2group/toolbar.move2group.js
  17. 320
      src/widget/multistringlist/multistringlist.js
  18. 178
      src/widget/multitreelist/multitreelist.js
  19. 48
      src/widget/multitreelist/multitreelist.popup.js
  20. 108
      src/widget/simplesearcher/searcher.simple.js
  21. 104
      src/widget/simpleselectdata/searcher/searcher.simpleselectdata.js
  22. 104
      src/widget/simpleselectdata/searchpane/result.search.simpleselectdata.js
  23. 69
      src/widget/simpleselectdata/searchpane/segment.search.simpleselectdata.js
  24. 76
      src/widget/simpleselectdata/treenode/node.level0.js
  25. 81
      src/widget/simpleselectdata/treenode/node.level1.js
  26. 287
      src/widget/singleslider/singleslider.js
  27. 33
      src/widget/singleslider/slider/widget.slider.js
  28. 125
      src/widget/textarea/textarea.js
  29. 66
      src/widget/texttoolbar/alignchooser/texttoolbar.alignchooser.js
  30. 53
      src/widget/texttoolbar/backgroundchooser/texttoolbar.backgroundchooser.trigger.js
  31. 53
      src/widget/texttoolbar/colorchooser/texttoolbar.colorchooser.trigger.js
  32. 106
      src/widget/texttoolbar/sizechooser/texttoolbar.sizechooser.js
  33. 130
      src/widget/texttoolbar/texttoolbar.js
  34. 189
      src/widget/timeinterval/timeinterval.js
  35. 79
      src/widget/timesetting/timesetting.day.js
  36. 75
      src/widget/timesetting/timesetting.hour.js
  37. 51
      src/widget/treelabel/treelabel.js
  38. 144
      src/widget/treelabel/treelabel.view.js

12
dist/base.js vendored

@ -2349,6 +2349,7 @@ BI.Bubbles = new BI.BubblesController();
BI.Tooltips = new BI.TooltipsController(); BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.FloatBoxController(); BI.Popovers = new BI.FloatBoxController();
BI.Broadcasts = new BI.BroadcastController(); BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();
BI.servletURL = "dist/"; BI.servletURL = "dist/";
BI.i18n = {};/** BI.i18n = {};/**
@ -3597,6 +3598,14 @@ $.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Widg
return layout; return layout;
}, },
addItems: function (items) {
this.layouts.addItems(items);
},
prependItems: function (items) {
this.layouts.prependItems(items);
},
populate: function (items) { populate: function (items) {
var self = this; var self = this;
items = items || []; items = items || [];
@ -4607,8 +4616,7 @@ BI.Tab = BI.inherit(BI.Widget, {
}) })
}, },
_init: function () { render: function () {
BI.Tab.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
if (BI.isObject(o.tab)) { if (BI.isObject(o.tab)) {
this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"}); this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"});

47
dist/core.js vendored

@ -14369,8 +14369,12 @@ BI.Widget = BI.inherit(BI.OB, {
var o = this.options; var o = this.options;
this.widgetName = o.widgetName || BI.uniqueId("widget"); this.widgetName = o.widgetName || BI.uniqueId("widget");
if (BI.isWidget(o.element)) { if (BI.isWidget(o.element)) {
if (o.element instanceof BI.Widget) {
this._parent = o.element; this._parent = o.element;
this._parent.addWidget(this.widgetName, this); this._parent.addWidget(this.widgetName, this);
} else {
this._isRoot = true;
}
this.element = this.options.element.element; this.element = this.options.element.element;
} else if (o.element) { } else if (o.element) {
this.element = $(o.element); this.element = $(o.element);
@ -14465,7 +14469,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._isMounted = true; this._isMounted = true;
this._mountChildren(); this._mountChildren();
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
widget._mount(); widget._mount&&widget._mount();
}); });
this.mounted(); this.mounted();
}, },
@ -14487,7 +14491,7 @@ BI.Widget = BI.inherit(BI.OB, {
_unMount: function () { _unMount: function () {
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
widget._unMount(); widget._unMount && widget._unMount();
}); });
this._children = {}; this._children = {};
this._parent = null; this._parent = null;
@ -14558,7 +14562,7 @@ BI.Widget = BI.inherit(BI.OB, {
if (this._children[name]) { if (this._children[name]) {
throw new Error("name has already been existed"); throw new Error("name has already been existed");
} }
widget._setParent(this); widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () { widget.on(BI.Events.DESTROY, function () {
delete self._children[name] delete self._children[name]
}); });
@ -19439,19 +19443,11 @@ BI.Layout = BI.inherit(BI.Widget, {
* @param {JSON/BI.Widget} item 子组件 * @param {JSON/BI.Widget} item 子组件
*/ */
addItem: function (item) { addItem: function (item) {
var w = this._addElement(this.options.items.length, item); return this.addItemAt(this.options.items.length, item);
this.options.items.push(item);
w.element.appendTo(this._getWrapper());
w._mount();
return w;
}, },
prependItem: function (item) { prependItem: function (item) {
var w = this._addElement(this.options.items.length, item); return this.addItemAt(0,item);
this.options.items.unshift(item);
w.element.prependTo(this._getWrapper());
w._mount();
return w;
}, },
addItemAt: function (index, item) { addItemAt: function (index, item) {
@ -19486,14 +19482,18 @@ BI.Layout = BI.inherit(BI.Widget, {
if (updated = this._children[this._getChildName(index)].update(this._getOptions(item))) { if (updated = this._children[this._getChildName(index)].update(this._getOptions(item))) {
return updated; return updated;
} }
this._children[this._getChildName(index)].destroy(); var del = this._children[this._getChildName(index)];
delete this._children[this._getChildName(index)];
this.options.items.splice(index, 1);
var w = this._addElement(index, item); var w = this._addElement(index, item);
this.options.items.splice(index, 0, item);
this._children[this._getChildName(index)] = w; this._children[this._getChildName(index)] = w;
if (index > 0) { if (index > 0) {
this._children[this._getChildName(index - 1)].element.after(w.element); this._children[this._getChildName(index - 1)].element.after(w.element);
} else { } else {
w.element.prependTo(this._getWrapper()); w.element.prependTo(this._getWrapper());
} }
del.destroy();
w._mount(); w._mount();
}, },
@ -19503,6 +19503,7 @@ BI.Layout = BI.inherit(BI.Widget, {
var added = []; var added = [];
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
var w = self._addElement(o.items.length, item); var w = self._addElement(o.items.length, item);
self._children[self._getChildName(o.items.length)] = w;
o.items.push(item); o.items.push(item);
added.push(w); added.push(w);
fragment.appendChild(w.element[0]); fragment.appendChild(w.element[0]);
@ -19514,11 +19515,13 @@ BI.Layout = BI.inherit(BI.Widget, {
}, },
prependItems: function (items) { prependItems: function (items) {
items = items || []; var self =this,items = items || [];
var fragment = document.createDocumentFragment(); var fragment = document.createDocumentFragment();
var added = []; var added = [];
for (var i = items.length - 1; i >= 0; i--) { for (var i = items.length - 1; i >= 0; i--) {
var w = this._addElement(this.options.items.length, items[i]); this._addItemAt(0, items[i]);
var w = this._addElement(0, items[i]);
self._children[self._getChildName(0)] = w;
this.options.items.unshift(items[i]); this.options.items.unshift(items[i]);
added.push(w); added.push(w);
fragment.appendChild(w.element[0]); fragment.appendChild(w.element[0]);
@ -19563,9 +19566,13 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
} }
if (o.items.length > items.length) { if (o.items.length > items.length) {
var deleted = [];
for (i = items.length; i < o.items.length; i++) { for (i = items.length; i < o.items.length; i++) {
this.removeItemAt(i); deleted.push(this._children[this._getChildName(i)]);
} }
BI.each(deleted, function (i, w) {
w.destroy();
})
} else if (items.length > o.items.length) { } else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) { for (i = o.items.length; i < items.length; i++) {
this.addItemAt(i, items[i]); this.addItemAt(i, items[i]);
@ -20544,10 +20551,14 @@ BI.BroadcastController = BI.inherit(BI.Controller, {
}, },
on: function (name, fn) { on: function (name, fn) {
var self = this;
if (!this._broadcasts[name]) { if (!this._broadcasts[name]) {
this._broadcasts[name] = []; this._broadcasts[name] = [];
} }
this._broadcasts[name].push(fn); this._broadcasts[name].push(fn);
return function () {
self._broadcasts[name].remove(fn);
}
}, },
send: function (name) { send: function (name) {
@ -20559,7 +20570,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, {
remove: function (name, fn) { remove: function (name, fn) {
if (fn) { if (fn) {
BI.remove(this._broadcasts[name], fn); this._broadcasts[name].remove(fn);
} else { } else {
delete this._broadcasts[name]; delete this._broadcasts[name];
} }

4652
dist/widget.js vendored

File diff suppressed because it is too large Load Diff

1
src/base/base.js

@ -5,6 +5,7 @@ BI.Bubbles = new BI.BubblesController();
BI.Tooltips = new BI.TooltipsController(); BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.FloatBoxController(); BI.Popovers = new BI.FloatBoxController();
BI.Broadcasts = new BI.BroadcastController(); BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();
BI.servletURL = "dist/"; BI.servletURL = "dist/";
BI.i18n = {}; BI.i18n = {};

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

@ -47,6 +47,14 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
return layout; return layout;
}, },
addItems: function (items) {
this.layouts.addItems(items);
},
prependItems: function (items) {
this.layouts.prependItems(items);
},
populate: function (items) { populate: function (items) {
var self = this; var self = this;
items = items || []; items = items || [];

3
src/base/combination/tab.js

@ -18,8 +18,7 @@ BI.Tab = BI.inherit(BI.Widget, {
}) })
}, },
_init: function () { render: function () {
BI.Tab.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
if (BI.isObject(o.tab)) { if (BI.isObject(o.tab)) {
this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"}); this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"});

118
src/component/allvaluechooser/combo.allvaluechooser.js

@ -0,0 +1,118 @@
/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.AllValueChooserCombo
* @extends BI.Widget
*/
BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
_const: {
perPage: 10
},
_defaultConfig: function () {
return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-combo",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this.element,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(self.items)) {
BI.some(self.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
}
return text;
},
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
});
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!o.cache || !this.items) {
o.itemsCreator({}, function (items) {
self.items = items;
call(items);
});
} else {
call(this.items);
}
function call(items) {
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
items = search.matched.concat(search.finded);
});
if (options.selected_values) {//过滤
var filter = BI.makeObject(options.selected_values, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
}
if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
items: items
});
return;
}
if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
callback({
items: items,
hasNext: false
});
}
},
setValue: function (v) {
this.combo.setValue({
type: BI.Selection.Multi,
value: v || []
});
},
getValue: function () {
var val = this.combo.getValue() || {};
if (val.type === BI.Selection.All) {
return val.assist;
}
return val.value || [];
},
populate: function () {
this.combo.populate.apply(this, arguments);
}
});
BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM";
$.shortcut('bi.all_value_chooser_combo', BI.AllValueChooserCombo);

6
src/core/controller/controller.broadcast.js

@ -15,10 +15,14 @@ BI.BroadcastController = BI.inherit(BI.Controller, {
}, },
on: function (name, fn) { on: function (name, fn) {
var self = this;
if (!this._broadcasts[name]) { if (!this._broadcasts[name]) {
this._broadcasts[name] = []; this._broadcasts[name] = [];
} }
this._broadcasts[name].push(fn); this._broadcasts[name].push(fn);
return function () {
self._broadcasts[name].remove(fn);
}
}, },
send: function (name) { send: function (name) {
@ -30,7 +34,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, {
remove: function (name, fn) { remove: function (name, fn) {
if (fn) { if (fn) {
BI.remove(this._broadcasts[name], fn); this._broadcasts[name].remove(fn);
} else { } else {
delete this._broadcasts[name]; delete this._broadcasts[name];
} }

10
src/core/widget.js

@ -70,8 +70,12 @@ BI.Widget = BI.inherit(BI.OB, {
var o = this.options; var o = this.options;
this.widgetName = o.widgetName || BI.uniqueId("widget"); this.widgetName = o.widgetName || BI.uniqueId("widget");
if (BI.isWidget(o.element)) { if (BI.isWidget(o.element)) {
if (o.element instanceof BI.Widget) {
this._parent = o.element; this._parent = o.element;
this._parent.addWidget(this.widgetName, this); this._parent.addWidget(this.widgetName, this);
} else {
this._isRoot = true;
}
this.element = this.options.element.element; this.element = this.options.element.element;
} else if (o.element) { } else if (o.element) {
this.element = $(o.element); this.element = $(o.element);
@ -166,7 +170,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._isMounted = true; this._isMounted = true;
this._mountChildren(); this._mountChildren();
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
widget._mount(); widget._mount&&widget._mount();
}); });
this.mounted(); this.mounted();
}, },
@ -188,7 +192,7 @@ BI.Widget = BI.inherit(BI.OB, {
_unMount: function () { _unMount: function () {
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
widget._unMount(); widget._unMount && widget._unMount();
}); });
this._children = {}; this._children = {};
this._parent = null; this._parent = null;
@ -259,7 +263,7 @@ BI.Widget = BI.inherit(BI.OB, {
if (this._children[name]) { if (this._children[name]) {
throw new Error("name has already been existed"); throw new Error("name has already been existed");
} }
widget._setParent(this); widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () { widget.on(BI.Events.DESTROY, function () {
delete self._children[name] delete self._children[name]
}); });

31
src/core/wrapper/layout.js

@ -181,19 +181,11 @@ BI.Layout = BI.inherit(BI.Widget, {
* @param {JSON/BI.Widget} item 子组件 * @param {JSON/BI.Widget} item 子组件
*/ */
addItem: function (item) { addItem: function (item) {
var w = this._addElement(this.options.items.length, item); return this.addItemAt(this.options.items.length, item);
this.options.items.push(item);
w.element.appendTo(this._getWrapper());
w._mount();
return w;
}, },
prependItem: function (item) { prependItem: function (item) {
var w = this._addElement(this.options.items.length, item); return this.addItemAt(0,item);
this.options.items.unshift(item);
w.element.prependTo(this._getWrapper());
w._mount();
return w;
}, },
addItemAt: function (index, item) { addItemAt: function (index, item) {
@ -228,14 +220,18 @@ BI.Layout = BI.inherit(BI.Widget, {
if (updated = this._children[this._getChildName(index)].update(this._getOptions(item))) { if (updated = this._children[this._getChildName(index)].update(this._getOptions(item))) {
return updated; return updated;
} }
this._children[this._getChildName(index)].destroy(); var del = this._children[this._getChildName(index)];
delete this._children[this._getChildName(index)];
this.options.items.splice(index, 1);
var w = this._addElement(index, item); var w = this._addElement(index, item);
this.options.items.splice(index, 0, item);
this._children[this._getChildName(index)] = w; this._children[this._getChildName(index)] = w;
if (index > 0) { if (index > 0) {
this._children[this._getChildName(index - 1)].element.after(w.element); this._children[this._getChildName(index - 1)].element.after(w.element);
} else { } else {
w.element.prependTo(this._getWrapper()); w.element.prependTo(this._getWrapper());
} }
del.destroy();
w._mount(); w._mount();
}, },
@ -245,6 +241,7 @@ BI.Layout = BI.inherit(BI.Widget, {
var added = []; var added = [];
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
var w = self._addElement(o.items.length, item); var w = self._addElement(o.items.length, item);
self._children[self._getChildName(o.items.length)] = w;
o.items.push(item); o.items.push(item);
added.push(w); added.push(w);
fragment.appendChild(w.element[0]); fragment.appendChild(w.element[0]);
@ -256,11 +253,13 @@ BI.Layout = BI.inherit(BI.Widget, {
}, },
prependItems: function (items) { prependItems: function (items) {
items = items || []; var self =this,items = items || [];
var fragment = document.createDocumentFragment(); var fragment = document.createDocumentFragment();
var added = []; var added = [];
for (var i = items.length - 1; i >= 0; i--) { for (var i = items.length - 1; i >= 0; i--) {
var w = this._addElement(this.options.items.length, items[i]); this._addItemAt(0, items[i]);
var w = this._addElement(0, items[i]);
self._children[self._getChildName(0)] = w;
this.options.items.unshift(items[i]); this.options.items.unshift(items[i]);
added.push(w); added.push(w);
fragment.appendChild(w.element[0]); fragment.appendChild(w.element[0]);
@ -305,9 +304,13 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
} }
if (o.items.length > items.length) { if (o.items.length > items.length) {
var deleted = [];
for (i = items.length; i < o.items.length; i++) { for (i = items.length; i < o.items.length; i++) {
this.removeItemAt(i); deleted.push(this._children[this._getChildName(i)]);
} }
BI.each(deleted, function (i, w) {
w.destroy();
})
} else if (items.length > o.items.length) { } else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) { for (i = o.items.length; i < items.length; i++) {
this.addItemAt(i, items[i]); this.addItemAt(i, items[i]);

219
src/widget/dynamicgrouptab/dynamicgroup.tab.buttongroup.js

@ -1,219 +0,0 @@
/**
* Created by windy on 2016/12/20.
*/
BI.DynamicGroupTabButtonGroup = BI.inherit(BI.Widget, {
_const: {
MERGE_ADD_WIDTH: 65
},
_defaultConfig: function () {
return BI.extend(BI.DynamicGroupTabButtonGroup.superclass._defaultConfig.apply(this, arguments), {
cls: "bi-dynamic-group-tab-button-group",
items: [],
frozenButtons: [],
height: 30
})
},
_init: function () {
BI.DynamicGroupTabButtonGroup.superclass._init.apply(this, arguments);
var o = this.options;
this.tab = BI.createWidget({
type: "bi.button_group",
height: o.height,
items: [],
layouts: [{
type: "bi.horizontal",
scrollable: false,
scrollx: false
}]
});
this.tab.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
self.fireEvent(BI.DynamicGroupTabButtonGroup.EVENT_CHANGE, arguments);
});
var self = this;
this.scrollLeft = BI.createWidget({
type: "bi.icon_button",
cls: "pre-page-font bi-icon-button-scroll",
invisible: true
});
this.scrollLeft.on(BI.IconButton.EVENT_CHANGE, function () {
self._scrollLeft();
});
this.scrollRight = BI.createWidget({
type: "bi.icon_button",
cls: "next-page-font bi-icon-button-scroll",
invisible: true
});
this.scrollRight.on(BI.IconButton.EVENT_CHANGE, function () {
self._scrollRight();
});
BI.ResizeDetector.addResizeListener(this, function () {
self.resize();
});
BI.createWidget({
type: "bi.left",
element: this,
items: [{
type: "bi.horizontal",
tgap: -1,
height: o.height,
scrollx: false,
cls: "bi-sheet-tab-dynamic-horizontal",
items: [this.tab,
{
type: "bi.vertical_adapt",
items: [this.scrollLeft],
height: o.height
},
{
type: "bi.vertical_adapt",
items: [this.scrollRight],
height: o.height
},
{
type: "bi.vertical_adapt",
items: o.frozenButtons,
height: o.height,
lgap: 10
}
]
}]
})
},
_scrollLeft: function () {
this._scrollTo(this.tab.element[0].scrollLeft - this.scrollSection)
},
_scrollRight: function () {
this._scrollTo(this.tab.element[0].scrollLeft + this.scrollSection)
},
_getTotalWidth: function () {
var totalWidth = this.element.outerWidth();
totalWidth -= this._const.MERGE_ADD_WIDTH;
BI.each(this.options.frozenButtons, function (idx, button) {
if (BI.isWidget(button)) {
totalWidth -= button.getWidth();
} else {
totalWidth -= button.width;
}
})
return totalWidth;
},
_calculateButtonsWith: function (fn) {
var buttonWidth = 0;
var self = this;
BI.some(this.tab.getAllButtons(), function (idx, item) {
buttonWidth += item.element.outerWidth();
if (BI.isNotNull(fn) && fn.apply(self, [item])) {
return true;
}
})
return buttonWidth;
},
_dealWithScrollButtonState: function () {
var buttonWidth = this._calculateButtonsWith();
if (this.tab.element[0].scrollLeft === 0) {
this.scrollLeft.setEnable(false);
} else {
this.scrollLeft.setEnable(true);
}
var ulWidth = this.tab.element.outerWidth();
//可以滚动的最大距离
var maxLeft = buttonWidth - ulWidth;
if (this.tab.element[0].scrollLeft === maxLeft) {
this.scrollRight.setEnable(false);
} else {
this.scrollRight.setEnable(true);
}
},
_needScroll: function (visibleWidth, buttonWidth) {
var currentLeft = this.tab.element[0].scrollLeft;
return (visibleWidth > currentLeft && visibleWidth - currentLeft > buttonWidth) ||
(visibleWidth < currentLeft)
},
_scrollTo: function (value) {
var self = this;
BI.delay(function () {
self.tab.element.scrollLeft(value);
self._dealWithScrollButtonState();
}, 30);
},
_scrollToEnd: function () {
this._scrollTo(this._calculateButtonsWith())
},
resize: function () {
//获取当前所有可使用的宽度,不包含添加和合并和导航按钮以及之间的空隙
var totalWidth = this._getTotalWidth();
//所有button的宽度
var buttonWidth = this._calculateButtonsWith();
var width = buttonWidth;
var showScrollButton = false;
if (buttonWidth > totalWidth) {
width = totalWidth;
showScrollButton = true;
}
this.scrollLeft.setVisible(showScrollButton);
this.scrollRight.setVisible(showScrollButton);
//这边动态改变buttongroup的宽度,因为最大宽度是变的
this.tab.element.width(width);
this._dealWithScrollButtonState();
this.scrollSection = width * 2 / 3;
this.scrollSelectedVisible();
},
scrollSelectedVisible: function () {
var value = this.tab.getValue()[0];
//从index 0到当前选中的tab的所有button的宽度
var visibleWidth = this._calculateButtonsWith(function (item) {
if (item.getValue() === value) {
return true;
}
})
var buttonWidth = this._getTotalWidth();
var scrollWidth = visibleWidth - buttonWidth / 2;
if (this._needScroll(visibleWidth, buttonWidth)) {
this._scrollTo(scrollWidth)
}
},
getAllButtons: function () {
return this.tab.getAllButtons.apply(this.tab, arguments);
},
addItems: function (items) {
this.tab.addItems.apply(this.tab, arguments);
this.resize();
this._scrollToEnd();
},
getValue: function () {
this.tab.getValue.apply(this.tab, arguments);
},
setValue: function (v) {
this.tab.setValue.apply(this.tab, arguments);
},
populate: function () {
this.tab.populate.apply(this.tab, arguments);
this.resize();
}
})
BI.DynamicGroupTabButtonGroup.EVENT_CHANGE = "EVENT_CHANGE";
$.shortcut("bi.dynamic_group_tab_button_group", BI.DynamicGroupTabButtonGroup);

437
src/widget/intervalslider/intervalslider.js

@ -1,437 +0,0 @@
/**
* Created by zcf on 2016/9/26.
*/
BI.IntervalSlider = BI.inherit(BI.Widget, {
_constant: {
EDITOR_WIDTH: 90,
EDITOR_HEIGHT: 30,
HEIGHT: 28,
SLIDER_WIDTH_HALF: 15,
SLIDER_WIDTH: 30,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24
},
_defaultConfig: function () {
return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track"
})
},
_init: function () {
BI.IntervalSlider.superclass._init.apply(this, arguments);
var self = this;
var c = this._constant;
this.enable = false;
this.valueOne = "";
this.valueTwo = "";
this.calculation = new BI.AccurateCalculationModel();
this.backgroundTrack = BI.createWidget({
type: "bi.layout",
cls: "background-track",
height: c.TRACK_HEIGHT
});
this.grayTrack = BI.createWidget({
type: "bi.layout",
cls: "gray-track",
height: 8
});
this.blueTrack = BI.createWidget({
type: "bi.layout",
cls: "blue-track",
height: 8
});
this.track = this._createTrackWrapper();
this.labelOne = BI.createWidget({
type: "bi.sign_editor",
cls: "slider-editor-button",
errorText: "",
allowBlank: false,
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
validationChecker: function (v) {
return self._checkValidation(v);
},
quitChecker: function (v) {
return self._checkValidation(v);
}
});
this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () {
var percent = self._getPercentByValue(this.getValue());
var significantPercent = BI.parseFloat(percent.toFixed(1));//分成1000份
self._setLabelOnePosition(significantPercent);
self._setSliderOnePosition(significantPercent);
self._setBlueTrack();
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
});
this.labelTwo = BI.createWidget({
type: "bi.sign_editor",
cls: "slider-editor-button",
errorText: "",
allowBlank: false,
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
validationChecker: function (v) {
return self._checkValidation(v);
},
quitChecker: function (v) {
return self._checkValidation(v);
}
});
this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () {
var percent = self._getPercentByValue(this.getValue());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
self._setSliderTwoPosition(significantPercent);
self._setBlueTrack();
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
});
this.sliderOne = BI.createWidget({
type: "bi.single_slider_slider"
});
this.sliderOne.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelOnePosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.labelOne.setValue(v);
self.valueOne = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderOnePosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}
});
this.sliderTwo = BI.createWidget({
type: "bi.single_slider_slider"
});
this.sliderTwo.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setLabelTwoPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.labelTwo.setValue(v);
self.valueTwo = v;
self._setBlueTrack();
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderTwoPosition(significantPercent);
self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
}
});
this._setVisible(false);
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.track,
width: "100%",
height: c.TRACK_HEIGHT
}]
}],
hgap: 7,
height: c.TRACK_HEIGHT
},
top: 33,
left: 0,
width: "100%"
},
this._createLabelWrapper(),
this._createSliderWrapper()
]
})
},
_createLabelWrapper: function () {
var c = this._constant;
return {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.labelOne,
top: 0,
left: "0%"
}]
}, {
type: "bi.absolute",
items: [{
el: this.labelTwo,
top: 0,
left: "100%"
}]
}],
rgap: c.EDITOR_WIDTH,
height: 90
},
top: 0,
left: 0,
width: "100%"
}
},
_createSliderWrapper: function () {
var c = this._constant;
return {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.sliderOne,
top: 0,
left: "0%"
}]
}, {
type: "bi.absolute",
items: [{
el: this.sliderTwo,
top: 0,
left: "100%"
}]
}],
hgap: c.SLIDER_WIDTH_HALF,
height: c.SLIDER_HEIGHT
},
top: 30,
left: 0,
width: "100%"
}
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",
items: [{
el: this.backgroundTrack,
width: "100%"
}, {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.grayTrack,
top: 0,
left: 0,
width: "100%"
}, {
el: this.blueTrack,
top: 0,
left: 0,
width: "0%"
}]
}],
hgap: 8,
height: 8
},
top: 8,
left: 0,
width: "100%"
}]
})
},
_checkValidation: function (v) {
return !(BI.isNull(v) || v < this.min || v > this.max)
},
_checkOverlap: function () {
var labelOneLeft = this.labelOne.element[0].offsetLeft;
var labelTwoLeft = this.labelTwo.element[0].offsetLeft;
if (labelOneLeft <= labelTwoLeft) {
if ((labelTwoLeft - labelOneLeft) < 90) {
this.labelTwo.element.css({"top": 60});
} else {
this.labelTwo.element.css({"top": 0});
}
} else {
if ((labelOneLeft - labelTwoLeft) < 90) {
this.labelTwo.element.css({"top": 60});
} else {
this.labelTwo.element.css({"top": 0});
}
}
},
_setLabelOnePosition: function (percent) {
this.labelOne.element.css({"left": percent + "%"});
this._checkOverlap();
},
_setLabelTwoPosition: function (percent) {
this.labelTwo.element.css({"left": percent + "%"});
this._checkOverlap();
},
_setSliderOnePosition: function (percent) {
this.sliderOne.element.css({"left": percent + "%"});
},
_setSliderTwoPosition: function (percent) {
this.sliderTwo.element.css({"left": percent + "%"});
},
_setBlueTrackLeft: function (percent) {
this.blueTrack.element.css({"left": percent + "%"});
},
_setBlueTrackWidth: function (percent) {
this.blueTrack.element.css({"width": percent + "%"});
},
_setBlueTrack: function () {
var percentOne = this._getPercentByValue(this.labelOne.getValue());
var percentTwo = this._getPercentByValue(this.labelTwo.getValue());
if (percentOne <= percentTwo) {
this._setBlueTrackLeft(percentOne);
this._setBlueTrackWidth(percentTwo - percentOne);
} else {
this._setBlueTrackLeft(percentTwo);
this._setBlueTrackWidth(percentOne - percentTwo);
}
},
_setAllPosition: function (one, two) {
this._setSliderOnePosition(one);
this._setLabelOnePosition(one);
this._setSliderTwoPosition(two);
this._setLabelTwoPosition(two);
this._setBlueTrack();
},
_setVisible: function (visible) {
this.sliderOne.setVisible(visible);
this.sliderTwo.setVisible(visible);
this.labelOne.setVisible(visible);
this.labelTwo.setVisible(visible);
},
_setErrorText: function () {
var errorText = BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number");
this.labelOne.setErrorText(errorText);
this.labelTwo.setErrorText(errorText);
},
_getGrayTrackLength: function () {
return this.grayTrack.element[0].scrollWidth
},
_getValueByPercent: function (percent) {//return (((max-min)*percent)/100+min)
var sub = this.calculation.accurateSubtraction(this.max, this.min);
var mul = this.calculation.accurateMultiplication(sub, percent);
var div = this.calculation.accurateDivisionTenExponent(mul, 2);
return this.calculation.accurateAddition(div, this.min);
},
_getPercentByValue: function (v) {
return (v - this.min) * 100 / (this.max - this.min);
},
_setDraggableEnable: function (enable) {
if (enable) {
this.sliderOne.element.draggable("enable");
this.sliderTwo.element.draggable("enable")
} else {
this.sliderOne.element.draggable("disable");
this.sliderTwo.element.draggable("disable")
}
},
getValue: function () {
if (this.valueOne <= this.valueTwo) {
return {min: this.valueOne, max: this.valueTwo}
} else {
return {min: this.valueTwo, max: this.valueOne}
}
},
setMinAndMax: function (v) {
var minNumber = BI.parseFloat(v.min);
var maxNumber = BI.parseFloat(v.max);
if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber >= minNumber )) {
this.min = minNumber;
this.max = maxNumber;
this.valueOne = minNumber;
this.valueTwo = maxNumber;
this._setDraggableEnable(true);
}
if (maxNumber === minNumber) {
this._setDraggableEnable(false);
}
},
setValue: function (v) {
var valueOne = BI.parseFloat(v.min);
var valueTwo = BI.parseFloat(v.max);
if (!isNaN(valueOne) && !isNaN(valueTwo)) {
if (this._checkValidation(valueOne)) {
this.valueOne = valueOne;
}
if (this._checkValidation(valueTwo)) {
this.valueTwo = valueTwo;
}
if (valueOne < this.min) {
this.valueOne = this.min;
}
if (valueTwo > this.max) {
this.valueTwo = this.max;
}
}
},
reset: function () {
this._setVisible(false);
this.enable = false;
this.valueOne = "";
this.valueTwo = "";
this.min = NaN;
this.max = NaN;
this._setBlueTrackWidth(0);
},
populate: function () {
if (!isNaN(this.min) && !isNaN(this.max)) {
this.enable = true;
this._setVisible(true);
this._setErrorText();
if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) {
this.labelOne.setValue(this.valueOne);
this.labelTwo.setValue(this.valueTwo);
this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo));
} else {
this.labelOne.setValue(this.min);
this.labelTwo.setValue(this.max);
this._setAllPosition(0, 100)
}
}
}
});
BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE";
$.shortcut("bi.interval_slider", BI.IntervalSlider);

222
src/widget/intervalslider/model.accuratecalculation.js

@ -1,222 +0,0 @@
/**
* Created by zcf on 2017/3/1.
* 万恶的IEEE-754
* 使用字符串精确计算含小数加法减法乘法和10的指数倍除法支持负数
*/
BI.AccurateCalculationModel = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.AccurateCalculationModel.superclass._defaultConfig.apply(this, arguments), {
baseCls: ""
})
},
_init: function () {
BI.AccurateCalculationModel.superclass._init.apply(this, arguments);
},
_getMagnitude: function (n) {
var magnitude = "1";
for (var i = 0; i < n; i++) {
magnitude += "0";
}
return BI.parseInt(magnitude);
},
_formatDecimal: function (stringNumber1, stringNumber2) {
if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) {
return;
}
var magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
if (magnitudeDiff > 0) {
var needAddZero = stringNumber2
} else {
var needAddZero = stringNumber1;
magnitudeDiff = (0 - magnitudeDiff);
}
for (var i = 0; i < magnitudeDiff; i++) {
if (needAddZero.numDecimal === "0" && i === 0) {
continue
}
needAddZero.numDecimal += "0"
}
},
_stringNumberFactory: function (num) {
var strNum = num.toString();
var numStrArray = strNum.split(".");
var numInteger = numStrArray[0];
if (numStrArray.length === 1) {
var numDecimal = "0";
var numDecimalLength = 0;
} else {
var numDecimal = numStrArray[1];
var numDecimalLength = numStrArray[1].length;
}
return {
"numInteger": numInteger,
"numDecimal": numDecimal,
"numDecimalLength": numDecimalLength
}
},
_accurateSubtraction: function (num1, num2) {//num1-num2 && num1>num2
var stringNumber1 = this._stringNumberFactory(num1);
var stringNumber2 = this._stringNumberFactory(num2);
//整数部分计算
var integerResult = BI.parseInt(stringNumber1.numInteger) - BI.parseInt(stringNumber2.numInteger);
//小数部分
this._formatDecimal(stringNumber1, stringNumber2);
var decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2);
if (BI.parseInt(stringNumber1.numDecimal) >= BI.parseInt(stringNumber2.numDecimal)) {
var decimalResultTemp = (BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
} else {//否则借位
integerResult--;
var borrow = this._getMagnitude(decimalMaxLength);
var decimalResultTemp = (borrow + BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
}
var result = integerResult + "." + decimalResult;
return BI.parseFloat(result);
function getDecimalMaxLength(num1, num2) {
if (num1.numDecimal.length >= num2.numDecimal.length) {
return num1.numDecimal.length
}
return num2.numDecimal.length
}
function addZero(resultTemp, length) {
var diff = length - resultTemp.length;
for (var i = 0; i < diff; i++) {
resultTemp = "0" + resultTemp;
}
return resultTemp
}
},
_accurateAddition: function (num1, num2) {//加法结合律
var stringNumber1 = this._stringNumberFactory(num1);
var stringNumber2 = this._stringNumberFactory(num2);
//整数部分计算
var integerResult = BI.parseInt(stringNumber1.numInteger) + BI.parseInt(stringNumber2.numInteger);
//小数部分
this._formatDecimal(stringNumber1, stringNumber2);
var decimalResult = (BI.parseInt(stringNumber1.numDecimal) + BI.parseInt(stringNumber2.numDecimal)).toString();
if (decimalResult !== "0") {
if (decimalResult.length <= stringNumber1.numDecimal.length) {
decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length)
} else {
integerResult++;//进一
decimalResult = decimalResult.slice(1);
}
}
var result = integerResult + "." + decimalResult;
return BI.parseFloat(result);
function addZero(resultTemp, length) {
var diff = length - resultTemp.length;
for (var i = 0; i < diff; i++) {
resultTemp = "0" + resultTemp;
}
return resultTemp
}
},
_accurateMultiplication: function (num1, num2) {//乘法分配律
var stringNumber1 = this._stringNumberFactory(num1);
var stringNumber2 = this._stringNumberFactory(num2);
//整数部分计算
var integerResult = BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numInteger);
//num1的小数和num2的整数
var dec1Int2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numInteger), stringNumber1.numDecimalLength);
//num1的整数和num2的小数
var int1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numDecimal), stringNumber2.numDecimalLength);
//小数*小数
var dec1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numDecimal), (stringNumber1.numDecimalLength + stringNumber2.numDecimalLength));
return this._accurateAddition(this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2), dec1dec2);
},
_accurateDivisionTenExponent: function (num, n) {// num/10^n && n>0
var stringNumber = this._stringNumberFactory(num);
if (stringNumber.numInteger.length > n) {
var integerResult = stringNumber.numInteger.slice(0, (stringNumber.numInteger.length - n));
var partDecimalResult = stringNumber.numInteger.slice(-n);
} else {
var integerResult = "0";
var partDecimalResult = addZero(stringNumber.numInteger, n);
}
var result = integerResult + "." + partDecimalResult + stringNumber.numDecimal;
return BI.parseFloat(result);
function addZero(resultTemp, length) {
var diff = length - resultTemp.length;
for (var i = 0; i < diff; i++) {
resultTemp = "0" + resultTemp;
}
return resultTemp
}
},
accurateSubtraction: function (num1, num2) {
if (num1 >= 0 && num2 >= 0) {
if (num1 >= num2) {
return this._accurateSubtraction(num1, num2)
}
return this._accurateSubtraction(num2, num1)
}
if (num1 >= 0 && num2 < 0) {
return this._accurateAddition(num1, -num2)
}
if (num1 < 0 && num2 >= 0) {
return -this._accurateAddition(-num1, num2)
}
if (num1 < 0 && num2 < 0) {
if (num1 >= num2) {
return this._accurateSubtraction(-num2, -num1)
}
return this._accurateSubtraction(-num1, -num2)
}
},
accurateAddition: function (num1, num2) {
if (num1 >= 0 && num2 >= 0) {
return this._accurateAddition(num1, num2)
}
if (num1 >= 0 && num2 < 0) {
return this.accurateSubtraction(num1, -num2)
}
if (num1 < 0 && num2 >= 0) {
return this.accurateSubtraction(num2, -num1)
}
if (num1 < 0 && num2 < 0) {
return -this._accurateAddition(-num1, -num2)
}
},
accurateMultiplication: function (num1, num2) {
if (num1 >= 0 && num2 >= 0) {
return this._accurateMultiplication(num1, num2)
}
if (num1 >= 0 && num2 < 0) {
return -this._accurateMultiplication(num1, -num2)
}
if (num1 < 0 && num2 >= 0) {
return -this._accurateMultiplication(-num1, num2)
}
if (num1 < 0 && num2 < 0) {
return this._accurateMultiplication(-num1, -num2)
}
},
accurateDivisionTenExponent: function (num1, n) {
if (num1 >= 0) {
return this._accurateDivisionTenExponent(num1, n);
}
return -this._accurateDivisionTenExponent(-num1, n);
}
});

59
src/widget/move2group/button.add.move2group.js

@ -1,59 +0,0 @@
/**
* 新建并选中某个分组按钮
*
* Created by GUY on 2015/9/25.
* @class BI.Move2GroupAddButton
* @extends BI.BasicButton
*/
BI.Move2GroupAddButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.Move2GroupAddButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + ' bi-move2group-add-button',
shadow: true,
isShadowShowingOnSelected: true,
height: 30
})
},
_init: function () {
BI.Move2GroupAddButton.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
text: BI.i18nText("BI-Create_And_Move_To") + "\"江苏\"",
height: o.height
})
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: {
type: "bi.icon_button",
cls: "move2group-add-font"
},
width: 30
}, {
el: this.text
}]
})
},
setValue: function (v) {
this.text.setValue(BI.i18nText("BI-Create_And_Move_To") + "\"" + v + "\"");
this.setTitle(BI.i18nText("BI-Create_And_Move_To") + "\"" + v + "\"", {
container: "body"
});
},
doClick: function () {
BI.Move2GroupAddButton.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.Move2GroupAddButton.EVENT_CHANGE);
}
}
});
BI.Move2GroupAddButton.EVENT_CHANGE = "Move2GroupAddButton.EVENT_CHANGE";
$.shortcut('bi.move2group_add_button', BI.Move2GroupAddButton);

136
src/widget/move2group/combo.move2group.js

@ -1,136 +0,0 @@
/**
* 移动到分组下拉框
*
* Created by GUY on 2015/9/25.
* @class BI.Move2GroupCombo
* @extends BI.Widget
*/
BI.Move2GroupCombo = BI.inherit(BI.Single, {
_defaultConfig: function () {
var conf = BI.Move2GroupCombo.superclass._defaultConfig.apply(this, arguments)
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-move2group-combo",
height: 30,
tipType: "warning",
items: []
});
},
_init: function () {
BI.Move2GroupCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.button",
text: BI.i18nText("BI-Move_To_Group"),
title: o.title,
height: o.height
});
this.tools = BI.createWidget({
type: "bi.move2group_bar"
});
this.tools.on(BI.Move2GroupBar.EVENT_START, function () {
self.combo.adjustHeight();
self.searcher.adjustHeight();
});
this.tools.on(BI.Move2GroupBar.EVENT_EMPTY, function () {
self.combo.adjustHeight();
});
this.tools.on(BI.Move2GroupBar.EVENT_CLICK_BUTTON, function () {
self.fireEvent(BI.Move2GroupCombo.EVENT_CLICK_NEW_BUTTON);
self.searcher.stopSearch();
self.combo.hideView();
});
this.tools.on(BI.Move2GroupBar.EVENT_CHANGE, function () {
this.setButtonVisible(!self.searcher.hasMatched());
self.combo.adjustHeight();
self.searcher.adjustHeight();
});
this.popup = this._createPopup(this.options.items);
this.searcher = BI.createWidget({
type: "bi.searcher",
el: this.tools,
adapter: this.popup
});
this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
self.fireEvent(BI.Move2GroupCombo.EVENT_CONFIRM);
self.combo.hideView();
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
isNeedAdjustWidth: false,
popup: {
width: 200,
stopPropagation: false,
el: this.popup,
tool: this.searcher
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
self.combo.hideView();
self.fireEvent(BI.Move2GroupCombo.EVENT_CONFIRM);
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.Move2GroupCombo.EVENT_BEFORE_POPUPVIEW);
});
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
self.searcher.stopSearch();
})
},
_createItems: function (items) {
return BI.createItems(items, {
type: "bi.single_select_item",
height: 25,
handler: function (v) {
}
})
},
_createPopup: function (items, opt) {
return BI.createWidget(BI.extend({
type: "bi.button_group",
items: this._createItems(items),
chooseType: 0,
layouts: [{
type: "bi.vertical"
}]
}, opt));
},
populate: function (items) {
this.options.items = items;
this.combo.populate(this._createItems(items));
},
setValue: function (v) {
this.combo.setValue(v);
},
setEnable: function (enable) {
this.combo.setEnable.apply(this.combo, arguments);
},
getTargetValue: function () {
return this.tools.getValue();
},
getValue: function () {
var value = this.searcher.getValue();
return value[0];
}
});
BI.Move2GroupCombo.EVENT_BEFORE_POPUPVIEW = "Move2GroupCombo.EVENT_BEFORE_POPUPVIEW";
BI.Move2GroupCombo.EVENT_CHANGE = "Move2GroupCombo.EVENT_CHANGE";
BI.Move2GroupCombo.EVENT_CONFIRM = "Move2GroupCombo.EVENT_CONFIRM";
BI.Move2GroupCombo.EVENT_CLICK_NEW_BUTTON = "Move2GroupCombo.EVENT_CLICK_NEW_BUTTON";
$.shortcut('bi.move2group_combo', BI.Move2GroupCombo);

85
src/widget/move2group/toolbar.move2group.js

@ -1,85 +0,0 @@
/**
* guy
* 复选导航条
* Created by GUY on 2015/9/25.
* @class BI.Move2GroupBar
* @extends BI.Widget
*/
BI.Move2GroupBar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Move2GroupBar.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-move2group-bar"
})
},
_init: function () {
BI.Move2GroupBar.superclass._init.apply(this, arguments);
var self = this;
this.search = BI.createWidget({
type: "bi.text_editor",
watermark: BI.i18nText("BI-Search_And_Create_Group"),
allowBlank: true
});
this.search.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.search.on(BI.TextEditor.EVENT_CHANGE, function () {
self.button.setValue(this.getValue());
if (this.getValue() !== "") {
self.fireEvent(BI.Move2GroupBar.EVENT_CHANGE);
}
});
this.search.on(BI.TextEditor.EVENT_EMPTY, function () {
self.button.invisible();
self.fireEvent(BI.Move2GroupBar.EVENT_EMPTY);
});
this.search.on(BI.TextEditor.EVENT_START, function () {
self.button.visible();
self.fireEvent(BI.Move2GroupBar.EVENT_START);
});
this.button = BI.createWidget({
type: "bi.move2group_add_button"
});
this.button.on(BI.Move2GroupAddButton.EVENT_CHANGE, function () {
self.fireEvent(BI.Move2GroupBar.EVENT_CLICK_BUTTON);
});
BI.createWidget({
type: "bi.vertical",
element: this,
vgap: 5,
hgap: 5,
items: [this.search, this.button]
});
this.button.invisible();
},
blur: function(){
this.search.blur();
},
setButtonVisible: function (b) {
this.button.setVisible(b);
},
getValue: function () {
return this.search.getValue();
},
setValue: function (v) {
this.search.setValue(v);
this.button.setValue(v);
}
});
BI.Move2GroupBar.EVENT_START = "Move2GroupBar.EVENT_START";
BI.Move2GroupBar.EVENT_EMPTY = "Move2GroupBar.EVENT_EMPTY";
BI.Move2GroupBar.EVENT_CHANGE = "Move2GroupBar.EVENT_CHANGE";
BI.Move2GroupBar.EVENT_CLICK_BUTTON = "Move2GroupBar.EVENT_CLICK_BUTTON";
$.shortcut("bi.move2group_bar", BI.Move2GroupBar);

320
src/widget/multistringlist/multistringlist.js

@ -1,320 +0,0 @@
/**
* Created by zcf on 2016/12/14.
*/
BI.MultiStringList = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiStringList.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25
})
},
_init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
};
this.storeValue = {};
this.popup = BI.createWidget({
type: "bi.multi_select_loader",
cls: "popup-multi-string-list",
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded,
el: {
height: ""
}
});
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue();
self._adjust(function () {
assertShowValue();
self.fireEvent(BI.MultiStringList.EVENT_CHANGE);
});
});
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
valueFormatter: o.valueFormatter,
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keyword)) {
self.trigger.setValue(self.getValue());
}
callback.apply(self, arguments);
});
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self._setStartValue("");
this.getSearcher().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
self.fireEvent(BI.MultiStringList.EVENT_CHANGE);
})
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
assertShowValue();
self.popup.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
assertShowValue();
}
});
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () {
assertShowValue();
});
} else {
self._join(this.getValue(), function () {//安徽省 北京
assertShowValue();
});
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({
type: "bi.vtape",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
}, {
el: this.popup,
height: "fill"
}]
});
},
_defaultState: function () {
this.trigger.stopEditing();
},
_assertValue: function (val) {
val || (val = {});
val.type || (val.type = BI.Selection.Multi);
val.value || (val.value = []);
},
_makeMap: function (values) {
return BI.makeObject(values || []);
},
_joinKeywords: function (keywords, callback) {
var self = this, o = this.options;
this._assertValue(this.storeValue);
if (!this._allData) {
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA
}, function (ob) {
self._allData = BI.pluck(ob.items, "value");
digest(self._allData);
})
} else {
digest(this._allData)
}
function digest(items) {
var selectedMap = self._makeMap(items);
BI.each(keywords, function (i, val) {
if (BI.isNotNull(selectedMap[val])) {
self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val);
}
});
self._adjust(callback);
}
},
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey()
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];
BI.each(items, function (i, item) {
if (BI.isNotNull(selectedMap[items[i]])) {
delete selectedMap[items[i]];
}
if (BI.isNull(notSelectedMap[items[i]])) {
newItems.push(item);
}
});
self.storeValue.value = newItems.concat(BI.values(selectedMap));
self._adjust(callback);
})
},
_adjust: function (callback) {
var self = this, o = this.options;
if (!this._count) {
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_DATA_LENGTH
}, function (res) {
self._count = res.count;
adjust();
callback();
});
} else {
adjust();
callback();
}
function adjust() {
if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
self.storeValue = {
type: BI.Selection.Multi,
value: []
}
} else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
self.storeValue = {
type: BI.Selection.All,
value: []
}
}
}
},
_join: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this._assertValue(this.storeValue);
if (this.storeValue.type === res.type) {
var map = this._makeMap(this.storeValue.value);
BI.each(res.value, function (i, v) {
if (!map[v]) {
self.storeValue.value.push(v);
map[v] = v;
}
});
var change = false;
BI.each(res.assist, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
this._joinAll(res, callback);
},
_setStartValue: function (value) {
this._startValue = value;
this.popup.setStartValue(value);
},
// isAllSelected: function () {
// return this.popup.isAllSelected();
// },
resize: function () {
this.trigger.getCounter().adjustView();
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);
this.popup.setValue(this.storeValue);
this.trigger.setValue(this.storeValue);
},
getValue: function () {
return this.storeValue;
},
populate: function () {
this._count = null;
this._allData = null;
this.popup.populate.apply(this.popup, arguments);
this.trigger.populate.apply(this.trigger, arguments);
}
});
BI.extend(BI.MultiStringList, {
REQ_GET_DATA_LENGTH: 0,
REQ_GET_ALL_DATA: -1
});
BI.MultiStringList.EVENT_CHANGE = "BI.MultiStringList.EVENT_CHANGE";
$.shortcut("bi.multi_string_list", BI.MultiStringList);

178
src/widget/multitreelist/multitreelist.js

@ -1,178 +0,0 @@
/**
* Created by zcf on 2016/12/20.
*/
BI.MultiTreeList = BI.inherit(BI.Widget, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
_defaultConfig: function () {
return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-tree-combo',
itemsCreator: BI.emptyFn,
height: 25
});
},
_init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var isInit = false;
var want2showCounter = false;
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
itemsCreator: o.itemsCreator
});
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () {
self.trigger.getCounter().adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
}
});
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
}
});
this.storeValue = {value: {}};
var isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
BI.nextTick(function () {
self.trigger.populate();
self.popup.populate();
});
});
function showCounter() {
if (isSearching()) {
self.storeValue = {value: self.trigger.getValue()};
} else {
self.storeValue = {value: self.popup.getValue()};
}
self.trigger.setValue(self.storeValue);
}
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var val = {
type: BI.Selection.Multi,
value: this.getSearcher().hasChecked() ? {1: 1} : {}
};
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
});
this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () {
showCounter();
var val = {
type: BI.Selection.Multi,
value: this.hasChecked() ? {1: 1} : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeList.EVENT_CHANGE);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({
type: "bi.vtape",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
}, {
el: this.popup,
height: "fill"
}]
})
},
_defaultState: function () {
this.trigger.stopEditing();
},
resize: function () {
this.trigger.getCounter().adjustView();
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({
value: v || {}
});
this.trigger.setValue({
value: v || {}
});
},
getValue: function () {
return this.storeValue.value;
},
populate: function () {
this.trigger.populate.apply(this.trigger, arguments);
this.popup.populate.apply(this.popup, arguments);
}
});
BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE";
$.shortcut('bi.multi_tree_list', BI.MultiTreeList);

48
src/widget/multitreelist/multitreelist.popup.js

@ -1,48 +0,0 @@
/**
* Created by zcf on 2016/12/21.
*/
BI.MultiStringListPopup=BI.inherit(BI.Widget,{
_defaultConfig:function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup",
itemsCreator: BI.emptyFn
});
},
_init:function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.sync_tree",
height: 400,
element: this,
itemsCreator: o.itemsCreator
});
this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT)
});
this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE)
});
},
hasChecked: function () {
return this.popup.hasChecked();
},
getValue: function () {
return this.popup.getValue();
},
setValue: function (v) {
v || (v = {});
this.popup.setValue(v.value);
},
populate: function (config) {
this.popup.stroke(config);
}
});
BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT";
BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE";
$.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);

108
src/widget/simplesearcher/searcher.simple.js

@ -1,108 +0,0 @@
/**
* 简单的搜索功能
*
* Created by GUY on 2015/9/16.
* @class BI.SimpleSearcher
* @extends BI.Widget
*/
BI.SimpleSearcher = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SimpleSearcher.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-simple-searcher",
items: [],
itemsCreator: BI.emptyFn,
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
});
},
_init: function () {
BI.SimpleSearcher.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.tree = BI.createWidget({
type: "bi.select_data_tree",
items: o.items,
el: {
el: {
chooseType: o.chooseType
}
},
itemsCreator: o.itemsCreator
});
this.tree.on(BI.SelectDataTree.EVENT_CHANGE, function () {
self.fireEvent(BI.SimpleSearcher.EVENT_CHANGE, arguments);
});
this.searcher = BI.createWidget({
type: "bi.searcher",
el: {
type: "bi.small_search_editor"
},
isAutoSearch: false, //是否自动搜索
isAutoSync: false,
onSearch: function (op, populate) {
o.itemsCreator(op, function (searchResult, matchResult) {
populate(searchResult, matchResult, op.keyword);
})
},
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
popup: {
matcher: {
type: "bi.select_data_tree",
el: {
el: {
chooseType: o.chooseType
}
},
itemsCreator: o.itemsCreator
},
searcher: {
type: "bi.select_data_tree",
el: {
el: {
chooseType: o.chooseType
}
},
itemsCreator: o.itemsCreator
}
},
adapter: this.tree
});
BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: {
type: "bi.absolute",
items: [{
el: this.searcher,
left: 10,
right: 10,
top: 10
}]
},
height: 45
}, this.tree]
})
},
stopSearch: function () {
this.searcher.stopSearch();
},
setValue: function (v) {
},
getValue: function () {
return this.searcher.getValue();
},
populate: function () {
this.tree.populate.apply(this.tree, arguments);
}
});
BI.SimpleSearcher.EVENT_CHANGE = "SimpleSearcher.EVENT_CHANGE";
$.shortcut('bi.simple_searcher', BI.SimpleSearcher);

104
src/widget/simpleselectdata/searcher/searcher.simpleselectdata.js

@ -1,104 +0,0 @@
/**
* 完成搜索功能模块
*
* Created by GUY on 2015/9/16.
* @class BI.SimpleSelectDataSearcher
* @extends BI.Widget
*/
BI.SimpleSelectDataSearcher = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SimpleSelectDataSearcher.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-simple-select-data-searcher",
items: [],
itemsCreator: BI.emptyFn,
popup: {},
adapter: {}
});
},
_init: function () {
BI.SimpleSelectDataSearcher.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.tree = BI.createWidget(o.adapter, {
type: "bi.select_data_tree",
items: o.items,
el: {
el: {
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
}
},
itemsCreator: o.itemsCreator
});
this.tree.on(BI.SelectDataTree.EVENT_CHANGE, function () {
self.fireEvent(BI.SimpleSelectDataSearcher.EVENT_CLICK_ITEM, arguments);
});
this.searcherPane = BI.createWidget(o.popup, {
type: "bi.simple_select_data_search_result_pane",
itemsCreator: o.itemsCreator
});
this.searcherPane.on(BI.SimpleSelectDataSearchResultPane.EVENT_SEARCH_TYPE_CHANGE, function () {
self.searcher.doSearch();
});
this.searcherPane.on(BI.SimpleSelectDataSearchResultPane.EVENT_CHANGE, function () {
self.fireEvent(BI.SimpleSelectDataSearcher.EVENT_CLICK_ITEM, arguments);
});
this.searcher = BI.createWidget({
type: "bi.searcher",
el: {
type: "bi.small_search_editor"
},
isAutoSearch: false, //是否自动搜索
isAutoSync: false,
onSearch: function (op, populate) {
o.itemsCreator(BI.extend(op, {
searchType: self.searcherPane.getSegmentValue()
}), function (searchResult, matchResult) {
populate(searchResult, matchResult, op.keyword);
})
},
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
popup: this.searcherPane,
adapter: this.tree
});
BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: {
type: "bi.absolute",
items: [{
el: this.searcher,
left: 10,
right: 10,
top: 10
}]
},
height: 45
}, this.tree]
})
},
stopSearch: function () {
this.searcher.stopSearch();
},
setValue: function (v) {
},
getValue: function () {
return this.searcher.getValue();
},
populate: function () {
this.tree.populate.apply(this.tree, arguments);
}
});
BI.SimpleSelectDataSearcher.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
$.shortcut('bi.simple_select_data_searcher', BI.SimpleSelectDataSearcher);

104
src/widget/simpleselectdata/searchpane/result.search.simpleselectdata.js

@ -1,104 +0,0 @@
/**
* 搜索结果面板
*
* Created by GUY on 2015/9/16.
* @class BI.SimpleSelectDataSearchResultPane
* @extends BI.Widget
*/
BI.SimpleSelectDataSearchResultPane = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SimpleSelectDataSearchResultPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-select-data-search-result-pane bi-select-data-search-result-pane bi-searcher-view",
itemsCreator: BI.emptyFn,
segment: {}
});
},
_init: function () {
BI.SimpleSelectDataSearchResultPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.segment = BI.createWidget(o.segment, {
type: "bi.simple_select_data_search_segment",
cls: "search-result-toolbar"
});
this.segment.on(BI.SimpleSelectDataSearchSegment.EVENT_CHANGE, function () {
self.fireEvent(BI.SimpleSelectDataSearchResultPane.EVENT_SEARCH_TYPE_CHANGE);
});
this.resultPane = BI.createWidget({
type: "bi.searcher_view",
matcher: {
type: "bi.select_data_tree",
el: {
el: {
chooseType: BI.Selection.Single
}
},
itemsCreator: o.itemsCreator
},
searcher: {
type: "bi.select_data_tree",
el: {
el: {
chooseType: BI.Selection.Single
}
},
itemsCreator: o.itemsCreator
}
});
this.resultPane.on(BI.SearcherView.EVENT_CHANGE, function () {
self.fireEvent(BI.SimpleSelectDataSearchResultPane.EVENT_CHANGE, arguments);
});
BI.createWidget({
type: "bi.vtape",
element: this,
items: [{
el: this.segment,
height: 30
}, {
type: "bi.border",
cls: "search-result-line",
height: 2
}, {
type: "bi.border",
cls: "search-result-line",
height: 1
}, {
type: "bi.absolute",
items: [{
el: this.resultPane,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
}]
});
},
empty: function () {
this.resultPane.empty();
},
populate: function (searchResult, matchResult, keyword) {
this.resultPane.populate.apply(this.resultPane, arguments);
},
setValue: function (v) {
},
getSegmentValue: function () {
return this.segment.getValue();
},
getValue: function () {
return this.resultPane.getValue();
}
});
BI.SimpleSelectDataSearchResultPane.EVENT_SEARCH_TYPE_CHANGE = "EVENT_SEARCH_TYPE_CHANGE";
BI.SimpleSelectDataSearchResultPane.EVENT_CHANGE = "EVENT_CHANGE";
$.shortcut('bi.simple_select_data_search_result_pane', BI.SimpleSelectDataSearchResultPane);

69
src/widget/simpleselectdata/searchpane/segment.search.simpleselectdata.js

@ -1,69 +0,0 @@
/**
* search面板选项栏
*
* Created by GUY on 2015/9/16.
* @class BI.SimpleSelectDataSearchSegment
* @extends BI.Widget
*/
BI.SimpleSelectDataSearchSegment = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SimpleSelectDataSearchSegment.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-select-data-search-segment",
height: 30,
items: [{
text: BI.i18nText("BI-Basic_Field"),
selected: true,
value: BI.SelectDataSearchSegment.SECTION_FIELD
}, {
text: BI.i18nText("BI-Basic_Table"),
value: BI.SelectDataSearchSegment.SECTION_TABLE
}]
});
},
_init: function () {
BI.SimpleSelectDataSearchSegment.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.segment = BI.createWidget({
type: "bi.segment",
height: 20,
cls: "search-segment-field-table",
items: o.items
});
this.segment.on(BI.Segment.EVENT_CHANGE, function(){
self.fireEvent(BI.SimpleSelectDataSearchSegment.EVENT_CHANGE);
});
BI.createWidget({
type: "bi.vertical",
element: this,
items: [{
type: "bi.absolute",
height: o.height,
items: [{
el: this.segment,
top: 5,
right: 10,
left: 10,
bottom: 5
}]
}]
});
},
setValue: function (v) {
var self = this;
BI.each([BI.SelectDataSearchSegment.SECTION_FIELD,
BI.SelectDataSearchSegment.SECTION_TABLE], function (i, key) {
if (key & v) {
self.segment.setValue(key & v);
}
});
},
getValue: function () {
return this.segment.getValue()[0]
}
});
BI.SimpleSelectDataSearchSegment.EVENT_CHANGE = "SimpleSelectDataSearchSegment.EVENT_CHANGE";
$.shortcut('bi.simple_select_data_search_segment', BI.SimpleSelectDataSearchSegment);

76
src/widget/simpleselectdata/treenode/node.level0.js

@ -1,76 +0,0 @@
/**
* Created by GUY on 2015/9/6.
* @class BI.SimpleSelectDataLevel0Node
* @extends BI.NodeButton
*/
BI.SimpleSelectDataLevel0Node = BI.inherit(BI.NodeButton, {
_defaultConfig: function () {
return BI.extend(BI.SimpleSelectDataLevel0Node.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-simple-select-data-level0-node bi-list-item",
id: "",
pId: "",
open: false,
height: 25
})
},
_init: function () {
BI.SimpleSelectDataLevel0Node.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.checkbox = BI.createWidget({
type: "bi.tree_group_node_checkbox"
});
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap,
text: o.text,
value: o.value,
py: o.py
});
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
if (type === BI.Events.CLICK) {
self.setSelected(self.isSelected());
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
width: 23,
el: this.checkbox
}, {
el: this.text
}]
})
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doClick: function () {
BI.SimpleSelectDataLevel0Node.superclass.doClick.apply(this, arguments);
this.checkbox.setSelected(this.isOpened());
},
setOpened: function (v) {
BI.SimpleSelectDataLevel0Node.superclass.setOpened.apply(this, arguments);
this.checkbox.setSelected(v);
},
setEnable: function (b) {
BI.SimpleSelectDataLevel0Node.superclass.setEnable.apply(this, arguments);
this.checkbox.setEnable(b);
}
});
$.shortcut("bi.simple_select_data_level0_node", BI.SimpleSelectDataLevel0Node);

81
src/widget/simpleselectdata/treenode/node.level1.js

@ -1,81 +0,0 @@
/**
* Created by GUY on 2015/9/6.
* @class BI.SimpleSelectDataLevel1Node
* @extends BI.NodeButton
*/
BI.SimpleSelectDataLevel1Node = BI.inherit(BI.NodeButton, {
_defaultConfig: function () {
return BI.extend(BI.SimpleSelectDataLevel1Node.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-simple-select-data-level1-node bi-list-item",
id: "",
pId: "",
open: false,
height: 25
})
},
_init: function () {
BI.SimpleSelectDataLevel1Node.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.checkbox = BI.createWidget({
type: "bi.tree_group_node_checkbox"
});
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
whiteSpace: "nowrap",
textHeight: o.height,
height: o.height,
hgap: o.hgap,
text: o.text,
value: o.value,
py: o.py
});
this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
if(type === BI.Events.CLICK) {
self.setSelected(self.isSelected());
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: {
type: "bi.layout"
},
width: 10
},{
width: 23,
el: this.checkbox
}, {
el: this.text
}]
})
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doClick: function () {
BI.SimpleSelectDataLevel1Node.superclass.doClick.apply(this, arguments);
this.checkbox.setSelected(this.isOpened());
},
setOpened: function (v) {
BI.SimpleSelectDataLevel1Node.superclass.setOpened.apply(this, arguments);
this.checkbox.setSelected(v);
},
setEnable: function (b) {
BI.SimpleSelectDataLevel1Node.superclass.setEnable.apply(this, arguments);
this.checkbox.setEnable(b);
}
});
$.shortcut("bi.simple_select_data_level1_node", BI.SimpleSelectDataLevel1Node);

287
src/widget/singleslider/singleslider.js

@ -1,287 +0,0 @@
/**
* Created by zcf on 2016/9/22.
*/
BI.SingleSlider = BI.inherit(BI.Widget, {
_constant: {
EDITOR_WIDTH: 90,
EDITOR_HEIGHT: 30,
HEIGHT: 28,
SLIDER_WIDTH_HALF: 15,
SLIDER_WIDTH: 30,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24
},
_defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track"
});
},
_init: function () {
BI.SingleSlider.superclass._init.apply(this, arguments);
var self = this;
var c = this._constant;
this.enable = false;
this.value = "";
this.backgroundTrack = BI.createWidget({
type: "bi.layout",
cls: "background-track",
height: c.TRACK_HEIGHT
});
this.grayTrack = BI.createWidget({
type: "bi.layout",
cls: "gray-track",
height: 8
});
this.blueTrack = BI.createWidget({
type: "bi.layout",
cls: "blue-track",
height: 8
});
this.track = this._createTrackWrapper();
this.slider = BI.createWidget({
type: "bi.single_slider_slider"
});
this.slider.element.draggable({
axis: "x",
containment: this.grayTrack.element,
scroll: false,
drag: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.label.setValue(v);
self.value = v;
},
stop: function (e, ui) {
var percent = (ui.position.left) * 100 / (self._getGrayTrackLength());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setSliderPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
var sliderVertical = BI.createWidget({
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [this.slider]
}],
hgap: c.SLIDER_WIDTH_HALF,
height: c.SLIDER_HEIGHT
});
sliderVertical.element.click(function (e) {
if (self.enable) {
var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
var trackLength = self.track.element[0].scrollWidth;
var percent = 0;
if (offset < 0) {
percent = 0
}
if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
percent = offset * 100 / self._getGrayTrackLength();
}
if (offset > (trackLength - c.SLIDER_WIDTH)) {
percent = 100
}
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
self.label.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}
});
this.label = BI.createWidget({
type: "bi.sign_editor",
cls: "slider-editor-button",
errorText: "",
height: c.HEIGHT,
width: c.EDITOR_WIDTH,
allowBlank: false,
validationChecker: function (v) {
return self._checkValidation(v);
},
quitChecker: function (v) {
return self._checkValidation(v);
}
});
this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
var percent = self._getPercentByValue(this.getValue());
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
});
this._setVisible(false);
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.track,
width: "100%",
height: c.TRACK_HEIGHT
}]
}],
hgap: 7,
height: c.TRACK_HEIGHT
},
top: 33,
left: 0,
width: "100%"
}, {
el: sliderVertical,
top: 30,
left: 0,
width: "100%"
}, {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [this.label]
}],
rgap: c.EDITOR_WIDTH,
height: c.EDITOR_HEIGHT
},
top: 0,
left: 0,
width: "100%"
}]
})
},
_createTrackWrapper: function () {
return BI.createWidget({
type: "bi.absolute",
items: [{
el: this.backgroundTrack,
width: "100%"
}, {
el: {
type: "bi.vertical",
items: [{
type: "bi.absolute",
items: [{
el: this.grayTrack,
top: 0,
left: 0,
width: "100%"
}, {
el: this.blueTrack,
top: 0,
left: 0,
width: "0%"
}]
}],
hgap: 8,
height: 8
},
top: 8,
left: 0,
width: "100%"
}]
})
},
_checkValidation: function (v) {
return !(BI.isNull(v) || v < this.min || v > this.max)
},
_setBlueTrack: function (percent) {
this.blueTrack.element.css({"width": percent + "%"});
},
_setLabelPosition: function (percent) {
this.label.element.css({"left": percent + "%"});
},
_setSliderPosition: function (percent) {
this.slider.element.css({"left": percent + "%"});
},
_setAllPosition: function (percent) {
this._setSliderPosition(percent);
this._setLabelPosition(percent);
this._setBlueTrack(percent);
},
_setVisible: function (visible) {
this.slider.setVisible(visible);
this.label.setVisible(visible);
},
_getGrayTrackLength: function () {
return this.grayTrack.element[0].scrollWidth
},
_getValueByPercent: function (percent) {
var thousandth = BI.parseInt(percent * 10);
return (((this.max - this.min) * thousandth) / 1000 + this.min);
},
_getPercentByValue: function (v) {
return (v - this.min) * 100 / (this.max - this.min);
},
getValue: function () {
return this.value;
},
setValue: function (v) {
var value = BI.parseFloat(v);
if ((!isNaN(value))) {
if (this._checkValidation(value)) {
this.value = value;
}
if (value > this.max) {
this.value = this.max;
}
if (value < this.min) {
this.value = this.min;
}
}
},
setMinAndMax: function (v) {
var minNumber = BI.parseFloat(v.min);
var maxNumber = BI.parseFloat(v.max);
if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) {
this.min = minNumber;
this.max = maxNumber;
}
},
reset: function () {
this._setVisible(false);
this.enable = false;
this.value = "";
this.min = 0;
this.max = 0;
this._setBlueTrack(0);
},
populate: function () {
if (!isNaN(this.min) && !isNaN(this.max)) {
this._setVisible(true);
this.enable = true;
this.label.setErrorText(BI.i18nText("BI-Please_Enter") + this.min + "-" + this.max + BI.i18nText("BI-Basic_De") + BI.i18nText("BI-Basic_Number"));
if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
this.label.setValue(this.value);
this._setAllPosition(this._getPercentByValue(this.value));
} else {
this.label.setValue(this.max);
this._setAllPosition(100);
}
}
}
});
BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE";
$.shortcut("bi.single_slider", BI.SingleSlider);

33
src/widget/singleslider/slider/widget.slider.js

@ -1,33 +0,0 @@
/**
* Created by zcf on 2016/9/22.
*/
BI.Slider = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Slider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider-slider"
});
},
_init: function () {
BI.extend(BI.Slider.superclass._init.apply(this, arguments));
this.slider = BI.createWidget({
type: "bi.icon_button",
cls: "widget-slider-icon",
iconWidth: 30,
iconHeight: 30,
height: 30,
width: 30
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.slider,
top: 0,
left: -15
}],
width: 0,
height: 30
});
}
});
$.shortcut("bi.single_slider_slider", BI.Slider);

125
src/widget/textarea/textarea.js

@ -1,125 +0,0 @@
/**
* 文本组件中 编辑栏作为trigger
*
* Created by GameJian on 2016/1/24.
*/
BI.TextArea = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TextArea.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-text-area"
});
},
_init: function () {
BI.TextArea.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.textarea = BI.createWidget({
type: "bi.textarea_editor",
width: "100%",
height: "100%"
});
this.textarea.on(BI.TextAreaEditor.EVENT_FOCUS, function () {
self.combo.showView();
});
this.textarea.on(BI.TextAreaEditor.EVENT_BLUR, function () {
if (BI.isEmptyString(this.getValue()) && !self.combo.isViewVisible()) {
self._showLabel();
} else {
self._showInput();
}
self.fireEvent(BI.TextArea.EVENT_VALUE_CHANGE, arguments)
});
this.toolbar = BI.createWidget({
type: "bi.text_toolbar"
});
this.toolbar.on(BI.TextToolbar.EVENT_CHANGE, function () {
var style = this.getValue();
self.textarea.setStyle(style);
self.element.css(style);
self.fireEvent(BI.TextArea.EVENT_VALUE_CHANGE, arguments);
});
this.combo = BI.createWidget({
type: "bi.combo",
toggle: false,
direction: "top",
isNeedAdjustWidth: false,
isNeedAdjustHeight: false,
adjustLength: 1,
el: this.textarea,
popup: {
el: this.toolbar,
width: 253,
height: 30,
stopPropagation: false
}
});
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
if (BI.isNotEmptyString(self.textarea.getValue())) {
self._showInput();
} else {
self._showLabel();
}
});
this.label = BI.createWidget({
type: "bi.text_button",
cls: "text-area-editor-text-button-label",
whiteSpace: "normal",
text: BI.i18nText("BI-Click_To_Input_Text")
});
this.label.on(BI.TextButton.EVENT_CHANGE, function () {
self._showInput();
self.textarea.focus();
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.combo,
left: 10,
right: 10,
top: 10,
bottom: 10
}, {
el: this.label,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
},
_showInput: function () {
this.label.setVisible(false);
},
_showLabel: function () {
this.label.setVisible(true);
},
setValue: function (v) {
v || (v = {});
if (BI.isNotEmptyString(v.content)) {
this._showInput();
}
this.textarea.setValue(v.content);
this.toolbar.setValue(v.style);
this.textarea.setStyle(v.style);
this.element.css(v.style);
},
getValue: function () {
return {style: this.toolbar.getValue(), content: this.textarea.getValue()};
}
});
BI.TextArea.EVENT_VALUE_CHANGE = "EVENT_VALUE_CHANGE";
$.shortcut("bi.text_area", BI.TextArea);

66
src/widget/texttoolbar/alignchooser/texttoolbar.alignchooser.js

@ -1,66 +0,0 @@
/**
* 对齐方式选择
*
* Created by GUY on 2015/11/26.
* @class BI.TextToolbarAlignChooser
* @extends BI.Widget
*/
BI.TextToolbarAlignChooser = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TextToolbarAlignChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-text-toolbar-align-chooser",
width: 60,
height: 20
});
},
_init: function () {
BI.TextToolbarAlignChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.button_group = BI.createWidget({
type: "bi.button_group",
element: this,
items: BI.createItems([{
cls: "align-chooser-button text-align-left-font",
selected: true,
title: BI.i18nText("BI-Word_Align_Left"),
value: BI.TextToolbarAlignChooser.TEXT_ALIGN_LEFT
}, {
cls: "align-chooser-button text-align-center-font",
title: BI.i18nText("BI-Word_Align_Middle"),
value: BI.TextToolbarAlignChooser.TEXT_ALIGN_CENTER
}, {
cls: "align-chooser-button text-align-right-font",
title: BI.i18nText("BI-Word_Align_Right"),
value: BI.TextToolbarAlignChooser.TEXT_ALIGN_RIGHT
}], {
type: "bi.icon_button",
height: o.height
}),
layouts: [{
type: "bi.center"
}]
});
this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function () {
self.fireEvent(BI.TextToolbarAlignChooser.EVENT_CHANGE, arguments);
});
},
setValue: function (v) {
this.button_group.setValue(v);
},
getValue: function () {
return this.button_group.getValue()[0];
}
});
BI.extend(BI.TextToolbarAlignChooser, {
TEXT_ALIGN_LEFT: "left",
TEXT_ALIGN_CENTER: "center",
TEXT_ALIGN_RIGHT: "right"
});
BI.TextToolbarAlignChooser.EVENT_CHANGE = "BI.TextToolbarAlignChooser.EVENT_CHANGE";
$.shortcut('bi.text_toolbar_align_chooser', BI.TextToolbarAlignChooser);

53
src/widget/texttoolbar/backgroundchooser/texttoolbar.backgroundchooser.trigger.js

@ -1,53 +0,0 @@
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.TextToolbarBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.TextToolbarBackgroundChooserTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
var conf = BI.TextToolbarBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-toolbar-background-chooser-trigger",
width: 20,
height: 20
});
},
_init: function () {
BI.TextToolbarBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 3,
left: 2
}, {
el: this.underline,
top: 9,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
$.shortcut('bi.text_toolbar_background_chooser_trigger', BI.TextToolbarBackgroundChooserTrigger);

53
src/widget/texttoolbar/colorchooser/texttoolbar.colorchooser.trigger.js

@ -1,53 +0,0 @@
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.TextToolbarColorChooserTrigger
* @extends BI.Widget
*/
BI.TextToolbarColorChooserTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
var conf = BI.TextToolbarColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-toolbar-color-chooser-trigger",
width: 20,
height: 20
});
},
_init: function () {
BI.TextToolbarColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 4,
left: 2
},{
el: this.underline,
top: 9,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
$.shortcut('bi.text_toolbar_color_chooser_trigger', BI.TextToolbarColorChooserTrigger);

106
src/widget/texttoolbar/sizechooser/texttoolbar.sizechooser.js

@ -1,106 +0,0 @@
/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.TextToolbarSizeChooser
* @extends BI.Widget
*/
BI.TextToolbarSizeChooser = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TextToolbarSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-text-toolbar-size-chooser",
width: 50,
height: 20
});
},
_items: [{
value: 12
}, {
value: 14,
selected: true
}, {
value: 16
}, {
value: 18
}, {
value: 20
}, {
value: 22
}, {
value: 24
}, {
value: 26
}, {
value: 28
}, {
value: 30
}, {
value: 32
}, {
value: 34
}, {
value: 36
}, {
value: 38
}, {
value: 40
}, {
value: 64
}, {
value: 128
}],
_init: function () {
BI.TextToolbarSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.editor_trigger",
cls: "text-toolbar-size-chooser-editor-trigger",
height: o.height,
triggerWidth: 12,
validationChecker: function (size) {
return BI.isInteger(size) && size > 0;
},
value: 14
});
this.trigger.on(BI.EditorTrigger.EVENT_CHANGE, function () {
self.setValue(BI.parseInt(this.getValue()));
self.fireEvent(BI.TextToolbarSizeChooser.EVENT_CHANGE, arguments);
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: o.width,
minWidth: o.width,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
this.hideView();
self.fireEvent(BI.TextToolbarSizeChooser.EVENT_CHANGE, arguments);
})
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
return BI.parseInt(this.trigger.getValue());
}
});
BI.TextToolbarSizeChooser.EVENT_CHANGE = "BI.TextToolbarSizeChooser.EVENT_CHANGE";
$.shortcut('bi.text_toolbar_size_chooser', BI.TextToolbarSizeChooser);

130
src/widget/texttoolbar/texttoolbar.js

@ -1,130 +0,0 @@
/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.TextToolbar
* @extends BI.Widget
*/
BI.TextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-text-toolbar",
width: 253,
height: 28
});
},
_init: function () {
BI.TextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.size = BI.createWidget({
type: "bi.text_toolbar_size_chooser",
cls: "text-toolbar-size-chooser-trigger",
title: BI.i18nText("BI-Font_Size")
});
this.size.on(BI.TextToolbarSizeChooser.EVENT_CHANGE, function () {
self.fireEvent(BI.TextToolbar.EVENT_CHANGE, arguments);
});
this.bold = BI.createWidget({
type: "bi.icon_button",
title: BI.i18nText("BI-Basic_Bold"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-bold-font"
});
this.bold.on(BI.IconButton.EVENT_CHANGE, function () {
self.fireEvent(BI.TextToolbar.EVENT_CHANGE, arguments);
});
this.italic = BI.createWidget({
type: "bi.icon_button",
title: BI.i18nText("BI-Basic_Italic"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-italic-font"
});
this.italic.on(BI.IconButton.EVENT_CHANGE, function () {
self.fireEvent(BI.TextToolbar.EVENT_CHANGE, arguments);
});
this.underline = BI.createWidget({
type: "bi.icon_button",
title: BI.i18nText("BI-Underline"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-underline-font"
});
this.underline.on(BI.IconButton.EVENT_CHANGE, function () {
self.fireEvent(BI.TextToolbar.EVENT_CHANGE, arguments);
});
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
el: {
type: "bi.text_toolbar_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.fireEvent(BI.TextToolbar.EVENT_CHANGE, arguments);
});
this.backgroundchooser = BI.createWidget({
type: "bi.color_chooser",
el: {
type: "bi.text_toolbar_background_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.backgroundchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.fireEvent(BI.TextToolbar.EVENT_CHANGE, arguments);
});
this.alignchooser = BI.createWidget({
type: "bi.text_toolbar_align_chooser",
cls: "text-toolbar-button"
});
this.alignchooser.on(BI.TextToolbarAlignChooser.EVENT_CHANGE, function () {
self.fireEvent(BI.TextToolbar.EVENT_CHANGE, arguments);
});
BI.createWidget({
type: "bi.left",
element: this,
items: [this.size, this.bold, this.italic, this.underline, this.colorchooser, this.backgroundchooser, this.alignchooser],
hgap: 3,
vgap: 3
})
},
isColorChooserVisible: function () {
return this.colorchooser.isViewVisible();
},
isBackgroundChooserVisible: function () {
return this.backgroundchooser.isViewVisible();
},
setValue: function (v) {
v || (v = {});
this.size.setValue(v["fontSize"] || 14);
this.bold.setSelected(v["fontWeight"] === "bold");
this.italic.setSelected(v["fontStyle"] === "italic");
this.underline.setSelected(v["textDecoration"] === "underline");
this.colorchooser.setValue(v["color"] || "#000000");
this.backgroundchooser.setValue(v["backgroundColor"] || "#ffffff");
this.alignchooser.setValue(v["textAlign"] || "left");
},
getValue: function () {
return {
"fontSize": this.size.getValue(),
"fontWeight": this.bold.isSelected() ? "bold" : "normal",
"fontStyle": this.italic.isSelected() ? "italic" : "normal",
"textDecoration": this.underline.isSelected() ? "underline" : "initial",
"color": this.colorchooser.getValue(),
"backgroundColor": this.backgroundchooser.getValue(),
"textAlign": this.alignchooser.getValue()
}
}
});
BI.TextToolbar.EVENT_CHANGE = "BI.TextToolbar.EVENT_CHANGE";
$.shortcut('bi.text_toolbar', BI.TextToolbar);

189
src/widget/timeinterval/timeinterval.js

@ -1,189 +0,0 @@
/**
* Created by Baron on 2015/10/19.
*/
BI.TimeInterval = BI.inherit(BI.Single, {
constants: {
height: 25,
width: 25,
lgap: 15,
offset: -15,
timeErrorCls: "time-error",
DATE_MIN_VALUE: "1900-01-01",
DATE_MAX_VALUE: "2099-12-31"
},
_defaultConfig: function () {
var conf = BI.TimeInterval.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
extraCls: "bi-time-interval"
})
},
_init: function () {
var self = this;
BI.TimeInterval.superclass._init.apply(this, arguments);
this.left = this._createCombo();
this.right = this._createCombo();
this.label = BI.createWidget({
type: 'bi.label',
height: this.constants.height,
width: this.constants.width,
text: "-"
});
BI.createWidget({
element: self,
type: "bi.center",
hgap: 15,
height: this.constants.height,
items: [{
type: "bi.absolute",
items: [{
el: self.left,
left: this.constants.offset,
right: 0,
top: 0,
bottom: 0
}]
}, {
type: "bi.absolute",
items: [{
el: self.right,
left: 0,
right: this.constants.offset,
top: 0,
bottom: 0
}]
}]
});
BI.createWidget({
type: "bi.horizontal_auto",
element: this,
items: [
self.label
]
});
},
_createCombo: function () {
var self = this;
var combo = BI.createWidget({
type: 'bi.multidate_combo'
});
combo.on(BI.MultiDateCombo.EVENT_ERROR, function () {
self._clearTitle();
self.element.removeClass(self.constants.timeErrorCls);
self.fireEvent(BI.TimeInterval.EVENT_ERROR);
});
combo.on(BI.MultiDateCombo.EVENT_VALID, function(){
BI.Bubbles.hide("error");
var smallDate = self.left.getKey(), bigDate = self.right.getKey();
if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
self.element.addClass(self.constants.timeErrorCls);
BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
offsetStyle: "center"
});
self.fireEvent(BI.TimeInterval.EVENT_ERROR);
} else {
self._clearTitle();
self.element.removeClass(self.constants.timeErrorCls);
}
});
combo.on(BI.MultiDateCombo.EVENT_FOCUS, function(){
BI.Bubbles.hide("error");
var smallDate = self.left.getKey(), bigDate = self.right.getKey();
if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
self.element.addClass(self.constants.timeErrorCls);
BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
offsetStyle: "center"
});
self.fireEvent(BI.TimeInterval.EVENT_ERROR);
} else {
self._clearTitle();
self.element.removeClass(self.constants.timeErrorCls);
}
});
combo.on(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW, function () {
self.left.hidePopupView();
self.right.hidePopupView();
});
//combo.on(BI.MultiDateCombo.EVENT_CHANGE, function () {
// BI.Bubbles.hide("error");
// var smallDate = self.left.getKey(), bigDate = self.right.getKey();
// if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
// self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
// self.element.addClass(self.constants.timeErrorCls);
// BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
// offsetStyle: "center"
// });
// self.fireEvent(BI.TimeInterval.EVENT_ERROR);
// } else {
// self._clearTitle();
// self.element.removeClass(self.constants.timeErrorCls);
// }
//});
combo.on(BI.MultiDateCombo.EVENT_CONFIRM, function(){
BI.Bubbles.hide("error");
var smallDate = self.left.getKey(), bigDate = self.right.getKey();
if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
self.element.addClass(self.constants.timeErrorCls);
self.fireEvent(BI.TimeInterval.EVENT_ERROR);
}else{
self._clearTitle();
self.element.removeClass(self.constants.timeErrorCls);
self.fireEvent(BI.TimeInterval.EVENT_CHANGE);
}
});
return combo;
},
_dateCheck: function (date) {
return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date;
},
_checkVoid: function (obj) {
return !Date.checkVoid(obj.year, obj.month, obj.day, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0];
},
_check: function (smallDate, bigDate) {
var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g);
return this._dateCheck(smallDate) && Date.checkLegal(smallDate) && this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2]
}) && this._dateCheck(bigDate) && Date.checkLegal(bigDate) && this._checkVoid({
year: bigObj[0],
month: bigObj[1],
day: bigObj[2]
});
},
_compare: function (smallDate, bigDate) {
smallDate = Date.parseDateTime(smallDate, "%Y-%X-%d").print("%Y-%X-%d");
bigDate = Date.parseDateTime(bigDate, "%Y-%X-%d").print("%Y-%X-%d");
return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate;
},
_setTitle: function (v) {
this.left.setTitle(v);
this.right.setTitle(v);
this.label.setTitle(v);
},
_clearTitle: function () {
this.left.setTitle("");
this.right.setTitle("");
this.label.setTitle("");
},
setValue: function (date) {
date = date || {};
this.left.setValue(date.start);
this.right.setValue(date.end);
},
getValue: function () {
return {start: this.left.getValue(), end: this.right.getValue()};
}
});
BI.TimeInterval.EVENT_VALID = "EVENT_VALID";
BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR";
BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE";
$.shortcut("bi.time_interval", BI.TimeInterval);

79
src/widget/timesetting/timesetting.day.js

@ -1,79 +0,0 @@
/**
* Created by Young's on 2016/4/22.
*/
BI.DayTimeSetting = BI.inherit(BI.Widget, {
_defaultConfig: function(){
return BI.extend(BI.DayTimeSetting.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-time-setting-day",
day: 1
})
},
_init: function(){
BI.DayTimeSetting.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var decrease = BI.createWidget({
type: "bi.text_button",
cls: "operator-button",
text: "-",
height: 28,
width: 28
});
decrease.on(BI.Button.EVENT_CHANGE, function(){
var day = BI.parseInt(self.day.getValue());
if(day === 1) {
day = 31;
} else {
day --;
}
self.day.setValue(day);
self.fireEvent(BI.DayTimeSetting.EVENT_CHANGE);
});
var increase = BI.createWidget({
type: "bi.text_button",
cls: "operator-button",
text: "+",
height: 28,
width: 28
});
increase.on(BI.Button.EVENT_CHANGE, function(){
var day = BI.parseInt(self.day.getValue());
if(day === 31) {
day = 1;
} else {
day ++;
}
self.day.setValue(day);
self.fireEvent(BI.DayTimeSetting.EVENT_CHANGE);
});
this.day = BI.createWidget({
type: "bi.label",
value: o.day,
height: 30,
width: 40
});
BI.createWidget({
type: "bi.left",
element: this,
items: [decrease, this.day, increase, {
type: "bi.label",
text: BI.i18nText("BI-Day_Ri"),
height: 30,
width: 20
}],
height: 30
})
},
getValue: function(){
return BI.parseInt(this.day.getValue());
},
setValue: function(v) {
this.day.setValue(v);
}
});
BI.DayTimeSetting.EVENT_CHANGE = "EVENT_CHANGE";
$.shortcut("bi.day_time_setting", BI.DayTimeSetting);

75
src/widget/timesetting/timesetting.hour.js

@ -1,75 +0,0 @@
/**
* Created by Young's on 2016/4/22.
*/
BI.HourTimeSetting = BI.inherit(BI.Widget, {
_defaultConfig: function(){
return BI.extend(BI.HourTimeSetting.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-time-setting-hour",
hour: 0
})
},
_init: function(){
BI.HourTimeSetting.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var decrease = BI.createWidget({
type: "bi.text_button",
cls: "operator-button",
text: "-",
height: 28,
width: 28
});
decrease.on(BI.Button.EVENT_CHANGE, function(){
var hour = BI.parseInt(self.hour.getValue());
if(hour === 0) {
hour = 23;
} else {
hour --;
}
self.hour.setValue(hour);
self.fireEvent(BI.HourTimeSetting.EVENT_CHANGE);
});
var increase = BI.createWidget({
type: "bi.text_button",
cls: "operator-button",
text: "+",
height: 28,
width: 28
});
increase.on(BI.Button.EVENT_CHANGE, function(){
var hour = BI.parseInt(self.hour.getValue());
hour === 23 ? (hour = 0) : (hour ++);
self.hour.setValue(hour);
self.fireEvent(BI.HourTimeSetting.EVENT_CHANGE);
});
this.hour = BI.createWidget({
type: "bi.label",
value: o.hour,
height: 30,
width: 40
});
BI.createWidget({
type: "bi.left",
element: this,
items: [decrease, this.hour, increase, {
type: "bi.label",
text: BI.i18nText("BI-Hour_Dian"),
height: 30,
width: 20
}],
height: 30
})
},
getValue: function(){
return BI.parseInt(this.hour.getValue());
},
setValue: function(v) {
this.hour.setValue(v);
}
});
BI.HourTimeSetting.EVENT_CHANGE = "EVENT_CHANGE";
$.shortcut("bi.hour_time_setting", BI.HourTimeSetting);

51
src/widget/treelabel/treelabel.js

@ -1,51 +0,0 @@
BI.TreeLabel = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TreeLabel.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-label",
itemsCreator: BI.emptyFn,
titles: [],
items: []
})
},
_init: function () {
BI.TreeLabel.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.titles = o.titles;
this.items = o.items;
this.view = BI.createWidget({
type: "bi.tree_label_view",
element: this,
titles: o.titles,
items: o.items
});
this.view.on(BI.TreeLabelView.EVENT_CHANGE, function (floors) {
var op = {};
if (floors !== self.view.getMaxFloor() - 1) {
op.floors = floors;
op.selectedValues = self.getValue();
self._itemsCreator(op);
}
self.fireEvent(BI.TreeLabel.EVENT_CHANGE, arguments);
});
},
_itemsCreator: function (options) {
var self = this, o = this.options;
o.itemsCreator(options, function (data) {
self.populate(data);
})
},
populate: function (v) {
this.view.populate(v);
},
getValue: function () {
return this.view.getValue();
}
});
BI.TreeLabel.EVENT_CHANGE = "BI.TreeLabel.EVENT_CHANGE";
$.shortcut('bi.tree_label', BI.TreeLabel);

144
src/widget/treelabel/treelabel.view.js

@ -1,144 +0,0 @@
BI.TreeLabelView = BI.inherit(BI.Widget, {
_constant: {
LIST_LABEL_HEIGHT: 40,
DEFAULT_LEFT_GAP: 5
},
_defaultConfig: function () {
return BI.extend(BI.TreeLabelView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-label-view",
titleWidth: 60,
titles: [],
items: []
})
},
_init: function () {
BI.TreeLabelView.superclass._init.apply(this, arguments);
this.items = [];
this._initView();
},
_initView: function () {
var self = this, o = this.options;
this.title = BI.createWidget({
type: "bi.button_group",
height: this._constant.LIST_LABEL_HEIGHT * o.titles.length,
layouts: [{
type: "bi.vertical"
}]
});
this.right = BI.createWidget({
type: "bi.button_group",
cls: "list-label-group",
height: this._constant.LIST_LABEL_HEIGHT * this.items.length,
layouts: [{
type: "bi.horizontal"
}]
});
this._setTitles(o.titles);
this._setItems(o.items);
BI.createWidget({
type: "bi.absolute",
items: [{
el: this.title,
left: 0,
right: 0,
top: 0,
bottom: 0,
width: 60
}, {
el: this.right,
left: 65,
right: 0,
top: 0,
bottom: 0
}],
element: this
});
},
_setItems: function (items) {
var self = this;
var length = this.right.getAllButtons().length;
var deletes = [];
for (var i = 0; i < length; i++) {
deletes.push(i);
}
this.right.removeItemAt(deletes);
self.items = [];
BI.each(items, function (idx, values) {
var labelItems = [];
BI.each(values, function (idx, value) {
labelItems.push({
title: value,
text: value,
value: value
})
});
var temp = BI.createWidget({
type: "bi.list_label",
items: labelItems,
showTitle: false
});
temp.on(BI.ListLabel.EVENT_CHANGE, function () {
self.fireEvent(BI.TreeLabelView.EVENT_CHANGE, idx);
});
self.items.push(temp);
});
var temp = BI.createWidget({
type: "bi.default",
items: self.items
});
this.right.addItems([temp]);
this.right.setHeight(self.items.length * this._constant.LIST_LABEL_HEIGHT);
},
_setTitles: function (titles) {
var length = this.title.getAllButtons().length;
var deletes = [], titleItems = [];
for (var i = 0; i < length; i++) {
deletes.push(i);
}
BI.each(titles, function (idx, title) {
titleItems.push({
text: title,
value: title,
title: title
});
});
this.title.removeItemAt(deletes);
this.title.addItems(BI.createItems(titleItems, {
type: "bi.label",
height: this._constant.LIST_LABEL_HEIGHT,
width: this.options.titleWidth
}));
this.title.setHeight(titles.length * this._constant.LIST_LABEL_HEIGHT);
},
_setValue: function (values) {
BI.each(this.items, function (idx, item) {
values[idx] && item.setValue(values[idx]);
})
},
populate: function(v) {
v.titles && this._setTitles(v.titles);
v.items && this._setItems(v.items);
v.values && this._setValue(v.values);
},
getMaxFloor: function () {
return this.items.length || 0;
},
getValue: function () {
var result = [];
BI.each(this.items, function (idx, item) {
result.push(item.getValue());
});
return result;
}
});
BI.TreeLabelView.EVENT_CHANGE = "BI.TreeLabelView.EVENT_CHANGE";
$.shortcut('bi.tree_label_view', BI.TreeLabelView);
Loading…
Cancel
Save