📄 dommenu.js
字号:
} // we are highlighting the top level, but menu is not yet 'active' else { if (currentTarget != relatedTarget) { domLib_clearTimeout(domMenu_timeouts['open'].get(currentTarget.id)); domMenu_toggleHighlight(currentTarget, false); } }} // }}}// {{{ domMenu_getElement()function domMenu_getElement(in_object, in_basename){ while (in_object) { try { if (in_object.id && in_object.id.search(new RegExp('^' + in_basename + '(\\[[0-9]\\])*\\[[1-9]\\]$')) == 0) { return in_object; } else { in_object = in_object.parentNode; } } catch(e) { return false; } } return false;}// }}}// {{{ domMenu_correctEdgeBleed()function domMenu_correctEdgeBleed(in_width, in_height, in_x, in_y, in_padding, in_axis){ // Gecko and IE swaps values of clientHeight, clientWidth properties when // in standards compliance mode from documentElement to document.body var doc = ((domLib_standardsMode && (domLib_isIE || domLib_isGecko)) ? document.documentElement : document.body); var pageHeight = domLib_isKHTML ? window.innerHeight : doc.clientHeight; var pageYOffset = domLib_isIE ? doc.scrollTop : window.pageYOffset; var pageXOffset = domLib_isIE ? doc.scrollLeft : window.pageXOffset; if (in_axis == 'horizontal') { var bleedRight = (in_x - pageXOffset) + in_width - (doc.clientWidth - in_padding); var bleedLeft = (in_x - pageXOffset) - in_padding; // we are bleeding off the right, move menu to stay on page if (bleedRight > 0) { in_x -= bleedRight; } // we are bleeding to the left, move menu over to stay on page // we don't want an 'else if' here, because if it doesn't fit we will bleed off the right if (bleedLeft < 0) { in_x += bleedLeft; } //Only in mvnforum case: //need update in_y again (Y_axis_old,in_y_old)=(0,402) -> (Y_axis_new,in_y_new)=(55,347) : pageYOffset = 55 in_y += pageYOffset; } else { var bleedTop = (in_y - pageYOffset) - in_padding; var bleedBottom = (in_y - pageYOffset) + in_height - (pageHeight - in_padding); // if we are bleeding off the bottom, move menu to stay on page if (bleedBottom > 0) { in_y -= bleedBottom; } // if we are bleeding off the top, move menu down // we don't want an 'else if' here, because if we just can't fit it, bleed off the bottom if (bleedTop < 0) { in_y += bleedTop; } } return [in_x, in_y];}// }}}// {{{ domMenu_toggleSubMenu()function domMenu_toggleSubMenu(in_parentElement, in_style){ var subMenu = in_parentElement.data.get('subMenu'); if (subMenu && subMenu.style.visibility != in_style) { var settings = domMenu_settings.get(in_parentElement.data.get('basename')); var isFirstLevelSub = in_parentElement.data.get('level') == 1; var targetOtherDoc = isFirstLevelSub && settings.get('subMenuTargetFrame'); var prefix = isFirstLevelSub ? 'menu' : 'subMenu'; var className = settings.get(prefix + 'ElementClass'); // :BUG: this is a problem if submenus click to open, then it won't // have the right class when you click to close if (in_style == 'visible') { className += ' ' + settings.get(prefix + 'Element' + (in_style == 'visible' ? 'Active' : 'Hover') + 'Class'); } in_parentElement.firstChild.className = className; // position our submenu if (in_style == 'visible') { var tmp_offsets = domLib_getOffsets(in_parentElement); if (isFirstLevelSub) { tmp_offsets.set('top', tmp_offsets.get('top') + settings.get('verticalSubMenuOffsetY')); tmp_offsets.set('bottom', tmp_offsets.get('bottom') + settings.get('verticalSubMenuOffsetY')); tmp_offsets.set('left', tmp_offsets.get('left') + settings.get('verticalSubMenuOffsetX')); tmp_offsets.set('right', tmp_offsets.get('right') + settings.get('verticalSubMenuOffsetX')); } // reposition if there was a change in the parent position/size if (!in_parentElement.data.get('offsets').compare(tmp_offsets)) { in_parentElement.data.set('offsets', tmp_offsets); var xCoor, yCoor; if (isFirstLevelSub && settings.get('axis') == 'horizontal') { xCoor = tmp_offsets.get('left'); // expand north if (settings.get('verticalExpand') == 'north') { if (targetOtherDoc) { yCoor = subMenu.offsetHeight; } else { yCoor = tmp_offsets.get('top') - subMenu.offsetHeight - settings.get('verticalSubMenuOffsetY'); } } // expand south else { if (targetOtherDoc) { yCoor = settings.get('targetDocumentYOrigin'); } else { yCoor = tmp_offsets.get('bottom'); } } } else { yCoor = tmp_offsets.get('top') + settings.get('horizontalSubMenuOffsetY'); // expand east if (settings.get('horizontalExpand') == 'east') { if (targetOtherDoc) { xCoor = settings.get('targetDocumentXOrigin'); } else { xCoor = tmp_offsets.get('right') + settings.get('horizontalSubMenuOffsetX'); } } // expand west else { xCoor = tmp_offsets.get('left') - subMenu.offsetWidth - settings.get('horizontalSubMenuOffsetX'); } if (!targetOtherDoc && (domLib_isOpera || domLib_isSafari)) { var marginLeft = parseInt(domLib_getComputedStyle(document.body, 'margin-left')); xCoor -= marginLeft; var marginTop = parseInt(domLib_getComputedStyle(document.body, 'margin-top')); yCoor -= marginTop; } } var minWidth = settings.get('subMenuMinWidth'); var renderedWidth = subMenu.offsetWidth; if (minWidth == 'inherit') { minWidth = in_parentElement.offsetWidth + settings.get('subMenuWidthCorrection'); } else if (minWidth == 'auto') { minWidth = renderedWidth; } if (domLib_isKonq) { // change with width of the first cell subMenu.firstChild.firstChild.firstChild.firstChild.style.width = Math.max(minWidth, renderedWidth) + 'px'; } else { // change the width of the table subMenu.firstChild.style.width = Math.max(minWidth, renderedWidth) + 'px'; } var coordinates = domMenu_correctEdgeBleed(subMenu.offsetWidth, subMenu.offsetHeight, xCoor, yCoor, settings.get('screenPadding'), settings.get('axis')); subMenu.style.left = coordinates[0] + 'px'; subMenu.style.top = coordinates[1] + 'px'; // ** if we inherit, it is necessary to check the parent element width again ** if (settings.get('axis') == 'horizontal' && settings.get('subMenuMinWidth') == 'inherit') { subMenu.firstChild.style.width = Math.max(in_parentElement.offsetWidth + settings.get('subMenuWidthCorrection'), renderedWidth) + 'px'; } } } // force konqueror to change the styles if (domLib_isKonq) { in_parentElement.firstChild.style.display = 'none'; in_parentElement.firstChild.style.display = ''; } subMenu.style.visibility = in_style; if (domLib_detectObstructionsEnabled) { domLib_detectObstructions(subMenu, (in_style == 'hidden'), true); } }}// }}}// {{{ domMenu_toggleHighlight()function domMenu_toggleHighlight(in_element, in_status){ // if this is a heading, don't change the style if (!in_element.data.get('numChildren') && !in_element.data.get('uri')) { return; } var settings = domMenu_settings.get(in_element.data.get('basename')); var prefix = in_element.data.get('level') == 1 ? 'menu' : 'subMenu'; var className = settings.get(prefix + 'ElementClass'); var highlightElement = in_element.firstChild; var pseudoClass; if (in_status) { if (in_element.data.has('subMenu') && in_element.data.get('subMenu').style.visibility == 'visible') { pseudoClass = 'Active'; } else if (in_element.data.get('numChildren') || in_element.data.get('uri')) { pseudoClass = 'Hover'; } } if (pseudoClass) { className += ' ' + settings.get(prefix + 'Element' + pseudoClass + 'Class'); // if we are changing to hover, change the alt contents (only change if needs it) if (highlightElement.childNodes.length == 2) { //alert(highlightElement.lastChild); } if (highlightElement.childNodes.length == 2 && highlightElement.lastChild.style.display == 'none') { highlightElement.firstChild.style.display = 'none'; highlightElement.lastChild.style.display = ''; } } else { // if we are changing to non-hover, change the alt contents (only change if needs it) if (highlightElement.childNodes.length == 2 && highlightElement.firstChild.style.display == 'none') { highlightElement.lastChild.style.display = 'none'; highlightElement.firstChild.style.display = ''; } } highlightElement.className = className; // force konqueror to change the styles if (domLib_isKonq) { highlightElement.style.display = 'none'; highlightElement.style.display = ''; }}// }}}// {{{ domMenu_resolveLink()function domMenu_resolveLink(in_this, in_event){ var eventObj = domLib_isIE ? event : in_event; var currentTarget = domLib_isIE ? in_this : eventObj.currentTarget; var basename = currentTarget.data.get('basename'); // close the menu system immediately when we resolve the uri domMenu_changeActivePath(false, domMenu_activeElement.get(basename), 0); var uri = currentTarget.data.get('uri'); if (uri) { window.status = 'Resolving Link...'; // if a baseUri is specified and the link begins with '/', prepend baseUri if (uri.charAt(0) == '/' && domMenu_settings.get(basename).get('baseUri').length > 0) { uri = domMenu_settings.get(basename).get('baseUri') + uri; } if (uri.indexOf('javascript: ') == 0) { eval(uri.substring(12)); } // open in current window else if (!currentTarget.data.get('target') || currentTarget.data.get('target') == '_self') { window.location = uri; } // open in new window else { window.open(uri, currentTarget.data.get('target')); } }}// }}}// {{{ domMenu_unloadEventCache()// We try and get rid of all circular references by avoiding the use of inner functions// However, some are still left, so we run this function for IE// @see http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=bcslfd%24ahl%241%248300dec7%40news.demon.co.ukfunction domMenu_unloadEventCache(){ var clearElementProps = ['data', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'ondblclick', 'onclick', 'onselectstart', 'oncontextmenu']; var el; for (var d = document.all.length; d--;) { el = document.all[d]; for (var c = clearElementProps.length; c--;) { el[clearElementProps[c]] = null; } }}// }}}// {{{ event handling methods// Functions which are attached to events instead of using inner functions to// avoid memory leaks.function domMenu_openMenuOnmouseoverHandler(in_event) { domMenu_openEvent(this, in_event, 'openMouseoverMenuDelay');}function domMenu_openMenuOnmousedownHandler(in_event) { domMenu_openEvent(this, in_event, 'openMousedownMenuDelay');}function domMenu_openSubMenuOnmouseoverHandler(in_event) { domMenu_openEvent(this, in_event, 'openMouseoverSubMenuDelay');}function domMenu_openSubMenuOnclickHandler(in_event) { domMenu_openEvent(this, in_event, 'openClickSubMenuDelay');}function domMenu_resolveLinkHandler(in_event) { domMenu_resolveLink(this, in_event);}function domMenu_closeMenuHandler(in_event) { domMenu_closeEvent(this, in_event);}// }}}// {{{ callback methodsfunction domMenu_closeMenuCallback(argv) { domMenu_toggleHighlight(argv[0], false); domMenu_toggleSubMenu(argv[0], 'hidden'); // if this is the top level, then the menu is being deactivated if (argv[0].data.get('level') == 1) { domMenu_activeElement.set(argv[1], false); }}function domMenu_openMenuCallback(argv){ if (!domMenu_activeElement.get(argv[1])) { domMenu_activeElement.set(argv[1], argv[0]); } domMenu_activateSubMenu(argv[0]);}// }}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -