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"); |
52 this._contextMenuElement.tabIndex = 0; | 53 this._contextMenuElement.tabIndex = 0; |
53 this._contextMenuElement.style.top = y + "px"; | 54 this._contextMenuElement.style.top = y + "px"; |
54 this._contextMenuElement.style.left = x + "px"; | 55 this._contextMenuElement.style.left = x + "px"; |
55 | 56 |
56 this._contextMenuElement.addEventListener("mouseup", consumeEvent, false
); | 57 this._contextMenuElement.addEventListener("mouseup", consumeEvent, false
); |
57 this._contextMenuElement.addEventListener("keydown", this._menuKeyDown.b
ind(this), false); | 58 this._contextMenuElement.addEventListener("keydown", this._menuKeyDown.b
ind(this), false); |
58 | 59 |
59 for (var i = 0; i < this._items.length; ++i) | 60 for (var i = 0; i < this._items.length; ++i) |
60 this._contextMenuElement.appendChild(this._createMenuItem(this._item
s[i])); | 61 this._contextMenuElement.appendChild(this._createMenuItem(this._item
s[i])); |
61 | 62 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 337 |
337 _discardSubMenus: function() | 338 _discardSubMenus: function() |
338 { | 339 { |
339 if (this._subMenu) | 340 if (this._subMenu) |
340 this._subMenu._discardSubMenus(); | 341 this._subMenu._discardSubMenus(); |
341 this._contextMenuElement.remove(); | 342 this._contextMenuElement.remove(); |
342 if (this._parentMenu) | 343 if (this._parentMenu) |
343 delete this._parentMenu._subMenu; | 344 delete this._parentMenu._subMenu; |
344 } | 345 } |
345 } | 346 } |
OLD | NEW |