///import core ///import uicore ///import ui\popup.js ///import ui\stateful.js (function (){ var utils = baidu.editor.utils, domUtils = baidu.editor.dom.domUtils, uiUtils = baidu.editor.ui.uiUtils, UIBase = baidu.editor.ui.UIBase, Popup = baidu.editor.ui.Popup, Stateful = baidu.editor.ui.Stateful, Menu = baidu.editor.ui.Menu = function (options){ this.initOptions(options); this.initMenu(); }; var menuSeparator = { renderHtml: function (){ return '
'; }, postRender: function (){}, queryAutoHide: function (){ return true; } }; Menu.prototype = { items: null, uiName: 'menu', initMenu: function (){ this.items = this.items || []; this.initPopup(); this.initItems(); }, initItems: function (){ for (var i=0; i' + buff.join('') + ''); }, _Popup_postRender: Popup.prototype.postRender, postRender: function (){ var me = this; for (var i=0; i' + '
' + this.renderLabelHtml() + '
' + ''; }, postRender: function (){ var me = this; this.addListener('over', function (){ me.ownerMenu.fireEvent('submenuover', me); if (me.subMenu) { me.delayShowSubMenu(); } }); if (this.subMenu) { this.getDom().className += ' edui-hassubmenu'; this.subMenu.render(); this.addListener('out', function (){ me.delayHideSubMenu(); }); this.subMenu.addListener('over', function (){ clearTimeout(me._closingTimer); me._closingTimer = null; me.addState('opened'); }); this.ownerMenu.addListener('hide', function (){ me.hideSubMenu(); }); this.ownerMenu.addListener('submenuover', function (t, subMenu){ if (subMenu !== me) { me.delayHideSubMenu(); } }); this.subMenu._bakQueryAutoHide = this.subMenu.queryAutoHide; this.subMenu.queryAutoHide = function (el){ if (el && uiUtils.contains(me.getDom(), el)) { return false; } return this._bakQueryAutoHide(el); }; } this.getDom().style.tabIndex = '-1'; uiUtils.makeUnselectable(this.getDom()); this.Stateful_postRender(); }, delayShowSubMenu: function (){ var me = this; if (!me.isDisabled()) { me.addState('opened'); clearTimeout(me._showingTimer); clearTimeout(me._closingTimer); me._closingTimer = null; me._showingTimer = setTimeout(function (){ me.showSubMenu(); }, 250); } }, delayHideSubMenu: function (){ var me = this; if (!me.isDisabled()) { me.removeState('opened'); clearTimeout(me._showingTimer); if (!me._closingTimer) { me._closingTimer = setTimeout(function (){ if (!me.hasState('opened')) { me.hideSubMenu(); } me._closingTimer = null; }, 400); } } }, renderLabelHtml: function (){ return '
' + '
' + '
' + (this.label || '') + '
'; }, getStateDom: function (){ return this.getDom(); }, queryAutoHide: function (el){ if (this.subMenu && this.hasState('opened')) { return this.subMenu.queryAutoHide(el); } }, _onClick: function (event, this_){ if (this.hasState('disabled')) return; if (this.fireEvent('click', event, this_) !== false) { if (this.subMenu) { this.showSubMenu(); } else { Popup.postHide(); } } }, showSubMenu: function (){ var rect = uiUtils.getClientRect(this.getDom()); rect.right -= 5; rect.left += 2; rect.width -= 7; rect.top -= 4; rect.bottom += 4; rect.height += 8; this.subMenu.showAnchorRect(rect, true, true); }, hideSubMenu: function (){ this.subMenu.hide(); } }; utils.inherits(MenuItem, UIBase); utils.extend(MenuItem.prototype, Stateful, true); })();