Browse Source

Merge pull request #1032 in VISUAL/fineui from ~WINDY/fineui:master to master

* commit '93fca052dc87ac8a750c88894d6b66f46ede0e13':
  REPORT-19662 feat: 新增修改watermark接口
es6
guy 5 years ago
parent
commit
080c4da2de
  1. 132
      dist/2.0/fineui.ie.js
  2. 132
      dist/2.0/fineui.js
  3. 81
      dist/base.js
  4. 132
      dist/bundle.ie.js
  5. 132
      dist/bundle.js
  6. 25
      dist/case.js
  7. 16
      dist/core.js
  8. 132
      dist/fineui.ie.js
  9. 132
      dist/fineui.js
  10. 335
      dist/fineui_without_jquery_polyfill.js
  11. 9
      dist/utils.js
  12. 10
      dist/widget.js
  13. 22
      src/base/__test__/button.test.js
  14. 81
      src/base/single/editor/editor.js
  15. 5
      src/case/editor/editor.clear.js
  16. 5
      src/case/editor/editor.shelter.js
  17. 5
      src/case/editor/editor.sign.js
  18. 5
      src/case/editor/editor.state.js
  19. 5
      src/case/editor/editor.state.simple.js
  20. 5
      src/widget/editor/editor.search.js
  21. 5
      src/widget/editor/editor.text.js

132
dist/2.0/fineui.ie.js vendored

@ -11829,17 +11829,16 @@ if (!_global.BI) {
* @private * @private
*/ */
_mount: function (force, deep, lifeHook, predicate) { _mount: function (force, deep, lifeHook, predicate) {
var self = this;
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false; return false;
} }
lifeHook !== false && this.beforeMount && this.beforeMount(); lifeHook !== false && this.beforeMount && this.beforeMount();
this._isMounted = true; this._isMounted = true;
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
if (BI.isNotNull(this._parent)) {
!this._parent.isEnabled() && this._setEnable(false);
!this._parent.isValid() && this._setValid(false);
}
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate); widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate);
}); });
lifeHook !== false && this.mounted && this.mounted(); lifeHook !== false && this.mounted && this.mounted();
@ -15502,14 +15501,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -15534,7 +15533,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -15544,7 +15544,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})();!(function () { })();!(function () {
@ -46773,32 +46773,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -46822,6 +46797,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -46940,6 +46918,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -46962,6 +46972,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;
@ -57628,6 +57657,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -57837,6 +57871,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },
@ -58121,6 +58160,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();
@ -58368,6 +58412,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -58650,6 +58699,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -66807,6 +66861,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -67013,6 +67072,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

132
dist/2.0/fineui.js vendored

@ -11829,17 +11829,16 @@ if (!_global.BI) {
* @private * @private
*/ */
_mount: function (force, deep, lifeHook, predicate) { _mount: function (force, deep, lifeHook, predicate) {
var self = this;
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false; return false;
} }
lifeHook !== false && this.beforeMount && this.beforeMount(); lifeHook !== false && this.beforeMount && this.beforeMount();
this._isMounted = true; this._isMounted = true;
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
if (BI.isNotNull(this._parent)) {
!this._parent.isEnabled() && this._setEnable(false);
!this._parent.isValid() && this._setValid(false);
}
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate); widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate);
}); });
lifeHook !== false && this.mounted && this.mounted(); lifeHook !== false && this.mounted && this.mounted();
@ -15502,14 +15501,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -15534,7 +15533,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -15544,7 +15544,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})();!(function () { })();!(function () {
@ -47177,32 +47177,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -47226,6 +47201,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -47344,6 +47322,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -47366,6 +47376,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;
@ -58032,6 +58061,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -58241,6 +58275,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },
@ -58525,6 +58564,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();
@ -58772,6 +58816,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -59054,6 +59103,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -67211,6 +67265,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -67417,6 +67476,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

81
dist/base.js vendored

@ -8913,32 +8913,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -8962,6 +8937,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -9080,6 +9058,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -9102,6 +9112,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;

132
dist/bundle.ie.js vendored

@ -11829,17 +11829,16 @@ if (!_global.BI) {
* @private * @private
*/ */
_mount: function (force, deep, lifeHook, predicate) { _mount: function (force, deep, lifeHook, predicate) {
var self = this;
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false; return false;
} }
lifeHook !== false && this.beforeMount && this.beforeMount(); lifeHook !== false && this.beforeMount && this.beforeMount();
this._isMounted = true; this._isMounted = true;
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
if (BI.isNotNull(this._parent)) {
!this._parent.isEnabled() && this._setEnable(false);
!this._parent.isValid() && this._setValid(false);
}
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate); widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate);
}); });
lifeHook !== false && this.mounted && this.mounted(); lifeHook !== false && this.mounted && this.mounted();
@ -15502,14 +15501,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -15534,7 +15533,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -15544,7 +15544,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})();!(function () { })();!(function () {
@ -46773,32 +46773,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -46822,6 +46797,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -46940,6 +46918,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -46962,6 +46972,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;
@ -57628,6 +57657,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -57837,6 +57871,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },
@ -58121,6 +58160,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();
@ -58368,6 +58412,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -58650,6 +58699,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -66807,6 +66861,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -67013,6 +67072,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

132
dist/bundle.js vendored

@ -11829,17 +11829,16 @@ if (!_global.BI) {
* @private * @private
*/ */
_mount: function (force, deep, lifeHook, predicate) { _mount: function (force, deep, lifeHook, predicate) {
var self = this;
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false; return false;
} }
lifeHook !== false && this.beforeMount && this.beforeMount(); lifeHook !== false && this.beforeMount && this.beforeMount();
this._isMounted = true; this._isMounted = true;
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
if (BI.isNotNull(this._parent)) {
!this._parent.isEnabled() && this._setEnable(false);
!this._parent.isValid() && this._setValid(false);
}
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate); widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate);
}); });
lifeHook !== false && this.mounted && this.mounted(); lifeHook !== false && this.mounted && this.mounted();
@ -15502,14 +15501,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -15534,7 +15533,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -15544,7 +15544,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})();!(function () { })();!(function () {
@ -47177,32 +47177,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -47226,6 +47201,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -47344,6 +47322,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -47366,6 +47376,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;
@ -58032,6 +58061,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -58241,6 +58275,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },
@ -58525,6 +58564,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();
@ -58772,6 +58816,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -59054,6 +59103,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -67211,6 +67265,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -67417,6 +67476,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

25
dist/case.js vendored

@ -5639,6 +5639,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -5848,6 +5853,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },
@ -6132,6 +6142,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();
@ -6379,6 +6394,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -6661,6 +6681,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;

