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(e) { | 78 this.addEventListener('blur', function() { |
79 // This check helps us exclude external events like application switch. | 79 this.classList.remove('no-outline'); |
80 if (e.sourceCapabilities) | |
81 this.classList.remove('no-outline'); | |
82 }); | 80 }); |
83 }, | 81 }, |
84 | 82 |
85 /** @type {boolean} */ | 83 /** @type {boolean} */ |
86 set disabled(disabled) { | 84 set disabled(disabled) { |
87 if (disabled) | 85 if (disabled) |
88 HTMLAnchorElement.prototype.setAttribute.call(this, 'disabled', ''); | 86 HTMLAnchorElement.prototype.setAttribute.call(this, 'disabled', ''); |
89 else | 87 else |
90 HTMLAnchorElement.prototype.removeAttribute.call(this, 'disabled'); | 88 HTMLAnchorElement.prototype.removeAttribute.call(this, 'disabled'); |
91 this.tabIndex = disabled ? -1 : 0; | 89 this.tabIndex = disabled ? -1 : 0; |
(...skipping 14 matching lines...) Expand all Loading... |
106 removeAttribute: function(attr) { | 104 removeAttribute: function(attr) { |
107 if (attr.toLowerCase() == 'disabled') | 105 if (attr.toLowerCase() == 'disabled') |
108 this.disabled = false; | 106 this.disabled = false; |
109 else | 107 else |
110 HTMLAnchorElement.prototype.removeAttribute.apply(this, arguments); | 108 HTMLAnchorElement.prototype.removeAttribute.apply(this, arguments); |
111 }, | 109 }, |
112 }, | 110 }, |
113 | 111 |
114 extends: 'a', | 112 extends: 'a', |
115 }); | 113 }); |
OLD | NEW |