forked from fanruan/fineui
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.
79 lines
1.9 KiB
79 lines
1.9 KiB
8 years ago
|
/**
|
||
|
*
|
||
8 years ago
|
* Created by GUY on 2017/09/18.
|
||
8 years ago
|
* @class BI.TextToolbar
|
||
|
* @extends BI.Widget
|
||
|
*/
|
||
|
BI.RichEditorAction = BI.inherit(BI.Widget, {
|
||
|
_defaultConfig: function () {
|
||
|
return BI.extend(BI.RichEditorAction.superclass._defaultConfig.apply(this, arguments), {
|
||
|
width: 20,
|
||
|
height: 20,
|
||
8 years ago
|
command: ""
|
||
8 years ago
|
});
|
||
|
},
|
||
|
|
||
|
_init: function () {
|
||
|
BI.RichEditorAction.superclass._init.apply(this, arguments);
|
||
|
var self = this, o = this.options;
|
||
8 years ago
|
o.editor.on(BI.NicEditor.EVENT_SELECTED, function (e) {
|
||
8 years ago
|
self.setEnable(true);
|
||
8 years ago
|
self.checkNodes(e.target);
|
||
8 years ago
|
self.key(e);
|
||
8 years ago
|
});
|
||
|
o.editor.on(BI.NicEditor.EVENT_BLUR, function () {
|
||
|
self.setEnable(false);
|
||
|
});
|
||
8 years ago
|
o.editor.on(BI.NicEditor.EVENT_KEYDOWN, BI.bind(this.keydown, this));
|
||
8 years ago
|
},
|
||
|
|
||
|
checkNodes: function (e) {
|
||
|
if (!e) {
|
||
|
return false;
|
||
|
}
|
||
|
var elm = e;
|
||
|
do {
|
||
|
if (this.options.tags && this.options.tags.contains(elm.nodeName)) {
|
||
|
this.activate();
|
||
|
return true;
|
||
|
}
|
||
|
} while (elm = elm.parentNode && elm.className && elm.className.indexOf("bi-nic-editor") >= -1);
|
||
|
elm = e;
|
||
|
while (elm.nodeType == 3) {
|
||
|
elm = elm.parentNode;
|
||
|
}
|
||
|
if (this.options.css) {
|
||
|
for (var itm in this.options.css) {
|
||
|
if ($(elm).css(itm) == this.options.css[itm]) {
|
||
|
this.activate();
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
this.deactivate();
|
||
|
return false;
|
||
|
},
|
||
|
|
||
8 years ago
|
start: function () {
|
||
|
|
||
|
},
|
||
|
|
||
8 years ago
|
key: function () {
|
||
|
|
||
|
},
|
||
|
|
||
8 years ago
|
keydown: function () {
|
||
|
},
|
||
|
|
||
8 years ago
|
activate: function () {
|
||
|
},
|
||
|
|
||
|
deactivate: function () {
|
||
|
},
|
||
|
|
||
|
doCommand: function (args) {
|
||
|
if (this.options.command) {
|
||
|
this.options.editor.nicCommand(this.options.command, args);
|
||
|
}
|
||
|
}
|
||
|
});
|