| 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 // Action links are elements that are used to perform an in-page navigation or | 5 // Action links are elements that are used to perform an in-page navigation or |
| 6 // action (e.g. showing a dialog). | 6 // action (e.g. showing a dialog). |
| 7 // | 7 // |
| 8 // They look like normal anchor (<a>) tags as their text color is blue. However, | 8 // They look like normal anchor (<a>) tags as their text color is blue. However, |
| 9 // they're subtly different as they're not initially underlined (giving users a | 9 // they're subtly different as they're not initially underlined (giving users a |
| 10 // clue that underlined links navigate while action links don't). | 10 // clue that underlined links navigate while action links don't). |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 // While the mouse is down, prevent text selection from dragging. | 69 // While the mouse is down, prevent text selection from dragging. |
| 70 document.addEventListener('selectstart', preventDefault); | 70 document.addEventListener('selectstart', preventDefault); |
| 71 document.addEventListener('mouseup', removePreventDefault); | 71 document.addEventListener('mouseup', removePreventDefault); |
| 72 | 72 |
| 73 // If focus started via mouse press, don't show an outline. | 73 // If focus started via mouse press, don't show an outline. |
| 74 if (document.activeElement != this) | 74 if (document.activeElement != this) |
| 75 this.classList.add('no-outline'); | 75 this.classList.add('no-outline'); |
| 76 }); | 76 }); |
| 77 | 77 |
| 78 this.addEventListener('blur', function() { | 78 this.addEventListener('blur', function(e) { |
| 79 this.classList.remove('no-outline'); | 79 // This check helps us exclude external events like application switch. |
| 80 if (e.sourceCapabilities) |
| 81 this.classList.remove('no-outline'); |
| 80 }); | 82 }); |
| 81 }, | 83 }, |
| 82 | 84 |
| 83 /** @type {boolean} */ | 85 /** @type {boolean} */ |
| 84 set disabled(disabled) { | 86 set disabled(disabled) { |
| 85 if (disabled) | 87 if (disabled) |
| 86 HTMLAnchorElement.prototype.setAttribute.call(this, 'disabled', ''); | 88 HTMLAnchorElement.prototype.setAttribute.call(this, 'disabled', ''); |
| 87 else | 89 else |
| 88 HTMLAnchorElement.prototype.removeAttribute.call(this, 'disabled'); | 90 HTMLAnchorElement.prototype.removeAttribute.call(this, 'disabled'); |
| 89 this.tabIndex = disabled ? -1 : 0; | 91 this.tabIndex = disabled ? -1 : 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 104 removeAttribute: function(attr) { | 106 removeAttribute: function(attr) { |
| 105 if (attr.toLowerCase() == 'disabled') | 107 if (attr.toLowerCase() == 'disabled') |
| 106 this.disabled = false; | 108 this.disabled = false; |
| 107 else | 109 else |
| 108 HTMLAnchorElement.prototype.removeAttribute.apply(this, arguments); | 110 HTMLAnchorElement.prototype.removeAttribute.apply(this, arguments); |
| 109 }, | 111 }, |
| 110 }, | 112 }, |
| 111 | 113 |
| 112 extends: 'a', | 114 extends: 'a', |
| 113 }); | 115 }); |
| OLD | NEW |