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.

70 lines
2.4 KiB

/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
8 years ago
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
8 years ago
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
8 years ago
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
7 years ago
baseCls: "bi-rich-editor-text-toolbar",
buttons: [
7 years ago
{type: "bi.rich_editor_font_chooser"},
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
7 years ago
{type: "bi.rich_editor_param_button"}
],
height: 28
});
},
_init: function () {
8 years ago
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
7 years ago
var buttons = BI.createWidgets(BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}));
this.element.mousedown(function (e) {
BI.each(buttons, function (i, btn) {
btn.hideIf(e);
});
});
BI.createWidget({
type: "bi.left",
element: this,
7 years ago
items: buttons,
hgap: 3,
vgap: 3
7 years ago
});
},
mounted: function () {
var self = this;
7 years ago
if (BI.isIE9Below()) {// IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
7 years ago
if (element.setAttribute && element.nodeName.toLowerCase() != "input" && element.nodeName.toLowerCase() != "textarea") {
element.setAttribute("unselectable", "on");
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
7 years ago
BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);