| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2011 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 * @param {number} y | 42 * @param {number} y |
| 43 */ | 43 */ |
| 44 show: function(x, y) | 44 show: function(x, y) |
| 45 { | 45 { |
| 46 this._x = x; | 46 this._x = x; |
| 47 this._y = y; | 47 this._y = y; |
| 48 this._time = new Date().getTime(); | 48 this._time = new Date().getTime(); |
| 49 | 49 |
| 50 // Create context menu. | 50 // Create context menu. |
| 51 this._contextMenuElement = document.createElementWithClass("div", "soft-
context-menu"); | 51 this._contextMenuElement = document.createElementWithClass("div", "soft-
context-menu"); |
| 52 this._contextMenuElement.classList.add("component-root"); | |
| 53 this._contextMenuElement.tabIndex = 0; | 52 this._contextMenuElement.tabIndex = 0; |
| 54 this._contextMenuElement.style.top = y + "px"; | 53 this._contextMenuElement.style.top = y + "px"; |
| 55 this._contextMenuElement.style.left = x + "px"; | 54 this._contextMenuElement.style.left = x + "px"; |
| 56 | 55 |
| 57 this._contextMenuElement.addEventListener("mouseup", consumeEvent, false
); | 56 this._contextMenuElement.addEventListener("mouseup", consumeEvent, false
); |
| 58 this._contextMenuElement.addEventListener("keydown", this._menuKeyDown.b
ind(this), false); | 57 this._contextMenuElement.addEventListener("keydown", this._menuKeyDown.b
ind(this), false); |
| 59 | 58 |
| 60 for (var i = 0; i < this._items.length; ++i) | 59 for (var i = 0; i < this._items.length; ++i) |
| 61 this._contextMenuElement.appendChild(this._createMenuItem(this._item
s[i])); | 60 this._contextMenuElement.appendChild(this._createMenuItem(this._item
s[i])); |
| 62 | 61 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 336 |
| 338 _discardSubMenus: function() | 337 _discardSubMenus: function() |
| 339 { | 338 { |
| 340 if (this._subMenu) | 339 if (this._subMenu) |
| 341 this._subMenu._discardSubMenus(); | 340 this._subMenu._discardSubMenus(); |
| 342 this._contextMenuElement.remove(); | 341 this._contextMenuElement.remove(); |
| 343 if (this._parentMenu) | 342 if (this._parentMenu) |
| 344 delete this._parentMenu._subMenu; | 343 delete this._parentMenu._subMenu; |
| 345 } | 344 } |
| 346 } | 345 } |
| OLD | NEW |