| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // <include src="../../assert.js"> | 5 // <include src="../../assert.js"> |
| 6 | 6 |
| 7 cr.exportPath('cr.ui'); | 7 cr.exportPath('cr.ui'); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Enum for type of hide. Delayed is used when called by clicking on a | 10 * Enum for type of hide. Delayed is used when called by clicking on a |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * Handles event callbacks. | 91 * Handles event callbacks. |
| 92 * @param {Event} e The event object. | 92 * @param {Event} e The event object. |
| 93 */ | 93 */ |
| 94 handleEvent: function(e) { | 94 handleEvent: function(e) { |
| 95 if (!this.menu) | 95 if (!this.menu) |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 switch (e.type) { | 98 switch (e.type) { |
| 99 case 'mousedown': | 99 case 'mousedown': |
| 100 if (e.currentTarget == this.ownerDocument) { | 100 if (e.currentTarget == this.ownerDocument) { |
| 101 if (e.target instanceof Element && !this.contains(e.target) && | 101 if (e.target instanceof Node && !this.contains(e.target) && |
| 102 !this.menu.contains(e.target)) { | 102 !this.menu.contains(e.target)) { |
| 103 this.hideMenu(); | 103 this.hideMenu(); |
| 104 } else { | 104 } else { |
| 105 e.preventDefault(); | 105 e.preventDefault(); |
| 106 } | 106 } |
| 107 } else { | 107 } else { |
| 108 if (this.isMenuShown()) { | 108 if (this.isMenuShown()) { |
| 109 this.hideMenu(); | 109 this.hideMenu(); |
| 110 } else if (e.button == 0) { // Only show the menu when using left | 110 } else if (e.button == 0) { // Only show the menu when using left |
| 111 // mouse button. | 111 // mouse button. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 126 if (this.menu.handleKeyDown(e)) { | 126 if (this.menu.handleKeyDown(e)) { |
| 127 e.preventDefault(); | 127 e.preventDefault(); |
| 128 e.stopPropagation(); | 128 e.stopPropagation(); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 // Show the focus ring on keypress. | 132 // Show the focus ring on keypress. |
| 133 this.classList.remove('using-mouse'); | 133 this.classList.remove('using-mouse'); |
| 134 break; | 134 break; |
| 135 case 'focus': | 135 case 'focus': |
| 136 if (e.target instanceof Element && !this.contains(e.target) && | 136 if (e.target instanceof Node && !this.contains(e.target) && |
| 137 !this.menu.contains(e.target)) { | 137 !this.menu.contains(e.target)) { |
| 138 this.hideMenu(); | 138 this.hideMenu(); |
| 139 // Show the focus ring on focus - if it's come from a mouse event, | 139 // Show the focus ring on focus - if it's come from a mouse event, |
| 140 // the focus ring will be hidden in the mousedown event handler, | 140 // the focus ring will be hidden in the mousedown event handler, |
| 141 // executed after this. | 141 // executed after this. |
| 142 this.classList.remove('using-mouse'); | 142 this.classList.remove('using-mouse'); |
| 143 } | 143 } |
| 144 break; | 144 break; |
| 145 case 'activate': | 145 case 'activate': |
| 146 var hideDelayed = e.target instanceof cr.ui.MenuItem && | 146 var hideDelayed = e.target instanceof cr.ui.MenuItem && |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 'drop-down-arrow-hover', ARROW_WIDTH, ARROW_HEIGHT, opt_hoverColor); | 300 'drop-down-arrow-hover', ARROW_WIDTH, ARROW_HEIGHT, opt_hoverColor); |
| 301 createDropDownArrowCanvas( | 301 createDropDownArrowCanvas( |
| 302 'drop-down-arrow-active', ARROW_WIDTH, ARROW_HEIGHT, opt_activeColor); | 302 'drop-down-arrow-active', ARROW_WIDTH, ARROW_HEIGHT, opt_activeColor); |
| 303 }; | 303 }; |
| 304 | 304 |
| 305 // Export | 305 // Export |
| 306 return { | 306 return { |
| 307 MenuButton: MenuButton, | 307 MenuButton: MenuButton, |
| 308 }; | 308 }; |
| 309 }); | 309 }); |
| OLD | NEW |