menu2.js
来自「Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是」· JavaScript 代码 · 共 456 行 · 第 1/2 页
JS
456 行
}, {templateString:"<tr class=\"dojoMenuItem2\" dojoAttachEvent=\"onMouseOver: onHover; onMouseOut: onUnhover; onClick: _onClick; onKey:onKey;\">" + "<td><div class=\"${this.iconClass}\" style=\"${this.iconStyle}\"></div></td>" + "<td tabIndex=\"-1\" class=\"dojoMenuItem2Label\" dojoAttachPoint=\"caption\">${this.caption}</td>" + "<td class=\"dojoMenuItem2Accel\">${this.accelKey}</td>" + "<td><div class=\"dojoMenuItem2Submenu\" style=\"display:${this.arrowDisplay};\" dojoAttachPoint=\"arrow\"></div></td>" + "</tr>", is_hovering:false, hover_timer:null, is_open:false, topPosition:0, caption:"Untitled", accelKey:"", iconSrc:"", disabledClass:"dojoMenuItem2Disabled", iconClass:"dojoMenuItem2Icon", submenuId:"", eventNaming:"default", highlightClass:"dojoMenuItem2Hover", postMixInProperties:function () {
this.iconStyle = "";
if (this.iconSrc) {
if ((this.iconSrc.toLowerCase().substring(this.iconSrc.length - 4) == ".png") && (dojo.render.html.ie55 || dojo.render.html.ie60)) {
this.iconStyle = "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.iconSrc + "', sizingMethod='image')";
} else {
this.iconStyle = "background-image: url(" + this.iconSrc + ")";
}
}
this.arrowDisplay = this.submenuId ? "block" : "none";
dojo.widget.MenuItem2.superclass.postMixInProperties.apply(this, arguments);
}, fillInTemplate:function () {
dojo.html.disableSelection(this.domNode);
if (this.disabled) {
this.setDisabled(true);
}
if (this.eventNaming == "default") {
for (var eventName in this.eventNames) {
this.eventNames[eventName] = this.widgetId + "/" + eventName;
}
}
}, onHover:function () {
this.onUnhover();
if (this.is_hovering) {
return;
}
if (this.is_open) {
return;
}
if (this.parent._highlighted_option) {
this.parent._highlighted_option.onUnhover();
}
this.parent.closeSubmenu();
this.parent._highlighted_option = this;
dojo.widget.PopupManager.setFocusedMenu(this.parent);
this._highlightItem();
if (this.is_hovering) {
this._stopSubmenuTimer();
}
this.is_hovering = true;
this._startSubmenuTimer();
}, onUnhover:function () {
if (!this.is_open) {
this._unhighlightItem();
}
this.is_hovering = false;
this.parent._highlighted_option = null;
if (this.parent.parentMenu) {
dojo.widget.PopupManager.setFocusedMenu(this.parent.parentMenu);
}
this._stopSubmenuTimer();
}, _onClick:function (focus) {
var displayingSubMenu = false;
if (this.disabled) {
return false;
}
if (this.submenuId) {
if (!this.is_open) {
this._stopSubmenuTimer();
this._openSubmenu();
}
displayingSubMenu = true;
} else {
this.onUnhover();
this.parent.closeAll(true);
}
this.onClick();
dojo.event.topic.publish(this.eventNames.engage, this);
if (displayingSubMenu && focus) {
dojo.widget.getWidgetById(this.submenuId)._highlightOption(1);
}
return;
}, onClick:function () {
this.parent.onItemClick(this);
}, _highlightItem:function () {
dojo.html.addClass(this.domNode, this.highlightClass);
}, _unhighlightItem:function () {
dojo.html.removeClass(this.domNode, this.highlightClass);
}, _startSubmenuTimer:function () {
this._stopSubmenuTimer();
if (this.disabled) {
return;
}
var self = this;
var closure = function () {
return function () {
self._openSubmenu();
};
}();
this.hover_timer = dojo.lang.setTimeout(closure, this.parent.submenuDelay);
}, _stopSubmenuTimer:function () {
if (this.hover_timer) {
dojo.lang.clearTimeout(this.hover_timer);
this.hover_timer = null;
}
}, _openSubmenu:function () {
if (this.disabled) {
return;
}
this.parent.closeSubmenu();
var submenu = dojo.widget.getWidgetById(this.submenuId);
if (submenu) {
this.parent._openSubmenu(submenu, this);
}
}, _closedSubmenu:function () {
this.onUnhover();
}, setDisabled:function (value) {
this.disabled = value;
if (this.disabled) {
dojo.html.addClass(this.domNode, this.disabledClass);
} else {
dojo.html.removeClass(this.domNode, this.disabledClass);
}
}, enable:function () {
this.setDisabled(false);
}, disable:function () {
this.setDisabled(true);
}, menuOpen:function (message) {
}});
dojo.widget.defineWidget("dojo.widget.MenuSeparator2", dojo.widget.HtmlWidget, {templateString:"<tr class=\"dojoMenuSeparator2\"><td colspan=4>" + "<div class=\"dojoMenuSeparator2Top\"></div>" + "<div class=\"dojoMenuSeparator2Bottom\"></div>" + "</td></tr>", postCreate:function () {
dojo.html.disableSelection(this.domNode);
}});
dojo.widget.defineWidget("dojo.widget.MenuBar2", [dojo.widget.HtmlWidget, dojo.widget.MenuBase], {menuOverlap:2, templateString:"<div class=\"dojoMenuBar2\" dojoAttachPoint=\"containerNode\" tabIndex=\"0\"></div>", close:function (force) {
if (this._highlighted_option) {
this._highlighted_option.onUnhover();
}
this.closeSubmenu(force);
}, closeAll:function (force) {
this.close(force);
}, processKey:function (evt) {
if (evt.ctrlKey || evt.altKey) {
return false;
}
var rval = false;
switch (evt.key) {
case evt.KEY_DOWN_ARROW:
rval = this._moveToChildMenu(evt);
break;
case evt.KEY_UP_ARROW:
rval = this._moveToParentMenu(evt);
break;
case evt.KEY_RIGHT_ARROW:
rval = this._moveToNext(evt);
break;
case evt.KEY_LEFT_ARROW:
rval = this._moveToPrevious(evt);
break;
default:
rval = dojo.widget.MenuBar2.superclass.processKey.apply(this, arguments);
break;
}
return rval;
}, postCreate:function () {
dojo.widget.MenuBar2.superclass.postCreate.apply(this, arguments);
this.isShowingNow = true;
}, _openSubmenu:function (submenu, from_item) {
submenu._openAsSubmenu(this, from_item.domNode, {"BL":"TL", "TL":"BL"});
this.currentSubmenu = submenu;
this.currentSubmenuTrigger = from_item;
this.currentSubmenuTrigger.is_open = true;
}});
dojo.widget.defineWidget("dojo.widget.MenuBarItem2", dojo.widget.MenuItem2, {templateString:"<span class=\"dojoMenuItem2\" dojoAttachEvent=\"onMouseOver: onHover; onMouseOut: onUnhover; onClick: _onClick;\">${this.caption}</span>"});
dojo.widget.Menu2.OperaAndKonqFixer = new function () {
var implement = true;
var delfunc = false;
if (!dojo.lang.isFunction(dojo.doc().oncontextmenu)) {
dojo.doc().oncontextmenu = function () {
implement = false;
delfunc = true;
};
}
if (dojo.doc().createEvent) {
try {
var e = dojo.doc().createEvent("MouseEvents");
e.initMouseEvent("contextmenu", 1, 1, dojo.global(), 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null);
dojo.doc().dispatchEvent(e);
}
catch (e) {
}
} else {
implement = false;
}
if (delfunc) {
delete dojo.doc().oncontextmenu;
}
this.fixNode = function (node) {
if (implement) {
if (!dojo.lang.isFunction(node.oncontextmenu)) {
node.oncontextmenu = function (e) {
};
}
if (dojo.render.html.opera) {
node._menufixer_opera = function (e) {
if (e.ctrlKey) {
this.oncontextmenu(e);
}
};
dojo.event.connect(node, "onclick", node, "_menufixer_opera");
} else {
node._menufixer_konq = function (e) {
if (e.button == 2) {
e.preventDefault();
this.oncontextmenu(e);
}
};
dojo.event.connect(node, "onmousedown", node, "_menufixer_konq");
}
}
};
this.cleanNode = function (node) {
if (implement) {
if (node._menufixer_opera) {
dojo.event.disconnect(node, "onclick", node, "_menufixer_opera");
delete node._menufixer_opera;
} else {
if (node._menufixer_konq) {
dojo.event.disconnect(node, "onmousedown", node, "_menufixer_konq");
delete node._menufixer_konq;
}
}
if (node.oncontextmenu) {
delete node.oncontextmenu;
}
}
};
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?