From aee0d19bd3b334f62e077ab03b682d348e02752e Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 24 Mar 2017 18:12:18 +0800 Subject: [PATCH] update --- dist/base.js | 12 +- dist/core.js | 51 +- dist/widget.js | 4894 +++-------------- src/base/base.js | 1 + src/base/combination/group.virtual.js | 8 + src/base/combination/tab.js | 3 +- .../allvaluechooser/combo.allvaluechooser.js | 118 + src/core/controller/controller.broadcast.js | 6 +- src/core/widget.js | 14 +- src/core/wrapper/layout.js | 31 +- .../dynamicgroup.tab.buttongroup.js | 219 - src/widget/intervalslider/intervalslider.js | 437 -- .../model.accuratecalculation.js | 222 - .../move2group/button.add.move2group.js | 59 - src/widget/move2group/combo.move2group.js | 136 - src/widget/move2group/toolbar.move2group.js | 85 - src/widget/multistringlist/multistringlist.js | 320 -- src/widget/multitreelist/multitreelist.js | 178 - .../multitreelist/multitreelist.popup.js | 48 - src/widget/simplesearcher/searcher.simple.js | 108 - .../searcher/searcher.simpleselectdata.js | 104 - .../result.search.simpleselectdata.js | 104 - .../segment.search.simpleselectdata.js | 69 - .../simpleselectdata/treenode/node.level0.js | 76 - .../simpleselectdata/treenode/node.level1.js | 81 - src/widget/singleslider/singleslider.js | 287 - .../singleslider/slider/widget.slider.js | 33 - src/widget/textarea/textarea.js | 125 - .../alignchooser/texttoolbar.alignchooser.js | 66 - .../texttoolbar.backgroundchooser.trigger.js | 53 - .../texttoolbar.colorchooser.trigger.js | 53 - .../sizechooser/texttoolbar.sizechooser.js | 106 - src/widget/texttoolbar/texttoolbar.js | 130 - src/widget/timeinterval/timeinterval.js | 189 - src/widget/timesetting/timesetting.day.js | 79 - src/widget/timesetting/timesetting.hour.js | 75 - src/widget/treelabel/treelabel.js | 51 - src/widget/treelabel/treelabel.view.js | 144 - 38 files changed, 901 insertions(+), 7874 deletions(-) create mode 100644 src/component/allvaluechooser/combo.allvaluechooser.js delete mode 100644 src/widget/dynamicgrouptab/dynamicgroup.tab.buttongroup.js delete mode 100644 src/widget/intervalslider/intervalslider.js delete mode 100644 src/widget/intervalslider/model.accuratecalculation.js delete mode 100644 src/widget/move2group/button.add.move2group.js delete mode 100644 src/widget/move2group/combo.move2group.js delete mode 100644 src/widget/move2group/toolbar.move2group.js delete mode 100644 src/widget/multistringlist/multistringlist.js delete mode 100644 src/widget/multitreelist/multitreelist.js delete mode 100644 src/widget/multitreelist/multitreelist.popup.js delete mode 100644 src/widget/simplesearcher/searcher.simple.js delete mode 100644 src/widget/simpleselectdata/searcher/searcher.simpleselectdata.js delete mode 100644 src/widget/simpleselectdata/searchpane/result.search.simpleselectdata.js delete mode 100644 src/widget/simpleselectdata/searchpane/segment.search.simpleselectdata.js delete mode 100644 src/widget/simpleselectdata/treenode/node.level0.js delete mode 100644 src/widget/simpleselectdata/treenode/node.level1.js delete mode 100644 src/widget/singleslider/singleslider.js delete mode 100644 src/widget/singleslider/slider/widget.slider.js delete mode 100644 src/widget/textarea/textarea.js delete mode 100644 src/widget/texttoolbar/alignchooser/texttoolbar.alignchooser.js delete mode 100644 src/widget/texttoolbar/backgroundchooser/texttoolbar.backgroundchooser.trigger.js delete mode 100644 src/widget/texttoolbar/colorchooser/texttoolbar.colorchooser.trigger.js delete mode 100644 src/widget/texttoolbar/sizechooser/texttoolbar.sizechooser.js delete mode 100644 src/widget/texttoolbar/texttoolbar.js delete mode 100644 src/widget/timeinterval/timeinterval.js delete mode 100644 src/widget/timesetting/timesetting.day.js delete mode 100644 src/widget/timesetting/timesetting.hour.js delete mode 100644 src/widget/treelabel/treelabel.js delete mode 100644 src/widget/treelabel/treelabel.view.js diff --git a/dist/base.js b/dist/base.js index 115ef4340..14edec7ef 100644 --- a/dist/base.js +++ b/dist/base.js @@ -2349,6 +2349,7 @@ BI.Bubbles = new BI.BubblesController(); BI.Tooltips = new BI.TooltipsController(); BI.Popovers = new BI.FloatBoxController(); BI.Broadcasts = new BI.BroadcastController(); +BI.StyleLoaders = new BI.StyleLoaderManager(); BI.servletURL = "dist/"; BI.i18n = {};/** @@ -3597,6 +3598,14 @@ $.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Widg return layout; }, + addItems: function (items) { + this.layouts.addItems(items); + }, + + prependItems: function (items) { + this.layouts.prependItems(items); + }, + populate: function (items) { var self = this; items = items || []; @@ -4607,8 +4616,7 @@ BI.Tab = BI.inherit(BI.Widget, { }) }, - _init: function () { - BI.Tab.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; if (BI.isObject(o.tab)) { this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"}); diff --git a/dist/core.js b/dist/core.js index ee7845ebb..b4f0d8dcc 100644 --- a/dist/core.js +++ b/dist/core.js @@ -14369,8 +14369,12 @@ BI.Widget = BI.inherit(BI.OB, { var o = this.options; this.widgetName = o.widgetName || BI.uniqueId("widget"); if (BI.isWidget(o.element)) { - this._parent = o.element; - this._parent.addWidget(this.widgetName, this); + if (o.element instanceof BI.Widget) { + this._parent = o.element; + this._parent.addWidget(this.widgetName, this); + } else { + this._isRoot = true; + } this.element = this.options.element.element; } else if (o.element) { this.element = $(o.element); @@ -14465,7 +14469,7 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = true; this._mountChildren(); BI.each(this._children, function (i, widget) { - widget._mount(); + widget._mount&&widget._mount(); }); this.mounted(); }, @@ -14487,7 +14491,7 @@ BI.Widget = BI.inherit(BI.OB, { _unMount: function () { BI.each(this._children, function (i, widget) { - widget._unMount(); + widget._unMount && widget._unMount(); }); this._children = {}; this._parent = null; @@ -14558,7 +14562,7 @@ BI.Widget = BI.inherit(BI.OB, { if (this._children[name]) { throw new Error("name has already been existed"); } - widget._setParent(this); + widget._setParent && widget._setParent(this); widget.on(BI.Events.DESTROY, function () { delete self._children[name] }); @@ -19439,19 +19443,11 @@ BI.Layout = BI.inherit(BI.Widget, { * @param {JSON/BI.Widget} item 子组件 */ addItem: function (item) { - var w = this._addElement(this.options.items.length, item); - this.options.items.push(item); - w.element.appendTo(this._getWrapper()); - w._mount(); - return w; + return this.addItemAt(this.options.items.length, item); }, prependItem: function (item) { - var w = this._addElement(this.options.items.length, item); - this.options.items.unshift(item); - w.element.prependTo(this._getWrapper()); - w._mount(); - return w; + return this.addItemAt(0,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))) { 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); + this.options.items.splice(index, 0, item); this._children[this._getChildName(index)] = w; if (index > 0) { this._children[this._getChildName(index - 1)].element.after(w.element); } else { w.element.prependTo(this._getWrapper()); } + del.destroy(); w._mount(); }, @@ -19503,6 +19503,7 @@ BI.Layout = BI.inherit(BI.Widget, { var added = []; BI.each(items, function (i, item) { var w = self._addElement(o.items.length, item); + self._children[self._getChildName(o.items.length)] = w; o.items.push(item); added.push(w); fragment.appendChild(w.element[0]); @@ -19514,11 +19515,13 @@ BI.Layout = BI.inherit(BI.Widget, { }, prependItems: function (items) { - items = items || []; + var self =this,items = items || []; var fragment = document.createDocumentFragment(); var added = []; 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]); added.push(w); fragment.appendChild(w.element[0]); @@ -19563,9 +19566,13 @@ BI.Layout = BI.inherit(BI.Widget, { } } if (o.items.length > items.length) { + var deleted = []; 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) { for (i = o.items.length; i < items.length; i++) { this.addItemAt(i, items[i]); @@ -20544,10 +20551,14 @@ BI.BroadcastController = BI.inherit(BI.Controller, { }, on: function (name, fn) { + var self = this; if (!this._broadcasts[name]) { this._broadcasts[name] = []; } this._broadcasts[name].push(fn); + return function () { + self._broadcasts[name].remove(fn); + } }, send: function (name) { @@ -20559,7 +20570,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, { remove: function (name, fn) { if (fn) { - BI.remove(this._broadcasts[name], fn); + this._broadcasts[name].remove(fn); } else { delete this._broadcasts[name]; } diff --git a/dist/widget.js b/dist/widget.js index a6c6172b1..28a602cf3 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -6894,224 +6894,6 @@ BI.DownListPopup = BI.inherit(BI.Pane, { BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE"; BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; $.shortcut("bi.down_list_popup", BI.DownListPopup);/** - * 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);/** * * Created by GUY on 2016/3/28. * @class BI.ExcelTableCell @@ -8707,753 +8489,96 @@ BI.InteractiveArrangement = BI.inherit(BI.Widget, { }); BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE"; $.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/** - * Created by zcf on 2016/9/26. + * 月份下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.MonthCombo + * @extends BI.Trigger */ -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 - }, - +BI.MonthCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.IntervalSlider.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-slider bi-slider-track" - }) + return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-combo", + height: 25 + }); }, - _init: function () { - BI.IntervalSlider.superclass._init.apply(this, arguments); + BI.MonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; - var self = this; - var c = this._constant; - this.enable = false; - this.valueOne = ""; - this.valueTwo = ""; - this.calculation = new BI.AccurateCalculationModel(); + this.trigger = BI.createWidget({ + type: "bi.month_trigger" + }); - this.backgroundTrack = BI.createWidget({ - type: "bi.layout", - cls: "background-track", - height: c.TRACK_HEIGHT + this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { + if(this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getValue()); + }else if(!this.getKey()){ + self.setValue(); + } + self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); }); - this.grayTrack = BI.createWidget({ - type: "bi.layout", - cls: "gray-track", - height: 8 + this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); }); - this.blueTrack = BI.createWidget({ - type: "bi.layout", - cls: "blue-track", - height: 8 + this.trigger.on(BI.MonthTrigger.EVENT_START, function () { + self.combo.hideView(); }); - 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.trigger.on(BI.MonthTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); } }); - 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.trigger.on(BI.MonthTrigger.EVENT_CHANGE, function () { + self.combo.isViewVisible() && self.combo.hideView(); }); - 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.popup = BI.createWidget({ + type: "bi.month_popup" + }); + this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); }); - this._setVisible(false); - BI.createWidget({ - type: "bi.absolute", + this.combo = BI.createWidget({ + type: "bi.combo", 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() - ] + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + el: this.popup + } }) }, - _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%" - } + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); }, - _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);/** - * 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); - } -});/** - * 月份下拉框 - * - * Created by GUY on 2015/8/28. - * @class BI.MonthCombo - * @extends BI.Trigger - */ -BI.MonthCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-month-combo", - height: 25 - }); - }, - _init: function () { - BI.MonthCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.month_trigger" - }); - - this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { - if(this.getKey() && this.getKey() !== self.storeValue) { - self.setValue(this.getValue()); - }else if(!this.getKey()){ - self.setValue(); - } - self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); - }); - this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () { - self.storeValue = this.getKey(); - }); - this.trigger.on(BI.MonthTrigger.EVENT_START, function () { - self.combo.hideView(); - }); - this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - this.trigger.on(BI.MonthTrigger.EVENT_CHANGE, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - - this.popup = BI.createWidget({ - type: "bi.month_popup" - }); - this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - el: this.popup - } - }) - }, - - setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); - -BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -$.shortcut('bi.month_combo', BI.MonthCombo);/** - * 月份展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.MonthPopup - * @extends BI.Trigger - */ -BI.MonthPopup = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-month-popup" - }); + getValue: function () { + return this.popup.getValue(); + } +}); + +BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +$.shortcut('bi.month_combo', BI.MonthCombo);/** + * 月份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.MonthPopup + * @extends BI.Trigger + */ +BI.MonthPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-popup" + }); }, _init: function () { @@ -9632,286 +8757,9 @@ BI.MonthTrigger.EVENT_START = "EVENT_START"; BI.MonthTrigger.EVENT_STOP = "EVENT_STOP"; BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE"; $.shortcut("bi.month_trigger", BI.MonthTrigger);/** - * 新建并选中某个分组按钮 - * - * Created by GUY on 2015/9/25. - * @class BI.Move2GroupAddButton - * @extends BI.BasicButton + * Created by fay on 2016/9/14. */ -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);/** - * 移动到分组下拉框 - * - * 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);/** - * 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);/** - * Created by fay on 2016/9/14. - */ -BI.TextLabelItemGroup = BI.inherit(BI.ButtonGroup, { +BI.TextLabelItemGroup = BI.inherit(BI.ButtonGroup, { _defaultConfig: function () { return BI.extend(BI.TextLabelItemGroup.superclass._defaultConfig.apply(this, arguments), { chooseType: BI.Selection.Multi @@ -12992,478 +11840,159 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; $.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** - * Created by zcf on 2016/12/14. + * + * @class BI.MultiTreeCheckPane + * @extends BI.Pane */ -BI.MultiStringList = BI.inherit(BI.Widget, { +BI.MultiTreeCheckPane = BI.inherit(BI.Pane, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + _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 - }) + return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-check-pane", + onClickContinueSelect: BI.emptyFn + }); }, - _init: function () { - BI.MultiStringList.superclass._init.apply(this, arguments); - var self = this, o = this.options; + _init: function () { + BI.MultiTreeCheckPane.superclass._init.apply(this, arguments); - 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 = {}; + var self = this, opts = this.options; + this.selected_values = {}; - 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: "" - } + var continueSelect = BI.createWidget({ + type: 'bi.text_button', + text: BI.i18nText('BI-Continue_Select'), + cls: 'multi-tree-check-selected' }); - this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { + opts.onClickContinueSelect(); + BI.nextTick(function () { + self.empty(); }); }); - 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, + var backToPopup = BI.createWidget({ + type: 'bi.left', + cls: 'multi-tree-continue-select', + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText('BI-Selected_Data') + }, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }, + { + el: continueSelect, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }] + }); + + this.display = BI.createWidget({ + type: "bi.display_tree", + cls: "bi-multi-tree-display", 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); - }); + op.type = BI.TreeView.REQ_TYPE_SELECTED_DATA; + opts.itemsCreator(op, callback); } }); - 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.display.on(BI.Events.AFTERINIT, function () { + self.fireEvent(BI.Events.AFTERINIT); }); - 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); + this.display.on(BI.TreeView.EVENT_INIT, function () { + backToPopup.setVisible(false); }); - var div = BI.createWidget({ - type: "bi.layout" + + this.display.on(BI.TreeView.EVENT_AFTERINIT, function () { + backToPopup.setVisible(true); }); + BI.createWidget({ - type: "bi.vtape", + type: 'bi.vtape', element: this, - height: "100%", - width: "100%", items: [{ - el: this.trigger, - height: 25 - }, { - el: div, - height: 2 + height: this.constants.height, + el: backToPopup }, { - el: this.popup, - height: "fill" + height: 'fill', + el: this.display }] }); - }, - _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(); + empty: function () { + this.display.empty(); }, - setEnable: function (v) { - this.trigger.setEnable(v); - this.popup.setEnable(v); + populate: function (configs) { + this.display.stroke(configs); }, setValue: function (v) { - this.storeValue = v || {}; - this._assertValue(this.storeValue); - this.popup.setValue(this.storeValue); - this.trigger.setValue(this.storeValue); + v || (v = {}); + this.display.setValue(v.value); }, 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.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK"; + -BI.MultiStringList.EVENT_CHANGE = "BI.MultiStringList.EVENT_CHANGE"; -$.shortcut("bi.multi_string_list", BI.MultiStringList);/** +$.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/** * - * @class BI.MultiTreeCheckPane - * @extends BI.Pane + * @class BI.MultiTreeCombo + * @extends BI.Single */ -BI.MultiTreeCheckPane = BI.inherit(BI.Pane, { + +BI.MultiTreeCombo = BI.inherit(BI.Single, { constants: { - height: 25, - lgap: 10, - tgap: 5 + offset: { + top: 1, + left: 1, + right: 2, + bottom: 33 + } }, + _defaultConfig: function () { - return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-tree-check-pane", - onClickContinueSelect: BI.emptyFn + return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-combo', + itemsCreator: BI.emptyFn, + height: 25 }); }, _init: function () { - BI.MultiTreeCheckPane.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; + BI.MultiTreeCombo.superclass._init.apply(this, arguments); - this.selected_values = {}; + var self = this, o = this.options; - var continueSelect = BI.createWidget({ - type: 'bi.text_button', - text: BI.i18nText('BI-Continue_Select'), - cls: 'multi-tree-check-selected' - }); - continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { - opts.onClickContinueSelect(); - BI.nextTick(function () { - self.empty(); - }); - }); - - var backToPopup = BI.createWidget({ - type: 'bi.left', - cls: 'multi-tree-continue-select', - items: [ - { - el: { - type: "bi.label", - text: BI.i18nText('BI-Selected_Data') - }, - lgap: this.constants.lgap, - tgap: this.constants.tgap - }, - { - el: continueSelect, - lgap: this.constants.lgap, - tgap: this.constants.tgap - }] - }); - - this.display = BI.createWidget({ - type: "bi.display_tree", - cls: "bi-multi-tree-display", - itemsCreator: function (op, callback) { - op.type = BI.TreeView.REQ_TYPE_SELECTED_DATA; - opts.itemsCreator(op, callback); - } - }); - - this.display.on(BI.Events.AFTERINIT, function () { - self.fireEvent(BI.Events.AFTERINIT); - }); - - this.display.on(BI.TreeView.EVENT_INIT, function () { - backToPopup.setVisible(false); - }); - - this.display.on(BI.TreeView.EVENT_AFTERINIT, function () { - backToPopup.setVisible(true); - }); - - BI.createWidget({ - type: 'bi.vtape', - element: this, - items: [{ - height: this.constants.height, - el: backToPopup - }, { - height: 'fill', - el: this.display - }] - }); - - }, - - empty: function () { - this.display.empty(); - }, - - populate: function (configs) { - this.display.stroke(configs); - }, - - setValue: function (v) { - v || (v = {}); - this.display.setValue(v.value); - }, - - getValue: function () { - - } -}); - -BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK"; - - -$.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/** - * - * @class BI.MultiTreeCombo - * @extends BI.Single - */ - -BI.MultiTreeCombo = BI.inherit(BI.Single, { - - constants: { - offset: { - top: 1, - left: 1, - right: 2, - bottom: 33 - } - }, - - - _defaultConfig: function () { - return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-tree-combo', - itemsCreator: BI.emptyFn, - height: 25 - }); - }, - - _init: function () { - BI.MultiTreeCombo.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - this.popup = BI.createWidget({ - type: 'bi.multi_tree_popup_view', - itemsCreator: o.itemsCreator, - onLoaded: function () { - BI.nextTick(function () { - self.trigger.getCounter().adjustView(); - self.trigger.getSearcher().adjustView(); - }); - } + this.popup = BI.createWidget({ + type: 'bi.multi_tree_popup_view', + itemsCreator: o.itemsCreator, + onLoaded: function () { + BI.nextTick(function () { + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } }); var isInit = false; var want2showCounter = false; @@ -14048,325 +12577,101 @@ BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; -$.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** - * Created by zcf on 2016/12/20. +$.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);//小于号的值为:0,小于等于号的值为:1 +//closeMIn:最小值的符号,closeMax:最大值的符号 +/** + * Created by roy on 15/9/17. + * */ -BI.MultiTreeList = BI.inherit(BI.Widget, { +BI.NumericalInterval = BI.inherit(BI.Single, { constants: { - offset: { - left: 1, - top: 0, - right: 2, - bottom: 1 - } + typeError: "typeBubble", + numberError: "numberBubble", + signalError: "signalBubble", + editorWidth: 114, + columns: 5, + width: 30, + rows: 1, + numberErrorCls: "number-error", + border: 1, + less: 0, + less_equal: 1, + numTip: "" }, - _defaultConfig: function () { - return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-tree-combo', - itemsCreator: BI.emptyFn, + var conf = BI.NumericalInterval.superclass._defaultConfig.apply(this, arguments) + return BI.extend(conf, { + extraCls: "bi-numerical-interval", 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 + var self = this, c = this.constants, o = this.options; + BI.NumericalInterval.superclass._init.apply(this, arguments) + this.smallEditor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Unrestricted"), + allowBlank: true, + value: o.min, + level: "warning", + tipType: "warning", + quitChecker: function () { + return false; + }, + validationChecker: function (v) { + if (!BI.isNumeric(v)) { + self.smallEditorBubbleType = c.typeError; + return false; + } + return true; + }, + cls: "numerical-interval-small-editor" }); - this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { - self.trigger.getCounter().adjustView(); - isInit = true; - if (want2showCounter === true) { - showCounter(); - } + this.smallTip = BI.createWidget({ + type: "bi.label", + text: o.numTip, + height: o.height - 2, + invisible: true + }); + BI.createWidget({ + type: "bi.absolute", + element: this.smallEditor.element, + items: [{ + el: this.smallTip, + top: 0, + right: 5 + }] }); - 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 + this.bigEditor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Unrestricted"), + allowBlank: true, + value: o.max, + level: "warning", + tipType: "warning", + quitChecker: function () { + return false; }, - switcher: { - el: { - type: "bi.multi_tree_check_selected_button" - }, - popup: { - type: "bi.multi_tree_check_pane", - itemsCreator: o.itemsCreator + validationChecker: function (v) { + if (!BI.isNumeric(v)) { + self.bigEditorBubbleType = c.typeError; + return false; } - } + return true; + }, + cls: "numerical-interval-big-editor" }); - 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);/** - * 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);//小于号的值为:0,小于等于号的值为:1 -//closeMIn:最小值的符号,closeMax:最大值的符号 -/** - * Created by roy on 15/9/17. - * - */ -BI.NumericalInterval = BI.inherit(BI.Single, { - constants: { - typeError: "typeBubble", - numberError: "numberBubble", - signalError: "signalBubble", - editorWidth: 114, - columns: 5, - width: 30, - rows: 1, - numberErrorCls: "number-error", - border: 1, - less: 0, - less_equal: 1, - numTip: "" - }, - _defaultConfig: function () { - var conf = BI.NumericalInterval.superclass._defaultConfig.apply(this, arguments) - return BI.extend(conf, { - extraCls: "bi-numerical-interval", - height: 25 - - }) - }, - _init: function () { - var self = this, c = this.constants, o = this.options; - BI.NumericalInterval.superclass._init.apply(this, arguments) - this.smallEditor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height - 2, - watermark: BI.i18nText("BI-Unrestricted"), - allowBlank: true, - value: o.min, - level: "warning", - tipType: "warning", - quitChecker: function () { - return false; - }, - validationChecker: function (v) { - if (!BI.isNumeric(v)) { - self.smallEditorBubbleType = c.typeError; - return false; - } - return true; - }, - cls: "numerical-interval-small-editor" - }); - - this.smallTip = BI.createWidget({ - type: "bi.label", - text: o.numTip, - height: o.height - 2, - invisible: true - }); - BI.createWidget({ - type: "bi.absolute", - element: this.smallEditor.element, - items: [{ - el: this.smallTip, - top: 0, - right: 5 - }] - }); - - this.bigEditor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height - 2, - watermark: BI.i18nText("BI-Unrestricted"), - allowBlank: true, - value: o.max, - level: "warning", - tipType: "warning", - quitChecker: function () { - return false; - }, - validationChecker: function (v) { - if (!BI.isNumeric(v)) { - self.bigEditorBubbleType = c.typeError; - return false; - } - return true; - }, - cls: "numerical-interval-big-editor" - }); - - this.bigTip = BI.createWidget({ - type: "bi.label", - text: o.numTip, - height: o.height - 2, - invisible: true + this.bigTip = BI.createWidget({ + type: "bi.label", + text: o.numTip, + height: o.height - 2, + invisible: true }); BI.createWidget({ type: "bi.absolute", @@ -17682,2403 +15987,489 @@ BI.SequenceTable = BI.inherit(BI.Widget, { headerCellStyleGetter: o.headerCellStyleGetter, summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter - }); - this.table = BI.createWidget(o.el, { - type: "bi.adaptive_table", - width: o.showSequence === true ? o.width - 60 : o.width, - height: o.height, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter, - - header: o.header, - items: o.items, - //交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { - if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { - self.sequence.setVerticalScroll(this.getVerticalScroll()); - self.sequence.populate(); - } - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - - this.htape = BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.sequence, - left: 0, - top: 0 - }, { - el: this.table, - top: 0, - left: o.showSequence === true ? 60 : 0 - }] - }); - this._populate(); - }, - - _populate: function () { - var o = this.options; - this.sequence.attr({ - items: o.items, - header: o.header, - crossItems: o.crossItems, - crossHeader: o.crossHeader - }); - if (o.showSequence === true) { - this.sequence.setVisible(true); - this.table.element.css("left", "60px"); - this.table.setWidth(o.width - 60); - } else { - this.sequence.setVisible(false); - this.table.element.css("left", "0px"); - this.table.setWidth(o.width); - } - }, - - setWidth: function (width) { - BI.PageTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(this.options.showSequence ? width - 60 : width); - }, - - setHeight: function (height) { - BI.PageTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - hasLeftHorizontalScroll: function () { - return this.table.hasLeftHorizontalScroll(); - }, - - hasRightHorizontalScroll: function () { - return this.table.hasRightHorizontalScroll(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - this.sequence.setVerticalScroll(scrollTop); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - setVPage: function (page) { - this.sequence.setVPage && this.sequence.setVPage(page); - }, - - setHPage: function (page) { - this.sequence.setHPage && this.sequence.setHPage(page); - }, - - attr: function () { - BI.SequenceTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - this.sequence.attr.apply(this.sequence, arguments); - }, - - restore: function () { - this.table.restore(); - this.sequence.restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items) { - o.items = items; - } - if (header) { - o.header = header; - } - if (crossItems) { - o.crossItems = crossItems; - } - if (crossHeader) { - o.crossHeader = crossHeader; - } - this._populate(); - this.table.populate.apply(this.table, arguments); - this.sequence.populate.apply(this.sequence, arguments); - this.sequence.setVerticalScroll(this.table.getVerticalScroll()); - }, - - destroy: function () { - this.table.destroy(); - BI.SequenceTable.superclass.destroy.apply(this, arguments); - } -}); -$.shortcut('bi.sequence_table', BI.SequenceTable);/** - * 简单的搜索功能 - * - * 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);/** - * 完成搜索功能模块 - * - * 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);/** - * 搜索结果面板 - * - * 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);/** - * 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);/** - * 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);/** - * 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);/** - * 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);/** - * 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);/** - * @class BI.SingleTreeCombo - * @extends BI.Widget - */ -BI.SingleTreeCombo = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-tree-combo", - trigger: {}, - height: 30, - text: "", - items: [] - }); - }, - - _init: function () { - BI.SingleTreeCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget(BI.extend({ - type: "bi.single_tree_trigger", - text: o.text, - height: o.height, - items: o.items - }, o.trigger)); - - this.popup = BI.createWidget({ - type: "bi.single_tree_popup", - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup - } - }); - - this.combo.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments); - }); - - this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); - }); - }, - - populate: function (items) { - this.combo.populate(items); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); - -BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE"; -BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -$.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/** - * @class BI.SingleTreePopup - * @extends BI.Pane - */ - -BI.SingleTreePopup = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-tree-popup", - tipText: BI.i18nText("BI-No_Selected_Item"), - items: [] - }); - }, - - _init: function () { - BI.SingleTreePopup.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - this.tree = BI.createWidget({ - type: 'bi.level_tree', - expander: { - isDefaultInit: true - }, - items: o.items, - chooseType: BI.Selection.Single - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.tree] - }); - - this.tree.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE); - }); - - this.check(); - }, - - getValue: function () { - return this.tree.getValue(); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.tree.setValue(v); - }, - - populate: function (items) { - BI.SingleTreePopup.superclass.populate.apply(this, arguments); - this.tree.populate(items); - } -}); - -BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.single_tree_popup", BI.SingleTreePopup);/** - * @class BI.SingleTreeTrigger - * @extends BI.Trigger - */ - -BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { - - _defaultConfig: function () { - return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-tree-trigger", - height: 30, - text: "", - items: [] - }); - }, - - _init: function () { - BI.SingleTreeTrigger.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.select_text_trigger", - element: this, - text: o.text, - items: o.items, - height: o.height - }); - }, - - _checkTitle: function () { - var self = this, val = this.getValue(); - BI.any(this.options.items, function (i, item) { - if (val.contains(item.value)) { - self.trigger.setTitle(item.text || item.value); - return true; - } - }); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.options.value = v; - this.trigger.setValue(v); - this._checkTitle(); - }, - - getValue: function () { - return this.options.value || []; - }, - - populate: function (items) { - BI.SingleTreeTrigger.superclass.populate.apply(this, arguments); - this.trigger.populate(items); - } - -}); - -$.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/** - * 可以单选多选切换的树 - * - * Created by GUY on 2015/12/21. - * @class BI.SwitchTree - * @extends BI.Widget - */ -BI.SwitchTree = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-switch-tree", - items: [] - }); - }, - - _init: function () { - BI.SwitchTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tab = BI.createWidget({ - type: "bi.tab", - element: this, - tab: null, - defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect, - cardCreator: BI.bind(this._createTree, this) - }); - }, - - _createTree: function (type) { - var self = this, o = this.options; - switch (type) { - case BI.SwitchTree.SelectType.SingleSelect: - this.levelTree = BI.createWidget({ - type: "bi.multilayer_single_level_tree", - isDefaultInit: true, - items: BI.deepClone(o.items) - }); - this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); - }); - return this.levelTree; - case BI.SwitchTree.SelectType.MultiSelect: - this.tree = BI.createWidget({ - type: "bi.simple_tree", - items: this._removeIsParent(BI.deepClone(o.items)) - }); - this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); - }); - return this.tree; - } - }, - - _removeIsParent: function(items) { - BI.each(items, function(i, item) { - BI.isNotNull(item.isParent) && delete item.isParent; - }); - return items; - }, - - switchSelect: function () { - switch (this.getSelect()) { - case BI.SwitchTree.SelectType.SingleSelect: - this.setSelect(BI.SwitchTree.SelectType.MultiSelect); - break; - case BI.SwitchTree.SelectType.MultiSelect: - this.setSelect(BI.SwitchTree.SelectType.SingleSelect); - break; - } - }, - - setSelect: function (v) { - this.tab.setSelect(v); - }, - - getSelect: function () { - return this.tab.getSelect(); - }, - - setValue: function (v) { - this.storeValue = v; - switch (this.getSelect()) { - case BI.SwitchTree.SelectType.SingleSelect: - this.levelTree.setValue(v); - break; - case BI.SwitchTree.SelectType.MultiSelect: - this.tree.setValue(v); - break; - } - }, - - getValue: function () { - return this.tab.getValue(); - }, - - populate: function (items) { - this.options.items = items; - if (BI.isNotNull(this.levelTree)) { - this.levelTree.populate(BI.deepClone(items)); - } - if (BI.isNotNull(this.tree)) { - this.tree.populate(this._removeIsParent(BI.deepClone(items))); - } - } -}); -BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; -BI.SwitchTree.SelectType = { - SingleSelect: BI.Selection.Single, - MultiSelect: BI.Selection.Multi -}; -$.shortcut('bi.switch_tree', BI.SwitchTree); -/** - * 文本组件中 编辑栏作为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" + sequenceCellStyleGetter: o.sequenceCellStyleGetter }); - }, + this.table = BI.createWidget(o.el, { + type: "bi.adaptive_table", + width: o.showSequence === true ? o.width - 60 : o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, - _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%" - }); + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, - this.textarea.on(BI.TextAreaEditor.EVENT_FOCUS, function () { - self.combo.showView(); - }); + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, - 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) - }); + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, - this.toolbar = BI.createWidget({ - type: "bi.text_toolbar" - }); + regionColumnSize: o.regionColumnSize, - 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); - }); + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, - 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 - } + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems }); - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - if (BI.isNotEmptyString(self.textarea.getValue())) { - self._showInput(); - } else { - self._showLabel(); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { + if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { + self.sequence.setVerticalScroll(this.getVerticalScroll()); + self.sequence.populate(); } + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); }); - - 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.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); }); - - this.label.on(BI.TextButton.EVENT_CHANGE, function () { - self._showInput(); - self.textarea.focus(); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); }); - BI.createWidget({ + this.htape = BI.createWidget({ type: "bi.absolute", element: this, items: [{ - el: this.combo, - left: 10, - right: 10, - top: 10, - bottom: 10 - }, { - el: this.label, + el: this.sequence, left: 0, - right: 0, + top: 0 + }, { + el: this.table, top: 0, - bottom: 0 + left: o.showSequence === true ? 60 : 0 }] }); + this._populate(); }, - _showInput: function () { - this.label.setVisible(false); + _populate: function () { + var o = this.options; + this.sequence.attr({ + items: o.items, + header: o.header, + crossItems: o.crossItems, + crossHeader: o.crossHeader + }); + if (o.showSequence === true) { + this.sequence.setVisible(true); + this.table.element.css("left", "60px"); + this.table.setWidth(o.width - 60); + } else { + this.sequence.setVisible(false); + this.table.element.css("left", "0px"); + this.table.setWidth(o.width); + } }, - _showLabel: function () { - this.label.setVisible(true); + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(this.options.showSequence ? width - 60 : width); }, - 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); + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); }, - 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);/** - * 对齐方式选择 - * - * 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 - }); + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); }, - _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); - }); + getColumnSize: function () { + return this.table.getColumnSize(); }, - setValue: function (v) { - this.button_group.setValue(v); + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); }, - 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);/** - * 颜色选择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 - }); + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); }, - _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 - }] - }) + hasLeftHorizontalScroll: function () { + return this.table.hasLeftHorizontalScroll(); }, - setValue: function (color) { - this.underline.element.css("color", color); + hasRightHorizontalScroll: function () { + return this.table.hasRightHorizontalScroll(); }, - getValue: function () { - return this.font.element.css("color"); - } -}); -$.shortcut('bi.text_toolbar_background_chooser_trigger', BI.TextToolbarBackgroundChooserTrigger);/** - * 颜色选择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 - }); + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + this.sequence.setVerticalScroll(scrollTop); }, - _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 - }] - }) + getVerticalScroll: function () { + return this.table.getVerticalScroll(); }, - setValue: function (color) { - this.underline.element.css("color", color); + setVPage: function (page) { + this.sequence.setVPage && this.sequence.setVPage(page); }, - getValue: function () { - return this.font.element.css("color"); - } -}); -$.shortcut('bi.text_toolbar_color_chooser_trigger', BI.TextToolbarColorChooserTrigger);/** - * 字体大小选择 - * - * 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 - }], + setHPage: function (page) { + this.sequence.setHPage && this.sequence.setHPage(page); + }, - _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); - }); + attr: function () { + BI.SequenceTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + this.sequence.attr.apply(this.sequence, 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); - }) + restore: function () { + this.table.restore(); + this.sequence.restore(); }, - setValue: function (v) { - this.combo.setValue(v); + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items) { + o.items = items; + } + if (header) { + o.header = header; + } + if (crossItems) { + o.crossItems = crossItems; + } + if (crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + this.table.populate.apply(this.table, arguments); + this.sequence.populate.apply(this.sequence, arguments); + this.sequence.setVerticalScroll(this.table.getVerticalScroll()); }, - getValue: function () { - return BI.parseInt(this.trigger.getValue()); + destroy: function () { + this.table.destroy(); + BI.SequenceTable.superclass.destroy.apply(this, arguments); } }); -BI.TextToolbarSizeChooser.EVENT_CHANGE = "BI.TextToolbarSizeChooser.EVENT_CHANGE"; -$.shortcut('bi.text_toolbar_size_chooser', BI.TextToolbarSizeChooser);/** - * 颜色选择 - * - * Created by GUY on 2015/11/26. - * @class BI.TextToolbar +$.shortcut('bi.sequence_table', BI.SequenceTable);/** + * @class BI.SingleTreeCombo * @extends BI.Widget */ -BI.TextToolbar = BI.inherit(BI.Widget, { +BI.SingleTreeCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { - return BI.extend(BI.TextToolbar.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-text-toolbar", - width: 253, - height: 28 + return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-combo", + trigger: {}, + height: 30, + text: "", + items: [] }); }, _init: function () { - BI.TextToolbar.superclass._init.apply(this, arguments); + BI.SingleTreeCombo.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.trigger = BI.createWidget(BI.extend({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items + }, o.trigger)); + + this.popup = BI.createWidget({ + type: "bi.single_tree_popup", + items: o.items }); - 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.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup } }); - 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.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); - this.alignchooser.on(BI.TextToolbarAlignChooser.EVENT_CHANGE, function () { - self.fireEvent(BI.TextToolbar.EVENT_CHANGE, arguments); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, 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(); + this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); + }); }, - isBackgroundChooserVisible: function () { - return this.backgroundchooser.isViewVisible(); + populate: function (items) { + this.combo.populate(items); }, 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"); + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); }, 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() - } + return this.popup.getValue(); } }); -BI.TextToolbar.EVENT_CHANGE = "BI.TextToolbar.EVENT_CHANGE"; -$.shortcut('bi.text_toolbar', BI.TextToolbar);/** - * Created by Baron on 2015/10/19. + +BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE"; +BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +$.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/** + * @class BI.SingleTreePopup + * @extends BI.Pane */ -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" - }, + +BI.SingleTreePopup = BI.inherit(BI.Pane, { + _defaultConfig: function () { - var conf = BI.TimeInterval.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-time-interval" - }) + return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + items: [] + }); }, + _init: function () { - var self = this; - BI.TimeInterval.superclass._init.apply(this, arguments); + BI.SingleTreePopup.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 - }] - }] + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: 'bi.level_tree', + expander: { + isDefaultInit: true + }, + items: o.items, + chooseType: BI.Selection.Single }); + BI.createWidget({ - type: "bi.horizontal_auto", + type: "bi.vertical", 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); - } + items: [this.tree] }); - 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); - } + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); - 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);/** - * 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); + this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleTreePopup.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.check(); + }, - 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 this.tree.getValue(); }, - getValue: function(){ - return BI.parseInt(this.day.getValue()); + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); }, - setValue: function(v) { - this.day.setValue(v); + populate: function (items) { + BI.SingleTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); } }); -BI.DayTimeSetting.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.day_time_setting", BI.DayTimeSetting);/** - * 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 - }) - }, +BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +$.shortcut("bi.single_tree_popup", BI.SingleTreePopup);/** + * @class BI.SingleTreeTrigger + * @extends BI.Trigger + */ - getValue: function(){ - return BI.parseInt(this.hour.getValue()); - }, +BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { - setValue: function(v) { - this.hour.setValue(v); - } -}); -BI.HourTimeSetting.EVENT_CHANGE = "EVENT_CHANGE"; -$.shortcut("bi.hour_time_setting", BI.HourTimeSetting);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: [], + return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-trigger", + height: 30, + text: "", items: [] - }) + }); }, _init: function () { - BI.TreeLabel.superclass._init.apply(this, arguments); - var self = this, o = this.options; + BI.SingleTreeTrigger.superclass._init.apply(this, arguments); - this.titles = o.titles; - this.items = o.items; + var self = this, o = this.options; - this.view = BI.createWidget({ - type: "bi.tree_label_view", + this.trigger = BI.createWidget({ + type: "bi.select_text_trigger", element: this, - titles: o.titles, - items: o.items + text: o.text, + items: o.items, + height: o.height }); - 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); + }, + + _checkTitle: function () { + var self = this, val = this.getValue(); + BI.any(this.options.items, function (i, item) { + if (val.contains(item.value)) { + self.trigger.setTitle(item.text || item.value); + return true; } - self.fireEvent(BI.TreeLabel.EVENT_CHANGE, arguments); }); }, - _itemsCreator: function (options) { - var self = this, o = this.options; - o.itemsCreator(options, function (data) { - self.populate(data); - }) + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.options.value = v; + this.trigger.setValue(v); + this._checkTitle(); }, - populate: function (v) { - this.view.populate(v); + getValue: function () { + return this.options.value || []; }, - getValue: function () { - return this.view.getValue(); + populate: function (items) { + BI.SingleTreeTrigger.superclass.populate.apply(this, arguments); + this.trigger.populate(items); } + }); -BI.TreeLabel.EVENT_CHANGE = "BI.TreeLabel.EVENT_CHANGE"; -$.shortcut('bi.tree_label', BI.TreeLabel);BI.TreeLabelView = BI.inherit(BI.Widget, { - _constant: { - LIST_LABEL_HEIGHT: 40, - DEFAULT_LEFT_GAP: 5 - }, + +$.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/** + * 可以单选多选切换的树 + * + * Created by GUY on 2015/12/21. + * @class BI.SwitchTree + * @extends BI.Widget + */ +BI.SwitchTree = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.TreeLabelView.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-tree-label-view", - titleWidth: 60, - titles: [], + return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-switch-tree", items: [] - }) + }); }, _init: function () { - BI.TreeLabelView.superclass._init.apply(this, arguments); - this.items = []; - this._initView(); + BI.SwitchTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tab = BI.createWidget({ + type: "bi.tab", + element: this, + tab: null, + defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect, + cardCreator: BI.bind(this._createTree, this) + }); }, - _initView: function () { + _createTree: function (type) { 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 - }); + switch (type) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree = BI.createWidget({ + type: "bi.multilayer_single_level_tree", + isDefaultInit: true, + items: BI.deepClone(o.items) + }); + this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.levelTree; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree = BI.createWidget({ + type: "bi.simple_tree", + items: this._removeIsParent(BI.deepClone(o.items)) + }); + this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.tree; + } }, - _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 + _removeIsParent: function(items) { + BI.each(items, function(i, item) { + BI.isNotNull(item.isParent) && delete item.isParent; }); - this.right.addItems([temp]); - this.right.setHeight(self.items.length * this._constant.LIST_LABEL_HEIGHT); + return items; }, - _setTitles: function (titles) { - var length = this.title.getAllButtons().length; - var deletes = [], titleItems = []; - for (var i = 0; i < length; i++) { - deletes.push(i); + switchSelect: function () { + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.setSelect(BI.SwitchTree.SelectType.MultiSelect); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.setSelect(BI.SwitchTree.SelectType.SingleSelect); + break; } - 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]); - }) + setSelect: function (v) { + this.tab.setSelect(v); }, - populate: function(v) { - v.titles && this._setTitles(v.titles); - v.items && this._setItems(v.items); - v.values && this._setValue(v.values); + getSelect: function () { + return this.tab.getSelect(); }, - getMaxFloor: function () { - return this.items.length || 0; + setValue: function (v) { + this.storeValue = v; + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree.setValue(v); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree.setValue(v); + break; + } }, getValue: function () { - var result = []; - BI.each(this.items, function (idx, item) { - result.push(item.getValue()); - }); - return result; + return this.tab.getValue(); + }, + + populate: function (items) { + this.options.items = items; + if (BI.isNotNull(this.levelTree)) { + this.levelTree.populate(BI.deepClone(items)); + } + if (BI.isNotNull(this.tree)) { + this.tree.populate(this._removeIsParent(BI.deepClone(items))); + } } }); -BI.TreeLabelView.EVENT_CHANGE = "BI.TreeLabelView.EVENT_CHANGE"; -$.shortcut('bi.tree_label_view', BI.TreeLabelView);/** +BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; +BI.SwitchTree.SelectType = { + SingleSelect: BI.Selection.Single, + MultiSelect: BI.Selection.Multi +}; +$.shortcut('bi.switch_tree', BI.SwitchTree); +/** * web组件 * Created by GameJian on 2016/3/1. */ @@ -20646,6 +17037,123 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { }); BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; $.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** + * 简单的复选下拉框控件, 适用于数据量少的情况 + * 封装了字段处理逻辑 + * + * 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);/** * 简单的复选下拉树控件, 适用于数据量少的情况 * * Created by GUY on 2015/10/29. diff --git a/src/base/base.js b/src/base/base.js index 360de9e9d..0895b7388 100644 --- a/src/base/base.js +++ b/src/base/base.js @@ -5,6 +5,7 @@ BI.Bubbles = new BI.BubblesController(); BI.Tooltips = new BI.TooltipsController(); BI.Popovers = new BI.FloatBoxController(); BI.Broadcasts = new BI.BroadcastController(); +BI.StyleLoaders = new BI.StyleLoaderManager(); BI.servletURL = "dist/"; BI.i18n = {}; \ No newline at end of file diff --git a/src/base/combination/group.virtual.js b/src/base/combination/group.virtual.js index ceef16e3e..39448f5dd 100644 --- a/src/base/combination/group.virtual.js +++ b/src/base/combination/group.virtual.js @@ -47,6 +47,14 @@ BI.VirtualGroup = BI.inherit(BI.Widget, { return layout; }, + addItems: function (items) { + this.layouts.addItems(items); + }, + + prependItems: function (items) { + this.layouts.prependItems(items); + }, + populate: function (items) { var self = this; items = items || []; diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 68fe75c1a..196ea7f46 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -18,8 +18,7 @@ BI.Tab = BI.inherit(BI.Widget, { }) }, - _init: function () { - BI.Tab.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; if (BI.isObject(o.tab)) { this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"}); diff --git a/src/component/allvaluechooser/combo.allvaluechooser.js b/src/component/allvaluechooser/combo.allvaluechooser.js new file mode 100644 index 000000000..5003ed51c --- /dev/null +++ b/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); \ No newline at end of file diff --git a/src/core/controller/controller.broadcast.js b/src/core/controller/controller.broadcast.js index ee99ebb5c..7b7c43984 100644 --- a/src/core/controller/controller.broadcast.js +++ b/src/core/controller/controller.broadcast.js @@ -15,10 +15,14 @@ BI.BroadcastController = BI.inherit(BI.Controller, { }, on: function (name, fn) { + var self = this; if (!this._broadcasts[name]) { this._broadcasts[name] = []; } this._broadcasts[name].push(fn); + return function () { + self._broadcasts[name].remove(fn); + } }, send: function (name) { @@ -30,7 +34,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, { remove: function (name, fn) { if (fn) { - BI.remove(this._broadcasts[name], fn); + this._broadcasts[name].remove(fn); } else { delete this._broadcasts[name]; } diff --git a/src/core/widget.js b/src/core/widget.js index b5d1f5666..7ed29b380 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -70,8 +70,12 @@ BI.Widget = BI.inherit(BI.OB, { var o = this.options; this.widgetName = o.widgetName || BI.uniqueId("widget"); if (BI.isWidget(o.element)) { - this._parent = o.element; - this._parent.addWidget(this.widgetName, this); + if (o.element instanceof BI.Widget) { + this._parent = o.element; + this._parent.addWidget(this.widgetName, this); + } else { + this._isRoot = true; + } this.element = this.options.element.element; } else if (o.element) { this.element = $(o.element); @@ -166,7 +170,7 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = true; this._mountChildren(); BI.each(this._children, function (i, widget) { - widget._mount(); + widget._mount&&widget._mount(); }); this.mounted(); }, @@ -188,7 +192,7 @@ BI.Widget = BI.inherit(BI.OB, { _unMount: function () { BI.each(this._children, function (i, widget) { - widget._unMount(); + widget._unMount && widget._unMount(); }); this._children = {}; this._parent = null; @@ -259,7 +263,7 @@ BI.Widget = BI.inherit(BI.OB, { if (this._children[name]) { throw new Error("name has already been existed"); } - widget._setParent(this); + widget._setParent && widget._setParent(this); widget.on(BI.Events.DESTROY, function () { delete self._children[name] }); diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 424a51e67..7ede19eac 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -181,19 +181,11 @@ BI.Layout = BI.inherit(BI.Widget, { * @param {JSON/BI.Widget} item 子组件 */ addItem: function (item) { - var w = this._addElement(this.options.items.length, item); - this.options.items.push(item); - w.element.appendTo(this._getWrapper()); - w._mount(); - return w; + return this.addItemAt(this.options.items.length, item); }, prependItem: function (item) { - var w = this._addElement(this.options.items.length, item); - this.options.items.unshift(item); - w.element.prependTo(this._getWrapper()); - w._mount(); - return w; + return this.addItemAt(0,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))) { 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); + this.options.items.splice(index, 0, item); this._children[this._getChildName(index)] = w; if (index > 0) { this._children[this._getChildName(index - 1)].element.after(w.element); } else { w.element.prependTo(this._getWrapper()); } + del.destroy(); w._mount(); }, @@ -245,6 +241,7 @@ BI.Layout = BI.inherit(BI.Widget, { var added = []; BI.each(items, function (i, item) { var w = self._addElement(o.items.length, item); + self._children[self._getChildName(o.items.length)] = w; o.items.push(item); added.push(w); fragment.appendChild(w.element[0]); @@ -256,11 +253,13 @@ BI.Layout = BI.inherit(BI.Widget, { }, prependItems: function (items) { - items = items || []; + var self =this,items = items || []; var fragment = document.createDocumentFragment(); var added = []; 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]); added.push(w); fragment.appendChild(w.element[0]); @@ -305,9 +304,13 @@ BI.Layout = BI.inherit(BI.Widget, { } } if (o.items.length > items.length) { + var deleted = []; 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) { for (i = o.items.length; i < items.length; i++) { this.addItemAt(i, items[i]); diff --git a/src/widget/dynamicgrouptab/dynamicgroup.tab.buttongroup.js b/src/widget/dynamicgrouptab/dynamicgroup.tab.buttongroup.js deleted file mode 100644 index eab285f63..000000000 --- a/src/widget/dynamicgrouptab/dynamicgroup.tab.buttongroup.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/intervalslider/intervalslider.js b/src/widget/intervalslider/intervalslider.js deleted file mode 100644 index dcae95d42..000000000 --- a/src/widget/intervalslider/intervalslider.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/intervalslider/model.accuratecalculation.js b/src/widget/intervalslider/model.accuratecalculation.js deleted file mode 100644 index 310b39d02..000000000 --- a/src/widget/intervalslider/model.accuratecalculation.js +++ /dev/null @@ -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); - } -}); \ No newline at end of file diff --git a/src/widget/move2group/button.add.move2group.js b/src/widget/move2group/button.add.move2group.js deleted file mode 100644 index a47295cc5..000000000 --- a/src/widget/move2group/button.add.move2group.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/move2group/combo.move2group.js b/src/widget/move2group/combo.move2group.js deleted file mode 100644 index e36593b4c..000000000 --- a/src/widget/move2group/combo.move2group.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/move2group/toolbar.move2group.js b/src/widget/move2group/toolbar.move2group.js deleted file mode 100644 index e3782ba92..000000000 --- a/src/widget/move2group/toolbar.move2group.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/multistringlist/multistringlist.js b/src/widget/multistringlist/multistringlist.js deleted file mode 100644 index 06366f0bf..000000000 --- a/src/widget/multistringlist/multistringlist.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/multitreelist/multitreelist.js b/src/widget/multitreelist/multitreelist.js deleted file mode 100644 index fb1ada71e..000000000 --- a/src/widget/multitreelist/multitreelist.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/multitreelist/multitreelist.popup.js b/src/widget/multitreelist/multitreelist.popup.js deleted file mode 100644 index 9db3aebc5..000000000 --- a/src/widget/multitreelist/multitreelist.popup.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/simplesearcher/searcher.simple.js b/src/widget/simplesearcher/searcher.simple.js deleted file mode 100644 index a674174f6..000000000 --- a/src/widget/simplesearcher/searcher.simple.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/simpleselectdata/searcher/searcher.simpleselectdata.js b/src/widget/simpleselectdata/searcher/searcher.simpleselectdata.js deleted file mode 100644 index 30a3d3b58..000000000 --- a/src/widget/simpleselectdata/searcher/searcher.simpleselectdata.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/simpleselectdata/searchpane/result.search.simpleselectdata.js b/src/widget/simpleselectdata/searchpane/result.search.simpleselectdata.js deleted file mode 100644 index 49d25e338..000000000 --- a/src/widget/simpleselectdata/searchpane/result.search.simpleselectdata.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/simpleselectdata/searchpane/segment.search.simpleselectdata.js b/src/widget/simpleselectdata/searchpane/segment.search.simpleselectdata.js deleted file mode 100644 index 817a42a4b..000000000 --- a/src/widget/simpleselectdata/searchpane/segment.search.simpleselectdata.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/simpleselectdata/treenode/node.level0.js b/src/widget/simpleselectdata/treenode/node.level0.js deleted file mode 100644 index 3c5e85147..000000000 --- a/src/widget/simpleselectdata/treenode/node.level0.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/simpleselectdata/treenode/node.level1.js b/src/widget/simpleselectdata/treenode/node.level1.js deleted file mode 100644 index 863ca719b..000000000 --- a/src/widget/simpleselectdata/treenode/node.level1.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/singleslider/singleslider.js b/src/widget/singleslider/singleslider.js deleted file mode 100644 index e962f3373..000000000 --- a/src/widget/singleslider/singleslider.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/singleslider/slider/widget.slider.js b/src/widget/singleslider/slider/widget.slider.js deleted file mode 100644 index 58118c464..000000000 --- a/src/widget/singleslider/slider/widget.slider.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/textarea/textarea.js b/src/widget/textarea/textarea.js deleted file mode 100644 index c2c2345cb..000000000 --- a/src/widget/textarea/textarea.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/texttoolbar/alignchooser/texttoolbar.alignchooser.js b/src/widget/texttoolbar/alignchooser/texttoolbar.alignchooser.js deleted file mode 100644 index 34e6fd612..000000000 --- a/src/widget/texttoolbar/alignchooser/texttoolbar.alignchooser.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/texttoolbar/backgroundchooser/texttoolbar.backgroundchooser.trigger.js b/src/widget/texttoolbar/backgroundchooser/texttoolbar.backgroundchooser.trigger.js deleted file mode 100644 index c8c8851d8..000000000 --- a/src/widget/texttoolbar/backgroundchooser/texttoolbar.backgroundchooser.trigger.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/texttoolbar/colorchooser/texttoolbar.colorchooser.trigger.js b/src/widget/texttoolbar/colorchooser/texttoolbar.colorchooser.trigger.js deleted file mode 100644 index 899193c35..000000000 --- a/src/widget/texttoolbar/colorchooser/texttoolbar.colorchooser.trigger.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/texttoolbar/sizechooser/texttoolbar.sizechooser.js b/src/widget/texttoolbar/sizechooser/texttoolbar.sizechooser.js deleted file mode 100644 index 61d70f026..000000000 --- a/src/widget/texttoolbar/sizechooser/texttoolbar.sizechooser.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/texttoolbar/texttoolbar.js b/src/widget/texttoolbar/texttoolbar.js deleted file mode 100644 index c88875a64..000000000 --- a/src/widget/texttoolbar/texttoolbar.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/timeinterval/timeinterval.js b/src/widget/timeinterval/timeinterval.js deleted file mode 100644 index 6e330e9fc..000000000 --- a/src/widget/timeinterval/timeinterval.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/timesetting/timesetting.day.js b/src/widget/timesetting/timesetting.day.js deleted file mode 100644 index 50a7125eb..000000000 --- a/src/widget/timesetting/timesetting.day.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/timesetting/timesetting.hour.js b/src/widget/timesetting/timesetting.hour.js deleted file mode 100644 index c5eec3dd3..000000000 --- a/src/widget/timesetting/timesetting.hour.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/treelabel/treelabel.js b/src/widget/treelabel/treelabel.js deleted file mode 100644 index fa39f1f24..000000000 --- a/src/widget/treelabel/treelabel.js +++ /dev/null @@ -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); \ No newline at end of file diff --git a/src/widget/treelabel/treelabel.view.js b/src/widget/treelabel/treelabel.view.js deleted file mode 100644 index 2d8bd8d22..000000000 --- a/src/widget/treelabel/treelabel.view.js +++ /dev/null @@ -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); \ No newline at end of file