| OLD | NEW |
| 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 Loading... |
| 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')); | |
| 55 | 45 |
| 56 window.addEventListener('mousemove', remoting.Toolbar.onMouseMove, false); | 46 window.addEventListener('mousemove', remoting.Toolbar.onMouseMove, false); |
| 57 window.addEventListener('resize', this.center.bind(this), false); | 47 window.addEventListener('resize', this.center.bind(this), false); |
| 58 | 48 |
| 59 registerEventListener('new-connection', 'click', | 49 registerEventListener('new-connection', 'click', |
| 60 function() { | 50 function() { |
| 61 chrome.app.window.create('main.html', { 'width': 800, 'height': 600 }); | 51 chrome.app.window.create('main.html', { 'width': 800, 'height': 600 }); |
| 62 }); | 52 }); |
| 53 registerEventListener('send-ctrl-alt-del', 'click', remoting.sendCtrlAltDel); |
| 54 registerEventListener('send-print-screen', 'click', remoting.sendPrintScreen); |
| 55 registerEventListener('sign-out', 'click', remoting.signOut); |
| 63 registerEventListener('toolbar-disconnect', 'click', remoting.disconnect); | 56 registerEventListener('toolbar-disconnect', 'click', remoting.disconnect); |
| 64 registerEventListener('toolbar-stub', 'click', | 57 registerEventListener('toolbar-stub', 'click', |
| 65 function() { remoting.toolbar.toggle(); }); | 58 function() { remoting.toolbar.toggle(); }); |
| 66 | 59 |
| 67 // Prevent the preview canceling if the user is interacting with the tool-bar. | 60 // Prevent the preview canceling if the user is interacting with the tool-bar. |
| 68 /** @type {remoting.Toolbar} */ | 61 /** @type {remoting.Toolbar} */ |
| 69 var that = this; | 62 var that = this; |
| 70 var stopTimer = function() { | 63 var stopTimer = function() { |
| 71 if (that.timerId_) { | 64 if (that.timerId_) { |
| 72 window.clearTimeout(that.timerId_); | 65 window.clearTimeout(that.timerId_); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 }; | 97 }; |
| 105 | 98 |
| 106 /** | 99 /** |
| 107 * Toggle the tool-bar visibility. | 100 * Toggle the tool-bar visibility. |
| 108 */ | 101 */ |
| 109 remoting.Toolbar.prototype.toggle = function() { | 102 remoting.Toolbar.prototype.toggle = function() { |
| 110 this.toolbar_.classList.toggle(remoting.Toolbar.VISIBLE_CLASS_); | 103 this.toolbar_.classList.toggle(remoting.Toolbar.VISIBLE_CLASS_); |
| 111 }; | 104 }; |
| 112 | 105 |
| 113 /** | 106 /** |
| 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 /** | |
| 124 * Test the specified co-ordinate to see if it is close enough to the stub | 107 * Test the specified co-ordinate to see if it is close enough to the stub |
| 125 * to activate it. | 108 * to activate it. |
| 126 * | 109 * |
| 127 * @param {number} x The x co-ordinate. | 110 * @param {number} x The x co-ordinate. |
| 128 * @param {number} y The y co-ordinate. | 111 * @param {number} y The y co-ordinate. |
| 129 * @return {boolean} True if the position should activate the tool-bar stub, or | 112 * @return {boolean} True if the position should activate the tool-bar stub, or |
| 130 * false otherwise. | 113 * false otherwise. |
| 131 * @private | 114 * @private |
| 132 */ | 115 */ |
| 133 remoting.Toolbar.prototype.hitTest_ = function(x, y) { | 116 remoting.Toolbar.prototype.hitTest_ = function(x, y) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 159 } | 142 } |
| 160 }; | 143 }; |
| 161 | 144 |
| 162 /** @type {remoting.Toolbar} */ | 145 /** @type {remoting.Toolbar} */ |
| 163 remoting.toolbar = null; | 146 remoting.toolbar = null; |
| 164 | 147 |
| 165 /** @private */ | 148 /** @private */ |
| 166 remoting.Toolbar.STUB_EXTENDED_CLASS_ = 'toolbar-stub-extended'; | 149 remoting.Toolbar.STUB_EXTENDED_CLASS_ = 'toolbar-stub-extended'; |
| 167 /** @private */ | 150 /** @private */ |
| 168 remoting.Toolbar.VISIBLE_CLASS_ = 'toolbar-visible'; | 151 remoting.Toolbar.VISIBLE_CLASS_ = 'toolbar-visible'; |
| OLD | NEW |