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

Side by Side Diff: third_party/polymer/components-chromium/core-range/core-range-extracted.js

Issue 592593002: Inline scripts were extracted from Polymer elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/echo ""/echo/ Created 6 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
(Empty)
1
2
3 Polymer('core-range', {
4
5 /**
6 * The number that represents the current value.
7 *
8 * @attribute value
9 * @type number
10 * @default 0
11 */
12 value: 0,
13
14 /**
15 * The number that indicates the minimum value of the range.
16 *
17 * @attribute min
18 * @type number
19 * @default 0
20 */
21 min: 0,
22
23 /**
24 * The number that indicates the maximum value of the range.
25 *
26 * @attribute max
27 * @type number
28 * @default 100
29 */
30 max: 100,
31
32 /**
33 * Specifies the value granularity of the range's value.
34 *
35 * @attribute step
36 * @type number
37 * @default 1
38 */
39 step: 1,
40
41 /**
42 * Returns the ratio of the value.
43 *
44 * @attribute ratio
45 * @type number
46 * @default 0
47 */
48 ratio: 0,
49
50 observe: {
51 'value min max step': 'update'
52 },
53
54 calcRatio: function(value) {
55 return (this.clampValue(value) - this.min) / (this.max - this.min);
56 },
57
58 clampValue: function(value) {
59 return Math.min(this.max, Math.max(this.min, this.calcStep(value)));
60 },
61
62 calcStep: function(value) {
63 return this.step ? (Math.round(value / this.step) / (1 / this.step)) : val ue;
64 },
65
66 validateValue: function() {
67 var v = this.clampValue(this.value);
68 this.value = this.oldValue = isNaN(v) ? this.oldValue : v;
69 return this.value !== v;
70 },
71
72 update: function() {
73 this.validateValue();
74 this.ratio = this.calcRatio(this.value) * 100;
75 }
76
77 });
78
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698