| OLD | NEW |
| 1 | 1 /** @polymerBehavior Polymer.PaperButtonBehavior */ |
| 2 | |
| 3 /** @polymerBehavior */ | |
| 4 Polymer.PaperButtonBehaviorImpl = { | 2 Polymer.PaperButtonBehaviorImpl = { |
| 5 | 3 |
| 6 properties: { | 4 properties: { |
| 7 | 5 |
| 8 _elevation: { | 6 /** |
| 9 type: Number | 7 * The z-depth of this element, from 0-5. Setting to 0 will remove the |
| 8 * shadow, and each increasing number greater than 0 will be "deeper" |
| 9 * than the last. |
| 10 * |
| 11 * @attribute elevation |
| 12 * @type number |
| 13 * @default 1 |
| 14 */ |
| 15 elevation: { |
| 16 type: Number, |
| 17 reflectToAttribute: true, |
| 18 readOnly: true |
| 10 } | 19 } |
| 11 | 20 |
| 12 }, | 21 }, |
| 13 | 22 |
| 14 observers: [ | 23 observers: [ |
| 15 '_calculateElevation(focused, disabled, active, pressed, receivedFocusFrom
Keyboard)' | 24 '_calculateElevation(focused, disabled, active, pressed, receivedFocusFrom
Keyboard)', |
| 25 '_computeKeyboardClass(receivedFocusFromKeyboard)' |
| 16 ], | 26 ], |
| 17 | 27 |
| 18 hostAttributes: { | 28 hostAttributes: { |
| 19 role: 'button', | 29 role: 'button', |
| 20 tabindex: '0' | 30 tabindex: '0', |
| 31 animated: true |
| 21 }, | 32 }, |
| 22 | 33 |
| 23 _calculateElevation: function() { | 34 _calculateElevation: function() { |
| 24 var e = 1; | 35 var e = 1; |
| 25 if (this.disabled) { | 36 if (this.disabled) { |
| 26 e = 0; | 37 e = 0; |
| 27 } else if (this.active || this.pressed) { | 38 } else if (this.active || this.pressed) { |
| 28 e = 4; | 39 e = 4; |
| 29 } else if (this.receivedFocusFromKeyboard) { | 40 } else if (this.receivedFocusFromKeyboard) { |
| 30 e = 3; | 41 e = 3; |
| 31 } | 42 } |
| 32 this._elevation = e; | 43 this._setElevation(e); |
| 44 }, |
| 45 |
| 46 _computeKeyboardClass: function(receivedFocusFromKeyboard) { |
| 47 this.classList.toggle('keyboard-focus', receivedFocusFromKeyboard); |
| 48 }, |
| 49 |
| 50 /** |
| 51 * In addition to `IronButtonState` behavior, when space key goes down, |
| 52 * create a ripple down effect. |
| 53 */ |
| 54 _spaceKeyDownHandler: function(event) { |
| 55 Polymer.IronButtonStateImpl._spaceKeyDownHandler.call(this, event); |
| 56 if (this.hasRipple()) { |
| 57 this._ripple.uiDownAction(); |
| 58 } |
| 59 }, |
| 60 |
| 61 /** |
| 62 * In addition to `IronButtonState` behavior, when space key goes up, |
| 63 * create a ripple up effect. |
| 64 */ |
| 65 _spaceKeyUpHandler: function(event) { |
| 66 Polymer.IronButtonStateImpl._spaceKeyUpHandler.call(this, event); |
| 67 if (this.hasRipple()) { |
| 68 this._ripple.uiUpAction(); |
| 69 } |
| 33 } | 70 } |
| 71 |
| 34 }; | 72 }; |
| 35 | 73 |
| 36 /** @polymerBehavior */ | 74 /** @polymerBehavior */ |
| 37 Polymer.PaperButtonBehavior = [ | 75 Polymer.PaperButtonBehavior = [ |
| 38 Polymer.IronButtonState, | 76 Polymer.IronButtonState, |
| 39 Polymer.IronControlState, | 77 Polymer.IronControlState, |
| 78 Polymer.PaperRippleBehavior, |
| 40 Polymer.PaperButtonBehaviorImpl | 79 Polymer.PaperButtonBehaviorImpl |
| 41 ]; | 80 ]; |
| 42 | |
| OLD | NEW |