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

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

Issue 336293003: Refactor tool-bar event handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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/session_connector.js ('k') | 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 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 /**
46 * @type {remoting.OptionsMenu}
47 * @private
48 */
49 this.optionsMenu_ = new remoting.OptionsMenu(
50 document.getElementById('send-ctrl-alt-del'),
51 document.getElementById('send-print-screen'),
52 document.getElementById('screen-resize-to-client'),
53 document.getElementById('screen-shrink-to-fit'),
54 document.getElementById('toggle-full-screen'));
45 55
46 window.addEventListener('mousemove', remoting.Toolbar.onMouseMove, false); 56 window.addEventListener('mousemove', remoting.Toolbar.onMouseMove, false);
47 window.addEventListener('resize', this.center.bind(this), false); 57 window.addEventListener('resize', this.center.bind(this), false);
48 58
49 registerEventListener('new-connection', 'click', 59 registerEventListener('new-connection', 'click',
50 function() { 60 function() {
51 chrome.app.window.create('main.html', { 'width': 800, 'height': 600 }); 61 chrome.app.window.create('main.html', { 'width': 800, 'height': 600 });
52 }); 62 });
53 registerEventListener('send-ctrl-alt-del', 'click', remoting.sendCtrlAltDel);
54 registerEventListener('send-print-screen', 'click', remoting.sendPrintScreen);
55 registerEventListener('sign-out', 'click', remoting.signOut);
56 registerEventListener('toolbar-disconnect', 'click', remoting.disconnect); 63 registerEventListener('toolbar-disconnect', 'click', remoting.disconnect);
57 registerEventListener('toolbar-stub', 'click', 64 registerEventListener('toolbar-stub', 'click',
58 function() { remoting.toolbar.toggle(); }); 65 function() { remoting.toolbar.toggle(); });
59 66
60 // Prevent the preview canceling if the user is interacting with the tool-bar. 67 // Prevent the preview canceling if the user is interacting with the tool-bar.
61 /** @type {remoting.Toolbar} */ 68 /** @type {remoting.Toolbar} */
62 var that = this; 69 var that = this;
63 var stopTimer = function() { 70 var stopTimer = function() {
64 if (that.timerId_) { 71 if (that.timerId_) {
65 window.clearTimeout(that.timerId_); 72 window.clearTimeout(that.timerId_);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 }; 104 };
98 105
99 /** 106 /**
100 * Toggle the tool-bar visibility. 107 * Toggle the tool-bar visibility.
101 */ 108 */
102 remoting.Toolbar.prototype.toggle = function() { 109 remoting.Toolbar.prototype.toggle = function() {
103 this.toolbar_.classList.toggle(remoting.Toolbar.VISIBLE_CLASS_); 110 this.toolbar_.classList.toggle(remoting.Toolbar.VISIBLE_CLASS_);
104 }; 111 };
105 112
106 /** 113 /**
114 * @param {remoting.ClientSession} clientSession The active session, or null if
115 * there is no connection.
116 */
117 remoting.Toolbar.prototype.setClientSession = function(clientSession) {
118 this.optionsMenu_.setClientSession(clientSession);
119 var connectedTo = document.getElementById('connected-to');
120 connectedTo.innerText = clientSession.getHostDisplayName();
121 };
122
123 /**
107 * Test the specified co-ordinate to see if it is close enough to the stub 124 * Test the specified co-ordinate to see if it is close enough to the stub
108 * to activate it. 125 * to activate it.
109 * 126 *
110 * @param {number} x The x co-ordinate. 127 * @param {number} x The x co-ordinate.
111 * @param {number} y The y co-ordinate. 128 * @param {number} y The y co-ordinate.
112 * @return {boolean} True if the position should activate the tool-bar stub, or 129 * @return {boolean} True if the position should activate the tool-bar stub, or
113 * false otherwise. 130 * false otherwise.
114 * @private 131 * @private
115 */ 132 */
116 remoting.Toolbar.prototype.hitTest_ = function(x, y) { 133 remoting.Toolbar.prototype.hitTest_ = function(x, y) {
(...skipping 25 matching lines...) Expand all
142 } 159 }
143 }; 160 };
144 161
145 /** @type {remoting.Toolbar} */ 162 /** @type {remoting.Toolbar} */
146 remoting.toolbar = null; 163 remoting.toolbar = null;
147 164
148 /** @private */ 165 /** @private */
149 remoting.Toolbar.STUB_EXTENDED_CLASS_ = 'toolbar-stub-extended'; 166 remoting.Toolbar.STUB_EXTENDED_CLASS_ = 'toolbar-stub-extended';
150 /** @private */ 167 /** @private */
151 remoting.Toolbar.VISIBLE_CLASS_ = 'toolbar-visible'; 168 remoting.Toolbar.VISIBLE_CLASS_ = 'toolbar-visible';
OLDNEW
« no previous file with comments | « remoting/webapp/session_connector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698