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

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

Issue 12208141: Attach menu dismiss handler to <body>, not <html>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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';
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 * @private 44 * @private
45 */ 45 */
46 this.onClick_ = function(event) { 46 this.onClick_ = function(event) {
47 if (that.onShow_) { 47 if (that.onShow_) {
48 that.onShow_(); 48 that.onShow_();
49 } 49 }
50 that.button_.classList.add(remoting.MenuButton.BUTTON_ACTIVE_CLASS_); 50 that.button_.classList.add(remoting.MenuButton.BUTTON_ACTIVE_CLASS_);
51 that.button_.removeEventListener('click', that.onClick_, false); 51 that.button_.removeEventListener('click', that.onClick_, false);
52 window.setTimeout( 52 window.setTimeout(
53 function() { 53 function() {
54 document.all[0].addEventListener('click', that.closeHandler_, true); 54 document.body.addEventListener('click', that.closeHandler_, true);
55 }, 55 },
56 100); 56 100);
57 }; 57 };
58 58
59 /** 59 /**
60 * @type {function(Event):void} 60 * @type {function(Event):void}
61 * @private 61 * @private
62 */ 62 */
63 this.closeHandler_ = function(event) { 63 this.closeHandler_ = function(event) {
64 that.button_.classList.remove(remoting.MenuButton.BUTTON_ACTIVE_CLASS_); 64 that.button_.classList.remove(remoting.MenuButton.BUTTON_ACTIVE_CLASS_);
65 document.all[0].removeEventListener('click', that.closeHandler_, true); 65 document.body.removeEventListener('click', that.closeHandler_, true);
66 window.setTimeout( 66 window.setTimeout(
67 function() { 67 function() {
68 that.button_.addEventListener('click', that.onClick_, false); 68 that.button_.addEventListener('click', that.onClick_, false);
69 }, 69 },
70 100); 70 100);
71 }; 71 };
72 72
73 this.button_.addEventListener('click', this.onClick_, false); 73 this.button_.addEventListener('click', this.onClick_, false);
74 }; 74 };
75 75
76 /** 76 /**
77 * Set or unset the selected state of an <li> menu item. 77 * Set or unset the selected state of an <li> menu item.
78 * @param {HTMLElement} item The menu item to update. 78 * @param {HTMLElement} item The menu item to update.
79 * @param {boolean} selected True to select the item, false to deselect it. 79 * @param {boolean} selected True to select the item, false to deselect it.
80 * @return {void} Nothing. 80 * @return {void} Nothing.
81 */ 81 */
82 remoting.MenuButton.select = function(item, selected) { 82 remoting.MenuButton.select = function(item, selected) {
83 if (selected) { 83 if (selected) {
84 item.classList.add('selected'); 84 item.classList.add('selected');
85 } else { 85 } else {
86 item.classList.remove('selected'); 86 item.classList.remove('selected');
87 } 87 }
88 }; 88 };
89 89
90 /** @const @private */ 90 /** @const @private */
91 remoting.MenuButton.BUTTON_ACTIVE_CLASS_ = 'active'; 91 remoting.MenuButton.BUTTON_ACTIVE_CLASS_ = 'active';
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698