File: sub_menu.js.html

package info (click to toggle)
node-mj-context-menu 0.9.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,980 kB
  • sloc: javascript: 2,173; sh: 35; makefile: 7
file content (167 lines) | stat: -rw-r--r-- 7,085 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: sub_menu.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: sub_menu.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/*************************************************************
 *
 *  Copyright (c) 2015-2016 The MathJax Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/**
 * @fileoverview Class of sub menus.
 *
 * @author volker.sorge@gmail.com (Volker Sorge)
 */
/// &lt;reference path="abstract_menu.ts" />
var ContextMenu;
(function (ContextMenu) {
    class SubMenu extends ContextMenu.AbstractMenu {
        /**
         * @constructor
         * @extends {AbstractMenu}
         * @param {Submenu} anchor The item in the parent menu triggering this
         *     submenu.
         */
        constructor(anchor) {
            super();
            this.anchor = anchor;
            this.variablePool = this.anchor.getMenu().getPool();
            this.setBaseMenu();
        }
        /**
         * Parses a JSON respresentation of a variable pool.
         * @param {JSON} json The JSON object to parse.
         * @param {Submenu} anchor The anchor item the submenu is attached to.
         * @return {SubMenu} The new submenu object.
         */
        static parse({ items: items, id: id }, anchor) {
            let submenu = new SubMenu(anchor);
            submenu.parseItems(items);
            return submenu;
        }
        /**
         * @return {Submenu} The submenu item that anchors this popdown submenu to
         *     its parent.
         */
        getAnchor() {
            return this.anchor;
        }
        /**
         * @override
         */
        post() {
            if (!this.anchor.getMenu().isPosted()) {
                return;
            }
            //// TODO: These are currently ignored!
            let mobileFlag = false;
            let rtlFlag = false;
            let margin = 5;
            let parent = this.anchor.getHtml();
            let menu = this.getHtml();
            let base = this.baseMenu.getFrame();
            let side = 'left', mw = parent.offsetWidth;
            let x = (mobileFlag ? 30 : mw - 2);
            let y = 0;
            while (parent &amp;&amp; parent !== base) {
                x += parent.offsetLeft;
                y += parent.offsetTop;
                parent = parent.parentNode;
            }
            if (!mobileFlag) {
                if ((rtlFlag &amp;&amp; x - mw - menu.offsetWidth > margin) ||
                    (!rtlFlag &amp;&amp; x + menu.offsetWidth >
                        document.body.offsetWidth - margin)) {
                    side = 'right';
                    x = Math.max(margin, x - mw - menu.offsetWidth + 6);
                }
            }
            // Is the following useful?
            //
            // // if (!isPC) {
            // //   // in case these ever get implemented
            // //   menu.style["borderRadiusTop"+side] = 0;       // Opera 10.5
            // //   menu.style["WebkitBorderRadiusTop"+side] = 0; // Safari and Chrome
            // //   menu.style["MozBorderRadiusTop"+side] = 0;    // Firefox
            // //   menu.style["KhtmlBorderRadiusTop"+side] = 0;  // Konqueror
            // // }
            super.post(x, y);
        }
        /**
         * @override
         */
        display() {
            this.baseMenu.getFrame().appendChild(this.getHtml());
        }
        /**
         * Computes the topmost menu this submenu belongs to.
         */
        setBaseMenu() {
            //// TODO: Make this type safer!
            let menu = this;
            do {
                menu = menu.anchor.getMenu();
            } while (menu instanceof SubMenu);
            this.baseMenu = menu;
        }
    }
    ContextMenu.SubMenu = SubMenu;
})(ContextMenu || (ContextMenu = {}));
</code></pre>
        </article>
    </section>




</div>

<nav>
    <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>
</nav>

<br class="clear">

<footer>
    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)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>