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.

94 lines
3.1 KiB

7 years ago
/**
* 文本输入框trigger
*
* Created by GUY on 2015/9/15.
* @class BI.EditorTrigger
* @extends BI.Trigger
*/
BI.EditorTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function (config) {
7 years ago
var conf = BI.EditorTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-editor-trigger bi-border-radius " + (config.simple ? "bi-border-bottom" : "bi-border"),
7 years ago
height: 24,
validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn,
allowBlank: false,
watermark: "",
errorText: ""
});
},
_init: function () {
BI.EditorTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: BI.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: function () {
return self.getValue();
}
7 years ago
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.EditorTrigger.EVENT_CHANGE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.EditorTrigger.EVENT_FOCUS, arguments);
});
this.editor.on(BI.SignEditor.EVENT_EMPTY, function () {
self.fireEvent(BI.EditorTrigger.EVENT_EMPTY, arguments);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.EditorTrigger.EVENT_VALID, arguments);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.EditorTrigger.EVENT_ERROR, arguments);
});
7 years ago
BI.createWidget({
element: this,
3 years ago
type: "bi.horizontal_fill",
height: BI.toPix(o.height, 2),
7 years ago
items: [
{
3 years ago
el: this.editor,
width: "fill"
7 years ago
}, {
el: {
type: "bi.trigger_icon_button",
width: o.triggerWidth || BI.toPix(o.height, 2)
7 years ago
},
2 years ago
width: ""
7 years ago
}
]
});
},
getValue: function () {
return this.editor.getValue();
},
setValue: function (value) {
this.editor.setValue(value);
},
setText: function (text) {
this.editor.setState(text);
}
});
BI.EditorTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.EditorTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.EditorTrigger.EVENT_EMPTY = "EVENT_EMPTY";
BI.EditorTrigger.EVENT_VALID = "EVENT_VALID";
BI.EditorTrigger.EVENT_ERROR = "EVENT_ERROR";
BI.shortcut("bi.editor_trigger", BI.EditorTrigger);