Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-checkbox/paper-checkbox-extracted.js

Issue 1336623003: [MD settings] updating polymer to 1.1.13 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed Polymer.IronCheckedElementBehavior name Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 Polymer({ 1 Polymer({
2 is: 'paper-checkbox', 2 is: 'paper-checkbox',
3 3
4 behaviors: [ 4 behaviors: [
5 Polymer.PaperInkyFocusBehavior 5 Polymer.PaperInkyFocusBehavior,
6 Polymer.IronCheckedElementBehavior
6 ], 7 ],
7 8
8 hostAttributes: { 9 hostAttributes: {
9 role: 'checkbox', 10 role: 'checkbox',
10 'aria-checked': false, 11 'aria-checked': false,
11 tabindex: 0 12 tabindex: 0
12 }, 13 },
13 14
14 properties: { 15 properties: {
15 /** 16 /**
16 * Fired when the checked state changes due to user interaction. 17 * Fired when the checked state changes due to user interaction.
17 * 18 *
18 * @event change 19 * @event change
19 */ 20 */
20 21
21 /** 22 /**
22 * Fired when the checked state changes. 23 * Fired when the checked state changes.
23 * 24 *
24 * @event iron-change 25 * @event iron-change
25 */ 26 */
26 27 ariaActiveAttribute: {
27 /** 28 type: String,
28 * Gets or sets the state, `true` is checked and `false` is unchecked. 29 value: 'aria-checked'
29 */
30 checked: {
31 type: Boolean,
32 value: false,
33 reflectToAttribute: true,
34 notify: true,
35 observer: '_checkedChanged'
36 },
37
38 /**
39 * If true, the button toggles the active state with each tap or press
40 * of the spacebar.
41 */
42 toggles: {
43 type: Boolean,
44 value: true,
45 reflectToAttribute: true
46 } 30 }
47 }, 31 },
48 32
49 attached: function() { 33 attached: function() {
50 var trimmedText = Polymer.dom(this).textContent.trim(); 34 this._isReady = true;
51 if (trimmedText === '') { 35
52 this.$.checkboxLabel.hidden = true; 36 // Don't stomp over a user-set aria-label.
37 if (!this.getAttribute('aria-label')) {
38 this.updateAriaLabel();
53 } 39 }
54 // Don't stomp over a user-set aria-label. 40 },
55 if (trimmedText !== '' && !this.getAttribute('aria-label')) { 41
56 this.setAttribute('aria-label', trimmedText); 42 /**
57 } 43 * Update the checkbox aria-label. This is a temporary workaround not
58 this._isReady = true; 44 * being able to observe changes in <content>
45 * (see: https://github.com/Polymer/polymer/issues/1773)
46 *
47 * Call this if you manually change the contents of the checkbox
48 * and want the aria-label to match the new contents.
49 */
50 updateAriaLabel: function() {
51 this.setAttribute('aria-label', Polymer.dom(this).textContent.trim());
59 }, 52 },
60 53
61 // button-behavior hook 54 // button-behavior hook
62 _buttonStateChanged: function() { 55 _buttonStateChanged: function() {
63 if (this.disabled) { 56 if (this.disabled) {
64 return; 57 return;
65 } 58 }
66 if (this._isReady) { 59 if (this._isReady) {
67 this.checked = this.active; 60 this.checked = this.active;
68 } 61 }
69 }, 62 },
70 63
71 _checkedChanged: function(checked) { 64 _computeCheckboxClass: function(checked, invalid) {
72 this.setAttribute('aria-checked', this.checked ? 'true' : 'false'); 65 var className = '';
73 this.active = this.checked;
74 this.fire('iron-change');
75 },
76
77 _computeCheckboxClass: function(checked) {
78 if (checked) { 66 if (checked) {
79 return 'checked'; 67 className += 'checked ';
80 } 68 }
81 return ''; 69 if (invalid) {
70 className += 'invalid';
71 }
72 return className;
82 }, 73 },
83 74
84 _computeCheckmarkClass: function(checked) { 75 _computeCheckmarkClass: function(checked) {
85 if (!checked) { 76 return checked ? '' : 'hidden';
86 return 'hidden';
87 }
88 return '';
89 } 77 }
90 }); 78 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698