Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-behaviors/paper-ripple-behavior-extracted.js

Issue 1410143002: Update Polymer to fix closure compile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iron-list5
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * `Polymer.PaperRippleBehavior` dynamically implements a ripple 2 * `Polymer.PaperRippleBehavior` dynamically implements a ripple
3 * when the element has focus via pointer or keyboard. 3 * when the element has focus via pointer or keyboard.
4 * 4 *
5 * NOTE: This behavior is intended to be used in conjunction with and after 5 * NOTE: This behavior is intended to be used in conjunction with and after
6 * `Polymer.IronButtonState` and `Polymer.IronControlState`. 6 * `Polymer.IronButtonState` and `Polymer.IronControlState`.
7 * 7 *
8 * @polymerBehavior Polymer.PaperRippleBehavior 8 * @polymerBehavior Polymer.PaperRippleBehavior
9 */ 9 */
10 Polymer.PaperRippleBehavior = { 10 Polymer.PaperRippleBehavior = {
11 11
12 properties: { 12 properties: {
13 /** 13 /**
14 * If true, the element will not produce a ripple effect when interacted 14 * If true, the element will not produce a ripple effect when interacted
15 * with via the pointer. 15 * with via the pointer.
16 */ 16 */
17 noink: { 17 noink: {
18 type: Boolean, 18 type: Boolean,
19 observer: '_noinkChanged' 19 observer: '_noinkChanged'
20 },
21
22 /**
23 * @type {Element|undefined}
24 */
25 _rippleContainer: {
26 type: Object,
20 } 27 }
21 }, 28 },
22 29
23 /** 30 /**
24 * Ensures a `<paper-ripple>` element is available when the element is 31 * Ensures a `<paper-ripple>` element is available when the element is
25 * focused. 32 * focused.
26 */ 33 */
27 _buttonStateChanged: function() { 34 _buttonStateChanged: function() {
28 if (this.focused) { 35 if (this.focused) {
29 this.ensureRipple(); 36 this.ensureRipple();
30 } 37 }
31 }, 38 },
32 39
33 /** 40 /**
34 * In addition to the functionality provided in `IronButtonState`, ensures 41 * In addition to the functionality provided in `IronButtonState`, ensures
35 * a ripple effect is created when the element is in a `pressed` state. 42 * a ripple effect is created when the element is in a `pressed` state.
36 */ 43 */
37 _downHandler: function(event) { 44 _downHandler: function(event) {
38 Polymer.IronButtonStateImpl._downHandler.call(this, event); 45 Polymer.IronButtonStateImpl._downHandler.call(this, event);
39 if (this.pressed) { 46 if (this.pressed) {
40 this.ensureRipple(event); 47 this.ensureRipple(event);
41 } 48 }
42 }, 49 },
43 50
44 /** 51 /**
45 * Ensures this element contains a ripple effect. For startup efficiency 52 * Ensures this element contains a ripple effect. For startup efficiency
46 * the ripple effect is dynamically on demand when needed. 53 * the ripple effect is dynamically on demand when needed.
47 * @param {!Event=} opt_triggeringEvent (optional) event that triggered the 54 * @param {!Event=} opt_triggeringEvent (optional) event that triggered the
48 * ripple. 55 * ripple.
49 */ 56 */
50 ensureRipple: function(opt_triggeringEvent) { 57 ensureRipple: function(opt_triggeringEvent) {
51 if (!this.hasRipple()) { 58 if (!this.hasRipple()) {
52 this._ripple = this._createRipple(); 59 this._ripple = this._createRipple();
53 this._ripple.noink = this.noink; 60 this._ripple.noink = this.noink;
54 var rippleContainer = this._rippleContainer || this.root; 61 var rippleContainer = this._rippleContainer || this.root;
55 if (rippleContainer) { 62 if (rippleContainer) {
56 Polymer.dom(rippleContainer).appendChild(this._ripple); 63 Polymer.dom(rippleContainer).appendChild(this._ripple);
57 } 64 }
58 var domContainer = rippleContainer === this.shadyRoot ? this : 65 var domContainer = rippleContainer === this.shadyRoot ? this :
59 rippleContainer; 66 rippleContainer;
60 if (opt_triggeringEvent && 67 if (opt_triggeringEvent) {
61 domContainer.contains(opt_triggeringEvent.target)) { 68 var target = opt_triggeringEvent.target;
62 this._ripple.uiDownAction(opt_triggeringEvent); 69 if (domContainer.contains(/** @type {Node} */(target))) {
70 this._ripple.uiDownAction(opt_triggeringEvent);
71 }
63 } 72 }
64 } 73 }
65 }, 74 },
66 75
67 /** 76 /**
68 * Returns the `<paper-ripple>` element used by this element to create 77 * Returns the `<paper-ripple>` element used by this element to create
69 * ripple effects. The element's ripple is created on demand, when 78 * ripple effects. The element's ripple is created on demand, when
70 * necessary, and calling this method will force the 79 * necessary, and calling this method will force the
71 * ripple to be created. 80 * ripple to be created.
72 */ 81 */
73 getRipple: function() { 82 getRipple: function() {
74 this.ensureRipple(); 83 this.ensureRipple();
75 return this._ripple; 84 return this._ripple;
76 }, 85 },
77 86
78 /** 87 /**
79 * Returns true if this element currently contains a ripple effect. 88 * Returns true if this element currently contains a ripple effect.
80 * @return {boolean} 89 * @return {boolean}
81 */ 90 */
82 hasRipple: function() { 91 hasRipple: function() {
83 return Boolean(this._ripple); 92 return Boolean(this._ripple);
84 }, 93 },
85 94
86 /** 95 /**
87 * Create the element's ripple effect via creating a `<paper-ripple>`. 96 * Create the element's ripple effect via creating a `<paper-ripple>`.
88 * Override this method to customize the ripple element. 97 * Override this method to customize the ripple element.
89 * @return {element} Returns a `<paper-ripple>` element. 98 * @return {!PaperRippleElement} Returns a `<paper-ripple>` element.
90 */ 99 */
91 _createRipple: function() { 100 _createRipple: function() {
92 return document.createElement('paper-ripple'); 101 return /** @type {!PaperRippleElement} */ (
102 document.createElement('paper-ripple'));
93 }, 103 },
94 104
95 _noinkChanged: function(noink) { 105 _noinkChanged: function(noink) {
96 if (this.hasRipple()) { 106 if (this.hasRipple()) {
97 this._ripple.noink = noink; 107 this._ripple.noink = noink;
98 } 108 }
99 } 109 }
100 110
101 }; 111 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698