| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>JSDoc: Source: sub_menu.js</title> |
| 6 |
|
| 7 |
<script src="scripts/prettify/prettify.js"> </script> |
| 8 |
<script src="scripts/prettify/lang-css.js"> </script> |
| 9 |
<!--[if lt IE 9]> |
| 10 |
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
| 11 |
<![endif]--> |
| 12 |
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> |
| 13 |
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> |
| 14 |
</head> |
| 15 |
|
| 16 |
<body> |
| 17 |
|
| 18 |
<div id="main"> |
| 19 |
|
| 20 |
<h1 class="page-title">Source: sub_menu.js</h1> |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
<section> |
| 28 |
<article> |
| 29 |
<pre class="prettyprint source linenums"><code>/************************************************************* |
| 30 |
* |
| 31 |
* Copyright (c) 2015-2016 The MathJax Consortium |
| 32 |
* |
| 33 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 34 |
* you may not use this file except in compliance with the License. |
| 35 |
* You may obtain a copy of the License at |
| 36 |
* |
| 37 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 38 |
* |
| 39 |
* Unless required by applicable law or agreed to in writing, software |
| 40 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 41 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 42 |
* See the License for the specific language governing permissions and |
| 43 |
* limitations under the License. |
| 44 |
*/ |
| 45 |
/** |
| 46 |
* @fileoverview Class of sub menus. |
| 47 |
* |
| 48 |
* @author [email protected] (Volker Sorge) |
| 49 |
*/ |
| 50 |
/// <reference path="abstract_menu.ts" /> |
| 51 |
var ContextMenu; |
| 52 |
(function (ContextMenu) { |
| 53 |
class SubMenu extends ContextMenu.AbstractMenu { |
| 54 |
/** |
| 55 |
* @constructor |
| 56 |
* @extends {AbstractMenu} |
| 57 |
* @param {Submenu} anchor The item in the parent menu triggering this |
| 58 |
* submenu. |
| 59 |
*/ |
| 60 |
constructor(anchor) { |
| 61 |
super(); |
| 62 |
this.anchor = anchor; |
| 63 |
this.variablePool = this.anchor.getMenu().getPool(); |
| 64 |
this.setBaseMenu(); |
| 65 |
} |
| 66 |
/** |
| 67 |
* Parses a JSON respresentation of a variable pool. |
| 68 |
* @param {JSON} json The JSON object to parse. |
| 69 |
* @param {Submenu} anchor The anchor item the submenu is attached to. |
| 70 |
* @return {SubMenu} The new submenu object. |
| 71 |
*/ |
| 72 |
static parse({ items: items, id: id }, anchor) { |
| 73 |
let submenu = new SubMenu(anchor); |
| 74 |
submenu.parseItems(items); |
| 75 |
return submenu; |
| 76 |
} |
| 77 |
/** |
| 78 |
* @return {Submenu} The submenu item that anchors this popdown submenu to |
| 79 |
* its parent. |
| 80 |
*/ |
| 81 |
getAnchor() { |
| 82 |
return this.anchor; |
| 83 |
} |
| 84 |
/** |
| 85 |
* @override |
| 86 |
*/ |
| 87 |
post() { |
| 88 |
if (!this.anchor.getMenu().isPosted()) { |
| 89 |
return; |
| 90 |
} |
| 91 |
//// TODO: These are currently ignored! |
| 92 |
let mobileFlag = false; |
| 93 |
let rtlFlag = false; |
| 94 |
let margin = 5; |
| 95 |
let parent = this.anchor.getHtml(); |
| 96 |
let menu = this.getHtml(); |
| 97 |
let base = this.baseMenu.getFrame(); |
| 98 |
let side = 'left', mw = parent.offsetWidth; |
| 99 |
let x = (mobileFlag ? 30 : mw - 2); |
| 100 |
let y = 0; |
| 101 |
while (parent && parent !== base) { |
| 102 |
x += parent.offsetLeft; |
| 103 |
y += parent.offsetTop; |
| 104 |
parent = parent.parentNode; |
| 105 |
} |
| 106 |
if (!mobileFlag) { |
| 107 |
if ((rtlFlag && x - mw - menu.offsetWidth > margin) || |
| 108 |
(!rtlFlag && x + menu.offsetWidth > |
| 109 |
document.body.offsetWidth - margin)) { |
| 110 |
side = 'right'; |
| 111 |
x = Math.max(margin, x - mw - menu.offsetWidth + 6); |
| 112 |
} |
| 113 |
} |
| 114 |
// Is the following useful? |
| 115 |
// |
| 116 |
// // if (!isPC) { |
| 117 |
// // // in case these ever get implemented |
| 118 |
// // menu.style["borderRadiusTop"+side] = 0; // Opera 10.5 |
| 119 |
// // menu.style["WebkitBorderRadiusTop"+side] = 0; // Safari and Chrome |
| 120 |
// // menu.style["MozBorderRadiusTop"+side] = 0; // Firefox |
| 121 |
// // menu.style["KhtmlBorderRadiusTop"+side] = 0; // Konqueror |
| 122 |
// // } |
| 123 |
super.post(x, y); |
| 124 |
} |
| 125 |
/** |
| 126 |
* @override |
| 127 |
*/ |
| 128 |
display() { |
| 129 |
this.baseMenu.getFrame().appendChild(this.getHtml()); |
| 130 |
} |
| 131 |
/** |
| 132 |
* Computes the topmost menu this submenu belongs to. |
| 133 |
*/ |
| 134 |
setBaseMenu() { |
| 135 |
//// TODO: Make this type safer! |
| 136 |
let menu = this; |
| 137 |
do { |
| 138 |
menu = menu.anchor.getMenu(); |
| 139 |
} while (menu instanceof SubMenu); |
| 140 |
this.baseMenu = menu; |
| 141 |
} |
| 142 |
} |
| 143 |
ContextMenu.SubMenu = SubMenu; |
| 144 |
})(ContextMenu || (ContextMenu = {})); |
| 145 |
</code></pre> |
| 146 |
</article> |
| 147 |
</section> |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
</div> |
| 153 |
|
| 154 |
<nav> |
| 155 |
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AbstractEntry.html">AbstractEntry</a></li><li><a href="AbstractItem.html">AbstractItem</a></li><li><a href="AbstractMenu.html">AbstractMenu</a></li><li><a href="AbstractNavigatable.html">AbstractNavigatable</a></li><li><a href="AbstractPostable.html">AbstractPostable</a></li><li><a href="Checkbox.html">Checkbox</a></li><li><a href="CloseButton.html">CloseButton</a></li><li><a href="Command.html">Command</a></li><li><a href="ContextMenu.html">ContextMenu</a></li><li><a href="Info.html">Info</a></li><li><a href="Label.html">Label</a></li><li><a href="MenuElement.html">MenuElement</a></li><li><a href="MenuStore.html">MenuStore</a></li><li><a href="Popup.html">Popup</a></li><li><a href="Radio.html">Radio</a></li><li><a href="Rule.html">Rule</a></li><li><a href="SubMenu.html">SubMenu</a></li><li><a href="Submenu_.html">Submenu</a></li><li><a href="Variable.html">Variable</a></li><li><a href="VariablePool.html">VariablePool</a></li></ul><h3>Namespaces</h3><ul><li><a href="CssStyles.html">CssStyles</a></li><li><a href="MenuUtil.html">MenuUtil</a></li></ul><h3>Interfaces</h3><ul><li><a href="Element.html">Element</a></li><li><a href="Entry.html">Entry</a></li><li><a href="Item.html">Item</a></li><li><a href="KeyNavigatable.html">KeyNavigatable</a></li><li><a href="Menu.html">Menu</a></li><li><a href="MouseNavigatable.html">MouseNavigatable</a></li><li><a href="Postable.html">Postable</a></li><li><a href="TouchNavigatable.html">TouchNavigatable</a></li><li><a href="VariableItem.html">VariableItem</a></li></ul><h3>Global</h3><ul><li><a href="global.html#HtmlAttrs">HtmlAttrs</a></li><li><a href="global.html#HtmlClasses">HtmlClasses</a></li><li><a href="global.html#KEY">KEY</a></li><li><a href="global.html#MOUSE">MOUSE</a></li><li><a href="global.html#TOUCH">TOUCH</a></li></ul> |
| 156 |
</nav> |
| 157 |
|
| 158 |
<br class="clear"> |
| 159 |
|
| 160 |
<footer> |
| 161 |
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Aug 17 2016 12:38:38 GMT+0100 (BST) |
| 162 |
</footer> |
| 163 |
|
| 164 |
<script> prettyPrint(); </script> |
| 165 |
<script src="scripts/linenumber.js"> </script> |
| 166 |
</body> |
| 167 |
</html> |