///import core ///import uicore ///import ui/stateful.js (function (){ var utils = baidu.editor.utils, UIBase = baidu.editor.ui.UIBase, Stateful = baidu.editor.ui.Stateful, Button = baidu.editor.ui.Button = function (options){ if(options.name){ var btnName = options.name; var cssRules = options.cssRules; if(!options.className){ options.className = 'edui-for-' + btnName; } options.cssRules = '.edui-' + (options.theme || 'default') + ' .edui-toolbar .edui-button.edui-for-'+ btnName +' .edui-icon {'+ cssRules +'}' } this.initOptions(options); this.initButton(); }; Button.prototype = { uiName: 'button', label: '', title: '', showIcon: true, showText: true, cssRules:'', initButton: function (){ this.initUIBase(); this.Stateful_init(); if(this.cssRules){ utils.cssRule('edui-customize-'+this.name+'-style',this.cssRules); } }, getHtmlTpl: function (){ return '
' + '
' + '
' + (this.showIcon ? '
' : '') + (this.showText ? '
' + this.label + '
' : '') + '
' + '
' + '
'; }, postRender: function (){ this.Stateful_postRender(); this.setDisabled(this.disabled) }, _onMouseDown: function (e){ var target = e.target || e.srcElement, tagName = target && target.tagName && target.tagName.toLowerCase(); if (tagName == 'input' || tagName == 'object' || tagName == 'object') { return false; } }, _onClick: function (){ if (!this.isDisabled()) { this.fireEvent('click'); } }, setTitle: function(text){ var label = this.getDom('label'); label.innerHTML = text; } }; utils.inherits(Button, UIBase); utils.extend(Button.prototype, Stateful); })();