16
dist/core.js vendored

@ -11829,17 +11829,16 @@ if (!_global.BI) {
* @private * @private
*/ */
_mount: function (force, deep, lifeHook, predicate) { _mount: function (force, deep, lifeHook, predicate) {
var self = this;
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false; return false;
} }
lifeHook !== false && this.beforeMount && this.beforeMount(); lifeHook !== false && this.beforeMount && this.beforeMount();
this._isMounted = true; this._isMounted = true;
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
if (BI.isNotNull(this._parent)) {
!this._parent.isEnabled() && this._setEnable(false);
!this._parent.isValid() && this._setValid(false);
}
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate); widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate);
}); });
lifeHook !== false && this.mounted && this.mounted(); lifeHook !== false && this.mounted && this.mounted();
@ -15502,14 +15501,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -15534,7 +15533,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -15544,7 +15544,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})();!(function () { })();!(function () {

132
dist/fineui.ie.js vendored

@ -12074,17 +12074,16 @@ if (!_global.BI) {
* @private * @private
*/ */
_mount: function (force, deep, lifeHook, predicate) { _mount: function (force, deep, lifeHook, predicate) {
var self = this;
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false; return false;
} }
lifeHook !== false && this.beforeMount && this.beforeMount(); lifeHook !== false && this.beforeMount && this.beforeMount();
this._isMounted = true; this._isMounted = true;
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
if (BI.isNotNull(this._parent)) {
!this._parent.isEnabled() && this._setEnable(false);
!this._parent.isValid() && this._setValid(false);
}
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate); widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate);
}); });
lifeHook !== false && this.mounted && this.mounted(); lifeHook !== false && this.mounted && this.mounted();
@ -15747,14 +15746,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -15779,7 +15778,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -15789,7 +15789,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})();!(function () { })();!(function () {
@ -47018,32 +47018,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -47067,6 +47042,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -47185,6 +47163,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -47207,6 +47217,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;
@ -57873,6 +57902,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -58082,6 +58116,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },
@ -58366,6 +58405,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();
@ -58613,6 +58657,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -58895,6 +58944,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -67052,6 +67106,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -67258,6 +67317,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

132
dist/fineui.js vendored

@ -12074,17 +12074,16 @@ if (!_global.BI) {
* @private * @private
*/ */
_mount: function (force, deep, lifeHook, predicate) { _mount: function (force, deep, lifeHook, predicate) {
var self = this;
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false; return false;
} }
lifeHook !== false && this.beforeMount && this.beforeMount(); lifeHook !== false && this.beforeMount && this.beforeMount();
this._isMounted = true; this._isMounted = true;
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
if (BI.isNotNull(this._parent)) {
!this._parent.isEnabled() && this._setEnable(false);
!this._parent.isValid() && this._setValid(false);
}
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate); widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate);
}); });
lifeHook !== false && this.mounted && this.mounted(); lifeHook !== false && this.mounted && this.mounted();
@ -15747,14 +15746,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -15779,7 +15778,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -15789,7 +15789,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})();!(function () { })();!(function () {
@ -47422,32 +47422,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -47471,6 +47446,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -47589,6 +47567,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -47611,6 +47621,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;
@ -58277,6 +58306,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -58486,6 +58520,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },
@ -58770,6 +58809,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();
@ -59017,6 +59061,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -59299,6 +59348,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -67456,6 +67510,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -67662,6 +67721,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

335
dist/fineui_without_jquery_polyfill.js vendored

@ -11829,17 +11829,16 @@ if (!_global.BI) {
* @private * @private
*/ */
_mount: function (force, deep, lifeHook, predicate) { _mount: function (force, deep, lifeHook, predicate) {
var self = this;
if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) { if (!force && (this._isMounted || !this.isVisible() || this.__asking === true || !(this._isRoot === true || (this._parent && this._parent._isMounted === true)))) {
return false; return false;
} }
lifeHook !== false && this.beforeMount && this.beforeMount(); lifeHook !== false && this.beforeMount && this.beforeMount();
this._isMounted = true; this._isMounted = true;
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
if (BI.isNotNull(this._parent)) {
!this._parent.isEnabled() && this._setEnable(false);
!this._parent.isValid() && this._setValid(false);
}
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate); widget._mount && widget._mount(deep ? force : false, deep, lifeHook, predicate);
}); });
lifeHook !== false && this.mounted && this.mounted(); lifeHook !== false && this.mounted && this.mounted();
@ -15502,14 +15501,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -15534,7 +15533,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -15544,7 +15544,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})(); })();
@ -28556,7 +28556,208 @@ BI.ButtonTree = BI.inherit(BI.ButtonGroup, {
}); });
BI.ButtonTree.EVENT_CHANGE = "EVENT_CHANGE"; BI.ButtonTree.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.button_tree", BI.ButtonTree);BI.prepares.push(function () { BI.shortcut("bi.button_tree", BI.ButtonTree);/**
* Created by windy on 2018/01/23.
*/
describe("ButtonTest", function () {
/**
* test_author_windy
*/
it("Click点击触发事件", function (done) {
var button = BI.Test.createWidget({
type: "bi.button",
text: "CCC",
handler: function () {
this.setText("click");
}
});
BI.nextTick(function () {
button.element.click();
expect(button.element.children(".bi-text").text()).to.equal("click");
button.destroy();
done();
});
});
/**
* test_author_windy
*/
it("MouseDown触发事件", function (done) {
var button = BI.Test.createWidget({
type: "bi.button",
text: "CCC",
trigger: "mousedown",
handler: function () {
this.setText("click");
}
});
BI.nextTick(function () {
button.element.mousedown();
expect(button.element.children(".bi-text").text()).to.equal("click");
button.destroy();
done();
});
});
/**
* test_author_windy
*/
it("MouseUp触发事件", function (done) {
var button = BI.Test.createWidget({
type: "bi.button",
text: "CCC",
trigger: "mouseup",
handler: function () {
this.setText("click");
}
});
BI.nextTick(function () {
button.element.mousedown();
button.element.mouseup();
expect(button.element.children(".bi-text").text()).to.equal("click");
button.destroy();
done();
});
});
/**
* test_author_windy
*/
it("doubleClick触发事件", function (done) {
var button = BI.Test.createWidget({
type: "bi.button",
text: "CCC",
trigger: "dblclick",
handler: function () {
this.setText("click");
}
});
BI.nextTick(function () {
button.element.dblclick();
expect(button.element.children(".bi-text").text()).to.equal("click");
button.destroy();
done();
});
});
/**
* test_author_windy
*/
it("LongClick触发事件", function (done) {
var clickNum = 0;
var button = BI.Test.createWidget({
type: "bi.button",
text: "CCC",
trigger: "lclick",
listeners: [{
eventName: BI.Button.EVENT_CHANGE,
action: function () {
clickNum++;
}
}]
});
BI.nextTick(function () {
button.element.mousedown();
BI.delay(function () {
expect(clickNum).to.equal(2);
button.destroy();
done();
}, 360);
});
});
});
/**
* Created by windy on 2018/01/23.
*/
describe("TextTest", function () {
/**
* test_author_windy
*/
it("setText", function () {
var text = BI.Test.createWidget({
type: "bi.text"
});
text.setText("AAA");
expect(text.element.text()).to.equal("AAA");
text.destroy();
});
/**
* test_author_windy
*/
it("setStyle", function () {
var text = BI.Test.createWidget({
type: "bi.text"
});
text.setStyle({"color": "red"});
expect(text.element.getStyle("color")).to.equal("rgb(255, 0, 0)");
text.destroy();
});
/**
* test_author_windy
*/
it("高亮doHighlight", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "AAA",
highLight: true
});
expect(text.element.getStyle("color")).to.equal("rgb(54, 133, 242)");
text.destroy();
});
/**
* test_author_windy
*/
it("标红doRedMark", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "我是要标红的A",
keyword: "A"
});
expect(text.element.children(".bi-keyword-red-mark").length).to.not.equal(0);
text.destroy();
});
/**
* test_author_windy
*/
it("取消高亮undoHighlight", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "AAA",
highLight: true
});
text.unHighLight();
expect(text.element.getStyle("color")).to.not.equal("rgb(54, 133, 242)");
text.destroy();
});
/**
* test_author_windy
*/
it("取消标红undoRedMark", function () {
var text = BI.Test.createWidget({
type: "bi.text",
text: "我是要标红的A",
keyword: "A"
});
text.unRedMark();
expect(text.element.children(".bi-keyword-red-mark").length).to.equal(0);
text.destroy();
});
});
BI.prepares.push(function () {
BI.Resizers = new BI.ResizeController(); BI.Resizers = new BI.ResizeController();
BI.Layers = new BI.LayerController(); BI.Layers = new BI.LayerController();
BI.Maskers = new BI.MaskersController(); BI.Maskers = new BI.MaskersController();
@ -34540,32 +34741,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -34589,6 +34765,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -34707,6 +34886,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -34729,6 +34940,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;
@ -40857,6 +41087,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -41066,6 +41301,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },
@ -41350,6 +41590,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();
@ -41597,6 +41842,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -41879,6 +42129,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;
@ -49760,6 +50015,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -49966,6 +50226,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

9
dist/utils.js vendored

@ -16856,14 +16856,14 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968)));
}; };
var _mkPYRslt = function (arr) { var _mkPYRslt = function (arr, ignoreMulti) {
var arrRslt = [""], k, multiLen = 0; var arrRslt = [""], k, multiLen = 0;
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i]; var str = arr[i];
var strlen = str.length; var strlen = str.length;
// 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14
// 超过14个多音字之后,后面的都用第一个拼音 // 超过14个多音字之后,后面的都用第一个拼音
if (strlen == 1 || multiLen > 14) { if (strlen == 1 || multiLen > 14 || ignoreMulti) {
var tmpStr = str.substring(0, 1); var tmpStr = str.substring(0, 1);
for (k = 0; k < arrRslt.length; k++) { for (k = 0; k < arrRslt.length; k++) {
arrRslt[k] += tmpStr; arrRslt[k] += tmpStr;
@ -16888,7 +16888,8 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}; };
_.extend(BI, { _.extend(BI, {
makeFirstPY: function (str) { makeFirstPY: function (str, options) {
options = options || {};
if (typeof (str) !== "string") {return "" + str;} if (typeof (str) !== "string") {return "" + str;}
var arrResult = []; // 保存中间结果的数组 var arrResult = []; // 保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) { for (var i = 0, len = str.length; i < len; i++) {
@ -16898,7 +16899,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
arrResult.push(_checkPYCh(ch)); arrResult.push(_checkPYCh(ch));
} }
// 处理arrResult,返回所有可能的拼音首字母串数组 // 处理arrResult,返回所有可能的拼音首字母串数组
return _mkPYRslt(arrResult); return _mkPYRslt(arrResult, options.ignoreMulti);
} }
}); });
})(); })();

