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.github.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/CONTRIBUTORS.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/PATENTS.txt
13 `paper-button-base` is the base class for button-like elements with ripple and optional shadow.
15 @element paper-button-base
16 @mixins Polymer.CoreFocusable
20 <link href=
"../polymer/polymer.html" rel=
"import">
21 <link href=
"../core-focusable/core-focusable.html" rel=
"import">
22 <link href=
"../paper-ripple/paper-ripple.html" rel=
"import">
24 <polymer-element name=
"paper-button-base" tabindex=
"0">
36 activeChanged: function() {
41 // FIXME: remove when paper-ripple can have a default 'down' state.
42 if (!this.lastEvent
) {
43 var rect
= this.getBoundingClientRect();
45 x
: rect
.left
+ rect
.width
/ 2,
46 y
: rect
.top
+ rect
.height
/ 2
49 this.$.ripple
.downAction(this.lastEvent
);
51 this.$.ripple
.upAction();
58 disabledChanged: function() {
59 this._disabledChanged();
63 recenteringTouchChanged: function() {
65 this.$.ripple
.classList
.toggle('recenteringTouch', this.recenteringTouch
);
69 fillChanged: function() {
71 this.$.ripple
.classList
.toggle('fill', this.fill
);
80 this.$.shadow
.setZ(2);
81 } else if (this.disabled
) {
82 this.$.shadow
.setZ(0);
84 this.$.shadow
.setZ(1);
88 downAction: function(e
) {
91 if (this.hasAttribute('noink')) {
97 var ripple
= document
.createElement('paper-ripple');
98 ripple
.setAttribute('id', 'ripple');
99 ripple
.setAttribute('fit', '');
100 if (this.recenteringTouch
) {
101 ripple
.classList
.add('recenteringTouch');
104 ripple
.classList
.add('circle');
106 this.$.ripple
= ripple
;
107 this.shadowRoot
.insertBefore(ripple
, this.shadowRoot
.firstChild
);
108 // No need to forward the event to the ripple because the ripple
109 // is triggered in activeChanged
115 Polymer
.mixin2(p
, Polymer
.CoreFocusable
);