fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.1 KiB

import { SignEditor } from "../editor";
import { HorizontalFillLayout, shortcut, extend, emptyFn, createWidget, toPix, Controller } from "@/core";
import { TriggerIconButton } from "../button";
import { Trigger } from "@/base";
7 years ago
/**
* 文本输入框trigger
*
* Created by GUY on 2015/9/15.
* @class EditorTrigger
* @extends Trigger
7 years ago
*/
@shortcut()
export class EditorTrigger extends Trigger {
static xtype = "bi.editor_trigger";
static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_EMPTY = "EVENT_EMPTY";
static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR";
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-editor-trigger bi-border-radius ${
config.simple ? "bi-border-bottom" : "bi-border"
}`,
7 years ago
height: 24,
validationChecker: emptyFn,
quitChecker: emptyFn,
7 years ago
allowBlank: false,
watermark: "",
errorText: "",
7 years ago
});
}
7 years ago
_init() {
super._init(...arguments);
const o = this.options;
this.editor = createWidget({
type: SignEditor.xtype,
height: toPix(o.height, 2),
7 years ago
value: o.value,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText,
title: () => this.getValue(),
7 years ago
});
this.editor.on(Controller.EVENT_CHANGE, (...args) => {
this.fireEvent(Controller.EVENT_CHANGE, ...args);
7 years ago
});
this.editor.on(SignEditor.EVENT_CHANGE, (...args) => {
this.fireEvent(EditorTrigger.EVENT_CHANGE, ...args);
7 years ago
});
this.editor.on(SignEditor.EVENT_FOCUS, (...args) => {
this.fireEvent(EditorTrigger.EVENT_FOCUS, ...args);
});
this.editor.on(SignEditor.EVENT_EMPTY, (...args) => {
this.fireEvent(EditorTrigger.EVENT_EMPTY, ...args);
});
this.editor.on(SignEditor.EVENT_VALID, (...args) => {
this.fireEvent(EditorTrigger.EVENT_VALID, ...args);
});
this.editor.on(SignEditor.EVENT_ERROR, (...args) => {
this.fireEvent(EditorTrigger.EVENT_ERROR, ...args);
});
7 years ago
createWidget({
7 years ago
element: this,
type: HorizontalFillLayout.xtype,
height: toPix(o.height, 2),
7 years ago
items: [
{
3 years ago
el: this.editor,
width: "fill",
},
{
7 years ago
el: {
type: TriggerIconButton.xtype,
width: o.triggerWidth || toPix(o.height, 2),
7 years ago
},
width: "",
7 years ago
}
],
7 years ago
});
}
7 years ago
getValue() {
7 years ago
return this.editor.getValue();
}
7 years ago
setValue(value) {
7 years ago
this.editor.setValue(value);
}
7 years ago
setText(text) {
7 years ago
this.editor.setState(text);
}
}