added tests with paper-slider
This commit is contained in:
19
bower_components/core-range/.bower.json
vendored
Normal file
19
bower_components/core-range/.bower.json
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "core-range",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^0.5.0",
|
||||
"core-input": "Polymer/core-input#^0.5.0"
|
||||
},
|
||||
"version": "0.5.2",
|
||||
"homepage": "https://github.com/Polymer/core-range",
|
||||
"_release": "0.5.2",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "0.5.2",
|
||||
"commit": "e28dc17a46c09b68b9b0b8fc30c4ea71c5ce3444"
|
||||
},
|
||||
"_source": "git://github.com/Polymer/core-range.git",
|
||||
"_target": "^0.5.0",
|
||||
"_originalSource": "Polymer/core-range"
|
||||
}
|
||||
2
bower_components/core-range/README.md
vendored
Normal file
2
bower_components/core-range/README.md
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
core-range
|
||||
==========
|
||||
9
bower_components/core-range/bower.json
vendored
Normal file
9
bower_components/core-range/bower.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "core-range",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^0.5.0",
|
||||
"core-input": "Polymer/core-input#^0.5.0"
|
||||
},
|
||||
"version": "0.5.2"
|
||||
}
|
||||
108
bower_components/core-range/core-range.html
vendored
Normal file
108
bower_components/core-range/core-range.html
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<!--
|
||||
The `core-range` element is used for managing a numeric value within a given
|
||||
range. It has no visual appearance and is typically used in conjunction with
|
||||
another element.
|
||||
|
||||
One can build a progress bar using `core-range` like this:
|
||||
|
||||
<core-range min="0" max="200" value="100" ratio="{{ratio}}"></core-range>
|
||||
<div class="progress-bar" style="width: {{ratio}}%;"></div>
|
||||
|
||||
@group Polymer Core Elements
|
||||
@element core-range
|
||||
@homepage github.io
|
||||
|
||||
-->
|
||||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
|
||||
<polymer-element name="core-range" attributes="value min max step ratio">
|
||||
<script>
|
||||
|
||||
Polymer('core-range', {
|
||||
|
||||
/**
|
||||
* The number that represents the current value.
|
||||
*
|
||||
* @attribute value
|
||||
* @type number
|
||||
* @default 0
|
||||
*/
|
||||
value: 0,
|
||||
|
||||
/**
|
||||
* The number that indicates the minimum value of the range.
|
||||
*
|
||||
* @attribute min
|
||||
* @type number
|
||||
* @default 0
|
||||
*/
|
||||
min: 0,
|
||||
|
||||
/**
|
||||
* The number that indicates the maximum value of the range.
|
||||
*
|
||||
* @attribute max
|
||||
* @type number
|
||||
* @default 100
|
||||
*/
|
||||
max: 100,
|
||||
|
||||
/**
|
||||
* Specifies the value granularity of the range's value.
|
||||
*
|
||||
* @attribute step
|
||||
* @type number
|
||||
* @default 1
|
||||
*/
|
||||
step: 1,
|
||||
|
||||
/**
|
||||
* Returns the ratio of the value.
|
||||
*
|
||||
* @attribute ratio
|
||||
* @type number
|
||||
* @default 0
|
||||
*/
|
||||
ratio: 0,
|
||||
|
||||
observe: {
|
||||
'value min max step': 'update'
|
||||
},
|
||||
|
||||
calcRatio: function(value) {
|
||||
return (this.clampValue(value) - this.min) / (this.max - this.min);
|
||||
},
|
||||
|
||||
clampValue: function(value) {
|
||||
return Math.min(this.max, Math.max(this.min, this.calcStep(value)));
|
||||
},
|
||||
|
||||
calcStep: function(value) {
|
||||
return this.step ? (Math.round(value / this.step) / (1 / this.step)) : value;
|
||||
},
|
||||
|
||||
validateValue: function() {
|
||||
var v = this.clampValue(this.value);
|
||||
this.value = this.oldValue = isNaN(v) ? this.oldValue : v;
|
||||
return this.value !== v;
|
||||
},
|
||||
|
||||
update: function() {
|
||||
this.validateValue();
|
||||
this.ratio = this.calcRatio(this.value) * 100;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</polymer-element>
|
||||
74
bower_components/core-range/demo.html
vendored
Normal file
74
bower_components/core-range/demo.html
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>core-range</title>
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents.js"></script>
|
||||
|
||||
<link rel="import" href="core-range.html">
|
||||
<link rel="import" href="../core-input/core-input.html">
|
||||
|
||||
<style>
|
||||
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body unresolved>
|
||||
|
||||
<polymer-element name="x-progressbar" noscript attributes="value min max">
|
||||
|
||||
<template>
|
||||
|
||||
<style>
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
height: 40px;
|
||||
background-color: #555;
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
box-shadow: inset 0px 2px 5px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.progress {
|
||||
background-color: #999;
|
||||
height: 100%;
|
||||
border-radius: 4px;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
.progress-value {
|
||||
padding: 0 8px;
|
||||
font-size: 18px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<core-range min="{{min}}" max="{{max}}" value="{{value}}" ratio="{{ratio}}"></core-range>
|
||||
|
||||
<div class="progress" horizontal center layout _style="width: {{ratio}}%;">
|
||||
<div class="progress-value">{{ratio}}%</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
</polymer-element>
|
||||
|
||||
<x-progressbar min="0" max="200" value="120"></x-progressbar>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
22
bower_components/core-range/index.html
vendored
Normal file
22
bower_components/core-range/index.html
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents.js"></script>
|
||||
<link rel="import" href="../core-component-page/core-component-page.html">
|
||||
|
||||
</head>
|
||||
<body unresolved>
|
||||
|
||||
<core-component-page></core-component-page>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
103
bower_components/core-range/test/basic.html
vendored
Normal file
103
bower_components/core-range/test/basic.html
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>core-range-basic</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
|
||||
<link rel="import" href="../core-range.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<core-range></core-range>
|
||||
|
||||
<script>
|
||||
|
||||
var range = document.querySelector('core-range');
|
||||
|
||||
suite('basic', function() {
|
||||
|
||||
test('check default', function() {
|
||||
assert.equal(range.min, 0);
|
||||
assert.equal(range.max, 100);
|
||||
assert.equal(range.value, 0);
|
||||
});
|
||||
|
||||
test('set value', function(done) {
|
||||
range.value = 50;
|
||||
asyncPlatformFlush(function() {
|
||||
assert.equal(range.value, 50);
|
||||
// test clamp value
|
||||
range.value = 60.1;
|
||||
asyncPlatformFlush(function() {
|
||||
assert.equal(range.value, 60);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('set max', function(done) {
|
||||
range.max = 10;
|
||||
range.value = 11;
|
||||
asyncPlatformFlush(function() {
|
||||
assert.equal(range.value, range.max);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test ratio', function(done) {
|
||||
range.max = 10;
|
||||
range.value = 5;
|
||||
asyncPlatformFlush(function() {
|
||||
assert.equal(range.ratio, 50);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('set min', function(done) {
|
||||
range.min = 10
|
||||
range.max = 50;
|
||||
range.value = 30;
|
||||
asyncPlatformFlush(function() {
|
||||
assert.equal(range.ratio, 50);
|
||||
range.value = 0;
|
||||
asyncPlatformFlush(function() {
|
||||
assert.equal(range.value, range.min);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('set step', function(done) {
|
||||
range.min = 0;
|
||||
range.max = 10;
|
||||
range.value = 5.1;
|
||||
asyncPlatformFlush(function() {
|
||||
assert.equal(range.value, 5);
|
||||
range.step = 0.1;
|
||||
range.value = 5.1;
|
||||
asyncPlatformFlush(function() {
|
||||
assert.equal(range.value, 5.1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
24
bower_components/core-range/test/index.html
vendored
Normal file
24
bower_components/core-range/test/index.html
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
||||
<title>Tests</title>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
WCT.loadSuites([
|
||||
'basic.html'
|
||||
]);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user