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

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

Issue 594503004: Move ownership of the tool-bar's menu buttons into remoting.Toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove MenuButton changes (will follow up with a better fix. Created 6 years, 3 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/remoting.js ('k') | remoting/webapp/window_frame.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 the client tool-bar. 7 * Class representing the client tool-bar.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 24 matching lines...) Expand all
35 /** 35 /**
36 * @type {number} The left edge of the tool-bar stub, updated on resize. 36 * @type {number} The left edge of the tool-bar stub, updated on resize.
37 * @private 37 * @private
38 */ 38 */
39 this.stubLeft_ = 0; 39 this.stubLeft_ = 0;
40 /** 40 /**
41 * @type {number} The right edge of the tool-bar stub, updated on resize. 41 * @type {number} The right edge of the tool-bar stub, updated on resize.
42 * @private 42 * @private
43 */ 43 */
44 this.stubRight_ = 0; 44 this.stubRight_ = 0;
45
45 /** 46 /**
46 * @type {remoting.OptionsMenu} 47 * @type {remoting.MenuButton}
47 * @private 48 * @private
48 */ 49 */
49 this.optionsMenu_ = new remoting.OptionsMenu( 50 this.screenOptionsMenu_ = new remoting.MenuButton(
50 document.getElementById('send-ctrl-alt-del'), 51 document.getElementById('screen-options-menu'),
51 document.getElementById('send-print-screen'), 52 this.onShowOptionsMenu_.bind(this));
52 document.getElementById('screen-resize-to-client'), 53 /**
53 document.getElementById('screen-shrink-to-fit'), 54 * @type {remoting.MenuButton}
54 document.getElementById('new-connection'), 55 * @private
55 document.getElementById('toggle-full-screen'), 56 */
56 null); 57 this.sendKeysMenu_ = new remoting.MenuButton(
58 document.getElementById('send-keys-menu')
59 );
60
57 61
58 window.addEventListener('mousemove', remoting.Toolbar.onMouseMove, false); 62 window.addEventListener('mousemove', remoting.Toolbar.onMouseMove, false);
59 window.addEventListener('resize', this.center.bind(this), false); 63 window.addEventListener('resize', this.center.bind(this), false);
60 64
61 registerEventListener('toolbar-disconnect', 'click', remoting.disconnect); 65 registerEventListener('toolbar-disconnect', 'click', remoting.disconnect);
62 registerEventListener('toolbar-stub', 'click', 66 registerEventListener('toolbar-stub', 'click',
63 function() { remoting.toolbar.toggle(); }); 67 function() { remoting.toolbar.toggle(); });
64 68
65 // Prevent the preview canceling if the user is interacting with the tool-bar. 69 // Prevent the preview canceling if the user is interacting with the tool-bar.
66 /** @type {remoting.Toolbar} */ 70 /** @type {remoting.Toolbar} */
67 var that = this; 71 var that = this;
68 var stopTimer = function() { 72 var stopTimer = function() {
69 if (that.timerId_) { 73 if (that.timerId_) {
70 window.clearTimeout(that.timerId_); 74 window.clearTimeout(that.timerId_);
71 that.timerId_ = null; 75 that.timerId_ = null;
72 } 76 }
73 } 77 }
74 this.toolbar_.addEventListener('mousemove', stopTimer, false); 78 this.toolbar_.addEventListener('mousemove', stopTimer, false);
75 }; 79 };
76 80
81
82 /**
83 * @return {remoting.OptionsMenu}
84 */
85 remoting.Toolbar.prototype.createOptionsMenu = function() {
86 return new remoting.OptionsMenu(
87 document.getElementById('send-ctrl-alt-del'),
88 document.getElementById('send-print-screen'),
89 document.getElementById('screen-resize-to-client'),
90 document.getElementById('screen-shrink-to-fit'),
91 document.getElementById('new-connection'),
92 document.getElementById('toggle-full-screen'),
93 null);
94 };
95
77 /** 96 /**
78 * Preview the tool-bar functionality by showing it for 3s. 97 * Preview the tool-bar functionality by showing it for 3s.
79 * @return {void} Nothing. 98 * @return {void} Nothing.
80 */ 99 */
81 remoting.Toolbar.prototype.preview = function() { 100 remoting.Toolbar.prototype.preview = function() {
82 this.toolbar_.classList.add(remoting.Toolbar.VISIBLE_CLASS_); 101 this.toolbar_.classList.add(remoting.Toolbar.VISIBLE_CLASS_);
83 if (this.timerId_) { 102 if (this.timerId_) {
84 window.clearTimeout(this.timerId_); 103 window.clearTimeout(this.timerId_);
85 this.timerId_ = null; 104 this.timerId_ = null;
86 } 105 }
(...skipping 19 matching lines...) Expand all
106 */ 125 */
107 remoting.Toolbar.prototype.toggle = function() { 126 remoting.Toolbar.prototype.toggle = function() {
108 this.toolbar_.classList.toggle(remoting.Toolbar.VISIBLE_CLASS_); 127 this.toolbar_.classList.toggle(remoting.Toolbar.VISIBLE_CLASS_);
109 }; 128 };
110 129
111 /** 130 /**
112 * @param {remoting.ClientSession} clientSession The active session, or null if 131 * @param {remoting.ClientSession} clientSession The active session, or null if
113 * there is no connection. 132 * there is no connection.
114 */ 133 */
115 remoting.Toolbar.prototype.setClientSession = function(clientSession) { 134 remoting.Toolbar.prototype.setClientSession = function(clientSession) {
116 this.optionsMenu_.setClientSession(clientSession);
117 var connectedTo = document.getElementById('connected-to'); 135 var connectedTo = document.getElementById('connected-to');
118 connectedTo.innerText = 136 connectedTo.innerText =
119 clientSession ? clientSession.getHostDisplayName() : ""; 137 clientSession ? clientSession.getHostDisplayName() : "";
120 }; 138 };
121 139
122 /** 140 /**
123 * Test the specified co-ordinate to see if it is close enough to the stub 141 * Test the specified co-ordinate to see if it is close enough to the stub
124 * to activate it. 142 * to activate it.
125 * 143 *
126 * @param {number} x The x co-ordinate. 144 * @param {number} x The x co-ordinate.
(...skipping 24 matching lines...) Expand all
151 toolbarStub.classList.add(remoting.Toolbar.STUB_EXTENDED_CLASS_); 169 toolbarStub.classList.add(remoting.Toolbar.STUB_EXTENDED_CLASS_);
152 } else { 170 } else {
153 toolbarStub.classList.remove(remoting.Toolbar.STUB_EXTENDED_CLASS_); 171 toolbarStub.classList.remove(remoting.Toolbar.STUB_EXTENDED_CLASS_);
154 } 172 }
155 } else { 173 } else {
156 document.removeEventListener('mousemove', 174 document.removeEventListener('mousemove',
157 remoting.Toolbar.onMouseMove, false); 175 remoting.Toolbar.onMouseMove, false);
158 } 176 }
159 }; 177 };
160 178
179 /**
180 * Updates the options menu to reflect the current scale-to-fit and full-screen
181 * settings.
182 * @return {void} Nothing.
183 * @private
184 */
185 remoting.Toolbar.prototype.onShowOptionsMenu_ = function() {
186 remoting.optionsMenu.onShow();
187 };
188
161 /** @type {remoting.Toolbar} */ 189 /** @type {remoting.Toolbar} */
162 remoting.toolbar = null; 190 remoting.toolbar = null;
163 191
164 /** @private */ 192 /** @private */
165 remoting.Toolbar.STUB_EXTENDED_CLASS_ = 'toolbar-stub-extended'; 193 remoting.Toolbar.STUB_EXTENDED_CLASS_ = 'toolbar-stub-extended';
166 /** @private */ 194 /** @private */
167 remoting.Toolbar.VISIBLE_CLASS_ = 'toolbar-visible'; 195 remoting.Toolbar.VISIBLE_CLASS_ = 'toolbar-visible';
OLDNEW
« no previous file with comments | « remoting/webapp/remoting.js ('k') | remoting/webapp/window_frame.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698