From 7b3877ac7794a1b60a532fd70869a4b37e89672e Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 10 Sep 2019 15:52:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?BI-51100=20&&=20REPORT-21752=20=E5=8D=95?= =?UTF-8?q?=E6=B5=8B=E5=92=8C=E6=90=9C=E7=B4=A2=E5=AE=9E=E9=99=85=E5=80=BC?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/2.0/fineui.ie.js | 14 +- dist/2.0/fineui.js | 14 +- dist/base.js | 3 +- dist/bundle.ie.js | 14 +- dist/bundle.js | 14 +- dist/fineui.ie.js | 14 +- dist/fineui.js | 14 +- dist/fineui_without_jquery_polyfill.js | 14 +- dist/widget.js | 11 +- src/base/single/input/input.js | 3 +- src/widget/datetime/__test__/datetime.test.js | 70 +++---- .../editor/__test__/editor.search.test.js | 182 ++++++++++++++++++ .../editor/__test__/editor.text.test.js | 5 + src/widget/editor/editor.search.js | 3 +- .../multilayerselecttree.trigger.js | 4 +- .../multilayersingletree.trigger.js | 4 +- test/utils.js | 6 +- 17 files changed, 286 insertions(+), 103 deletions(-) create mode 100644 src/widget/editor/__test__/editor.search.test.js create mode 100644 src/widget/editor/__test__/editor.text.test.js diff --git a/dist/2.0/fineui.ie.js b/dist/2.0/fineui.ie.js index 46adfea4b3..af36c00c76 100644 --- a/dist/2.0/fineui.ie.js +++ b/dist/2.0/fineui.ie.js @@ -48357,7 +48357,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48440,6 +48440,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } @@ -66749,7 +66750,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", @@ -69263,11 +69265,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; @@ -70444,11 +70446,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/dist/2.0/fineui.js b/dist/2.0/fineui.js index f74cc8c4a3..8350988c2b 100644 --- a/dist/2.0/fineui.js +++ b/dist/2.0/fineui.js @@ -48761,7 +48761,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48844,6 +48844,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } @@ -67153,7 +67154,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", @@ -69667,11 +69669,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; @@ -70848,11 +70850,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/dist/base.js b/dist/base.js index ac06e71f17..5b9f91d29d 100644 --- a/dist/base.js +++ b/dist/base.js @@ -10488,7 +10488,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -10571,6 +10571,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/dist/bundle.ie.js b/dist/bundle.ie.js index 46adfea4b3..af36c00c76 100644 --- a/dist/bundle.ie.js +++ b/dist/bundle.ie.js @@ -48357,7 +48357,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48440,6 +48440,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } @@ -66749,7 +66750,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", @@ -69263,11 +69265,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; @@ -70444,11 +70446,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/dist/bundle.js b/dist/bundle.js index f74cc8c4a3..8350988c2b 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -48761,7 +48761,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48844,6 +48844,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } @@ -67153,7 +67154,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", @@ -69667,11 +69669,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; @@ -70848,11 +70850,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/dist/fineui.ie.js b/dist/fineui.ie.js index eebaa51748..11fecd5f64 100644 --- a/dist/fineui.ie.js +++ b/dist/fineui.ie.js @@ -48602,7 +48602,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48685,6 +48685,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } @@ -66994,7 +66995,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", @@ -69508,11 +69510,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; @@ -70689,11 +70691,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/dist/fineui.js b/dist/fineui.js index 70d91d48fb..131805df5f 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -49006,7 +49006,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -49089,6 +49089,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } @@ -67398,7 +67399,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", @@ -69912,11 +69914,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; @@ -71093,11 +71095,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/dist/fineui_without_jquery_polyfill.js b/dist/fineui_without_jquery_polyfill.js index 52206022d2..17d587fd11 100644 --- a/dist/fineui_without_jquery_polyfill.js +++ b/dist/fineui_without_jquery_polyfill.js @@ -35478,7 +35478,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -35561,6 +35561,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } @@ -49697,7 +49698,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", @@ -52211,11 +52213,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; @@ -53392,11 +53394,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/dist/widget.js b/dist/widget.js index e10c299dcd..79a2db36ca 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -4808,7 +4808,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", @@ -7322,11 +7323,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; @@ -8503,11 +8504,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index 2b01982f46..5b9266857e 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -52,7 +52,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input propertychange", function (e) { + .on("input", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -135,6 +135,7 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { + console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/src/widget/datetime/__test__/datetime.test.js b/src/widget/datetime/__test__/datetime.test.js index be508293de..b56e7f265b 100644 --- a/src/widget/datetime/__test__/datetime.test.js +++ b/src/widget/datetime/__test__/datetime.test.js @@ -35,71 +35,49 @@ describe("DateTime", function () { /** * test_author_windy */ - it("trigger的confirm-下拉面板选值confirm", function (done) { + it("点击确定选值", function (done) { var dateCombo = BI.Test.createWidget({ - type: "bi.dynamic_date_combo", - width: 220, - height: 30 + type: "bi.date_time_combo", + value: { + year: 2018, + month: 2, + day: 23, + hour: 12, + minute: 12, + second: 12 + } }); - // 点击日期,是否收起下拉 - dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + dateCombo.element.find(".bi-date-time-trigger").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.element.find(".bi-calendar:visible .bi-list-item-select :contains(16)").parent().click(); + dateCombo.element.find(".bi-date-time-popup .bi-text:contains(确定)").parent().click(); + expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-16 12:12:12"); 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) { + it("点击取消不选值", function () { var dateCombo = BI.Test.createWidget({ - type: "bi.dynamic_date_combo", - width: 220, - height: 30, + type: "bi.date_time_combo", value: { year: 2018, month: 2, - day: 23 + day: 23, + hour: 12, + minute: 12, + second: 12 } }); - dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); + dateCombo.element.find(".bi-date-time-trigger").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.element.find(".bi-calendar:visible .bi-list-item-select :contains(16)").parent().click(); + dateCombo.element.find(".bi-date-time-popup .bi-text:contains(取消)").parent().click(); + expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); dateCombo.destroy(); done(); }) diff --git a/src/widget/editor/__test__/editor.search.test.js b/src/widget/editor/__test__/editor.search.test.js new file mode 100644 index 0000000000..9e8c85d12f --- /dev/null +++ b/src/widget/editor/__test__/editor.search.test.js @@ -0,0 +1,182 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/9 + */ + +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/6 + */ + +describe("searchEditor", function () { + + /** + * test_author_windy + */ + it("defaultValue", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.search_editor", + width: 300, + value: "12345", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + expect(editor.element.find(".bi-water-mark").text()).to.equal("添加合法性判断"); + expect(editor.element.find(".bi-input").val()).to.equal("12345"); + editor.focus(); + BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { + expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4"); + editor.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("clear", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.search_editor", + width: 300, + value: "12345", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + BI.nextTick(function () { + editor.element.find(".close-font").click(); + expect(editor.element.find(".bi-input").val()).to.equal(""); + editor.destroy(); + done(); + }); + }); + + /** + * test_author_windy + */ + it("setValue", function () { + var editor = BI.Test.createWidget({ + type: "bi.search_editor", + width: 300, + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + editor.setValue("12345"); + expect(editor.element.find(".bi-input").val()).to.equal("12345"); + editor.destroy(); + }); + + + /** + * test_author_windy + */ + it("getValue", function () { + var editor = BI.Test.createWidget({ + type: "bi.search_editor", + width: 300, + value: "12346", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + expect(editor.getValue()).to.equal("12346"); + editor.destroy(); + }); + + + /** + * test_author_windy + */ + it("defaultValue1", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.small_search_editor", + width: 300, + value: "12345", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + expect(editor.element.find(".bi-water-mark").text()).to.equal("添加合法性判断"); + expect(editor.element.find(".bi-input").val()).to.equal("12345"); + editor.focus(); + BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { + expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4"); + editor.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("clear1", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.small_search_editor", + width: 300, + value: "12345", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + BI.nextTick(function () { + editor.element.find(".close-font").click(); + expect(editor.element.find(".bi-input").val()).to.equal(""); + editor.destroy(); + done(); + }); + }); + + /** + * test_author_windy + */ + it("setValue1", function () { + var editor = BI.Test.createWidget({ + type: "bi.small_search_editor", + width: 300, + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + editor.setValue("12345"); + expect(editor.element.find(".bi-input").val()).to.equal("12345"); + editor.destroy(); + }); + + + /** + * test_author_windy + */ + it("getValue1", function () { + var editor = BI.Test.createWidget({ + type: "bi.small_search_editor", + width: 300, + value: "12346", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + expect(editor.getValue()).to.equal("12346"); + editor.destroy(); + }); + +}); \ No newline at end of file diff --git a/src/widget/editor/__test__/editor.text.test.js b/src/widget/editor/__test__/editor.text.test.js new file mode 100644 index 0000000000..de00126d19 --- /dev/null +++ b/src/widget/editor/__test__/editor.text.test.js @@ -0,0 +1,5 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/9 + */ \ No newline at end of file diff --git a/src/widget/editor/editor.search.js b/src/widget/editor/editor.search.js index 2857a85937..f6079b67cb 100644 --- a/src/widget/editor/editor.search.js +++ b/src/widget/editor/editor.search.js @@ -25,7 +25,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, { hgap: 1, errorText: o.errorText, validationChecker: o.validationChecker, - quitChecker: o.quitChecker + quitChecker: o.quitChecker, + value: o.value }); this.clear = BI.createWidget({ type: "bi.icon_button", diff --git a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js index 894957496d..cd1212a2e2 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js @@ -134,11 +134,11 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/src/widget/multilayersingletree/multilayersingletree.trigger.js b/src/widget/multilayersingletree/multilayersingletree.trigger.js index 66c350231b..956e613110 100644 --- a/src/widget/multilayersingletree/multilayersingletree.trigger.js +++ b/src/widget/multilayersingletree/multilayersingletree.trigger.js @@ -134,11 +134,11 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, _getSearchItems: function(keyword) { - var o = this.options; + var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { - var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); if(find.find.length > 0 || find.match.length > 0) { items.push(node); return true; diff --git a/test/utils.js b/test/utils.js index bfc35cfa75..51f9a6a327 100644 --- a/test/utils.js +++ b/test/utils.js @@ -26,10 +26,10 @@ element.trigger(e1); // keyup 至少等300ms后触发 + var e2 = $.Event("keyup"); + e2.keyCode = keyCode; + element.trigger(e2); BI.delay(function () { - var e2 = jQuery.Event("keyup"); - e2.keyCode = keyCode; - element.trigger(e2); callback(); }, 300); }, From c11ef59e6f14811a2bb3f913d3221dc768c68908 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 10 Sep 2019 15:53:36 +0800 Subject: [PATCH 2/2] update --- dist/2.0/fineui.ie.js | 3 +-- dist/2.0/fineui.js | 3 +-- dist/base.js | 3 +-- dist/bundle.ie.js | 3 +-- dist/bundle.js | 3 +-- dist/fineui.ie.js | 3 +-- dist/fineui.js | 3 +-- dist/fineui_without_jquery_polyfill.js | 3 +-- src/base/single/input/input.js | 3 +-- 9 files changed, 9 insertions(+), 18 deletions(-) diff --git a/dist/2.0/fineui.ie.js b/dist/2.0/fineui.ie.js index af36c00c76..79f8dab2cd 100644 --- a/dist/2.0/fineui.ie.js +++ b/dist/2.0/fineui.ie.js @@ -48357,7 +48357,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48440,7 +48440,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/dist/2.0/fineui.js b/dist/2.0/fineui.js index 8350988c2b..b80972acbd 100644 --- a/dist/2.0/fineui.js +++ b/dist/2.0/fineui.js @@ -48761,7 +48761,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48844,7 +48844,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/dist/base.js b/dist/base.js index 5b9f91d29d..ac06e71f17 100644 --- a/dist/base.js +++ b/dist/base.js @@ -10488,7 +10488,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -10571,7 +10571,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/dist/bundle.ie.js b/dist/bundle.ie.js index af36c00c76..79f8dab2cd 100644 --- a/dist/bundle.ie.js +++ b/dist/bundle.ie.js @@ -48357,7 +48357,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48440,7 +48440,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/dist/bundle.js b/dist/bundle.js index 8350988c2b..b80972acbd 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -48761,7 +48761,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48844,7 +48844,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/dist/fineui.ie.js b/dist/fineui.ie.js index 11fecd5f64..aea5a2abce 100644 --- a/dist/fineui.ie.js +++ b/dist/fineui.ie.js @@ -48602,7 +48602,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -48685,7 +48685,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/dist/fineui.js b/dist/fineui.js index 131805df5f..4f60e98e83 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -49006,7 +49006,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -49089,7 +49089,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/dist/fineui_without_jquery_polyfill.js b/dist/fineui_without_jquery_polyfill.js index 17d587fd11..ab19150118 100644 --- a/dist/fineui_without_jquery_polyfill.js +++ b/dist/fineui_without_jquery_polyfill.js @@ -35478,7 +35478,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -35561,7 +35561,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); } diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index 5b9266857e..2b01982f46 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -52,7 +52,7 @@ BI.Input = BI.inherit(BI.Single, { _keydown(e.keyCode); } }) - .on("input", function (e) { + .on("input propertychange", function (e) { // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了 // 其中propertychange在元素属性发生改变的时候就会触发 是为了兼容IE8 // 通过keyCode判断会漏掉输入法点击输入(右键粘贴暂缓) @@ -135,7 +135,6 @@ BI.Input = BI.inherit(BI.Single, { }, onKeyDown: function (keyCode, ctrlKey) { - console.log(123); if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) { this._checkValidationOnValueChange(); }