From b444a56848de9d68c2a2c7eabc877bffb1d54baa Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 6 Sep 2019 17:19:04 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-21493=20&&=20REPORT-21002=20&&=20BI-5110?= =?UTF-8?q?0=20=E5=8D=95=E6=B5=8B=20&&=20=E8=A7=86=E8=A7=89=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/2.0/fineui.ie.js | 39 ++- dist/2.0/fineui.js | 39 ++- dist/base.js | 4 +- dist/bundle.ie.js | 39 ++- dist/bundle.js | 39 ++- dist/fineui.ie.js | 39 ++- dist/fineui.js | 39 ++- dist/fineui_without_jquery_polyfill.js | 39 ++- dist/widget.js | 35 +- src/base/single/a/__test__/a.test.js | 2 + src/widget/datetime/__test__/datetime.test.js | 107 ++++++ .../downlist/__test__/combo.downlist.test.js | 19 - src/widget/downlist/__test__/downlist.test.js | 63 ++++ ...date.combo.test.js => dynamicdate.test.js} | 65 ++++ src/widget/dynamicdate/dynamicdate.combo.js | 6 + src/widget/dynamicdate/dynamicdate.trigger.js | 4 + .../__test__/dynamicdatetime.test.js | 330 ++++++++++++++++++ .../dynamicdatetime/dynamicdatetime.combo.js | 8 +- .../dynamicdatetime.trigger.js | 6 +- src/widget/time/time.combo.js | 6 + src/widget/time/time.trigger.js | 5 + test/utils.js | 10 + 22 files changed, 890 insertions(+), 53 deletions(-) create mode 100644 src/widget/datetime/__test__/datetime.test.js delete mode 100644 src/widget/downlist/__test__/combo.downlist.test.js create mode 100644 src/widget/downlist/__test__/downlist.test.js rename src/widget/dynamicdate/__test__/{dynamicdate.combo.test.js => dynamicdate.test.js} (83%) create mode 100644 src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js diff --git a/dist/2.0/fineui.ie.js b/dist/2.0/fineui.ie.js index e798139338..46adfea4b3 100644 --- a/dist/2.0/fineui.ie.js +++ b/dist/2.0/fineui.ie.js @@ -48406,7 +48406,7 @@ BI.Input = BI.inherit(BI.Single, { blur(); } - function blur() { + function blur () { if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) { self.element.val(self._lastValidValue ? self._lastValidValue : ""); self._checkValidationOnValueChange(); @@ -48473,7 +48473,7 @@ BI.Input = BI.inherit(BI.Single, { // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { + if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { @@ -64721,6 +64721,11 @@ BI.extend(BI.DynamicDateCard, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -64920,6 +64925,7 @@ BI.extend(BI.DynamicDateCard, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -65324,6 +65330,9 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -65590,6 +65599,7 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; @@ -65609,7 +65619,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -65689,6 +65699,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -65891,6 +65906,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -66402,6 +66418,9 @@ BI.extend(BI.DynamicDateTimeSelect, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -66521,7 +66540,7 @@ BI.extend(BI.DynamicDateTimeSelect, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -66693,6 +66712,7 @@ BI.extend(BI.DynamicDateTimeSelect, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; @@ -83799,6 +83819,7 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -83830,6 +83851,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { @@ -84019,6 +84045,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/dist/2.0/fineui.js b/dist/2.0/fineui.js index a941bc4310..f74cc8c4a3 100644 --- a/dist/2.0/fineui.js +++ b/dist/2.0/fineui.js @@ -48810,7 +48810,7 @@ BI.Input = BI.inherit(BI.Single, { blur(); } - function blur() { + function blur () { if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) { self.element.val(self._lastValidValue ? self._lastValidValue : ""); self._checkValidationOnValueChange(); @@ -48877,7 +48877,7 @@ BI.Input = BI.inherit(BI.Single, { // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { + if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { @@ -65125,6 +65125,11 @@ BI.extend(BI.DynamicDateCard, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -65324,6 +65329,7 @@ BI.extend(BI.DynamicDateCard, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -65728,6 +65734,9 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -65994,6 +66003,7 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; @@ -66013,7 +66023,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -66093,6 +66103,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -66295,6 +66310,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -66806,6 +66822,9 @@ BI.extend(BI.DynamicDateTimeSelect, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -66925,7 +66944,7 @@ BI.extend(BI.DynamicDateTimeSelect, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -67097,6 +67116,7 @@ BI.extend(BI.DynamicDateTimeSelect, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; @@ -84203,6 +84223,7 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -84234,6 +84255,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { @@ -84423,6 +84449,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/dist/base.js b/dist/base.js index c1d81bc0d4..ac06e71f17 100644 --- a/dist/base.js +++ b/dist/base.js @@ -10537,7 +10537,7 @@ BI.Input = BI.inherit(BI.Single, { blur(); } - function blur() { + function blur () { if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) { self.element.val(self._lastValidValue ? self._lastValidValue : ""); self._checkValidationOnValueChange(); @@ -10604,7 +10604,7 @@ BI.Input = BI.inherit(BI.Single, { // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { + if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { diff --git a/dist/bundle.ie.js b/dist/bundle.ie.js index e798139338..46adfea4b3 100644 --- a/dist/bundle.ie.js +++ b/dist/bundle.ie.js @@ -48406,7 +48406,7 @@ BI.Input = BI.inherit(BI.Single, { blur(); } - function blur() { + function blur () { if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) { self.element.val(self._lastValidValue ? self._lastValidValue : ""); self._checkValidationOnValueChange(); @@ -48473,7 +48473,7 @@ BI.Input = BI.inherit(BI.Single, { // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { + if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { @@ -64721,6 +64721,11 @@ BI.extend(BI.DynamicDateCard, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -64920,6 +64925,7 @@ BI.extend(BI.DynamicDateCard, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -65324,6 +65330,9 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -65590,6 +65599,7 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; @@ -65609,7 +65619,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -65689,6 +65699,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -65891,6 +65906,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -66402,6 +66418,9 @@ BI.extend(BI.DynamicDateTimeSelect, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -66521,7 +66540,7 @@ BI.extend(BI.DynamicDateTimeSelect, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -66693,6 +66712,7 @@ BI.extend(BI.DynamicDateTimeSelect, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; @@ -83799,6 +83819,7 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -83830,6 +83851,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { @@ -84019,6 +84045,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/dist/bundle.js b/dist/bundle.js index a941bc4310..f74cc8c4a3 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -48810,7 +48810,7 @@ BI.Input = BI.inherit(BI.Single, { blur(); } - function blur() { + function blur () { if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) { self.element.val(self._lastValidValue ? self._lastValidValue : ""); self._checkValidationOnValueChange(); @@ -48877,7 +48877,7 @@ BI.Input = BI.inherit(BI.Single, { // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { + if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { @@ -65125,6 +65125,11 @@ BI.extend(BI.DynamicDateCard, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -65324,6 +65329,7 @@ BI.extend(BI.DynamicDateCard, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -65728,6 +65734,9 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -65994,6 +66003,7 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; @@ -66013,7 +66023,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -66093,6 +66103,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -66295,6 +66310,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -66806,6 +66822,9 @@ BI.extend(BI.DynamicDateTimeSelect, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -66925,7 +66944,7 @@ BI.extend(BI.DynamicDateTimeSelect, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -67097,6 +67116,7 @@ BI.extend(BI.DynamicDateTimeSelect, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; @@ -84203,6 +84223,7 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -84234,6 +84255,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { @@ -84423,6 +84449,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/dist/fineui.ie.js b/dist/fineui.ie.js index eb86c90184..eebaa51748 100644 --- a/dist/fineui.ie.js +++ b/dist/fineui.ie.js @@ -48651,7 +48651,7 @@ BI.Input = BI.inherit(BI.Single, { blur(); } - function blur() { + function blur () { if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) { self.element.val(self._lastValidValue ? self._lastValidValue : ""); self._checkValidationOnValueChange(); @@ -48718,7 +48718,7 @@ BI.Input = BI.inherit(BI.Single, { // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { + if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { @@ -64966,6 +64966,11 @@ BI.extend(BI.DynamicDateCard, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -65165,6 +65170,7 @@ BI.extend(BI.DynamicDateCard, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -65569,6 +65575,9 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -65835,6 +65844,7 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; @@ -65854,7 +65864,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -65934,6 +65944,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -66136,6 +66151,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -66647,6 +66663,9 @@ BI.extend(BI.DynamicDateTimeSelect, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -66766,7 +66785,7 @@ BI.extend(BI.DynamicDateTimeSelect, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -66938,6 +66957,7 @@ BI.extend(BI.DynamicDateTimeSelect, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; @@ -84044,6 +84064,7 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -84075,6 +84096,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { @@ -84264,6 +84290,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/dist/fineui.js b/dist/fineui.js index 9cc5ebcd53..70d91d48fb 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -49055,7 +49055,7 @@ BI.Input = BI.inherit(BI.Single, { blur(); } - function blur() { + function blur () { if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) { self.element.val(self._lastValidValue ? self._lastValidValue : ""); self._checkValidationOnValueChange(); @@ -49122,7 +49122,7 @@ BI.Input = BI.inherit(BI.Single, { // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { + if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { @@ -65370,6 +65370,11 @@ BI.extend(BI.DynamicDateCard, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -65569,6 +65574,7 @@ BI.extend(BI.DynamicDateCard, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -65973,6 +65979,9 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -66239,6 +66248,7 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; @@ -66258,7 +66268,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -66338,6 +66348,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -66540,6 +66555,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -67051,6 +67067,9 @@ BI.extend(BI.DynamicDateTimeSelect, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -67170,7 +67189,7 @@ BI.extend(BI.DynamicDateTimeSelect, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -67342,6 +67361,7 @@ BI.extend(BI.DynamicDateTimeSelect, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; @@ -84448,6 +84468,7 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -84479,6 +84500,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { @@ -84668,6 +84694,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/dist/fineui_without_jquery_polyfill.js b/dist/fineui_without_jquery_polyfill.js index 6cae22ac5f..52206022d2 100644 --- a/dist/fineui_without_jquery_polyfill.js +++ b/dist/fineui_without_jquery_polyfill.js @@ -35527,7 +35527,7 @@ BI.Input = BI.inherit(BI.Single, { blur(); } - function blur() { + function blur () { if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) { self.element.val(self._lastValidValue ? self._lastValidValue : ""); self._checkValidationOnValueChange(); @@ -35594,7 +35594,7 @@ BI.Input = BI.inherit(BI.Single, { // _valueChange中会更新_lastValue, 这边缓存用以后续STOP事件服务 var lastValue = this._lastValue; - if (BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")) { + if(BI.trim(this.getValue()) !== BI.trim(this._lastValue || "")){ this._valueChange(); } if (BI.isEndWithBlank(this.getValue())) { @@ -47669,6 +47669,11 @@ BI.extend(BI.DynamicDateCard, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -47868,6 +47873,7 @@ BI.extend(BI.DynamicDateCard, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -48272,6 +48278,9 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -48538,6 +48547,7 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; @@ -48557,7 +48567,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -48637,6 +48647,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -48839,6 +48854,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -49350,6 +49366,9 @@ BI.extend(BI.DynamicDateTimeSelect, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -49469,7 +49488,7 @@ BI.extend(BI.DynamicDateTimeSelect, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -49641,6 +49660,7 @@ BI.extend(BI.DynamicDateTimeSelect, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; @@ -66747,6 +66767,7 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -66778,6 +66799,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { @@ -66967,6 +66993,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/dist/widget.js b/dist/widget.js index 225f143e39..e10c299dcd 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -2780,6 +2780,11 @@ BI.extend(BI.DynamicDateCard, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -2979,6 +2984,7 @@ BI.extend(BI.DynamicDateCard, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -3383,6 +3389,9 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -3649,6 +3658,7 @@ BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; @@ -3668,7 +3678,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -3748,6 +3758,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -3950,6 +3965,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; @@ -4461,6 +4477,9 @@ BI.extend(BI.DynamicDateTimeSelect, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -4580,7 +4599,7 @@ BI.extend(BI.DynamicDateTimeSelect, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -4752,6 +4771,7 @@ BI.extend(BI.DynamicDateTimeSelect, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; @@ -21858,6 +21878,7 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -21889,6 +21910,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { @@ -22078,6 +22104,11 @@ BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () { self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/src/base/single/a/__test__/a.test.js b/src/base/single/a/__test__/a.test.js index 9e5b508ad6..6a78187c28 100644 --- a/src/base/single/a/__test__/a.test.js +++ b/src/base/single/a/__test__/a.test.js @@ -12,6 +12,7 @@ describe("ALinkTest", function () { text: "CCC" }); expect(a.element.is('a')).to.equal(true); + a.destroy(); }); /** @@ -26,5 +27,6 @@ describe("ALinkTest", function () { } }); expect(a.element.is('a') && a.element.hasClass("bi-label")).to.equal(true); + a.destroy(); }); }); diff --git a/src/widget/datetime/__test__/datetime.test.js b/src/widget/datetime/__test__/datetime.test.js new file mode 100644 index 0000000000..be508293de --- /dev/null +++ b/src/widget/datetime/__test__/datetime.test.js @@ -0,0 +1,107 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/6 + */ + +describe("DateTime", function () { + + before(function () { + BI.holidays = { + "2010-02-28": true, + "2010-02-27": true + }; + }); + + /** + * test_author_windy + */ + it("defaultValue", function () { + var dateCombo = BI.Test.createWidget({ + type: "bi.date_time_combo", + value: { + year: 2018, + month: 2, + day: 23, + hour: 12, + minute: 12, + second: 12 + } + }); + expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); + dateCombo.destroy(); + }); + + /** + * test_author_windy + */ + it("trigger的confirm-下拉面板选值confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + width: 220, + height: 30 + }); + // 点击日期,是否收起下拉 + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(5)").parent().click(); + expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("block"); + dateCombo.destroy(); + done(); + }) + + }); + + /** + * test_author_windy + */ + it("下拉后直接点击外部的触发的confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + width: 220, + height: 30, + }); + // 点击日期,是否收起下拉 + BI.nextTick(function () { + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + var input = dateCombo.element.find(".bi-date-time-trigger .bi-input"); + BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () { + BI.delay(function () { + expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("none"); + dateCombo.destroy(); + done(); + }, 300); + }); + }) + }); + }); + + + /** + * test_author_windy + */ + it("点击确定", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + width: 220, + height: 30, + value: { + year: 2018, + month: 2, + day: 23 + } + }); + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-dynamic-date-popup .bi-text:contains(确定)").parent().click(); + expect(dateCombo.getValue()).to.deep.equal({ + year: 2018, + month: 2, + day: 23 + }); + dateCombo.destroy(); + done(); + }) + }); +}); \ No newline at end of file diff --git a/src/widget/downlist/__test__/combo.downlist.test.js b/src/widget/downlist/__test__/combo.downlist.test.js deleted file mode 100644 index 6ef0314225..0000000000 --- a/src/widget/downlist/__test__/combo.downlist.test.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @author windy - * @version 2.0 - * Created by windy on 2019/9/3 - */ - -describe("DownListCombo", function () { - - /** - * test_author_windy - */ - it("defaultValue", function () { - var datePane = BI.Test.createWidget({ - type: "bi.down_list_combo", - adjustLength: 10, - items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]] - }); - }); -}); \ No newline at end of file diff --git a/src/widget/downlist/__test__/downlist.test.js b/src/widget/downlist/__test__/downlist.test.js new file mode 100644 index 0000000000..e84cd05254 --- /dev/null +++ b/src/widget/downlist/__test__/downlist.test.js @@ -0,0 +1,63 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/3 + */ + +describe("DownListCombo", function () { + + /** + * test_author_windy + */ + it("defaultValue", function () { + var downListCombo = BI.Test.createWidget({ + type: "bi.down_list_combo", + adjustLength: 10, + items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]] + }); + downListCombo.setValue([{value: 12, childValue: 21}]); + expect(downListCombo.getValue()).to.deep.equal([ { childValue: 21, value: 12 } ]); + downListCombo.destroy(); + }); + + + /** + * test_author_windy + */ + it("点击父亲选值", function (done) { + var downListCombo = BI.Test.createWidget({ + type: "bi.down_list_combo", + height: 30, + width: 30, + items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}], [{"text": "column 1122", value: 32}, {"text": "column 1133", value: 33}]] + }); + downListCombo.element.children(".pull-down-font").click(); + BI.nextTick(function () { + downListCombo.element.find(".bi-down-list-group:last-child .bi-down-list-item").click(); + expect(downListCombo.getValue()).to.deep.equal([ { value: 33 } ]); + done(); + }); + }); + + + /** + * test_author_windy + */ + it("点击儿子选值", function (done) { + var downListCombo = BI.Test.createWidget({ + type: "bi.down_list_combo", + height: 30, + width: 30, + items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]] + }); + downListCombo.element.children(".pull-down-font").click(); + BI.Test.triggerMouseover(downListCombo.element.find(".bi-down-list-group:first-child .bi-down-list-group-item"), function () { + BI.nextTick(function () { + downListCombo.element.find(".child-down-list-item:first-child").click(); + expect(downListCombo.getValue()).to.deep.equal([ { childValue: 21, value: 12 } ]); + downListCombo.destroy(); + done(); + }); + }); + }); +}); \ No newline at end of file diff --git a/src/widget/dynamicdate/__test__/dynamicdate.combo.test.js b/src/widget/dynamicdate/__test__/dynamicdate.test.js similarity index 83% rename from src/widget/dynamicdate/__test__/dynamicdate.combo.test.js rename to src/widget/dynamicdate/__test__/dynamicdate.test.js index ff854c4ddf..28ff2e9d9c 100644 --- a/src/widget/dynamicdate/__test__/dynamicdate.combo.test.js +++ b/src/widget/dynamicdate/__test__/dynamicdate.test.js @@ -6,6 +6,13 @@ describe("DateCombo", function () { + before(function () { + BI.holidays = { + "2010-02-28": true, + "2010-02-27": true + }; + }); + /** * test_author_windy */ @@ -202,6 +209,64 @@ describe("DateCombo", function () { }) }); + /** + * test_author_windy + */ + it("测试动态默认值", function () { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + width: 220, + height: 30, + value: { + type: 2, + value: { + year: -1, + month: 1, + quarter: -1, + week: 1, + day: -1, + position: 2 + } + } + }); + expect(dateCombo.getValue()).to.deep.equal({ + type: 2, + value: { + year: -1, + month: 1, + quarter: -1, + week: 1, + day: -1, + position: 2 + } + }); + dateCombo.destroy(); + }); + + /** + * test_author_windy + */ + it("测试工作日动态默认值", function () { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + width: 220, + height: 30, + value: { + type: 2, + value: { + workDay: -1 + } + } + }); + expect(dateCombo.getValue()).to.deep.equal({ + type: 2, + value: { + workDay: -1 + } + }); + dateCombo.destroy(); + }); + /** * test_author_windy diff --git a/src/widget/dynamicdate/dynamicdate.combo.js b/src/widget/dynamicdate/dynamicdate.combo.js index 6ae285f5c3..af9ea5b769 100644 --- a/src/widget/dynamicdate/dynamicdate.combo.js +++ b/src/widget/dynamicdate/dynamicdate.combo.js @@ -82,6 +82,11 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTrigger.EVENT_ERROR, action: function () { @@ -281,6 +286,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { BI.DynamicDateCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; diff --git a/src/widget/dynamicdate/dynamicdate.trigger.js b/src/widget/dynamicdate/dynamicdate.trigger.js index a3806bec4c..5089ec9c35 100644 --- a/src/widget/dynamicdate/dynamicdate.trigger.js +++ b/src/widget/dynamicdate/dynamicdate.trigger.js @@ -58,6 +58,9 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); }); @@ -324,6 +327,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { }); +BI.DynamicDateTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; diff --git a/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js b/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js new file mode 100644 index 0000000000..c6ffded8ee --- /dev/null +++ b/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js @@ -0,0 +1,330 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/4 + */ + +describe("DateTimeCombo", function () { + + before(function () { + BI.holidays = { + "2010-02-28": true, + "2010-02-27": true + }; + }); + + /** + * test_author_windy + */ + it("defaultValue", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23, + hour: 12, + minute: 12, + second: 12 + } + } + }); + BI.nextTick(function () { + expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); + dateCombo.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("测试输入值收起下拉清空值下拉出现", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23, + hour: 12, + minute: 12, + second: 12 + } + } + }); + BI.nextTick(function () { + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + // 输入8, 检查popup是否收起 + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), "8", 56, function () { + BI.nextTick(function () { + expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("none"); + // 清空输入, 检查popup是否弹出 + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () { + BI.nextTick(function () { + expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("block"); + dateCombo.destroy(); + done(); + }); + }); + }); + }); + }); + + }); + + /** + * test_author_windy + */ + it("trigger的confirm-下拉面板选值confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30 + }); + // 点击日期,是否收起下拉 + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(5)").parent().click(); + + expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("block"); + dateCombo.destroy(); + done(); + }) + + }); + + /** + * test_author_windy + */ + it("下拉后直接点击外部的触发的confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30, + }); + // 点击日期,是否收起下拉 + BI.nextTick(function () { + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + var input = dateCombo.element.find(".bi-date-time-trigger .bi-input"); + BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () { + BI.delay(function () { + expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("none"); + dateCombo.destroy(); + done(); + }, 300); + }); + }) + }); + }); + + + /** + * test_author_windy + */ + it("点击清空", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23, + hour: 12, + minute: 12, + second: 12 + } + } + }); + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(清除)").parent().click(); + expect(BI.isNull(dateCombo.getValue())).to.equal(true); + dateCombo.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("点击今天", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23, + hour: 12, + minute: 12, + second: 12 + } + } + }); + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(今天)").parent().click(); + var date = BI.getDate(); + expect(dateCombo.getValue()).to.deep.equal({ + type: 1, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate(), + hour: 0, + minute: 0, + second: 0 + } + }); + dateCombo.destroy(); + done(); + }) + }); + + + /** + * test_author_windy + */ + it("点击确定", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23, + hour: 12, + minute: 12, + second: 12 + } + } + }); + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(确定)").parent().click(); + expect(dateCombo.getValue()).to.deep.equal({ + type: 1, + value: { + year: 2018, + month: 2, + day: 23, + hour: 12, + minute: 12, + second: 12 + } + }); + dateCombo.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("测试动态默认值", function () { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30, + value: { + type: 2, + value: { + year: -1, + month: 1, + quarter: -1, + week: 1, + day: -1, + position: 2 + } + } + }); + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + expect(dateCombo.getValue()).to.deep.equal({ + type: 2, + value: { + year: -1, + month: 1, + quarter: -1, + week: 1, + day: -1, + position: 2 + } + }); + dateCombo.destroy(); + }); + + /** + * test_author_windy + */ + it("测试工作日动态默认值", function () { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30, + value: { + type: 2, + value: { + workDay: -1 + } + } + }); + expect(dateCombo.getValue()).to.deep.equal({ + type: 2, + value: { + workDay: -1 + } + }); + dateCombo.destroy(); + }); + + + /** + * test_author_windy + */ + it("trigger的输入日期后confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_time_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23 + } + } + }); + BI.nextTick(function () { + dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + BI.nextTick(function () { + var input = dateCombo.element.find(".bi-date-time-trigger .bi-input"); + input.val("2017-1-1"); + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), null, BI.KeyCode.ENTER, function () { + BI.delay(function () { + expect(dateCombo.element.find(".bi-date-time-trigger .bi-text-button").text()).to.equal("2017-01-01 00:00:00"); + dateCombo.destroy(); + done(); + }, 300); + }); + }); + }) + + }); +}); \ No newline at end of file diff --git a/src/widget/dynamicdatetime/dynamicdatetime.combo.js b/src/widget/dynamicdatetime/dynamicdatetime.combo.js index 6a277f8e11..59bd8c3613 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.combo.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.combo.js @@ -7,7 +7,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, props: { - baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow", + baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius", height: 22, minDate: "1900-01-01", maxDate: "2099-12-31", @@ -87,6 +87,11 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { } self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_BLUR, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BLUR); + } }, { eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, action: function () { @@ -289,6 +294,7 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { BI.DynamicDateTimeCombo.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; diff --git a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js index d8113f7ab0..297e3c09d7 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js @@ -58,6 +58,9 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { self.storeTriggerValue = self.getKey(); self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); }); + this.editor.on(BI.SignEditor.EVENT_BLUR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_BLUR); + }); this.editor.on(BI.SignEditor.EVENT_STOP, function () { self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); }); @@ -177,7 +180,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { v = BI.print(date, c.compareFormat); result = [0, 1, 2]; } - var dateArray = v.match(/\d+/g); + var dateArray = v.match(/\d+/g) || []; var newArray = []; // 处理乱序的年月日 BI.each(dateArray.slice(0, 3), function (idx) { @@ -349,6 +352,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { }); +BI.DynamicDateTimeTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; diff --git a/src/widget/time/time.combo.js b/src/widget/time/time.combo.js index 840a97463b..2a671adb27 100644 --- a/src/widget/time/time.combo.js +++ b/src/widget/time/time.combo.js @@ -65,6 +65,7 @@ isNeedAdjustWidth: false, el: { type: "bi.time_trigger", + height: opts.height, allowEdit: opts.allowEdit, watermark: opts.watermark, format: opts.format, @@ -96,6 +97,11 @@ } self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_ERROR", action: function () { diff --git a/src/widget/time/time.trigger.js b/src/widget/time/time.trigger.js index 5e2796f079..d9a3ef114a 100644 --- a/src/widget/time/time.trigger.js +++ b/src/widget/time/time.trigger.js @@ -64,6 +64,11 @@ self.storeTriggerValue = self.getKey(); self.fireEvent("EVENT_FOCUS"); } + }, { + eventName: "EVENT_BLUR", + action: function () { + self.fireEvent("EVENT_BLUR"); + } }, { eventName: "EVENT_STOP", action: function () { diff --git a/test/utils.js b/test/utils.js index cc83013cc7..bfc35cfa75 100644 --- a/test/utils.js +++ b/test/utils.js @@ -32,6 +32,16 @@ element.trigger(e2); callback(); }, 300); + }, + + /** + * 模拟一次鼠标hover + */ + triggerMouseover: function (element, callback) { + // keydown + var e = $.Event("mouseover"); + element.trigger(e); + callback && callback(); } }) })(); \ No newline at end of file