| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>JSDoc: Source: menu_util.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: menu_util.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 Utility class for menu handling. |
| 47 |
* |
| 48 |
* @author [email protected] (Volker Sorge) |
| 49 |
*/ |
| 50 |
/// <reference path="context_menu.ts" /> |
| 51 |
/// <reference path="item.ts" /> |
| 52 |
/// <reference path="menu.ts" /> |
| 53 |
/// <reference path="sub_menu.ts" /> |
| 54 |
|
| 55 |
|
| 56 |
/** |
| 57 |
* @namespace |
| 58 |
*/ |
| 59 |
var MenuUtil; |
| 60 |
|
| 61 |
(function (MenuUtil) { |
| 62 |
/** |
| 63 |
* Closes the entire context menu. |
| 64 |
* @param {Item} item The item on which the menu close is called. |
| 65 |
*/ |
| 66 |
MenuUtil.close = close; |
| 67 |
function close(item) { |
| 68 |
let menu = item.getMenu(); |
| 69 |
if (menu instanceof ContextMenu.SubMenu) { |
| 70 |
menu.baseMenu.unpost(); |
| 71 |
} |
| 72 |
else { |
| 73 |
menu.unpost(); |
| 74 |
} |
| 75 |
} |
| 76 |
/** |
| 77 |
* Retrieves the currently active element of the overall context menu. |
| 78 |
* @param {Item} item The item on which the last call was made. |
| 79 |
* @return {HtmlElement} The currently active element. |
| 80 |
*/ |
| 81 |
MenuUtil.getActiveElement = getActiveElement; |
| 82 |
function getActiveElement(item) { |
| 83 |
let menu = item.getMenu(); |
| 84 |
let baseMenu = menu instanceof ContextMenu.SubMenu ? |
| 85 |
menu.baseMenu : menu; |
| 86 |
return baseMenu.getStore().getActive(); |
| 87 |
} |
| 88 |
/** |
| 89 |
* Error function for controlled exceptions. |
| 90 |
* @param {Error} error The thrown error, containing the stack trace. |
| 91 |
* @param {string} msg The message to be signalled. |
| 92 |
*/ |
| 93 |
MenuUtil.error = error; |
| 94 |
function error(error, msg) { |
| 95 |
console.log('ContextMenu Error: ' + msg); |
| 96 |
} |
| 97 |
/** |
| 98 |
* @return {number} A global, increasing unique counter. |
| 99 |
*/ |
| 100 |
MenuUtil.counter = counter; |
| 101 |
function counter() { |
| 102 |
return count++; |
| 103 |
} |
| 104 |
let count = 0; |
| 105 |
})(MenuUtil = ContextMenu.MenuUtil || (ContextMenu.MenuUtil = {}));</code></pre> |
| 106 |
</article> |
| 107 |
</section> |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
</div> |
| 113 |
|
| 114 |
<nav> |
| 115 |
<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> |
| 116 |
</nav> |
| 117 |
|
| 118 |
<br class="clear"> |
| 119 |
|
| 120 |
<footer> |
| 121 |
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) |
| 122 |
</footer> |
| 123 |
|
| 124 |
<script> prettyPrint(); </script> |
| 125 |
<script src="scripts/linenumber.js"> </script> |
| 126 |
</body> |
| 127 |
</html> |