OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 * Provide an alternative location for the application's context menu items | 7 * Provide an alternative location for the application's context menu items |
8 * on platforms that don't provide it. | 8 * on platforms that don't provide it. |
9 * | 9 * |
10 * To mimic the behaviour of an OS-provided context menu, the menu is dismissed | 10 * To mimic the behaviour of an OS-provided context menu, the menu is dismissed |
(...skipping 13 matching lines...) Expand all Loading... |
24 /** @suppress {duplicate} */ | 24 /** @suppress {duplicate} */ |
25 var remoting = remoting || {}; | 25 var remoting = remoting || {}; |
26 | 26 |
27 /** | 27 /** |
28 * @constructor | 28 * @constructor |
29 * @implements {remoting.WindowShape.ClientUI} | 29 * @implements {remoting.WindowShape.ClientUI} |
30 * @implements {remoting.ContextMenuAdapter} | 30 * @implements {remoting.ContextMenuAdapter} |
31 * @param {HTMLElement} root The root of the context menu DOM. | 31 * @param {HTMLElement} root The root of the context menu DOM. |
32 */ | 32 */ |
33 remoting.ContextMenuDom = function(root) { | 33 remoting.ContextMenuDom = function(root) { |
34 /** | 34 /** @private {HTMLElement} */ |
35 * @type {HTMLElement} | |
36 * @private | |
37 */ | |
38 this.root_ = root; | 35 this.root_ = root; |
39 /** | 36 /** @private {HTMLElement} */ |
40 * @type {HTMLElement} | |
41 * @private | |
42 */ | |
43 this.stub_ = /** @type {HTMLElement} */ | 37 this.stub_ = /** @type {HTMLElement} */ |
44 (this.root_.querySelector('.context-menu-stub')); | 38 (this.root_.querySelector('.context-menu-stub')); |
45 /** | 39 /** @private {HTMLElement} */ |
46 * @type {HTMLElement} | |
47 * @private | |
48 */ | |
49 this.icon_ = /** @type {HTMLElement} */ | 40 this.icon_ = /** @type {HTMLElement} */ |
50 (this.root_.querySelector('.context-menu-icon')); | 41 (this.root_.querySelector('.context-menu-icon')); |
51 /** | 42 /** @private {HTMLElement} */ |
52 * @type {HTMLElement} | |
53 * @private | |
54 */ | |
55 this.screen_ = /** @type {HTMLElement} */ | 43 this.screen_ = /** @type {HTMLElement} */ |
56 (this.root_.querySelector('.context-menu-screen')); | 44 (this.root_.querySelector('.context-menu-screen')); |
57 /** | 45 /** @private {HTMLElement} */ |
58 * @type {HTMLElement} | |
59 * @private | |
60 */ | |
61 this.menu_ = /** @type {HTMLElement} */ (this.root_.querySelector('ul')); | 46 this.menu_ = /** @type {HTMLElement} */ (this.root_.querySelector('ul')); |
62 /** | 47 /** @private {number} */ |
63 * @type {number} | |
64 * @private | |
65 */ | |
66 this.bottom_ = 8; | 48 this.bottom_ = 8; |
67 /** | 49 /** @private {base.EventSourceImpl} */ |
68 * @type {base.EventSourceImpl} | |
69 * @private | |
70 */ | |
71 this.eventSource_ = new base.EventSourceImpl(); | 50 this.eventSource_ = new base.EventSourceImpl(); |
72 /** | 51 /** @private {string} */ |
73 * @type {string} | |
74 * @private | |
75 */ | |
76 this.eventName_ = '_click'; | 52 this.eventName_ = '_click'; |
77 /** | 53 /** |
78 * Since the same element is used to lock the icon open and to drag it, we | 54 * Since the same element is used to lock the icon open and to drag it, we |
79 * must keep track of drag events so that the corresponding click event can | 55 * must keep track of drag events so that the corresponding click event can |
80 * be ignored. | 56 * be ignored. |
81 * | 57 * |
82 * @type {boolean} | 58 * @private {boolean} |
83 * @private | |
84 */ | 59 */ |
85 this.stubDragged_ = false; | 60 this.stubDragged_ = false; |
86 | 61 |
87 /** | 62 /** |
88 * @private | 63 * @private |
89 */ | 64 */ |
90 this.dragAndDrop_ = new remoting.DragAndDrop( | 65 this.dragAndDrop_ = new remoting.DragAndDrop( |
91 this.stub_, this.onDragUpdate_.bind(this)); | 66 this.stub_, this.onDragUpdate_.bind(this)); |
92 | 67 |
93 this.eventSource_.defineEvents([this.eventName_]); | 68 this.eventSource_.defineEvents([this.eventName_]); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 this.bottom_ -= deltaY; | 294 this.bottom_ -= deltaY; |
320 this.root_.style.bottom = this.bottom_ + 'px'; | 295 this.root_.style.bottom = this.bottom_ + 'px'; |
321 // Deferring the window shape update until the DOM update has completed | 296 // Deferring the window shape update until the DOM update has completed |
322 // helps keep the position of the context menu consistent with the window | 297 // helps keep the position of the context menu consistent with the window |
323 // shape (though it's still not perfect). | 298 // shape (though it's still not perfect). |
324 window.requestAnimationFrame( | 299 window.requestAnimationFrame( |
325 function() { | 300 function() { |
326 remoting.windowShape.updateClientWindowShape(); | 301 remoting.windowShape.updateClientWindowShape(); |
327 }); | 302 }); |
328 }; | 303 }; |
OLD | NEW |