| 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 23 matching lines...) Expand all Loading... |
| 34 /** | 34 /** |
| 35 * @type {HTMLElement} | 35 * @type {HTMLElement} |
| 36 * @private | 36 * @private |
| 37 */ | 37 */ |
| 38 this.root_ = root; | 38 this.root_ = root; |
| 39 /** | 39 /** |
| 40 * @type {HTMLElement} | 40 * @type {HTMLElement} |
| 41 * @private | 41 * @private |
| 42 */ | 42 */ |
| 43 this.stub_ = /** @type {HTMLElement} */ | 43 this.stub_ = /** @type {HTMLElement} */ |
| 44 this.root_.querySelector('.context-menu-stub'); | 44 (this.root_.querySelector('.context-menu-stub')); |
| 45 /** | 45 /** |
| 46 * @type {HTMLElement} | 46 * @type {HTMLElement} |
| 47 * @private | 47 * @private |
| 48 */ | 48 */ |
| 49 this.icon_ = /** @type {HTMLElement} */ | 49 this.icon_ = /** @type {HTMLElement} */ |
| 50 this.root_.querySelector('.context-menu-icon'); | 50 (this.root_.querySelector('.context-menu-icon')); |
| 51 /** | 51 /** |
| 52 * @type {HTMLElement} | 52 * @type {HTMLElement} |
| 53 * @private | 53 * @private |
| 54 */ | 54 */ |
| 55 this.screen_ = /** @type {HTMLElement} */ | 55 this.screen_ = /** @type {HTMLElement} */ |
| 56 this.root_.querySelector('.context-menu-screen'); | 56 (this.root_.querySelector('.context-menu-screen')); |
| 57 /** | 57 /** |
| 58 * @type {HTMLElement} | 58 * @type {HTMLElement} |
| 59 * @private | 59 * @private |
| 60 */ | 60 */ |
| 61 this.menu_ = /** @type {HTMLElement} */ this.root_.querySelector('ul'); | 61 this.menu_ = /** @type {HTMLElement} */ (this.root_.querySelector('ul')); |
| 62 /** | 62 /** |
| 63 * @type {number} | 63 * @type {number} |
| 64 * @private | 64 * @private |
| 65 */ | 65 */ |
| 66 this.bottom_ = 8; | 66 this.bottom_ = 8; |
| 67 /** | 67 /** |
| 68 * @type {base.EventSource} | 68 * @type {base.EventSource} |
| 69 * @private | 69 * @private |
| 70 */ | 70 */ |
| 71 this.eventSource_ = new base.EventSource(); | 71 this.eventSource_ = new base.EventSource(); |
| 72 /** | 72 /** |
| 73 * @type {string} | 73 * @type {string} |
| 74 * @private | 74 * @private |
| 75 */ | 75 */ |
| 76 this.eventName_ = '_click'; | 76 this.eventName_ = '_click'; |
| 77 /** | 77 /** |
| 78 * Since the same element is used to lock the icon open and to drag it, we | 78 * 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 | 79 * must keep track of drag events so that the corresponding click event can |
| 80 * be ignored. | 80 * be ignored. |
| 81 * | 81 * |
| 82 * @type {boolean} | 82 * @type {boolean} |
| 83 * @private | 83 * @private |
| 84 */ | 84 */ |
| 85 this.stubDragged_ = false; | 85 this.stubDragged_ = false; |
| 86 | 86 |
| 87 /* | 87 /** |
| 88 * @private | 88 * @private |
| 89 */ | 89 */ |
| 90 this.dragAndDrop_ = new remoting.DragAndDrop( | 90 this.dragAndDrop_ = new remoting.DragAndDrop( |
| 91 this.stub_, this.onDragUpdate_.bind(this)); | 91 this.stub_, this.onDragUpdate_.bind(this)); |
| 92 | 92 |
| 93 this.eventSource_.defineEvents([this.eventName_]); | 93 this.eventSource_.defineEvents([this.eventName_]); |
| 94 this.root_.addEventListener( | 94 this.root_.addEventListener( |
| 95 'transitionend', this.onTransitionEnd_.bind(this), false); | 95 'transitionend', this.onTransitionEnd_.bind(this), false); |
| 96 this.stub_.addEventListener('click', this.onStubClick_.bind(this), false); | 96 this.stub_.addEventListener('click', this.onStubClick_.bind(this), false); |
| 97 this.icon_.addEventListener('click', this.onIconClick_.bind(this), false); | 97 this.icon_.addEventListener('click', this.onIconClick_.bind(this), false); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 * @param {string} id | 187 * @param {string} id |
| 188 */ | 188 */ |
| 189 remoting.ContextMenuDom.prototype.remove = function(id) { | 189 remoting.ContextMenuDom.prototype.remove = function(id) { |
| 190 var node = this.menu_.querySelector('[data-id="' + id + '"]'); | 190 var node = this.menu_.querySelector('[data-id="' + id + '"]'); |
| 191 if (node) { | 191 if (node) { |
| 192 this.menu_.removeChild(node); | 192 this.menu_.removeChild(node); |
| 193 } | 193 } |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 /** | 196 /** |
| 197 * @param {function(OnClickData):void} listener | 197 * @param {function(OnClickData=):void} listener |
| 198 */ | 198 */ |
| 199 remoting.ContextMenuDom.prototype.addListener = function(listener) { | 199 remoting.ContextMenuDom.prototype.addListener = function(listener) { |
| 200 this.eventSource_.addEventListener(this.eventName_, listener); | 200 this.eventSource_.addEventListener(this.eventName_, listener); |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 /** | 203 /** |
| 204 * @param {Event} event | 204 * @param {Event} event |
| 205 * @private | 205 * @private |
| 206 */ | 206 */ |
| 207 remoting.ContextMenuDom.prototype.onClick_ = function(event) { | 207 remoting.ContextMenuDom.prototype.onClick_ = function(event) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 this.bottom_ -= deltaY; | 319 this.bottom_ -= deltaY; |
| 320 this.root_.style.bottom = this.bottom_ + 'px'; | 320 this.root_.style.bottom = this.bottom_ + 'px'; |
| 321 // Deferring the window shape update until the DOM update has completed | 321 // Deferring the window shape update until the DOM update has completed |
| 322 // helps keep the position of the context menu consistent with the window | 322 // helps keep the position of the context menu consistent with the window |
| 323 // shape (though it's still not perfect). | 323 // shape (though it's still not perfect). |
| 324 window.requestAnimationFrame( | 324 window.requestAnimationFrame( |
| 325 function() { | 325 function() { |
| 326 remoting.windowShape.updateClientWindowShape(); | 326 remoting.windowShape.updateClientWindowShape(); |
| 327 }); | 327 }); |
| 328 }; | 328 }; |
| OLD | NEW |