OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @fileoverview | |
7 * Class handling the in-session options menu (or menus in the case of apps v1). | |
8 */ | |
9 | |
10 'use strict'; | |
11 | |
12 /** @suppress {duplicate} */ | |
13 var remoting = remoting || {}; | |
14 | |
15 /** | |
16 * @param {HTMLElement} sendCtrlAltDel | |
17 * @param {HTMLElement} sendPrtScrn | |
18 * @param {HTMLElement} resizeToClient | |
19 * @param {HTMLElement} shrinkToFit | |
20 * @param {HTMLElement?} fullscreen | |
21 * @constructor | |
22 */ | |
23 remoting.OptionsMenu = function(sendCtrlAltDel, sendPrtScrn, | |
24 resizeToClient, shrinkToFit, fullscreen) { | |
25 this.sendCtrlAltDel_ = sendCtrlAltDel; | |
26 this.sendPrtScrn_ = sendPrtScrn; | |
27 this.resizeToClient_ = resizeToClient; | |
28 this.shrinkToFit_ = shrinkToFit; | |
29 this.fullscreen_ = fullscreen; | |
30 /** | |
31 * @type {remoting.ClientSession} | |
32 * @private | |
33 */ | |
34 this.clientSession_ = null; | |
35 | |
36 this.sendCtrlAltDel_.addEventListener( | |
37 'click', this.onSendCtrlAltDel_.bind(this), false); | |
38 this.sendPrtScrn_.addEventListener( | |
39 'click', this.onSendPrtScrn_.bind(this), false); | |
40 this.resizeToClient_.addEventListener( | |
41 'click', this.onResizeToClient_.bind(this), false); | |
42 this.shrinkToFit_.addEventListener( | |
43 'click', this.onShrinkToFit_.bind(this), false); | |
44 if (this.fullscreen_) { | |
45 this.fullscreen_.addEventListener( | |
46 'click', this.onFullscreen_.bind(this), false); | |
47 } | |
48 }; | |
49 | |
50 /** | |
51 * @param {remoting.ClientSession} clientSession The active session, or null if | |
52 * there is no connection. | |
53 */ | |
54 remoting.OptionsMenu.prototype.setClientSession = function(clientSession) { | |
55 this.clientSession_ = clientSession; | |
56 }; | |
57 | |
58 remoting.OptionsMenu.prototype.onShow = function() { | |
59 if (this.clientSession_) { | |
60 remoting.MenuButton.select( | |
61 this.resizeToClient_, this.clientSession_.getResizeToClient()); | |
62 remoting.MenuButton.select( | |
63 this.shrinkToFit_, this.clientSession_.getShrinkToFit()); | |
64 if (this.fullscreen_) { | |
65 remoting.MenuButton.select( | |
66 this.fullscreen_, remoting.fullscreen.isActive()); | |
67 } | |
68 } | |
69 }; | |
70 | |
71 remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() { | |
72 if (this.clientSession_) { | |
73 this.clientSession_.sendCtrlAltDel(); | |
74 } | |
75 }; | |
76 | |
77 remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() { | |
78 if (this.clientSession_) { | |
79 this.clientSession_.sendPrintScreen(); | |
80 } | |
81 }; | |
82 | |
83 remoting.OptionsMenu.prototype.onResizeToClient_ = function() { | |
84 if (this.clientSession_) { | |
85 this.clientSession_.setScreenMode(this.clientSession_.getShrinkToFit(), | |
86 !this.clientSession_.getResizeToClient()); | |
87 } | |
88 }; | |
89 | |
90 remoting.OptionsMenu.prototype.onShrinkToFit_ = function() { | |
91 if (this.clientSession_) { | |
92 this.clientSession_.setScreenMode(!this.clientSession_.getShrinkToFit(), | |
93 this.clientSession_.getResizeToClient()); | |
94 } | |
95 }; | |
96 | |
97 remoting.OptionsMenu.prototype.onFullscreen_ = function() { | |
98 remoting.fullscreen.toggle(); | |
99 }; | |
OLD | NEW |