10
dist/widget.js vendored

@ -4897,6 +4897,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },
@ -5103,6 +5108,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

22
src/base/__test__/button.test.js

@ -114,26 +114,4 @@ describe("ButtonTest", function () {
}); });
}); });
it("LongClick触发事件", function (done) {
var clickNum = 0;
var button = BI.Test.createWidget({
type: "bi.button",
text: "CCC",
trigger: "lclick",
listeners: [{
eventName: BI.Button.EVENT_CHANGE,
action: function () {
clickNum++;
}
}]
});
BI.nextTick(function () {
button.element.dblclick();
expect(button.element.children(".bi-text").text()).to.equal("click");
button.destroy();
done();
});
});
}); });

81
src/base/single/editor/editor.js

@ -47,32 +47,7 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0" margin: "0"
}); });
if (BI.isKey(this.options.watermark)) { if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({ this._assertWaterMark();
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
} }
var _items = []; var _items = [];
@ -96,6 +71,9 @@ BI.Editor = BI.inherit(BI.Single, {
var items = [{ var items = [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function(_ref) {
self.contentWrapper = _ref;
},
items: _items items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
@ -214,6 +192,38 @@ BI.Editor = BI.inherit(BI.Single, {
} }
}, },
_assertWaterMark: function() {
var self = this, o = this.options;
if(BI.isNull(this.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
}
},
_checkError: function () { _checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid()); this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip(); this._checkToolTip();
@ -236,6 +246,25 @@ BI.Editor = BI.inherit(BI.Single, {
return this.options.errorText; return this.options.errorText;
}, },
setWaterMark: function(v) {
this.options.watermark = v;
if(BI.isNull(this.watermark)) {
this._assertWaterMark();
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}]
})
}
BI.isKey(v) && this.watermark.setText(v);
},
_setErrorVisible: function (b) { _setErrorVisible: function (b) {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;

5
src/case/editor/editor.clear.js

@ -129,6 +129,11 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

5
src/case/editor/editor.shelter.js

@ -161,6 +161,11 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
this.text.visible(); this.text.visible();
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
setTitle: function (title) { setTitle: function (title) {
this.text.setTitle(title); this.text.setTitle(title);
}, },

5
src/case/editor/editor.sign.js

@ -173,6 +173,11 @@ BI.SignEditor = BI.inherit(BI.Widget, {
this.text.setWarningTitle(title); this.text.setWarningTitle(title);
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this._showInput(); this._showInput();
this.editor.focus(); this.editor.focus();

5
src/case/editor/editor.state.js

@ -151,6 +151,11 @@ BI.StateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;

5
src/case/editor/editor.state.simple.js

@ -140,6 +140,11 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
doRedMark: function () { doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return; return;

5
src/widget/editor/editor.search.js

@ -133,6 +133,11 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
} }
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

5
src/widget/editor/editor.text.js

@ -118,6 +118,11 @@ BI.TextEditor = BI.inherit(BI.Widget, {
}); });
}, },
setWaterMark: function (v) {
this.options.watermark = v;
this.editor.setWaterMark(v);
},
focus: function () { focus: function () {
this.editor.focus(); this.editor.focus();
}, },

Loading…
Cancel
Save