Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / third_party / polymer / components-chromium / paper-button / paper-button-base-extracted.js
blob6d9831e4f2a8bce9d9fe4505451341032a381f0c
3   (function() {
5     var p = {
7       eventDelegates: {
8         down: 'downAction'
9       },
11       activeChanged: function() {
12         this.super();
14         if (this.$.ripple) {
15           if (this.active) {
16             // FIXME: remove when paper-ripple can have a default 'down' state.
17             if (!this.lastEvent) {
18               var rect = this.getBoundingClientRect();
19               this.lastEvent = {
20                 x: rect.left + rect.width / 2,
21                 y: rect.top + rect.height / 2
22               }
23             }
24             this.$.ripple.downAction(this.lastEvent);
25           } else {
26             this.$.ripple.upAction();
27           }
28         }
30         this.adjustZ();
31       },
33       disabledChanged: function() {
34         this._disabledChanged();
35         this.adjustZ();
36       },
38       recenteringTouchChanged: function() {
39         if (this.$.ripple) {
40           this.$.ripple.classList.toggle('recenteringTouch', this.recenteringTouch);
41         }
42       },
44       fillChanged: function() {
45         if (this.$.ripple) {
46           this.$.ripple.classList.toggle('fill', this.fill);
47         }
48       },
50       adjustZ: function() {
51         if (!this.$.shadow) {
52           return;
53         }
54         if (this.active) {
55           this.$.shadow.setZ(2);
56         } else if (this.disabled) {
57           this.$.shadow.setZ(0);
58         } else {
59           this.$.shadow.setZ(1);
60         }
61       },
63       downAction: function(e) {
64         this._downAction();
66         if (this.hasAttribute('noink')) {
67           return;
68         }
70         this.lastEvent = e;
71         if (!this.$.ripple) {
72           var ripple = document.createElement('paper-ripple');
73           ripple.setAttribute('id', 'ripple');
74           ripple.setAttribute('fit', '');
75           if (this.recenteringTouch) {
76             ripple.classList.add('recenteringTouch');
77           }
78           if (!this.fill) {
79             ripple.classList.add('circle');
80           }
81           this.$.ripple = ripple;
82           this.shadowRoot.insertBefore(ripple, this.shadowRoot.firstChild);
83           // No need to forward the event to the ripple because the ripple
84           // is triggered in activeChanged
85         }
86       }
88     };
90     Polymer.mixin2(p, Polymer.CoreFocusable);
91     Polymer('paper-button-base',p);
93   })();