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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js

Issue 1401633002: Update Polymer from 1.1.4 -> 1.1.5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dzhioev@ review 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 Polymer({
2
3 Polymer({
4 is: 'paper-slider', 2 is: 'paper-slider',
5 3
6 behaviors: [ 4 behaviors: [
7 Polymer.IronFormElementBehavior, 5 Polymer.IronFormElementBehavior,
8 Polymer.PaperInkyFocusBehavior, 6 Polymer.PaperInkyFocusBehavior,
9 Polymer.IronRangeBehavior 7 Polymer.IronRangeBehavior
10 ], 8 ],
11 9
12 properties: { 10 properties: {
13 11
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 95
98 markers: { 96 markers: {
99 type: Array, 97 type: Array,
100 readOnly: true, 98 readOnly: true,
101 value: [] 99 value: []
102 }, 100 },
103 }, 101 },
104 102
105 observers: [ 103 observers: [
106 '_updateKnob(value, min, max, snaps, step)', 104 '_updateKnob(value, min, max, snaps, step)',
107 '_minChanged(min)',
108 '_maxChanged(max)',
109 '_valueChanged(value)', 105 '_valueChanged(value)',
110 '_immediateValueChanged(immediateValue)' 106 '_immediateValueChanged(immediateValue)'
111 ], 107 ],
112 108
113 hostAttributes: { 109 hostAttributes: {
114 role: 'slider', 110 role: 'slider',
115 tabindex: 0 111 tabindex: 0
116 }, 112 },
117 113
118 keyBindings: { 114 keyBindings: {
119 'left down pagedown home': '_decrementKey', 115 'left down pagedown home': '_decrementKey',
120 'right up pageup end': '_incrementKey' 116 'right up pageup end': '_incrementKey'
121 }, 117 },
122 118
123 ready: function() { 119 ready: function() {
124 // issue polymer/polymer#1305 120 // issue polymer/polymer#1305
125
126 this.async(function() { 121 this.async(function() {
127 this._updateKnob(this.value); 122 this._updateKnob(this.value);
128 }, 1); 123 }, 1);
129 }, 124 },
130 125
131 /** 126 /**
132 * Increases value by `step` but not above `max`. 127 * Increases value by `step` but not above `max`.
133 * @method increment 128 * @method increment
134 */ 129 */
135 increment: function() { 130 increment: function() {
136 this.value = this._clampValue(this.value + this.step); 131 this.value = this._clampValue(this.value + this.step);
137 }, 132 },
138 133
139 /** 134 /**
140 * Decreases value by `step` but not below `min`. 135 * Decreases value by `step` but not below `min`.
141 * @method decrement 136 * @method decrement
142 */ 137 */
143 decrement: function() { 138 decrement: function() {
144 this.value = this._clampValue(this.value - this.step); 139 this.value = this._clampValue(this.value - this.step);
145 }, 140 },
146 141
147 _updateKnob: function(value) { 142 _updateKnob: function(value, min, max, snaps, step) {
143 this.setAttribute('aria-valuemin', min);
144 this.setAttribute('aria-valuemax', max);
145 this.setAttribute('aria-valuenow', value);
146
148 this._positionKnob(this._calcRatio(value)); 147 this._positionKnob(this._calcRatio(value));
149 }, 148 },
150 149
151 _minChanged: function() {
152 this.setAttribute('aria-valuemin', this.min);
153 },
154
155 _maxChanged: function() {
156 this.setAttribute('aria-valuemax', this.max);
157 },
158
159 _valueChanged: function() { 150 _valueChanged: function() {
160 this.setAttribute('aria-valuenow', this.value);
161 this.fire('value-change'); 151 this.fire('value-change');
162 }, 152 },
163 153
164 _immediateValueChanged: function() { 154 _immediateValueChanged: function() {
165 if (this.dragging) { 155 if (this.dragging) {
166 this.fire('immediate-value-change'); 156 this.fire('immediate-value-change');
167 } else { 157 } else {
168 this.value = this.immediateValue; 158 this.value = this.immediateValue;
169 } 159 }
170 }, 160 },
171 161
172 _secondaryProgressChanged: function() { 162 _secondaryProgressChanged: function() {
173 this.secondaryProgress = this._clampValue(this.secondaryProgress); 163 this.secondaryProgress = this._clampValue(this.secondaryProgress);
174 }, 164 },
175 165
176 _fixForInput: function(immediateValue) {
177 // paper-input/issues/114
178 return this.immediateValue.toString();
179 },
180
181 _expandKnob: function() { 166 _expandKnob: function() {
182 this._setExpand(true); 167 this._setExpand(true);
183 }, 168 },
184 169
185 _resetKnob: function() { 170 _resetKnob: function() {
186 this.cancelDebouncer('expandKnob'); 171 this.cancelDebouncer('expandKnob');
187 this._setExpand(false); 172 this._setExpand(false);
188 }, 173 },
189 174
190 _positionKnob: function(ratio) { 175 _positionKnob: function(ratio) {
191 this._setImmediateValue(this._calcStep(this._calcKnobPosition(ratio))); 176 this._setImmediateValue(this._calcStep(this._calcKnobPosition(ratio)));
192 this._setRatio(this._calcRatio(this.immediateValue)); 177 this._setRatio(this._calcRatio(this.immediateValue));
193 178
194 this.$.sliderKnob.style.left = (this.ratio * 100) + '%'; 179 this.$.sliderKnob.style.left = (this.ratio * 100) + '%';
195 }, 180 },
196 181
197 _inputChange: function() {
198 this.value = this.$$('#input').value;
199 this.fire('change');
200 },
201
202 _calcKnobPosition: function(ratio) { 182 _calcKnobPosition: function(ratio) {
203 return (this.max - this.min) * ratio + this.min; 183 return (this.max - this.min) * ratio + this.min;
204 }, 184 },
205 185
206 _onTrack: function(event) { 186 _onTrack: function(event) {
207 event.stopPropagation(); 187 event.stopPropagation();
208 switch (event.detail.state) { 188 switch (event.detail.state) {
209 case 'start': 189 case 'start':
210 this._trackStart(event); 190 this._trackStart(event);
211 break; 191 break;
212 case 'track': 192 case 'track':
213 this._trackX(event); 193 this._trackX(event);
214 break; 194 break;
215 case 'end': 195 case 'end':
216 this._trackEnd(); 196 this._trackEnd();
217 break; 197 break;
218 } 198 }
219 }, 199 },
220 200
221 _trackStart: function(event) { 201 _trackStart: function(event) {
222 this._w = this.$.sliderBar.offsetWidth; 202 this._w = this.$.sliderBar.offsetWidth;
223 this._x = this.ratio * this._w; 203 this._x = this.ratio * this._w;
224 this._startx = this._x || 0; 204 this._startx = this._x || 0;
225 this._minx = - this._startx; 205 this._minx = - this._startx;
226 this._maxx = this._w - this._startx; 206 this._maxx = this._w - this._startx;
227 this.$.sliderKnob.classList.add('dragging'); 207 this.$.sliderKnob.classList.add('dragging');
228
229 this._setDragging(true); 208 this._setDragging(true);
230 }, 209 },
231 210
232 _trackX: function(e) { 211 _trackX: function(e) {
233 if (!this.dragging) { 212 if (!this.dragging) {
234 this._trackStart(e); 213 this._trackStart(e);
235 } 214 }
236 215
237 var dx = Math.min(this._maxx, Math.max(this._minx, e.detail.dx)); 216 var dx = Math.min(this._maxx, Math.max(this._minx, e.detail.dx));
238 this._x = this._startx + dx; 217 this._x = this._startx + dx;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 snaps: this.snaps, 304 snaps: this.snaps,
326 ring: this.immediateValue <= this.min, 305 ring: this.immediateValue <= this.min,
327 expand: this.expand, 306 expand: this.expand,
328 dragging: this.dragging, 307 dragging: this.dragging,
329 transiting: this.transiting, 308 transiting: this.transiting,
330 editable: this.editable 309 editable: this.editable
331 }); 310 });
332 }, 311 },
333 312
334 _incrementKey: function(event) { 313 _incrementKey: function(event) {
335 if (event.detail.key === 'end') { 314 if (!this.disabled) {
336 this.value = this.max; 315 if (event.detail.key === 'end') {
337 } else { 316 this.value = this.max;
338 this.increment(); 317 } else {
318 this.increment();
319 }
320 this.fire('change');
339 } 321 }
322 },
323
324 _decrementKey: function(event) {
325 if (!this.disabled) {
326 if (event.detail.key === 'home') {
327 this.value = this.min;
328 } else {
329 this.decrement();
330 }
331 this.fire('change');
332 }
333 },
334
335 _changeValue: function(event) {
336 this.value = event.target.value;
340 this.fire('change'); 337 this.fire('change');
341 }, 338 },
342 339
343 _decrementKey: function(event) { 340 _inputKeyDown: function(event) {
344 if (event.detail.key === 'home') { 341 event.stopPropagation();
345 this.value = this.min; 342 },
346 } else { 343
347 this.decrement(); 344 // create the element ripple inside the `sliderKnob`
345 _createRipple: function() {
346 this._rippleContainer = this.$.sliderKnob;
347 return Polymer.PaperInkyFocusBehaviorImpl._createRipple.call(this);
348 },
349
350 // Hide the ripple when user is not interacting with keyboard.
351 // This behavior is different from other ripple-y controls, but is
352 // according to spec: https://www.google.com/design/spec/components/sliders. html
353 _focusedChanged: function(receivedFocusFromKeyboard) {
354 if (receivedFocusFromKeyboard) {
355 this.ensureRipple();
348 } 356 }
349 this.fire('change'); 357 if (this.hasRipple()) {
358 // note, ripple must be un-hidden prior to setting `holdDown`
359 if (receivedFocusFromKeyboard) {
360 this._ripple.removeAttribute('hidden');
361 } else {
362 this._ripple.setAttribute('hidden', '');
363 }
364 this._ripple.holdDown = receivedFocusFromKeyboard;
365 }
350 } 366 }
367
351 }); 368 });
352 369
353 /** 370 /**
354 * Fired when the slider's value changes. 371 * Fired when the slider's value changes.
355 * 372 *
356 * @event value-change 373 * @event value-change
357 */ 374 */
358 375
359 /** 376 /**
360 * Fired when the slider's immediateValue changes. 377 * Fired when the slider's immediateValue changes.
361 * 378 *
362 * @event immediate-value-change 379 * @event immediate-value-change
363 */ 380 */
364 381
365 /** 382 /**
366 * Fired when the slider's value changes due to user interaction. 383 * Fired when the slider's value changes due to user interaction.
367 * 384 *
368 * Changes to the slider's value due to changes in an underlying 385 * Changes to the slider's value due to changes in an underlying
369 * bound variable will not trigger this event. 386 * bound variable will not trigger this event.
370 * 387 *
371 * @event change 388 * @event change
372 */ 389 */
373
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698