Browse Source

Merge pull request #85 in ~GUY/fineui from ~WINDY/fineui:master to master

* commit '7e66a82318729d75d4ffe529cd5e02805205007d':
  codeeditor的水印问题
es6
windy 7 years ago
parent
commit
89089a6225
  1. 24
      bi/base.js
  2. 24
      docs/base.js
  3. 24
      src/base/single/editor/editor.code.js

24
bi/base.js

@ -17747,12 +17747,12 @@ BI.CodeEditor = BI.inherit(BI.Single, {
});
this.editor.on("focus", function () {
watermark.setVisible(false);
self.watermark.setVisible(false);
self.fireEvent(BI.CodeEditor.EVENT_FOCUS);
});
this.editor.on("blur", function () {
watermark.setVisible(BI.isEmptyString(self.getValue()));
self.watermark.setVisible(BI.isEmptyString(self.getValue()));
self.fireEvent(BI.CodeEditor.EVENT_BLUR);
});
@ -17761,21 +17761,21 @@ BI.CodeEditor = BI.inherit(BI.Single, {
// });
//水印
var watermark = BI.createWidget({
this.watermark = BI.createWidget({
type: "bi.label",
text: o.watermark,
cls: "bi-water-mark",
whiteSpace: "nowrap",
textAlign: "left"
});
watermark.element.bind(
this.watermark.element.bind(
"mousedown", function (e) {
self.insertString("");
self.editor.focus();
e.stopEvent();
}
);
watermark.element.bind("click", function (e) {
this.watermark.element.bind("click", function (e) {
self.editor.focus();
e.stopEvent();
});
@ -17783,7 +17783,7 @@ BI.CodeEditor = BI.inherit(BI.Single, {
type: "bi.absolute",
element: this,
items: [{
el: watermark,
el: this.watermark,
top: 0,
left: 5
}]
@ -17801,6 +17801,15 @@ BI.CodeEditor = BI.inherit(BI.Single, {
this.editor.setOption("readOnly", b === true ? false : "nocursor")
},
_checkWaterMark: function () {
var o = this.options;
if (BI.isEmptyString(this.editor.getValue()) && BI.isKey(o.watermark)) {
this.watermark && this.watermark.visible();
} else {
this.watermark && this.watermark.invisible();
}
},
insertParam: function (param) {
var from = this.editor.getCursor();
this.editor.replaceSelection(param);
@ -17855,7 +17864,8 @@ BI.CodeEditor = BI.inherit(BI.Single, {
} else {
self.insertString(item);
}
})
});
this._checkWaterMark();
},
focus: function () {

24
docs/base.js

@ -17747,12 +17747,12 @@ BI.CodeEditor = BI.inherit(BI.Single, {
});
this.editor.on("focus", function () {
watermark.setVisible(false);
self.watermark.setVisible(false);
self.fireEvent(BI.CodeEditor.EVENT_FOCUS);
});
this.editor.on("blur", function () {
watermark.setVisible(BI.isEmptyString(self.getValue()));
self.watermark.setVisible(BI.isEmptyString(self.getValue()));
self.fireEvent(BI.CodeEditor.EVENT_BLUR);
});
@ -17761,21 +17761,21 @@ BI.CodeEditor = BI.inherit(BI.Single, {
// });
//水印
var watermark = BI.createWidget({
this.watermark = BI.createWidget({
type: "bi.label",
text: o.watermark,
cls: "bi-water-mark",
whiteSpace: "nowrap",
textAlign: "left"
});
watermark.element.bind(
this.watermark.element.bind(
"mousedown", function (e) {
self.insertString("");
self.editor.focus();
e.stopEvent();
}
);
watermark.element.bind("click", function (e) {
this.watermark.element.bind("click", function (e) {
self.editor.focus();
e.stopEvent();
});
@ -17783,7 +17783,7 @@ BI.CodeEditor = BI.inherit(BI.Single, {
type: "bi.absolute",
element: this,
items: [{
el: watermark,
el: this.watermark,
top: 0,
left: 5
}]
@ -17801,6 +17801,15 @@ BI.CodeEditor = BI.inherit(BI.Single, {
this.editor.setOption("readOnly", b === true ? false : "nocursor")
},
_checkWaterMark: function () {
var o = this.options;
if (BI.isEmptyString(this.editor.getValue()) && BI.isKey(o.watermark)) {
this.watermark && this.watermark.visible();
} else {
this.watermark && this.watermark.invisible();
}
},
insertParam: function (param) {
var from = this.editor.getCursor();
this.editor.replaceSelection(param);
@ -17855,7 +17864,8 @@ BI.CodeEditor = BI.inherit(BI.Single, {
} else {
self.insertString(item);
}
})
});
this._checkWaterMark();
},
focus: function () {

24
src/base/single/editor/editor.code.js

@ -31,12 +31,12 @@ BI.CodeEditor = BI.inherit(BI.Single, {
});
this.editor.on("focus", function () {
watermark.setVisible(false);
self.watermark.setVisible(false);
self.fireEvent(BI.CodeEditor.EVENT_FOCUS);
});
this.editor.on("blur", function () {
watermark.setVisible(BI.isEmptyString(self.getValue()));
self.watermark.setVisible(BI.isEmptyString(self.getValue()));
self.fireEvent(BI.CodeEditor.EVENT_BLUR);
});
@ -45,21 +45,21 @@ BI.CodeEditor = BI.inherit(BI.Single, {
// });
//水印
var watermark = BI.createWidget({
this.watermark = BI.createWidget({
type: "bi.label",
text: o.watermark,
cls: "bi-water-mark",
whiteSpace: "nowrap",
textAlign: "left"
});
watermark.element.bind(
this.watermark.element.bind(
"mousedown", function (e) {
self.insertString("");
self.editor.focus();
e.stopEvent();
}
);
watermark.element.bind("click", function (e) {
this.watermark.element.bind("click", function (e) {
self.editor.focus();
e.stopEvent();
});
@ -67,7 +67,7 @@ BI.CodeEditor = BI.inherit(BI.Single, {
type: "bi.absolute",
element: this,
items: [{
el: watermark,
el: this.watermark,
top: 0,
left: 5
}]
@ -85,6 +85,15 @@ BI.CodeEditor = BI.inherit(BI.Single, {
this.editor.setOption("readOnly", b === true ? false : "nocursor")
},
_checkWaterMark: function () {
var o = this.options;
if (BI.isEmptyString(this.editor.getValue()) && BI.isKey(o.watermark)) {
this.watermark && this.watermark.visible();
} else {
this.watermark && this.watermark.invisible();
}
},
insertParam: function (param) {
var from = this.editor.getCursor();
this.editor.replaceSelection(param);
@ -139,7 +148,8 @@ BI.CodeEditor = BI.inherit(BI.Single, {
} else {
self.insertString(item);
}
})
});
this._checkWaterMark();
},
focus: function () {

Loading…
Cancel
Save