|
|
|
@ -3,7 +3,7 @@
|
|
|
|
|
* @class BI.Editor |
|
|
|
|
* @extends BI.Single |
|
|
|
|
*/ |
|
|
|
|
import { shortcut, Controller, extend, createWidget, isKey, isEmptyString, isFunction, isNull, trim, } from "../../../core"; |
|
|
|
|
import { shortcut, Controller, extend, createWidget, isKey, isEmptyString, isFunction, isNull, trim } from "../../../core"; |
|
|
|
|
import { Single } from "../0.single"; |
|
|
|
|
import { Input } from "../input/input"; |
|
|
|
|
import { Bubbles } from "../../0.base"; |
|
|
|
@ -17,6 +17,7 @@ export class Editor extends Single {
|
|
|
|
|
static EVENT_BLUR = "EVENT_BLUR"; |
|
|
|
|
static EVENT_CLICK = "EVENT_CLICK"; |
|
|
|
|
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; |
|
|
|
|
static EVENT_QUICK_DOWN = "EVENT_QUICK_DOWN"; |
|
|
|
|
static EVENT_SPACE = "EVENT_SPACE"; |
|
|
|
|
static EVENT_BACKSPACE = "EVENT_BACKSPACE"; |
|
|
|
|
|
|
|
|
@ -58,10 +59,10 @@ export class Editor extends Single {
|
|
|
|
|
render() { |
|
|
|
|
const { value, watermark, validationChecker, quitChecker, allowBlank, inputType, hgap, vgap, lgap, rgap, tgap, bgap } = this.options; |
|
|
|
|
// 密码输入框设置autocomplete="new-password"的情况下Firefox和chrome不会自动填充密码
|
|
|
|
|
const autocomplete = this.options.autocomplete ? " autocomplete=" + this.options.autocomplete : ""; |
|
|
|
|
const autocomplete = this.options.autocomplete ? ` autocomplete=${this.options.autocomplete}` : ""; |
|
|
|
|
this.editor = this.addWidget(createWidget({ |
|
|
|
|
type: "bi.input", |
|
|
|
|
element: "<input type='" + inputType + "'" + autocomplete + " />", |
|
|
|
|
element: `<input type='${inputType}'${autocomplete} />`, |
|
|
|
|
root: true, |
|
|
|
|
value, |
|
|
|
|
watermark, |
|
|
|
@ -82,7 +83,7 @@ export class Editor extends Single {
|
|
|
|
|
{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.absolute", |
|
|
|
|
ref: (_ref) => { |
|
|
|
|
ref: _ref => { |
|
|
|
|
this.contentWrapper = _ref; |
|
|
|
|
}, |
|
|
|
|
items: [ |
|
|
|
@ -132,11 +133,13 @@ export class Editor extends Single {
|
|
|
|
|
this.editor.on(Input.EVENT_KEY_DOWN, (v, ...args) => { |
|
|
|
|
this.fireEvent(Editor.EVENT_KEY_DOWN, v, ...args); |
|
|
|
|
}); |
|
|
|
|
this.editor.on(Input.EVENT_QUICK_DOWN, (e) => { |
|
|
|
|
this.editor.on(Input.EVENT_QUICK_DOWN, (...args) => { |
|
|
|
|
const [e] = args; |
|
|
|
|
// tab键就不要隐藏了
|
|
|
|
|
if (e.keyCode !== BI.KeyCode.TAB && this.watermark) { |
|
|
|
|
this.watermark.invisible(); |
|
|
|
|
} |
|
|
|
|
this.fireEvent(Editor.EVENT_QUICK_DOWN, ...args); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.editor.on(Input.EVENT_VALID, (...args) => { |
|
|
|
@ -190,7 +193,7 @@ export class Editor extends Single {
|
|
|
|
|
this.editor.on(Input.EVENT_CHANGE_CONFIRM, (...args) => { |
|
|
|
|
this.fireEvent(Editor.EVENT_CHANGE_CONFIRM, ...args); |
|
|
|
|
}); |
|
|
|
|
this.element.click((e) => { |
|
|
|
|
this.element.click(e => { |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
@ -230,7 +233,7 @@ export class Editor extends Single {
|
|
|
|
|
textAlign: "left", |
|
|
|
|
}); |
|
|
|
|
this.watermark.element.bind({ |
|
|
|
|
mousedown: (e) => { |
|
|
|
|
mousedown: e => { |
|
|
|
|
if (this.isEnabled()) { |
|
|
|
|
this.editor.isEditing() || this.editor.focus(); |
|
|
|
|
} else { |
|
|
|
@ -239,7 +242,7 @@ export class Editor extends Single {
|
|
|
|
|
e.stopEvent(); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
this.watermark.element.bind("click", (e) => { |
|
|
|
|
this.watermark.element.bind("click", e => { |
|
|
|
|
if (this.isEnabled()) { |
|
|
|
|
this.editor.isEditing() || this.editor.focus(); |
|
|
|
|
} else { |
|
|
|
|