Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: remoting/webapp/crd/js/menu_button.js

Issue 983023002: [Chromoting] Use compact notation for javascript @private types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/webapp/crd/js/log_to_server.js ('k') | remoting/webapp/crd/js/options_menu.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class representing a menu button and its associated menu items. 7 * Class representing a menu button and its associated menu items.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
11 11
12 /** @suppress {duplicate} */ 12 /** @suppress {duplicate} */
13 var remoting = remoting || {}; 13 var remoting = remoting || {};
14 14
15 /** 15 /**
16 * @constructor 16 * @constructor
17 * @param {Element} container The element containing the <button> and <ul> 17 * @param {Element} container The element containing the <button> and <ul>
18 * elements comprising the menu. It should have the "menu-button" class. 18 * elements comprising the menu. It should have the "menu-button" class.
19 * @param {function():void=} opt_onShow Optional callback invoked before the 19 * @param {function():void=} opt_onShow Optional callback invoked before the
20 * menu is shown. 20 * menu is shown.
21 * @param {function():void=} opt_onHide Optional callback after before the 21 * @param {function():void=} opt_onHide Optional callback after before the
22 * menu is hidden. 22 * menu is hidden.
23 */ 23 */
24 remoting.MenuButton = function(container, opt_onShow, opt_onHide) { 24 remoting.MenuButton = function(container, opt_onShow, opt_onHide) {
25 /** 25 /** @private {HTMLElement} */
26 * @type {HTMLElement}
27 * @private
28 */
29 this.button_ = /** @type {HTMLElement} */ 26 this.button_ = /** @type {HTMLElement} */
30 (container.querySelector('button,.menu-button-activator')); 27 (container.querySelector('button,.menu-button-activator'));
31 28
32 /** 29 /** @private {HTMLElement} */
33 * @type {HTMLElement}
34 * @private
35 */
36 this.menu_ = /** @type {HTMLElement} */ (container.querySelector('ul')); 30 this.menu_ = /** @type {HTMLElement} */ (container.querySelector('ul'));
37 31
38 /** 32 /** @private {undefined|function():void} */
39 * @type {undefined|function():void}
40 * @private
41 */
42 this.onShow_ = opt_onShow; 33 this.onShow_ = opt_onShow;
43 34
44 /** 35 /** @private {undefined|function():void} */
45 * @type {undefined|function():void}
46 * @private
47 */
48 this.onHide_ = opt_onHide; 36 this.onHide_ = opt_onHide;
49 37
50 /** 38 /**
51 * Create a "click-trap" div covering the entire document, but below the 39 * Create a "click-trap" div covering the entire document, but below the
52 * menu in the z-order. This ensures the the menu can be closed by clicking 40 * menu in the z-order. This ensures the the menu can be closed by clicking
53 * anywhere. Note that adding this event handler to <body> is not enough, 41 * anywhere. Note that adding this event handler to <body> is not enough,
54 * because elements can prevent event propagation; specifically, the client 42 * because elements can prevent event propagation; specifically, the client
55 * plugin element does this. 43 * plugin element does this.
56 * 44 *
57 * @type {HTMLElement} 45 * @private {HTMLElement}
58 * @private
59 */ 46 */
60 this.clickTrap_ = /** @type {HTMLElement} */ (document.createElement('div')); 47 this.clickTrap_ = /** @type {HTMLElement} */ (document.createElement('div'));
61 this.clickTrap_.classList.add('menu-button-click-trap'); 48 this.clickTrap_.classList.add('menu-button-click-trap');
62 49
63 /** @type {remoting.MenuButton} */ 50 /** @type {remoting.MenuButton} */
64 var that = this; 51 var that = this;
65 52
66 var closeHandler = function() { 53 var closeHandler = function() {
67 that.button_.classList.remove(remoting.MenuButton.BUTTON_ACTIVE_CLASS_); 54 that.button_.classList.remove(remoting.MenuButton.BUTTON_ACTIVE_CLASS_);
68 container.removeChild(that.clickTrap_); 55 container.removeChild(that.clickTrap_);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 remoting.MenuButton.select = function(item, selected) { 94 remoting.MenuButton.select = function(item, selected) {
108 if (selected) { 95 if (selected) {
109 item.classList.add('selected'); 96 item.classList.add('selected');
110 } else { 97 } else {
111 item.classList.remove('selected'); 98 item.classList.remove('selected');
112 } 99 }
113 }; 100 };
114 101
115 /** @const @private */ 102 /** @const @private */
116 remoting.MenuButton.BUTTON_ACTIVE_CLASS_ = 'active'; 103 remoting.MenuButton.BUTTON_ACTIVE_CLASS_ = 'active';
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/log_to_server.js ('k') | remoting/webapp/crd/js/options_menu.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698