Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / third_party / polymer / components / core-range / core-range.html
blobe16993c91b33b99dc0a12176c3e2fbb7180d0ea6
1 <!--
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
8 -->
10 <!--
11 The `core-range` element is used for managing a numeric value within a given
12 range. It has no visual appearance and is typically used in conjunction with
13 another element.
15 One can build a progress bar using `core-range` like this:
17 <core-range min="0" max="200" value="100" ratio="{{ratio}}"></core-range>
18 <div class="progress-bar" style="width: {{ratio}}%;"></div>
20 @group Polymer Core Elements
21 @element core-range
22 @homepage github.io
24 -->
26 <link rel="import" href="../polymer/polymer.html">
28 <polymer-element name="core-range" attributes="value min max step ratio">
29 <script>
31 Polymer('core-range', {
33 /**
34 * The number that represents the current value.
36 * @attribute value
37 * @type number
38 * @default 0
40 value: 0,
42 /**
43 * The number that indicates the minimum value of the range.
45 * @attribute min
46 * @type number
47 * @default 0
49 min: 0,
51 /**
52 * The number that indicates the maximum value of the range.
54 * @attribute max
55 * @type number
56 * @default 100
58 max: 100,
60 /**
61 * Specifies the value granularity of the range's value.
63 * @attribute step
64 * @type number
65 * @default 1
67 step: 1,
69 /**
70 * Returns the ratio of the value.
72 * @attribute ratio
73 * @type number
74 * @default 0
76 ratio: 0,
78 observe: {
79 'value min max step': 'update'
82 calcRatio: function(value) {
83 return (this.clampValue(value) - this.min) / (this.max - this.min);
86 clampValue: function(value) {
87 return Math.min(this.max, Math.max(this.min, this.calcStep(value)));
90 calcStep: function(value) {
91 return this.step ? (Math.round(value / this.step) / (1 / this.step)) : value;
94 validateValue: function() {
95 var v = this.clampValue(this.value);
96 this.value = this.oldValue = isNaN(v) ? this.oldValue : v;
97 return this.value !== v;
100 update: function() {
101 this.validateValue();
102 this.ratio = this.calcRatio(this.value) * 100;
107 </script>
108 </polymer-element>