From cd1bb6152b9b36ca297aff143299c15aedc36acb Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 27 Jun 2017 18:48:31 +0800 Subject: [PATCH] add --- bi/case.js | 7 +- docs/case.js | 7 +- src/case/combo/bubblecombo/combo.bubble.js | 444 ++++++++++----------- src/case/trigger/trigger.editor.js | 157 ++++---- 4 files changed, 306 insertions(+), 309 deletions(-) diff --git a/bi/case.js b/bi/case.js index dab3d678e..f32acbb04 100644 --- a/bi/case.js +++ b/bi/case.js @@ -4914,6 +4914,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { default: break; } + this.triangle && this.triangle.destroy(); this.triangle = BI.createWidget(op, { type: "bi.center_adapt", cls: "button-combo-triangle-wrapper", @@ -4974,6 +4975,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { _hideTriangle: function () { this.triangle && this.triangle.destroy(); + this.triangle = null; this.combo.getView() && this.combo.getView().hideLine(); }, @@ -4986,10 +4988,6 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { this.combo && this.combo.showView(); }, - hasView: function () { - return BI.isNotNull(this.combo.getView()); - }, - isViewVisible: function () { return this.combo.isViewVisible(); } @@ -12349,6 +12347,7 @@ BI.EditorTrigger = BI.inherit(BI.Trigger, { }, { el: { type: "bi.trigger_icon_button", + cls: "bi-border-left", width: o.triggerWidth }, width: o.triggerWidth diff --git a/docs/case.js b/docs/case.js index dab3d678e..f32acbb04 100644 --- a/docs/case.js +++ b/docs/case.js @@ -4914,6 +4914,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { default: break; } + this.triangle && this.triangle.destroy(); this.triangle = BI.createWidget(op, { type: "bi.center_adapt", cls: "button-combo-triangle-wrapper", @@ -4974,6 +4975,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { _hideTriangle: function () { this.triangle && this.triangle.destroy(); + this.triangle = null; this.combo.getView() && this.combo.getView().hideLine(); }, @@ -4986,10 +4988,6 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { this.combo && this.combo.showView(); }, - hasView: function () { - return BI.isNotNull(this.combo.getView()); - }, - isViewVisible: function () { return this.combo.isViewVisible(); } @@ -12349,6 +12347,7 @@ BI.EditorTrigger = BI.inherit(BI.Trigger, { }, { el: { type: "bi.trigger_icon_button", + cls: "bi-border-left", width: o.triggerWidth }, width: o.triggerWidth diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js index 55fcd60d3..2e73757e8 100644 --- a/src/case/combo/bubblecombo/combo.bubble.js +++ b/src/case/combo/bubblecombo/combo.bubble.js @@ -1,224 +1,222 @@ -/** - * Created by GUY on 2017/2/8. - * - * @class BI.BubbleCombo - * @extends BI.Widget - */ -BI.BubbleCombo = BI.inherit(BI.Widget, { - _const: { - TRIANGLE_LENGTH: 6 - }, - _defaultConfig: function () { - return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-bubble-combo", - trigger: "click", - toggle: true, - direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right - isDefaultInit: false, - destroyWhenHide: false, - isNeedAdjustHeight: true,//是否需要高度调整 - isNeedAdjustWidth: true, - stopPropagation: false, - adjustLength: 0,//调整的距离 - // adjustXOffset: 0, - // adjustYOffset: 10, - hideChecker: BI.emptyFn, - offsetStyle: "left", //left,right,center - el: {}, - popup: {}, - }) - }, - _init: function () { - BI.BubbleCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - trigger: o.trigger, - toggle: o.toggle, - direction: o.direction, - isDefaultInit: o.isDefaultInit, - destroyWhenHide: o.destroyWhenHide, - isNeedAdjustHeight: o.isNeedAdjustHeight, - isNeedAdjustWidth: o.isNeedAdjustWidth, - adjustLength: this._getAdjustLength(), - stopPropagation: o.stopPropagation, - adjustXOffset: 0, - adjustYOffset: 0, - hideChecker: o.hideChecker, - offsetStyle: o.offsetStyle, - el: o.el, - popup: BI.extend({ - type: "bi.bubble_popup_view" - }, o.popup), - }); - this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { - self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); - }); - this.combo.on(BI.Combo.EVENT_CHANGE, function () { - self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); - }); - this.combo.on(BI.Combo.EVENT_EXPAND, function () { - self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); - }); - this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { - self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); - }); - this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { - self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); - }); - this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { - self._showTriangle(); - self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); - }); - this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { - self._hideTriangle(); - self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); - }); - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); - }); - }, - - _getAdjustLength: function () { - return this._const.TRIANGLE_LENGTH + this.options.adjustLength; - }, - - _createTriangle: function (direction) { - var pos = {}, op = {}; - var adjustLength = this.options.adjustLength; - var offset = this.element.offset(); - var left = offset.left, right = offset.left + this.element.outerWidth(); - var top = offset.top, bottom = offset.top + this.element.outerHeight(); - switch (direction) { - case "left": - pos = { - top: top, - height: this.element.outerHeight(), - left: left - adjustLength - this._const.TRIANGLE_LENGTH - }; - op = {width: this._const.TRIANGLE_LENGTH}; - break; - case "right": - pos = { - top: top, - height: this.element.outerHeight(), - left: right + adjustLength - }; - op = {width: this._const.TRIANGLE_LENGTH}; - break; - case "top": - pos = { - left: left, - width: this.element.outerWidth(), - top: top - adjustLength - this._const.TRIANGLE_LENGTH - }; - op = {height: this._const.TRIANGLE_LENGTH}; - break; - case "bottom": - pos = { - left: left, - width: this.element.outerWidth(), - top: bottom + adjustLength - }; - op = {height: this._const.TRIANGLE_LENGTH}; - break; - default: - break; - } - this.triangle = BI.createWidget(op, { - type: "bi.center_adapt", - cls: "button-combo-triangle-wrapper", - items: [{ - type: "bi.layout", - cls: "bubble-combo-triangle-" + direction + " bi-high-light-border" - }] - }); - pos.el = this.triangle; - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [pos] - }) - }, - - _createLeftTriangle: function () { - this._createTriangle("left"); - }, - - _createRightTriangle: function () { - this._createTriangle("right"); - }, - - _createTopTriangle: function () { - this._createTriangle("top"); - }, - - _createBottomTriangle: function () { - this._createTriangle("bottom"); - }, - - _showTriangle: function () { - var pos = this.combo.getPopupPosition(); - switch (pos.dir) { - case "left,top": - case "left,bottom": - this._createLeftTriangle(); - this.combo.getView().showLine("right"); - break; - case "right,top": - case "right,bottom": - this._createRightTriangle(); - this.combo.getView().showLine("left"); - break; - case "top,left": - case "top,right": - this._createTopTriangle(); - this.combo.getView().showLine("bottom"); - break; - case "bottom,left": - case "bottom,right": - this._createBottomTriangle(); - this.combo.getView().showLine("top"); - break; - } - }, - - _hideTriangle: function () { - this.triangle && this.triangle.destroy(); - this.combo.getView() && this.combo.getView().hideLine(); - }, - - hideView: function () { - this._hideTriangle(); - this.combo && this.combo.hideView(); - }, - - showView: function () { - this.combo && this.combo.showView(); - }, - - hasView: function () { - return BI.isNotNull(this.combo.getView()); - }, - - isViewVisible: function () { - return this.combo.isViewVisible(); - } -}); - -BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; -BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND"; -BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; -BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; - - -BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; -BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; -BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; +/** + * Created by GUY on 2017/2/8. + * + * @class BI.BubbleCombo + * @extends BI.Widget + */ +BI.BubbleCombo = BI.inherit(BI.Widget, { + _const: { + TRIANGLE_LENGTH: 6 + }, + _defaultConfig: function () { + return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-bubble-combo", + trigger: "click", + toggle: true, + direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right + isDefaultInit: false, + destroyWhenHide: false, + isNeedAdjustHeight: true,//是否需要高度调整 + isNeedAdjustWidth: true, + stopPropagation: false, + adjustLength: 0,//调整的距离 + // adjustXOffset: 0, + // adjustYOffset: 10, + hideChecker: BI.emptyFn, + offsetStyle: "left", //left,right,center + el: {}, + popup: {}, + }) + }, + _init: function () { + BI.BubbleCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + trigger: o.trigger, + toggle: o.toggle, + direction: o.direction, + isDefaultInit: o.isDefaultInit, + destroyWhenHide: o.destroyWhenHide, + isNeedAdjustHeight: o.isNeedAdjustHeight, + isNeedAdjustWidth: o.isNeedAdjustWidth, + adjustLength: this._getAdjustLength(), + stopPropagation: o.stopPropagation, + adjustXOffset: 0, + adjustYOffset: 0, + hideChecker: o.hideChecker, + offsetStyle: o.offsetStyle, + el: o.el, + popup: BI.extend({ + type: "bi.bubble_popup_view" + }, o.popup), + }); + this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_CHANGE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_EXPAND, function () { + self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); + }); + this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { + self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { + self._showTriangle(); + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self._hideTriangle(); + self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); + }); + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); + }); + }, + + _getAdjustLength: function () { + return this._const.TRIANGLE_LENGTH + this.options.adjustLength; + }, + + _createTriangle: function (direction) { + var pos = {}, op = {}; + var adjustLength = this.options.adjustLength; + var offset = this.element.offset(); + var left = offset.left, right = offset.left + this.element.outerWidth(); + var top = offset.top, bottom = offset.top + this.element.outerHeight(); + switch (direction) { + case "left": + pos = { + top: top, + height: this.element.outerHeight(), + left: left - adjustLength - this._const.TRIANGLE_LENGTH + }; + op = {width: this._const.TRIANGLE_LENGTH}; + break; + case "right": + pos = { + top: top, + height: this.element.outerHeight(), + left: right + adjustLength + }; + op = {width: this._const.TRIANGLE_LENGTH}; + break; + case "top": + pos = { + left: left, + width: this.element.outerWidth(), + top: top - adjustLength - this._const.TRIANGLE_LENGTH + }; + op = {height: this._const.TRIANGLE_LENGTH}; + break; + case "bottom": + pos = { + left: left, + width: this.element.outerWidth(), + top: bottom + adjustLength + }; + op = {height: this._const.TRIANGLE_LENGTH}; + break; + default: + break; + } + this.triangle && this.triangle.destroy(); + this.triangle = BI.createWidget(op, { + type: "bi.center_adapt", + cls: "button-combo-triangle-wrapper", + items: [{ + type: "bi.layout", + cls: "bubble-combo-triangle-" + direction + " bi-high-light-border" + }] + }); + pos.el = this.triangle; + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [pos] + }) + }, + + _createLeftTriangle: function () { + this._createTriangle("left"); + }, + + _createRightTriangle: function () { + this._createTriangle("right"); + }, + + _createTopTriangle: function () { + this._createTriangle("top"); + }, + + _createBottomTriangle: function () { + this._createTriangle("bottom"); + }, + + _showTriangle: function () { + var pos = this.combo.getPopupPosition(); + switch (pos.dir) { + case "left,top": + case "left,bottom": + this._createLeftTriangle(); + this.combo.getView().showLine("right"); + break; + case "right,top": + case "right,bottom": + this._createRightTriangle(); + this.combo.getView().showLine("left"); + break; + case "top,left": + case "top,right": + this._createTopTriangle(); + this.combo.getView().showLine("bottom"); + break; + case "bottom,left": + case "bottom,right": + this._createBottomTriangle(); + this.combo.getView().showLine("top"); + break; + } + }, + + _hideTriangle: function () { + this.triangle && this.triangle.destroy(); + this.triangle = null; + this.combo.getView() && this.combo.getView().hideLine(); + }, + + hideView: function () { + this._hideTriangle(); + this.combo && this.combo.hideView(); + }, + + showView: function () { + this.combo && this.combo.showView(); + }, + + isViewVisible: function () { + return this.combo.isViewVisible(); + } +}); + +BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; +BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND"; +BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; +BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; + + +BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; +BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; +BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; BI.shortcut("bi.bubble_combo", BI.BubbleCombo); \ No newline at end of file diff --git a/src/case/trigger/trigger.editor.js b/src/case/trigger/trigger.editor.js index 5427b331a..0fa445285 100644 --- a/src/case/trigger/trigger.editor.js +++ b/src/case/trigger/trigger.editor.js @@ -1,79 +1,80 @@ -/** - * 文本输入框trigger - * - * Created by GUY on 2015/9/15. - * @class BI.EditorTrigger - * @extends BI.Trigger - */ -BI.EditorTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4 - }, - - _defaultConfig: function () { - var conf = BI.EditorTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-editor-trigger bi-border", - height: 30, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: false, - watermark: "", - errorText: "", - triggerWidth: 30 - }); - }, - - _init: function () { - this.options.height -= 2; - BI.EditorTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - value: o.value, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - mouseOut: false, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { - self.fireEvent(BI.EditorTrigger.EVENT_CHANGE, arguments); - }); - - BI.createWidget({ - element: this, - type: 'bi.htape', - items: [ - { - el: this.editor - }, { - el: { - type: "bi.trigger_icon_button", - width: o.triggerWidth - }, - width: o.triggerWidth - } - ] - }); - }, - - getValue: function () { - return this.editor.getValue(); - }, - - setValue: function (value) { - this.editor.setValue(value); - }, - - setText: function (text) { - this.editor.setState(text); - } -}); -BI.EditorTrigger.EVENT_CHANGE = "BI.EditorTrigger.EVENT_CHANGE"; +/** + * 文本输入框trigger + * + * Created by GUY on 2015/9/15. + * @class BI.EditorTrigger + * @extends BI.Trigger + */ +BI.EditorTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4 + }, + + _defaultConfig: function () { + var conf = BI.EditorTrigger.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-editor-trigger bi-border", + height: 30, + validationChecker: BI.emptyFn, + quitChecker: BI.emptyFn, + allowBlank: false, + watermark: "", + errorText: "", + triggerWidth: 30 + }); + }, + + _init: function () { + this.options.height -= 2; + BI.EditorTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + value: o.value, + validationChecker: o.validationChecker, + quitChecker: o.quitChecker, + mouseOut: false, + allowBlank: o.allowBlank, + watermark: o.watermark, + errorText: o.errorText + }); + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.EditorTrigger.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + element: this, + type: 'bi.htape', + items: [ + { + el: this.editor + }, { + el: { + type: "bi.trigger_icon_button", + cls: "bi-border-left", + width: o.triggerWidth + }, + width: o.triggerWidth + } + ] + }); + }, + + getValue: function () { + return this.editor.getValue(); + }, + + setValue: function (value) { + this.editor.setValue(value); + }, + + setText: function (text) { + this.editor.setState(text); + } +}); +BI.EditorTrigger.EVENT_CHANGE = "BI.EditorTrigger.EVENT_CHANGE"; BI.shortcut("bi.editor_trigger", BI.EditorTrigger); \ No newline at end of file