| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
| 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | |
| 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | |
| 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | |
| 6 Code distributed by Google as part of the polymer project is also | |
| 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | |
| 8 --> | |
| 9 | |
| 10 <!-- | |
| 11 @group Paper Elements | |
| 12 | |
| 13 `paper-button-base` is the base class for button-like elements with ripple and o
ptional shadow. | |
| 14 | |
| 15 @element paper-button-base | |
| 16 @extends paper-focusable | |
| 17 @status unstable | |
| 18 --> | |
| 19 | |
| 20 <link href="../polymer/polymer.html" rel="import"> | |
| 21 <link href="../paper-focusable/paper-focusable.html" rel="import"> | |
| 22 | |
| 23 <polymer-element name="paper-button-base" extends="paper-focusable"> | |
| 24 | |
| 25 <script> | |
| 26 Polymer({ | |
| 27 | |
| 28 z: 1, | |
| 29 | |
| 30 activeChanged: function() { | |
| 31 this.super(); | |
| 32 | |
| 33 if (this.active) { | |
| 34 // FIXME: remove when paper-ripple can have a default 'down' state. | |
| 35 if (!this.lastEvent) { | |
| 36 var rect = this.getBoundingClientRect(); | |
| 37 this.lastEvent = { | |
| 38 x: rect.left + rect.width / 2, | |
| 39 y: rect.top + rect.height / 2 | |
| 40 } | |
| 41 } | |
| 42 this.$.ripple.downAction(this.lastEvent); | |
| 43 } else { | |
| 44 this.$.ripple.upAction(); | |
| 45 } | |
| 46 this.adjustZ(); | |
| 47 }, | |
| 48 | |
| 49 disabledChanged: function() { | |
| 50 this.super(); | |
| 51 if (this.disabled) { | |
| 52 this.setAttribute('aria-disabled', ''); | |
| 53 } else { | |
| 54 this.removeAttribute('aria-disabled'); | |
| 55 } | |
| 56 this.adjustZ(); | |
| 57 }, | |
| 58 | |
| 59 recenteringTouchChanged: function() { | |
| 60 if (this.$.ripple) { | |
| 61 this.$.ripple.classList.toggle('recenteringTouch', this.recenteringTou
ch); | |
| 62 } | |
| 63 }, | |
| 64 | |
| 65 fillChanged: function() { | |
| 66 if (this.$.ripple) { | |
| 67 this.$.ripple.classList.toggle('fill', this.fill); | |
| 68 } | |
| 69 }, | |
| 70 | |
| 71 adjustZ: function() { | |
| 72 if (this.active) { | |
| 73 this.z = 2; | |
| 74 } else if (this.disabled) { | |
| 75 this.z = 0; | |
| 76 } else { | |
| 77 this.z = 1; | |
| 78 } | |
| 79 }, | |
| 80 | |
| 81 downAction: function(e) { | |
| 82 this.super(e); | |
| 83 this.lastEvent = e; | |
| 84 if (!this.$.ripple) { | |
| 85 var ripple = document.createElement('paper-ripple'); | |
| 86 ripple.setAttribute('id', 'ripple'); | |
| 87 ripple.setAttribute('fit', ''); | |
| 88 if (this.recenteringTouch) { | |
| 89 ripple.classList.add('recenteringTouch'); | |
| 90 } | |
| 91 if (!this.fill) { | |
| 92 ripple.classList.add('circle'); | |
| 93 } | |
| 94 this.$.ripple = ripple; | |
| 95 this.shadowRoot.insertBefore(ripple, this.shadowRoot.firstChild); | |
| 96 // No need to forward the event to the ripple because the ripple | |
| 97 // is triggered in activeChanged | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 }); | |
| 102 </script> | |
| 103 </polymer-element> | |
| OLD | NEW |