Service workers: Allow HTTPS pages arrived at via HTTP redirect to use SW
[chromium-blink-merge.git] / third_party / polymer / v1_0 / components-chromium / paper-checkbox / paper-checkbox-extracted.js
blobfdf903a9662d7d54d6d535d3e6953831a8fd8519
1 Polymer({
2       is: 'paper-checkbox',
4       behaviors: [
5         Polymer.PaperInkyFocusBehavior
6       ],
8       hostAttributes: {
9         role: 'checkbox',
10         'aria-checked': false,
11         tabindex: 0
12       },
14       properties: {
15         /**
16          * Fired when the checked state changes due to user interaction.
17          *
18          * @event change
19          */
21         /**
22          * Fired when the checked state changes.
23          *
24          * @event iron-change
25          */
27         /**
28          * Gets or sets the state, `true` is checked and `false` is unchecked.
29          */
30         checked: {
31           type: Boolean,
32           value: false,
33           reflectToAttribute: true,
34           notify: true,
35           observer: '_checkedChanged'
36         },
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         }
47       },
49       attached: function() {
50         var trimmedText = Polymer.dom(this).textContent.trim();
51         if (trimmedText === '') {
52           this.$.checkboxLabel.hidden = true;
53         }
54         // Don't stomp over a user-set aria-label.
55         if (trimmedText !== '' && !this.getAttribute('aria-label')) {
56           this.setAttribute('aria-label', trimmedText);
57         }
58         this._isReady = true;
59       },
61       // button-behavior hook
62       _buttonStateChanged: function() {
63         if (this.disabled) {
64           return;
65         }
66         if (this._isReady) {
67           this.checked = this.active;
68         }
69       },
71       _checkedChanged: function(checked) {
72         this.setAttribute('aria-checked', this.checked ? 'true' : 'false');
73         this.active = this.checked;
74         this.fire('iron-change');
75       },
77       _computeCheckboxClass: function(checked) {
78         if (checked) {
79           return 'checked';
80         }
81         return '';
82       },
84       _computeCheckmarkClass: function(checked) {
85         if (!checked) {
86           return 'hidden';
87         }
88         return '';
89       }
90     });