1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

remove paper-textarea

This commit is contained in:
Luke Pulverenti 2016-08-21 13:38:10 -04:00
parent d8c4154947
commit 4848adf508
79 changed files with 10 additions and 7062 deletions

View file

@ -1,48 +0,0 @@
{
"name": "iron-autogrow-textarea",
"version": "1.0.13",
"description": "A textarea element that automatically grows with input",
"authors": [
"The Polymer Authors"
],
"keywords": [
"web-components",
"polymer",
"input",
"textarea"
],
"main": "iron-autogrow-textarea.html",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/iron-autogrow-textarea.git"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/iron-autogrow-textarea",
"ignore": [],
"dependencies": {
"iron-behaviors": "PolymerElements/iron-behaviors#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0",
"iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#^1.0.0",
"polymer": "Polymer/polymer#^1.1.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"_release": "1.0.13",
"_resolution": {
"type": "version",
"tag": "v1.0.13",
"commit": "399cfdbb3fac0c7b61d14a8cf8402c0195b0ff04"
},
"_source": "git://github.com/PolymerElements/iron-autogrow-textarea.git",
"_target": "^1.0.0",
"_originalSource": "PolymerElements/iron-autogrow-textarea"
}

View file

@ -1,33 +0,0 @@
<!-- Instructions: https://github.com/PolymerElements/iron-autogrow-textarea/CONTRIBUTING.md#filing-issues -->
### Description
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
### Expected outcome
<!-- Example: The page stays the same color. -->
### Actual outcome
<!-- Example: The page turns pink. -->
### Live Demo
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
### Steps to reproduce
<!-- Example
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
-->
### Browsers Affected
<!-- Check all that apply -->
- [ ] Chrome
- [ ] Firefox
- [ ] Safari 9
- [ ] Safari 8
- [ ] Safari 7
- [ ] Edge
- [ ] IE 11
- [ ] IE 10

View file

@ -1 +0,0 @@
bower_components

View file

@ -1,23 +0,0 @@
language: node_js
sudo: required
before_script:
- npm install -g bower polylint web-component-tester
- bower install
- polylint
env:
global:
- secure: TqFz1Cdu4BtLCHYLFPES0q+6wPfCnj9bnTfven9LIU+gtek70FPDT3UlnviNwp5ob3o0sbLgsLWG5OkCsRHli+HCgPEVDazSrghfwaT9mL+h/DlM/PVB079VDdIKvZM6L7xEF0zPv7t26kljBRQcZJ81O3K7h1mNjeBj6sDXHzE=
- secure: ihYM52Uu3H7FGU+x+f+hzMcWt00B7l6GZOtxzT1xYx4hb4E9/WwXYR5z9bqN+s5p10yf3FG64zbmMTuJeBvknDpSyBt/vKP+QBBZT0hxv05GifS38hiSoYT3HBxEpwhYdpjlsSJtIbKfYGR3xIXutRzRrRKSYigcrQNX83MGWFY=
node_js: stable
addons:
firefox: '46.0'
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
sauce_connect: true
script:
- xvfb-run wct
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'default'; fi
dist: trusty

View file

@ -1,77 +0,0 @@
<!--
This file is autogenerated based on
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
If you edit that file, it will get updated everywhere else.
If you edit this file, your changes will get overridden :)
You can however override the jsbin link with one that's customized to this
specific element:
jsbin=https://jsbin.com/cagaye/edit?html,output
-->
# Polymer Elements
## Guide for Contributors
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
### Filing Issues
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
1. **Who will use the feature?** _“As someone filling out a form…”_
2. **When will they use the feature?** _“When I enter an invalid value…”_
3. **What is the users goal?** _“I want to be visually notified that the value needs to be corrected…”_
**If you are filing an issue to report a bug**, please provide:
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
```markdown
The `paper-foo` element causes the page to turn pink when clicked.
## Expected outcome
The page stays the same color.
## Actual outcome
The page turns pink.
## Steps to reproduce
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
```
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
### Submitting Pull Requests
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
When submitting pull requests, please provide:
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
```markdown
(For a single issue)
Fixes #20
(For multiple issues)
Fixes #32, fixes #40
```
2. **A succinct description of the design** used to fix any related issues. For example:
```markdown
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
```
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so dont be afraid to ask us if you need help with that!

View file

@ -1,39 +0,0 @@
{
"name": "iron-autogrow-textarea",
"version": "1.0.13",
"description": "A textarea element that automatically grows with input",
"authors": [
"The Polymer Authors"
],
"keywords": [
"web-components",
"polymer",
"input",
"textarea"
],
"main": "iron-autogrow-textarea.html",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/iron-autogrow-textarea.git"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/iron-autogrow-textarea",
"ignore": [],
"dependencies": {
"iron-behaviors": "PolymerElements/iron-behaviors#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0",
"iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#^1.0.0",
"polymer": "Polymer/polymer#^1.1.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}
}

View file

@ -1,111 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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 http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>iron-autogrow-textarea demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
<link rel="import" href="../iron-autogrow-textarea.html">
<style is="custom-style" include="demo-pages-shared-styles">
iron-autogrow-textarea {
display: block;
width: 200px;
margin: 5px 0;
}
textarea {
width: 200px;
}
.vertical-section {
box-sizing: border-box;
width: 400px;
margin: 0;
}
</style>
</head>
<body unresolved>
<div class="vertical-section-container centered">
<h3>An iron-autogrow-textarea grows automatically as more text is entered</h3>
<demo-snippet class="centered-demo">
<template>
<iron-autogrow-textarea></iron-autogrow-textarea>
</template>
</demo-snippet>
<h3>The maximum height can be controlled either through the <i>max-rows</i>
property, or through a fixed max height</h3>
<demo-snippet class="centered-demo">
<template>
<iron-autogrow-textarea max-rows="4" placeholder="scrolls after 4 rows"></iron-autogrow-textarea>
<iron-autogrow-textarea style="max-height: 50px;" placeholder="scrolls after 50px"></iron-autogrow-textarea>
</template>
</demo-snippet>
<h3>The initial height can also be controlled using the <i>rows</i> property,
or through a fixed height</h3>
<demo-snippet class="centered-demo">
<template>
<iron-autogrow-textarea rows="4" placeholder="start with 4 rows"></iron-autogrow-textarea>
<iron-autogrow-textarea style="height: 50px;"></iron-autogrow-textarea>
</template>
</demo-snippet>
<h3>Example of updating the value imperatively</h3>
<!-- TODO: replace this with a demo-snippet when https://github.com/webcomponents/webcomponentsjs/issues/362
is fixed -->
<div class="example">
<template is="dom-bind">
<div class="vertical-section">
<iron-autogrow-textarea bind-value="{{bindValue}}" id="a1"></iron-autogrow-textarea>
<br>
<code>bind-value</code>: <span>[[bindValue]]</span>
<p on-click="setValue">
Imperatively changing <code>bind-value</code> will also update
<code>textarea.value</code>:<br>
<textarea></textarea>
<button value="bindValue">set</button>
<br><br>
Imperatively updating <code>textarea.value</code> will update
the display, but not update <code>bind-value</code>:<br>
<textarea></textarea>
<button value="value">set</button>
</p>
</div>
</template>
</div>
</div>
<script>
var scope = document.querySelector('template[is=dom-bind]');
scope.setValue = function(event) {
if (!(event.target instanceof HTMLButtonElement)) {
return;
}
var inputValue = event.target.previousElementSibling.value;
if (event.target.value == "bindValue") {
document.querySelector('#a1').bindValue = inputValue;
} else {
document.querySelector('#a1').textarea.value = inputValue;
}
}
</script>
</body>
</html>

View file

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
<g id="background" display="none">
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
</g>
<g id="label">
</g>
<g id="art">
<path d="M140,47c-3,0-4.7-2.4-6.2-4.4c-1.3-1.9-2.4-3.6-4.7-3.6c-2.3,0-3.4,1.7-4.7,3.6c-1.5,2.1-3.1,4.4-6.4,4.4
c-3.3,0-4.9-2.4-6.4-4.4c-1.3-1.9-2.5-3.6-4.8-3.6c-2.3,0-3.4,1.7-4.8,3.6c-1.5,2.1-3.1,4.4-6.4,4.4s-5.2-2.4-6.7-4.4
c-1.3-1.9-2-3.6-5-3.6v-2c4,0,5.2,2.4,6.7,4.4c1.3,1.9,2.6,3.6,4.9,3.6c2.3,0,3.5-1.7,4.8-3.6c1.5-2.1,3.1-4.4,6.5-4.4
s5,2.4,6.4,4.4c1.3,1.9,2.5,3.6,4.8,3.6c2.3,0,3.4-1.7,4.8-3.6c1.5-2.1,3.1-4.4,6.4-4.4c3.3,0,4.7,2.4,6.2,4.4
c1.3,1.9,2.5,3.6,4.5,3.6V47z"/>
<path d="M140,65c-3,0-4.7-2.4-6.2-4.4c-1.3-1.9-2.4-3.6-4.7-3.6c-2.3,0-3.4,1.7-4.7,3.6c-1.5,2.1-3.1,4.4-6.4,4.4
c-3.3,0-4.9-2.4-6.4-4.4c-1.3-1.9-2.5-3.6-4.8-3.6c-2.3,0-3.4,1.7-4.8,3.6c-1.5,2.1-3.1,4.4-6.4,4.4s-5.2-2.4-6.7-4.4
c-1.3-1.9-2-3.6-5-3.6v-2c4,0,5.2,2.4,6.7,4.4c1.3,1.9,2.6,3.6,4.9,3.6c2.3,0,3.5-1.7,4.8-3.6c1.5-2.1,3.1-4.4,6.5-4.4
s5,2.4,6.4,4.4c1.3,1.9,2.5,3.6,4.8,3.6c2.3,0,3.4-1.7,4.8-3.6c1.5-2.1,3.1-4.4,6.4-4.4c3.3,0,4.7,2.4,6.2,4.4
c1.3,1.9,2.5,3.6,4.5,3.6V65z"/>
<path d="M140,83c-3,0-4.7-2.4-6.2-4.4c-1.3-1.9-2.4-3.6-4.7-3.6c-2.3,0-3.4,1.7-4.7,3.6c-1.5,2.1-3.1,4.4-6.4,4.4
c-3.3,0-4.9-2.4-6.4-4.4c-1.3-1.9-2.5-3.6-4.8-3.6c-2.3,0-3.4,1.7-4.8,3.6c-1.5,2.1-3.1,4.4-6.4,4.4s-5.2-2.4-6.7-4.4
c-1.3-1.9-2-3.6-5-3.6v-2c4,0,5.2,2.4,6.7,4.4c1.3,1.9,2.6,3.6,4.9,3.6c2.3,0,3.5-1.7,4.8-3.6c1.5-2.1,3.1-4.4,6.5-4.4
s5,2.4,6.4,4.4c1.3,1.9,2.5,3.6,4.8,3.6c2.3,0,3.4-1.7,4.8-3.6c1.5-2.1,3.1-4.4,6.4-4.4c3.3,0,4.7,2.4,6.2,4.4
c1.3,1.9,2.5,3.6,4.5,3.6V83z"/>
<g id="ic_x5F_add_x0D_">
</g>
<path d="M151,102H73V24h78V102z M75,100h74V26H75V100z"/>
</g>
<g id="Guides">
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -1,30 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>iron-autogrow-textarea</title>
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
<iron-component-page></iron-component-page>
</body>
</html>

View file

@ -1,353 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-behaviors/iron-control-state.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../iron-validatable-behavior/iron-validatable-behavior.html">
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
<!--
`iron-autogrow-textarea` is an element containing a textarea that grows in height as more
lines of input are entered. Unless an explicit height or the `maxRows` property is set, it will
never scroll.
Example:
<iron-autogrow-textarea></iron-autogrow-textarea>
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--iron-autogrow-textarea` | Mixin applied to the textarea | `{}`
`--iron-autogrow-textarea-placeholder` | Mixin applied to the textarea placeholder | `{}`
@group Iron Elements
@hero hero.svg
@demo demo/index.html
-->
<dom-module id="iron-autogrow-textarea">
<template>
<style>
:host {
display: inline-block;
position: relative;
width: 400px;
border: 1px solid;
padding: 2px;
-moz-appearance: textarea;
-webkit-appearance: textarea;
overflow: hidden;
}
.mirror-text {
visibility: hidden;
word-wrap: break-word;
}
.fit {
@apply(--layout-fit);
}
textarea {
position: relative;
outline: none;
border: none;
resize: none;
background: inherit;
color: inherit;
/* see comments in template */
width: 100%;
height: 100%;
font-size: inherit;
font-family: inherit;
line-height: inherit;
text-align: inherit;
@apply(--iron-autogrow-textarea);
}
::content textarea:invalid {
box-shadow: none;
}
textarea::-webkit-input-placeholder {
@apply(--iron-autogrow-textarea-placeholder);
}
textarea:-moz-placeholder {
@apply(--iron-autogrow-textarea-placeholder);
}
textarea::-moz-placeholder {
@apply(--iron-autogrow-textarea-placeholder);
}
textarea:-ms-input-placeholder {
@apply(--iron-autogrow-textarea-placeholder);
}
</style>
<!-- the mirror sizes the input/textarea so it grows with typing -->
<!-- use &#160; instead &nbsp; of to allow this element to be used in XHTML -->
<div id="mirror" class="mirror-text" aria-hidden="true">&#160;</div>
<!-- size the input/textarea with a div, because the textarea has intrinsic size in ff -->
<div class="textarea-container fit">
<textarea id="textarea"
name$="[[name]]"
autocomplete$="[[autocomplete]]"
autofocus$="[[autofocus]]"
inputmode$="[[inputmode]]"
placeholder$="[[placeholder]]"
readonly$="[[readonly]]"
required$="[[required]]"
disabled$="[[disabled]]"
rows$="[[rows]]"
maxlength$="[[maxlength]]"></textarea>
</div>
</template>
</dom-module>
<script>
Polymer({
is: 'iron-autogrow-textarea',
behaviors: [
Polymer.IronFormElementBehavior,
Polymer.IronValidatableBehavior,
Polymer.IronControlState
],
properties: {
/**
* Use this property instead of `value` for two-way data binding.
* This property will be deprecated in the future. Use `value` instead.
* @type {string|number}
*/
bindValue: {
observer: '_bindValueChanged',
type: String
},
/**
* The initial number of rows.
*
* @attribute rows
* @type number
* @default 1
*/
rows: {
type: Number,
value: 1,
observer: '_updateCached'
},
/**
* The maximum number of rows this element can grow to until it
* scrolls. 0 means no maximum.
*
* @attribute maxRows
* @type number
* @default 0
*/
maxRows: {
type: Number,
value: 0,
observer: '_updateCached'
},
/**
* Bound to the textarea's `autocomplete` attribute.
*/
autocomplete: {
type: String,
value: 'off'
},
/**
* Bound to the textarea's `autofocus` attribute.
*/
autofocus: {
type: Boolean,
value: false
},
/**
* Bound to the textarea's `inputmode` attribute.
*/
inputmode: {
type: String
},
/**
* Bound to the textarea's `placeholder` attribute.
*/
placeholder: {
type: String
},
/**
* Bound to the textarea's `readonly` attribute.
*/
readonly: {
type: String
},
/**
* Set to true to mark the textarea as required.
*/
required: {
type: Boolean
},
/**
* The maximum length of the input value.
*/
maxlength: {
type: Number
}
},
listeners: {
'input': '_onInput'
},
observers: [
'_onValueChanged(value)'
],
/**
* Returns the underlying textarea.
* @type HTMLTextAreaElement
*/
get textarea() {
return this.$.textarea;
},
/**
* Returns textarea's selection start.
* @type Number
*/
get selectionStart() {
return this.$.textarea.selectionStart;
},
/**
* Returns textarea's selection end.
* @type Number
*/
get selectionEnd() {
return this.$.textarea.selectionEnd;
},
/**
* Sets the textarea's selection start.
*/
set selectionStart(value) {
this.$.textarea.selectionStart = value;
},
/**
* Sets the textarea's selection end.
*/
set selectionEnd(value) {
this.$.textarea.selectionEnd = value;
},
/**
* Returns true if `value` is valid. The validator provided in `validator`
* will be used first, if it exists; otherwise, the `textarea`'s validity
* is used.
* @return {boolean} True if the value is valid.
*/
validate: function() {
// Empty, non-required input is valid.
if (!this.required && this.value == '') {
this.invalid = false;
return true;
}
var valid;
if (this.hasValidator()) {
valid = Polymer.IronValidatableBehavior.validate.call(this, this.value);
} else {
valid = this.$.textarea.validity.valid;
this.invalid = !valid;
}
this.fire('iron-input-validate');
return valid;
},
_bindValueChanged: function() {
var textarea = this.textarea;
if (!textarea) {
return;
}
// If the bindValue changed manually, then we need to also update
// the underlying textarea's value. Otherwise this change was probably
// generated from the _onInput handler, and the two values are already
// the same.
if (textarea.value !== this.bindValue) {
textarea.value = !(this.bindValue || this.bindValue === 0) ? '' : this.bindValue;
}
this.value = this.bindValue;
this.$.mirror.innerHTML = this._valueForMirror();
// manually notify because we don't want to notify until after setting value
this.fire('bind-value-changed', {value: this.bindValue});
},
_onInput: function(event) {
this.bindValue = event.path ? event.path[0].value : event.target.value;
},
_constrain: function(tokens) {
var _tokens;
tokens = tokens || [''];
// Enforce the min and max heights for a multiline input to avoid measurement
if (this.maxRows > 0 && tokens.length > this.maxRows) {
_tokens = tokens.slice(0, this.maxRows);
} else {
_tokens = tokens.slice(0);
}
while (this.rows > 0 && _tokens.length < this.rows) {
_tokens.push('');
}
// Use &#160; instead &nbsp; of to allow this element to be used in XHTML.
return _tokens.join('<br/>') + '&#160;';
},
_valueForMirror: function() {
var input = this.textarea;
if (!input) {
return;
}
this.tokens = (input && input.value) ? input.value.replace(/&/gm, '&amp;').replace(/"/gm, '&quot;').replace(/'/gm, '&#39;').replace(/</gm, '&lt;').replace(/>/gm, '&gt;').split('\n') : [''];
return this._constrain(this.tokens);
},
_updateCached: function() {
this.$.mirror.innerHTML = this._constrain(this.tokens);
},
_onValueChanged: function() {
this.bindValue = this.value;
}
});
</script>

View file

@ -1,190 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>
<title>iron-autogrow-textarea tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="../iron-autogrow-textarea.html">
</head>
<body>
<test-fixture id="basic">
<template>
<iron-autogrow-textarea></iron-autogrow-textarea>
</template>
</test-fixture>
<test-fixture id="has-bindValue">
<template>
<iron-autogrow-textarea bind-value="foobar"></iron-autogrow-textarea>
</template>
</test-fixture>
<test-fixture id="has-value">
<template>
<iron-autogrow-textarea value="foobar"></iron-autogrow-textarea>
</template>
</test-fixture>
<test-fixture id="rows">
<template>
<iron-autogrow-textarea rows="3"></iron-autogrow-textarea>
</template>
</test-fixture>
<script>
suite('basic', function() {
test('setting bindValue sets textarea value', function() {
var autogrow = fixture('basic');
var textarea = autogrow.textarea;
autogrow.bindValue = 'batman';
assert.equal(textarea.value, autogrow.bindValue, 'textarea value equals to bindValue');
});
test('can set an initial bindValue', function() {
var autogrow = fixture('has-bindValue');
assert.equal(autogrow.textarea.value, 'foobar', 'textarea value equals to initial bindValue');
assert.equal(autogrow.value, 'foobar', 'value equals to initial bindValue');
});
test('can set an initial value', function() {
var autogrow = fixture('has-value');
assert.equal(autogrow.textarea.value, 'foobar', 'textarea value equals to initial bindValue');
assert.equal(autogrow.bindValue, 'foobar', 'textarea bindValue equals to initial value');
});
test('can update the value', function() {
var autogrow = fixture('has-bindValue');
assert.equal(autogrow.textarea.value, 'foobar', 'textarea value equals to initial bindValue');
autogrow.value = 'batman';
assert.equal(autogrow.textarea.value, 'batman', 'textarea value is updated');
assert.equal(autogrow.bindValue, 'batman', 'bindValue is updated');
assert.equal(autogrow.value, 'batman', 'value is updated');
});
test('can update the bindValue', function() {
var autogrow = fixture('has-bindValue');
assert.equal(autogrow.textarea.value, 'foobar', 'textarea value equals to initial bindValue');
autogrow.bindValue = 'batman';
assert.equal(autogrow.textarea.value, 'batman', 'textarea value is updated');
assert.equal(autogrow.bindValue, 'batman', 'bindValue is updated');
assert.equal(autogrow.value, 'batman', 'value is updated');
});
test('can set an initial number of rows', function() {
var autogrow = fixture("rows");
assert.equal(autogrow.textarea.rows, 3, 'textarea has rows=3');
});
test('adding rows grows the textarea', function() {
var autogrow = fixture('basic');
var initialHeight = autogrow.offsetHeight;
autogrow.bindValue = 'batman\nand\nrobin';
var finalHeight = autogrow.offsetHeight
assert.isTrue(finalHeight > initialHeight);
});
test('removing rows shrinks the textarea', function() {
var autogrow = fixture('basic');
autogrow.bindValue = 'batman\nand\nrobin';
var initialHeight = autogrow.offsetHeight;
autogrow.bindValue = 'batman';
var finalHeight = autogrow.offsetHeight
assert.isTrue(finalHeight < initialHeight);
});
test('an undefined bindValue is the empty string', function() {
var autogrow = fixture('basic');
var initialHeight = autogrow.offsetHeight;
autogrow.bindValue = 'batman\nand\nrobin';
var finalHeight = autogrow.offsetHeight;
assert.isTrue(finalHeight > initialHeight);
autogrow.bindValue = undefined;
assert.equal(autogrow.offsetHeight, initialHeight);
assert.equal(autogrow.textarea.value, '');
});
test('textarea selection works', function() {
var autogrow = fixture('basic');
var textarea = autogrow.textarea;
autogrow.bindValue = 'batman\nand\nrobin';
autogrow.selectionStart = 3;
autogrow.selectionEnd = 5;
assert.equal(textarea.selectionStart, 3);
assert.equal(textarea.selectionEnd, 5);
});
});
suite('focus/blur events', function() {
var input;
setup(function() {
input = fixture('basic');
});
test('focus/blur events fired on host element', function(done) {
var nFocusEvents = 0;
var nBlurEvents = 0;
input.addEventListener('focus', function() {
nFocusEvents += 1;
// setTimeout to wait for potentially more, erroneous events
setTimeout(function() {
assert.equal(nFocusEvents, 1, 'one focus event fired');
MockInteractions.blur(input.textarea);
});
});
input.addEventListener('blur', function() {
nBlurEvents += 1;
// setTimeout to wait for potentially more, erroneous events
setTimeout(function() {
assert.equal(nBlurEvents, 1, 'one blur event fired');
done();
});
});
MockInteractions.focus(input.textarea);
});
});
suite('validation', function() {
test('a required textarea with no text is invalid', function() {
var input = fixture('basic');
input.required = true;
assert.isFalse(input.validate());
input.bindValue = 'batman';
assert.isTrue(input.validate());
});
});
</script>
</body>
</html>

View file

@ -1,24 +0,0 @@
<!DOCTYPE html><!--
@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
--><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>iron-autogrow-textarea tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'basic.html',
'basic.html?dom=shadow'
]);
</script>
</body></html>

View file

@ -1,44 +0,0 @@
{
"name": "iron-input",
"version": "1.0.10",
"description": "An input element with data binding",
"authors": [
"The Polymer Authors"
],
"keywords": [
"web-components",
"polymer",
"input"
],
"main": "iron-input.html",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/iron-input.git"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/iron-input",
"ignore": [],
"dependencies": {
"iron-a11y-announcer": "PolymerElements/iron-a11y-announcer#^1.0.0",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0",
"polymer": "Polymer/polymer#^1.0.0"
},
"devDependencies": {
"paper-styles": "polymerelements/paper-styles#^1.0.2",
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"_release": "1.0.10",
"_resolution": {
"type": "version",
"tag": "1.0.10",
"commit": "01d17407672ad8033ee447c9c7a65162f13c8f49"
},
"_source": "git://github.com/PolymerElements/iron-input.git",
"_target": "^1.0.0",
"_originalSource": "PolymerElements/iron-input"
}

View file

@ -1,33 +0,0 @@
<!-- Instructions: https://github.com/PolymerElements/iron-input/CONTRIBUTING.md#filing-issues -->
### Description
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
### Expected outcome
<!-- Example: The page stays the same color. -->
### Actual outcome
<!-- Example: The page turns pink. -->
### Live Demo
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
### Steps to reproduce
<!-- Example
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
-->
### Browsers Affected
<!-- Check all that apply -->
- [ ] Chrome
- [ ] Firefox
- [ ] Safari 9
- [ ] Safari 8
- [ ] Safari 7
- [ ] Edge
- [ ] IE 11
- [ ] IE 10

View file

@ -1 +0,0 @@
bower_components

View file

@ -1,23 +0,0 @@
language: node_js
sudo: required
before_script:
- npm install -g bower polylint web-component-tester
- bower install
- polylint
env:
global:
- secure: AnFRDBxxASn2RP4u+CHJS04g2klVTM+YL1fgNfkNIiECChymGRkeBiF7zvWPfodqPGKWhBZPAMxVuFKbztawQ95kWlbPSTNJtWhHhPcRarV5AYvjhyUV372E3REZ4CGt+T8nghD9bdJiMX5x0pXAz+wfBPPpiHwbiSPPjFLFvTs=
- secure: SvsE+VQL35CZ967ZVy0+7o5xclnBM8egjhsjNRG7WxVPZQboCQ3Xwm8tIDQSWeagM3ZQRkTGca4ta91F1ZEhm4Jdt5CwKhhSNC6JgS3CX819r9UKgUnSS3nvWdqcZq4GXcMoOZm4qE9ttd3xdoKCfkLRQlEGAvM2TEw69mBhj24=
node_js: stable
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
sauce_connect: true
script:
- xvfb-run wct
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
dist: trusty

View file

@ -1,77 +0,0 @@
<!--
This file is autogenerated based on
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
If you edit that file, it will get updated everywhere else.
If you edit this file, your changes will get overridden :)
You can however override the jsbin link with one that's customized to this
specific element:
jsbin=https://jsbin.com/cagaye/edit?html,output
-->
# Polymer Elements
## Guide for Contributors
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
### Filing Issues
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
1. **Who will use the feature?** _“As someone filling out a form…”_
2. **When will they use the feature?** _“When I enter an invalid value…”_
3. **What is the users goal?** _“I want to be visually notified that the value needs to be corrected…”_
**If you are filing an issue to report a bug**, please provide:
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
```markdown
The `paper-foo` element causes the page to turn pink when clicked.
## Expected outcome
The page stays the same color.
## Actual outcome
The page turns pink.
## Steps to reproduce
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
```
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
### Submitting Pull Requests
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
When submitting pull requests, please provide:
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
```markdown
(For a single issue)
Fixes #20
(For multiple issues)
Fixes #32, fixes #40
```
2. **A succinct description of the design** used to fix any related issues. For example:
```markdown
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
```
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so dont be afraid to ask us if you need help with that!

View file

@ -1,35 +0,0 @@
{
"name": "iron-input",
"version": "1.0.10",
"description": "An input element with data binding",
"authors": [
"The Polymer Authors"
],
"keywords": [
"web-components",
"polymer",
"input"
],
"main": "iron-input.html",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/iron-input.git"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/iron-input",
"ignore": [],
"dependencies": {
"iron-a11y-announcer": "PolymerElements/iron-a11y-announcer#^1.0.0",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0",
"polymer": "Polymer/polymer#^1.0.0"
},
"devDependencies": {
"paper-styles": "polymerelements/paper-styles#^1.0.2",
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}
}

View file

@ -1,87 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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 http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>iron-input demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-input.html">
<link rel="import" href="../../paper-styles/color.html">
<link rel="import" href="../../paper-styles/demo-pages.html">
<link rel="import" href="../../paper-styles/typography.html">
<style is="custom-style">
.vertical-section {
@apply(--paper-font-body1);
line-height: 40px;
}
code {
color: var(--google-grey-700);
}
input[is=iron-input] {
width: 100%;
box-sizing: border-box;
}
input, button {
font-size: 20px;
padding: 0.2em;
}
</style>
</head>
<body>
<div class="vertical-section vertical-section-container centered">
<template is="dom-bind">
<p>
<input is="iron-input" bind-value="{{bindValue}}" value="{{value::input}}">
<br>
bind to <code>bind-value</code>: <b>[[bindValue]]</b>
<br>
bind to <code>value::input</code>: <b>{{value}}</b>
</p>
<p on-click="setValue">
set bind-value to: <input> <button is="paper-button" value="bindValue">set</button>
<br>
set value to: <input> <button value="value">set</button>
</p>
</template>
<p>only allows these characters:
<code>!@#0123456789</code></p>
<input is="iron-input" allowed-pattern="[!@#0-9]" prevent-invalid-input>
</div>
<script>
var scope = document.querySelector('template[is=dom-bind]');
scope.setValue = function(event) {
if (!(event.target instanceof HTMLButtonElement)) {
return;
}
document.querySelector('input[is=iron-input]')[event.target.value] = event.target.previousElementSibling.value;
}
</script>
</body>
</html>

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
<g id="background" display="none">
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
</g>
<g id="label">
</g>
<g id="art">
<rect x="49" y="53" width="2" height="18"/>
<path d="M188,78H37V44h151V78z M39,76h147V46H39V76z"/>
<g id="ic_x5F_add_x0D_">
</g>
</g>
<g id="Guides">
</g>
</svg>

Before

Width:  |  Height:  |  Size: 733 B

View file

@ -1,30 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>iron-input</title>
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
<iron-component-page></iron-component-page>
</body>
</html>

View file

@ -1,306 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-a11y-announcer/iron-a11y-announcer.html">
<link rel="import" href="../iron-validatable-behavior/iron-validatable-behavior.html">
<script>
/*
`<iron-input>` adds two-way binding and custom validators using `Polymer.IronValidatorBehavior`
to `<input>`.
### Two-way binding
By default you can only get notified of changes to an `input`'s `value` due to user input:
<input value="{{myValue::input}}">
`iron-input` adds the `bind-value` property that mirrors the `value` property, and can be used
for two-way data binding. `bind-value` will notify if it is changed either by user input or by script.
<input is="iron-input" bind-value="{{myValue}}">
### Custom validators
You can use custom validators that implement `Polymer.IronValidatorBehavior` with `<iron-input>`.
<input is="iron-input" validator="my-custom-validator">
### Stopping invalid input
It may be desirable to only allow users to enter certain characters. You can use the
`prevent-invalid-input` and `allowed-pattern` attributes together to accomplish this. This feature
is separate from validation, and `allowed-pattern` does not affect how the input is validated.
<!-- only allow characters that match [0-9] -->
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]">
@hero hero.svg
@demo demo/index.html
*/
Polymer({
is: 'iron-input',
extends: 'input',
behaviors: [
Polymer.IronValidatableBehavior
],
properties: {
/**
* Use this property instead of `value` for two-way data binding.
*/
bindValue: {
observer: '_bindValueChanged',
type: String
},
/**
* Set to true to prevent the user from entering invalid input. If `allowedPattern` is set,
* any character typed by the user will be matched against that pattern, and rejected if it's not a match.
* Pasted input will have each character checked individually; if any character
* doesn't match `allowedPattern`, the entire pasted string will be rejected.
* If `allowedPattern` is not set, it will use the `type` attribute (only supported for `type=number`).
*/
preventInvalidInput: {
type: Boolean
},
/**
* Regular expression that list the characters allowed as input.
* This pattern represents the allowed characters for the field; as the user inputs text,
* each individual character will be checked against the pattern (rather than checking
* the entire value as a whole). The recommended format should be a list of allowed characters;
* for example, `[a-zA-Z0-9.+-!;:]`
*/
allowedPattern: {
type: String,
observer: "_allowedPatternChanged"
},
_previousValidInput: {
type: String,
value: ''
},
_patternAlreadyChecked: {
type: Boolean,
value: false
}
},
listeners: {
'input': '_onInput',
'keypress': '_onKeypress'
},
/** @suppress {checkTypes} */
registered: function() {
// Feature detect whether we need to patch dispatchEvent (i.e. on FF and IE).
if (!this._canDispatchEventOnDisabled()) {
this._origDispatchEvent = this.dispatchEvent;
this.dispatchEvent = this._dispatchEventFirefoxIE;
}
},
created: function() {
Polymer.IronA11yAnnouncer.requestAvailability();
},
_canDispatchEventOnDisabled: function() {
var input = document.createElement('input');
var canDispatch = false;
input.disabled = true;
input.addEventListener('feature-check-dispatch-event', function() {
canDispatch = true;
});
try {
input.dispatchEvent(new Event('feature-check-dispatch-event'));
} catch(e) {}
return canDispatch;
},
_dispatchEventFirefoxIE: function() {
// Due to Firefox bug, events fired on disabled form controls can throw
// errors; furthermore, neither IE nor Firefox will actually dispatch
// events from disabled form controls; as such, we toggle disable around
// the dispatch to allow notifying properties to notify
// See issue #47 for details
var disabled = this.disabled;
this.disabled = false;
this._origDispatchEvent.apply(this, arguments);
this.disabled = disabled;
},
get _patternRegExp() {
var pattern;
if (this.allowedPattern) {
pattern = new RegExp(this.allowedPattern);
} else {
switch (this.type) {
case 'number':
pattern = /[0-9.,e-]/;
break;
}
}
return pattern;
},
ready: function() {
this.bindValue = this.value;
},
/**
* @suppress {checkTypes}
*/
_bindValueChanged: function() {
if (this.value !== this.bindValue) {
this.value = !(this.bindValue || this.bindValue === 0 || this.bindValue === false) ? '' : this.bindValue;
}
// manually notify because we don't want to notify until after setting value
this.fire('bind-value-changed', {value: this.bindValue});
},
_allowedPatternChanged: function() {
// Force to prevent invalid input when an `allowed-pattern` is set
this.preventInvalidInput = this.allowedPattern ? true : false;
},
_onInput: function() {
// Need to validate each of the characters pasted if they haven't
// been validated inside `_onKeypress` already.
if (this.preventInvalidInput && !this._patternAlreadyChecked) {
var valid = this._checkPatternValidity();
if (!valid) {
this._announceInvalidCharacter('Invalid string of characters not entered.');
this.value = this._previousValidInput;
}
}
this.bindValue = this.value;
this._previousValidInput = this.value;
this._patternAlreadyChecked = false;
},
_isPrintable: function(event) {
// What a control/printable character is varies wildly based on the browser.
// - most control characters (arrows, backspace) do not send a `keypress` event
// in Chrome, but the *do* on Firefox
// - in Firefox, when they do send a `keypress` event, control chars have
// a charCode = 0, keyCode = xx (for ex. 40 for down arrow)
// - printable characters always send a keypress event.
// - in Firefox, printable chars always have a keyCode = 0. In Chrome, the keyCode
// always matches the charCode.
// None of this makes any sense.
// For these keys, ASCII code == browser keycode.
var anyNonPrintable =
(event.keyCode == 8) || // backspace
(event.keyCode == 9) || // tab
(event.keyCode == 13) || // enter
(event.keyCode == 27); // escape
// For these keys, make sure it's a browser keycode and not an ASCII code.
var mozNonPrintable =
(event.keyCode == 19) || // pause
(event.keyCode == 20) || // caps lock
(event.keyCode == 45) || // insert
(event.keyCode == 46) || // delete
(event.keyCode == 144) || // num lock
(event.keyCode == 145) || // scroll lock
(event.keyCode > 32 && event.keyCode < 41) || // page up/down, end, home, arrows
(event.keyCode > 111 && event.keyCode < 124); // fn keys
return !anyNonPrintable && !(event.charCode == 0 && mozNonPrintable);
},
_onKeypress: function(event) {
if (!this.preventInvalidInput && this.type !== 'number') {
return;
}
var regexp = this._patternRegExp;
if (!regexp) {
return;
}
// Handle special keys and backspace
if (event.metaKey || event.ctrlKey || event.altKey)
return;
// Check the pattern either here or in `_onInput`, but not in both.
this._patternAlreadyChecked = true;
var thisChar = String.fromCharCode(event.charCode);
if (this._isPrintable(event) && !regexp.test(thisChar)) {
event.preventDefault();
this._announceInvalidCharacter('Invalid character ' + thisChar + ' not entered.');
}
},
_checkPatternValidity: function() {
var regexp = this._patternRegExp;
if (!regexp) {
return true;
}
for (var i = 0; i < this.value.length; i++) {
if (!regexp.test(this.value[i])) {
return false;
}
}
return true;
},
/**
* Returns true if `value` is valid. The validator provided in `validator` will be used first,
* then any constraints.
* @return {boolean} True if the value is valid.
*/
validate: function() {
// First, check what the browser thinks. Some inputs (like type=number)
// behave weirdly and will set the value to "" if something invalid is
// entered, but will set the validity correctly.
var valid = this.checkValidity();
// Only do extra checking if the browser thought this was valid.
if (valid) {
// Empty, required input is invalid
if (this.required && this.value === '') {
valid = false;
} else if (this.hasValidator()) {
valid = Polymer.IronValidatableBehavior.validate.call(this, this.value);
}
}
this.invalid = !valid;
this.fire('iron-input-validate');
return valid;
},
_announceInvalidCharacter: function(message) {
this.fire('iron-announce', { text: message });
}
});
/*
The `iron-input-validate` event is fired whenever `validate()` is called.
@event iron-input-validate
*/
</script>

View file

@ -1,32 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../../polymer/polymer.html">
<dom-module id="disabled-input">
<template>
<input is="iron-input" bind-value="{{myValue}}" invalid="{{myInvalid}}" disabled id="input">
</template>
</dom-module>
<script>
Polymer({
is: 'disabled-input',
properties: {
myValue: {
value: 'foo'
},
myInvalid: {
value: false
}
}
});
</script>

View file

@ -1,24 +0,0 @@
<!DOCTYPE html><!--
@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
--><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>iron-input tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'iron-input.html',
'iron-input.html?dom=shadow'
]);
</script>
</body></html>

View file

@ -1,281 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>
<title>iron-input tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../iron-input.html">
<link rel="import" href="letters-only.html">
<link rel="import" href="disabled-input.html">
</head>
<body>
<test-fixture id="basic">
<template>
<input is="iron-input">
</template>
</test-fixture>
<test-fixture id="has-value">
<template>
<input is="iron-input" value="foobar">
</template>
</test-fixture>
<test-fixture id="has-bind-value">
<template>
<input is="iron-input" bind-value="foobar">
</template>
</test-fixture>
<test-fixture id="prevent-invalid-input">
<template>
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]">
</template>
</test-fixture>
<test-fixture id="prevent-invalid-input-with-pattern">
<template>
<input is="iron-input" prevent-invalid-input pattern="[a-zA-Z]{3}[0-9]*">
</template>
</test-fixture>
<test-fixture id="prevent-invalid-input-has-value">
<template>
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]" value="foobar">
</template>
</test-fixture>
<test-fixture id="prevent-invalid-input-has-bind-value">
<template>
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]" bind-value="foobar">
</template>
</test-fixture>
<test-fixture id="automatically-prevent-invalid-input-if-allowed-pattern">
<template>
<input is="iron-input" allowed-pattern="[0-9]">
</template>
</test-fixture>
<test-fixture id="no-validator">
<template>
<input is="iron-input" pattern="[a-zA-Z]{3}[0-9]*">
</template>
</test-fixture>
<test-fixture id="has-validator">
<template>
<letters-only></letters-only>
<input is="iron-input" validator="letters-only" pattern="[0-9]*">
</template>
</test-fixture>
<test-fixture id="native-and-custom-validator">
<template>
<letters-only></letters-only>
<input is="iron-input" validator="letters-only" pattern="[a-c]*">
</template>
</test-fixture>
<template is="dom-bind" id="bind-to-object">
<input is="iron-input" id="input" bind-value="{{foo}}">
</template>
<test-fixture id="disabled-input">
<template>
<disabled-input></disabled-input>
</template>
</test-fixture>
<script>
suite('basic', function() {
test('setting bindValue sets value', function() {
var input = fixture('basic');
input.bindValue = 'foobar';
assert.equal(input.value, input.bindValue, 'value equals to bindValue');
});
test('changing the input triggers an event', function(done) {
var input = fixture('basic');
input.addEventListener('bind-value-changed', function(value) {
assert.equal(input.value, input.bindValue, 'value equals to bindValue');
done();
});
input.value = "foo";
input._onInput();
});
test('default value sets bindValue', function() {
var input = fixture('has-value');
assert.equal(input.bindValue, input.value, 'bindValue equals value');
});
test('default bindValue sets value', function() {
var input = fixture('has-bind-value');
assert.equal(input.value, input.bindValue, 'value equals to bindValue');
});
test('set bindValue to undefined', function() {
var scope = document.getElementById('bind-to-object');
scope.foo = undefined;
assert.ok(!scope.$.input.bindValue, 'bindValue is falsy');
assert.ok(!scope.$.input.value, 'value is falsy');
});
test('can validate using a complex regex', function() {
var input = fixture('no-validator');
input.value = '123';
input.validate();
assert.isTrue(input.invalid, 'input is invalid');
input.value = 'foo';
input.validate();
assert.isFalse(input.invalid, 'input is valid');
input.value = 'foo123';
input.validate();
assert.isFalse(input.invalid, 'input is valid');
});
test('set bindValue to false', function() {
var scope = document.getElementById('bind-to-object');
scope.foo = false;
assert.isFalse(scope.$.input.bindValue);
assert.equal(scope.$.input.value, 'false');
});
test('validator used instead of constraints api if provided', function() {
var input = fixture('has-validator')[1];
input.value = '123';
input.validate();
assert.isTrue(input.invalid, 'input is invalid');
});
test('prevent invalid input works in _onInput', function() {
var input = fixture('prevent-invalid-input');
input.value = '123';
input._onInput();
assert.equal(input.bindValue, '123');
input.value = '123foo';
input._onInput();
assert.equal(input.bindValue, '123');
});
test('inputs can be validated', function() {
var input = fixture('prevent-invalid-input-with-pattern');
input.value = '123';
input._onInput();
assert.equal(input.bindValue, '123');
input.validate();
assert.isTrue(input.invalid, 'input is invalid');
input.value = 'foo';
input._onInput();
assert.equal(input.bindValue, 'foo');
input.validate();
assert.isFalse(input.invalid, 'input is valid');
input.value = 'foo123';
input._onInput();
assert.equal(input.bindValue, 'foo123');
input.validate();
assert.isFalse(input.invalid, 'input is valid');
});
test('prevent invalid input works automatically when allowed pattern is set', function() {
var input = fixture('automatically-prevent-invalid-input-if-allowed-pattern');
input.value = '123';
input._onInput();
assert.equal(input.bindValue, '123');
input.value = '123foo';
input._onInput();
assert.equal(input.bindValue, '123');
input.allowedPattern = '';
input.value = '#123foo BAR!';
input._onInput();
assert.equal(input.bindValue, '#123foo BAR!');
input.allowedPattern = '[a-zA-Z]';
input.value = 'foo';
input._onInput();
input.value = 'bar123';
input._onInput();
assert.equal(input.bindValue, 'foo');
});
test('disabled input doesn\'t throw on Firefox', function() {
var el = fixture('disabled-input');
var input = el.$.input;
assert.equal(input.bindValue, 'foo');
assert.isFalse(el.myInvalid);
assert.isTrue(input.disabled);
});
test('browser validation beats custom validation', function() {
var input = fixture('native-and-custom-validator')[1];
// The input allows any letters, but the browser only allows one
// of [abc].
input.value = 'aaaa';
input.validate();
assert.isFalse(input.invalid, 'input is valid');
// The validator allows this, but the browser doesn't.
input.value = 'zzz';
input.validate();
assert.isTrue(input.invalid, 'input is invalid');
});
});
suite('a11y', function() {
test('announces invalid characters when _onInput is called', function() {
var input = fixture('prevent-invalid-input');
input.addEventListener('iron-announce', function(event) {
assert.equal(event.detail.text, 'Invalid string of characters not entered.');
});
input.value = 'foo';
input._onInput();
});
test('announces invalid characters on keypress', function() {
var input = fixture('prevent-invalid-input');
input.addEventListener('iron-announce', function(event) {
assert.equal(event.detail.text, 'Invalid character a not entered.');
});
// Simulate key press event.
var event = new CustomEvent('keypress', {
bubbles: true,
cancelable: true
});
event.charCode = 97 /* a */;
input.dispatchEvent(event);
});
});
</script>
</body>
</html>

View file

@ -1,30 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../iron-validator-behavior/iron-validator-behavior.html">
<script>
Polymer({
is: 'letters-only',
behaviors: [
Polymer.IronValidatorBehavior
],
validate: function(value) {
return !value || value.match(/^[a-zA-Z]*$/) !== null;
}
});
</script>

View file

@ -1,39 +0,0 @@
{
"name": "iron-range-behavior",
"version": "1.0.6",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "Provides a behavior for something with a minimum and maximum value",
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"behavior"
],
"main": "iron-range-behavior.html",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/iron-range-behavior.git"
},
"dependencies": {
"polymer": "Polymer/polymer#^1.1.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-input": "PolymerElements/iron-input#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"ignore": [],
"homepage": "https://github.com/PolymerElements/iron-range-behavior",
"_release": "1.0.6",
"_resolution": {
"type": "version",
"tag": "v1.0.6",
"commit": "1317604307387599725b80b63cbd293102ea2db0"
},
"_source": "git://github.com/PolymerElements/iron-range-behavior.git",
"_target": "^1.0.0",
"_originalSource": "PolymerElements/iron-range-behavior"
}

View file

@ -1,33 +0,0 @@
<!-- Instructions: https://github.com/PolymerElements/iron-range-behavior/CONTRIBUTING.md#filing-issues -->
### Description
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
### Expected outcome
<!-- Example: The page stays the same color. -->
### Actual outcome
<!-- Example: The page turns pink. -->
### Live Demo
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
### Steps to reproduce
<!-- Example
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
-->
### Browsers Affected
<!-- Check all that apply -->
- [ ] Chrome
- [ ] Firefox
- [ ] Safari 9
- [ ] Safari 8
- [ ] Safari 7
- [ ] Edge
- [ ] IE 11
- [ ] IE 10

View file

@ -1 +0,0 @@
bower_components

View file

@ -1,23 +0,0 @@
language: node_js
sudo: required
before_script:
- npm install -g bower polylint web-component-tester
- bower install
- polylint
env:
global:
- secure: ioGoTHzroJHO2O9B8y/xB7dsnWY+dArvRF+Dem/0Z8yTJZ/QFCeqFctQXNdj7HIm/y7ZxetVFBnxr+0HbF62qdmVkvfBzD/TaQPeXOHSyrSbR2aAQLeSwRbcUyOmmtk/q0frf1o81i3inoLjrGKieCZq7U8VF/6YyfRDhouU5/Q=
- secure: LxoITNXWo1Vh2dOlg0I/KI/wuEaiMpNPRcg8MN6TOwy6UIKPwlpA69YZ4eLNDnuCjndQHL7Cl/TA5njubss4UeXG+L3oQMGNBEcRSHGZGxEyTZpofJp5FFK3Ja9CpaBMB7IsWAwuGPJZXM/6aoyAVipJ1et2Gbbasd5EbQYjRwc=
node_js: stable
addons:
firefox: '46.0'
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
sauce_connect: true
script:
- xvfb-run wct
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'default'; fi
dist: trusty

View file

@ -1,77 +0,0 @@
<!--
This file is autogenerated based on
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
If you edit that file, it will get updated everywhere else.
If you edit this file, your changes will get overridden :)
You can however override the jsbin link with one that's customized to this
specific element:
jsbin=https://jsbin.com/cagaye/edit?html,output
-->
# Polymer Elements
## Guide for Contributors
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
### Filing Issues
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
1. **Who will use the feature?** _“As someone filling out a form…”_
2. **When will they use the feature?** _“When I enter an invalid value…”_
3. **What is the users goal?** _“I want to be visually notified that the value needs to be corrected…”_
**If you are filing an issue to report a bug**, please provide:
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
```markdown
The `paper-foo` element causes the page to turn pink when clicked.
## Expected outcome
The page stays the same color.
## Actual outcome
The page turns pink.
## Steps to reproduce
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
```
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
### Submitting Pull Requests
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
When submitting pull requests, please provide:
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
```markdown
(For a single issue)
Fixes #20
(For multiple issues)
Fixes #32, fixes #40
```
2. **A succinct description of the design** used to fix any related issues. For example:
```markdown
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
```
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so dont be afraid to ask us if you need help with that!

View file

@ -1,29 +0,0 @@
{
"name": "iron-range-behavior",
"version": "1.0.6",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "Provides a behavior for something with a minimum and maximum value",
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"behavior"
],
"main": "iron-range-behavior.html",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/iron-range-behavior.git"
},
"dependencies": {
"polymer": "Polymer/polymer#^1.1.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-input": "PolymerElements/iron-input#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"ignore": []
}

View file

@ -1,80 +0,0 @@
<!--
@license
Copyright (c) 2015 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>iron-range-behavior demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-range-behavior.html">
<link rel="import" href="../../iron-input/iron-input.html">
<style>
body {
font-family: sans-serif;
}
</style>
</head>
<body unresolved>
<dom-module id="x-progressbar">
<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>
<div class="progress" horizontal center layout style$="{{_computeStyle(ratio)}}">
<div class="progress-value"><span>{{ratio}}</span>%</div>
</div>
</template>
</dom-module>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-progressbar',
behaviors: [Polymer.IronRangeBehavior],
_computeStyle: function(ratio) {
return 'width: ' + ratio + '%;';
}
});
});
</script>
<x-progressbar min="0" max="200" value="120"></x-progressbar>
</body>
</html>

View file

@ -1,24 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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, initial-scale=1.0">
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
<iron-component-page></iron-component-page>
</body>
</html>

View file

@ -1,121 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<script>
/**
* `iron-range-behavior` provides the behavior for something with a minimum to maximum range.
*
* @demo demo/index.html
* @polymerBehavior
*/
Polymer.IronRangeBehavior = {
properties: {
/**
* The number that represents the current value.
*/
value: {
type: Number,
value: 0,
notify: true,
reflectToAttribute: true
},
/**
* The number that indicates the minimum value of the range.
*/
min: {
type: Number,
value: 0,
notify: true
},
/**
* The number that indicates the maximum value of the range.
*/
max: {
type: Number,
value: 100,
notify: true
},
/**
* Specifies the value granularity of the range's value.
*/
step: {
type: Number,
value: 1,
notify: true
},
/**
* Returns the ratio of the value.
*/
ratio: {
type: Number,
value: 0,
readOnly: true,
notify: true
},
},
observers: [
'_update(value, min, max, step)'
],
_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) {
// polymer/issues/2493
value = parseFloat(value);
if (!this.step) {
return value;
}
var numSteps = Math.round((value - this.min) / this.step);
if (this.step < 1) {
/**
* For small values of this.step, if we calculate the step using
* `Math.round(value / step) * step` we may hit a precision point issue
* eg. 0.1 * 0.2 = 0.020000000000000004
* http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
*
* as a work around we can divide by the reciprocal of `step`
*/
return numSteps / (1 / this.step) + this.min;
} else {
return numSteps * this.step + this.min;
}
},
_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._setRatio(this._calcRatio(this.value) * 100);
}
};
</script>

View file

@ -1,180 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>iron-range-behavior</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="x-progressbar.html">
<link rel="import" href="../../test-fixture/test-fixture.html">
</head>
<body>
<test-fixture id="trivialRange">
<template>
<x-progressbar></x-progressbar>
</template>
</test-fixture>
<script>
suite('<x-progressbar>', function() {
var range;
setup(function() {
range = fixture('trivialRange');
});
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;
flush(function() {
assert.equal(range.value, 50);
// test clamp value
range.value = 60.1;
flush(function() {
assert.equal(range.value, 60);
done();
});
});
});
test('set max', function(done) {
range.max = 10;
range.value = 11;
flush(function() {
assert.equal(range.value, range.max);
done();
});
});
test('test ratio', function(done) {
range.max = 10;
range.value = 5;
flush(function() {
assert.equal(range.ratio, 50);
done();
});
});
test('set min', function(done) {
range.min = 10
range.max = 50;
range.value = 30;
flush(function() {
assert.equal(range.ratio, 50);
range.value = 0;
flush(function() {
assert.equal(range.value, range.min);
done();
});
});
});
test('set step', function(done) {
range.min = 0;
range.max = 10;
range.value = 5.1;
flush(function() {
assert.equal(range.value, 5);
range.step = 0.1;
range.value = 5.1;
flush(function() {
assert.equal(range.value, 5.1);
done();
});
});
});
test('set large step', function(done) {
// PolymerElements/paper-slider#135
range.min = 0;
range.max = 2625;
range.step = 875;
range.value = 875;
flush(function() {
assert.equal(range.value, 875);
done();
});
});
test('set step with min', function(done) {
range.min = -0.9;
range.max = 1.1;
range.step = 0.5;
range.value = -0.5;
flush(function() {
assert.equal(range.value, -0.4);
range.value = 0.7;
flush(function() {
assert.equal(range.value, 0.6);
done();
});
});
});
test('odd values', function(done) {
range.min = 1;
range.max = 7;
range.step = 2;
range.value = 3;
flush(function() {
assert.equal(range.value, 3);
range.value += range.step;
assert.equal(range.value, 5);
range.value += range.step;
assert.equal(range.value, 7);
done();
});
});
test('negative values should round up', function(done) {
range.min = -10;
range.max = 10;
range.step = 0.1;
range.value = -8.4252;
flush(function() {
assert.equal(range.value, -8.4);
done();
});
});
test('positive values should round up', function(done) {
range.min = 10;
range.max = 100;
range.step = 0.25;
range.value = 19.34567;
flush(function() {
assert.equal(range.value, 19.25);
done();
});
});
});
</script>
</body>
</html>

View file

@ -1,24 +0,0 @@
<!DOCTYPE html><!--
@license
Copyright (c) 2015 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',
'basic.html?dom=shadow'
]);
</script>
</body></html>

View file

@ -1,19 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../iron-range-behavior.html">
<script>
Polymer({
is: 'x-progressbar',
behaviors: [Polymer.IronRangeBehavior]
});
</script>

View file

@ -1,60 +0,0 @@
{
"name": "paper-input",
"version": "1.1.17",
"description": "Material design text fields",
"authors": [
"The Polymer Authors"
],
"keywords": [
"web-components",
"polymer",
"input"
],
"main": [
"paper-input.html",
"paper-textarea.html",
"paper-input-behavior.html",
"paper-input-container.html",
"paper-input-error.html",
"paper-input-addon-behavior.html",
"paper-input-char-counter.html"
],
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-input.git"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/paper-input",
"ignore": [],
"dependencies": {
"polymer": "Polymer/polymer#^1.2.0",
"iron-autogrow-textarea": "PolymerElements/iron-autogrow-textarea#^1.0.0",
"iron-behaviors": "PolymerElements/iron-behaviors#^1.0.0",
"iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#^1.0.0",
"iron-input": "PolymerElements/iron-input#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.1.4",
"iron-a11y-keys-behavior": "PolymerElements/iron-a11y-keys-behavior#^1.0.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
"iron-icon": "PolymerElements/iron-icon#^1.0.0",
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
"paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"_release": "1.1.17",
"_resolution": {
"type": "version",
"tag": "v1.1.17",
"commit": "61d482886c58324b682cea3c605695c31154e084"
},
"_source": "git://github.com/PolymerElements/paper-input.git",
"_target": "^1.1.11",
"_originalSource": "PolymerElements/paper-input"
}

View file

@ -1,33 +0,0 @@
<!-- Instructions: https://github.com/PolymerElements/paper-input/CONTRIBUTING.md#filing-issues -->
### Description
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
### Expected outcome
<!-- Example: The page stays the same color. -->
### Actual outcome
<!-- Example: The page turns pink. -->
### Live Demo
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
### Steps to reproduce
<!-- Example
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
-->
### Browsers Affected
<!-- Check all that apply -->
- [ ] Chrome
- [ ] Firefox
- [ ] Safari 9
- [ ] Safari 8
- [ ] Safari 7
- [ ] Edge
- [ ] IE 11
- [ ] IE 10

View file

@ -1 +0,0 @@
bower_components

View file

@ -1,23 +0,0 @@
language: node_js
sudo: required
before_script:
- npm install -g bower polylint web-component-tester
- bower install
- polylint
env:
global:
- secure: Hg2KIEhKqOw0J8ZW2C3Pdgp5N4HD/f9jhdluH0tiYRCU4I/jf5grQuA3ohqsbqnJKV5l06gWVIDCdxBDwDEH0h8v9uUG5z/i2diiuLQc94SLQu8kWKkUPDOx+pUyXmfRKj6KnaRTotTLFrwlyuKDi9OfGjQbLZWTvmJUWoFwh4g=
- secure: U6/Hp/V0ezT/yxeP2bv4S99LSLScKEaOfYwQUbe0+v5dPbN5XZaCUS6iSbNP2K8Mtb1UQUEyL8uN6Zn+khFlJ8/KJshppJ6HJi235CykahBhh9/Cv7EapgDUoss14ntE8EKpm6Ijo4LvVyPVmhgqKk9wP5ykDFtvhoKD4C3guVU=
node_js: stable
addons:
firefox: '46.0'
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
sauce_connect: true
script:
- xvfb-run wct
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'default'; fi
dist: trusty

View file

@ -1,77 +0,0 @@
<!--
This file is autogenerated based on
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
If you edit that file, it will get updated everywhere else.
If you edit this file, your changes will get overridden :)
You can however override the jsbin link with one that's customized to this
specific element:
jsbin=https://jsbin.com/cagaye/edit?html,output
-->
# Polymer Elements
## Guide for Contributors
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
### Filing Issues
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
1. **Who will use the feature?** _“As someone filling out a form…”_
2. **When will they use the feature?** _“When I enter an invalid value…”_
3. **What is the users goal?** _“I want to be visually notified that the value needs to be corrected…”_
**If you are filing an issue to report a bug**, please provide:
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
```markdown
The `paper-foo` element causes the page to turn pink when clicked.
## Expected outcome
The page stays the same color.
## Actual outcome
The page turns pink.
## Steps to reproduce
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
```
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
### Submitting Pull Requests
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
When submitting pull requests, please provide:
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
```markdown
(For a single issue)
Fixes #20
(For multiple issues)
Fixes #32, fixes #40
```
2. **A succinct description of the design** used to fix any related issues. For example:
```markdown
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
```
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so dont be afraid to ask us if you need help with that!

View file

@ -1,12 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="paper-input.html">
<link rel="import" href="paper-textarea.html">

View file

@ -1,51 +0,0 @@
{
"name": "paper-input",
"version": "1.1.17",
"description": "Material design text fields",
"authors": [
"The Polymer Authors"
],
"keywords": [
"web-components",
"polymer",
"input"
],
"main": [
"paper-input.html",
"paper-textarea.html",
"paper-input-behavior.html",
"paper-input-container.html",
"paper-input-error.html",
"paper-input-addon-behavior.html",
"paper-input-char-counter.html"
],
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-input.git"
},
"license": "http://polymer.github.io/LICENSE.txt",
"homepage": "https://github.com/PolymerElements/paper-input",
"ignore": [],
"dependencies": {
"polymer": "Polymer/polymer#^1.2.0",
"iron-autogrow-textarea": "PolymerElements/iron-autogrow-textarea#^1.0.0",
"iron-behaviors": "PolymerElements/iron-behaviors#^1.0.0",
"iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#^1.0.0",
"iron-input": "PolymerElements/iron-input#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.1.4",
"iron-a11y-keys-behavior": "PolymerElements/iron-a11y-keys-behavior#^1.0.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
"iron-icon": "PolymerElements/iron-icon#^1.0.0",
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
"paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}
}

View file

@ -1,155 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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 http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>paper-input demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../../iron-icon/iron-icon.html">
<link rel="import" href="../../iron-icons/iron-icons.html">
<link rel="import" href="../../iron-input/iron-input.html">
<link rel="import" href="../../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../paper-styles/color.html">
<link rel="import" href="../paper-input-container.html">
<link rel="import" href="../paper-input-error.html">
<link rel="import" href="../paper-input.html">
<link rel="import" href="../paper-textarea.html">
<link rel="import" href="ssn-input.html">
<style is="custom-style" include="demo-pages-shared-styles">
paper-input {
display: block;
}
demo-snippet.horizontal {
--demo-snippet-demo: {
@apply(--layout-horizontal);
@apply(--layout-justified);
@apply(--layout-wrap);
}
}
demo-snippet.horizontal paper-input {
display: inline-block;
}
button {
width: 70px;
}
#inputForValidation {
display: inline-block;
width: calc(100% - 75px);
}
.vertical-section-container {
max-width: 600px;
}
paper-icon-button {
color: var(--paper-red-300);
--paper-icon-button-ink-color: var(--paper-red-a100);
width: 23px; /* 15px + 2*4px for padding */
height: 23px;
padding: 0px 4px;
}
iron-icon {
padding-right: 5px;
}
</style>
</head>
<body unresolved>
<div class="vertical-section-container centered">
<h3>Inputs can have different types, and be disabled</h3>
<demo-snippet>
<template>
<paper-input label="text input"></paper-input>
<paper-textarea label="autoresizing textarea input"></paper-textarea>
<paper-input label="password input" type="password"></paper-input>
<paper-input label="disabled input" disabled></paper-input>
</template>
</demo-snippet>
<h3>Inputs can have character counters</h3>
<demo-snippet>
<template>
<paper-input label="simple character counter" char-counter></paper-input>
<paper-input label="input with at most 10 characters" char-counter maxlength="10"></paper-input>
</template>
</demo-snippet>
<h3>The label can have different floating states</h3>
<demo-snippet>
<template>
<paper-input label="this label floats after typing"></paper-input>
<paper-input label="this label is always floating" always-float-label></paper-input>
<paper-input label="this label never floats" no-label-float></paper-input>
<paper-input label="this label is always floating" always-float-label placeholder="placeholder text"></paper-input>
</template>
</demo-snippet>
<h3>Inputs can validate automatically or on demand, and can have custom error messages</h3>
<demo-snippet>
<template>
<paper-input label="this input requires some text" required auto-validate error-message="needs some text!"></paper-input>
<paper-input label="this input requires letters only" auto-validate pattern="[a-zA-Z]*" error-message="letters only!"></paper-input>
<paper-input label="this input will only let you type letters" auto-validate allowed-pattern="[a-zA-Z]"></paper-input>
<paper-input id="inputForValidation" required label="this input is manually validated" pattern="[a-zA-Z]*" error-message="letters only!"></paper-input>
<button onclick="validate()">Validate!</button>
</template>
</demo-snippet>
<h3>Inputs can have prefixes and suffixes</h3>
<demo-snippet class="horizontal">
<template>
<paper-input label="total" type="number">
<div prefix>$</div>
</paper-input>
<paper-input label="username" id="inputWithButton">
<iron-icon icon="mail" prefix></iron-icon>
<div suffix>@email.com</div>
<paper-icon-button suffix onclick="clearInput()"
icon="clear" alt="clear" title="clear">
</paper-icon-button>
</paper-input>
</template>
</demo-snippet>
<h3>Inputs can have custom logic</h3>
<demo-snippet>
<template>
<paper-input-container always-float-label auto-validate attr-for-value="value">
<label>Social Security Number</label>
<ssn-input class="paper-input-input"></ssn-input>
<paper-input-error>SSN invalid!</paper-input-error>
</paper-input-container>
</template>
</demo-snippet>
</div>
<script>
function validate() {
document.getElementById('inputForValidation').validate();
}
function clearInput() {
document.getElementById('inputWithButton').value = '';
}
</script>
</body>
</html>

View file

@ -1,96 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../iron-input/iron-input.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="ssn-validator.html">
<dom-module id="ssn-input">
<template>
<style>
:host {
display: inline-block;
}
:host([hidden]) {
display: none !important;
}
input[is="iron-input"] {
font: inherit;
outline: none;
box-shadow: none;
border: none;
width: auto;
text-align: center;
}
.container {
@apply(--layout-horizontal);
}
</style>
<ssn-validator></ssn-validator>
<div class="container">
<input is="iron-input" maxlength="3" bind-value="{{_ssn1}}" size="3" aria-label="First 3 digits of social security number">
-
<input is="iron-input" maxlength="2" bind-value="{{_ssn2}}" size="2" aria-label="Middle 2 digits of social security number">
-
<input is="iron-input" maxlength="4" bind-value="{{_ssn3}}" size="4" aria-label="Last 4 digits of social security number">
</div>
</template>
</dom-module>
<script>
Polymer({
is: 'ssn-input',
behaviors: [
Polymer.IronValidatableBehavior
],
properties: {
value: {
notify: true,
type: String
},
_ssn1: {
type: String
},
_ssn2: {
type: String
},
_ssn3: {
type: String
},
validator: {
type: String,
value: 'ssn-validator'
}
},
observers: [
'_computeValue(_ssn1,_ssn2,_ssn3)'
],
_computeValue: function(ssn1, ssn2, ssn3) {
this.value = ssn1.trim() + '-' + ssn2.trim() + '-' + ssn3.trim();
}
});
</script>

View file

@ -1,27 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../iron-validator-behavior/iron-validator-behavior.html">
<script>
Polymer({
is: 'ssn-validator',
behaviors: [
Polymer.IronValidatorBehavior
],
validate: function(value) {
// this regex validates incomplete ssn's (by design)
return !value || value.match(/^[0-9]{0,3}-[0-9]{0,2}-[0-9]{0,4}$/);
}
});
</script>

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
<g id="background" display="none">
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
</g>
<g id="label">
</g>
<g id="art">
<rect x="49" y="53" width="2" height="18"/>
<path d="M188,78H37V44h151V78z M39,76h147V46H39V76z"/>
<g id="ic_x5F_add_x0D_">
</g>
</g>
<g id="Guides">
</g>
</svg>

Before

Width:  |  Height:  |  Size: 733 B

View file

@ -1,28 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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, initial-scale=1.0">
<title>paper-input</title>
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
<iron-component-page src="all-imports.html"></iron-component-page>
</body>
</html>

View file

@ -1,47 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<script>
/**
* Use `Polymer.PaperInputAddonBehavior` to implement an add-on for `<paper-input-container>`. A
* add-on appears below the input, and may display information based on the input value and
* validity such as a character counter or an error message.
* @polymerBehavior
*/
Polymer.PaperInputAddonBehavior = {
hostAttributes: {
'add-on': ''
},
attached: function() {
this.fire('addon-attached');
},
/**
* The function called by `<paper-input-container>` when the input value or validity changes.
* @param {{
* inputElement: (Element|undefined),
* value: (string|undefined),
* invalid: boolean
* }} state -
* inputElement: The input element.
* value: The input value.
* invalid: True if the input value is invalid.
*/
update: function(state) {
}
};
</script>

View file

@ -1,569 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
<link rel="import" href="../iron-behaviors/iron-control-state.html">
<script>
// Generate unique, monotonically increasing IDs for labels (needed by
// aria-labelledby) and add-ons.
Polymer.PaperInputHelper = {};
Polymer.PaperInputHelper.NextLabelID = 1;
Polymer.PaperInputHelper.NextAddonID = 1;
/**
* Use `Polymer.PaperInputBehavior` to implement inputs with `<paper-input-container>`. This
* behavior is implemented by `<paper-input>`. It exposes a number of properties from
* `<paper-input-container>` and `<input is="iron-input">` and they should be bound in your
* template.
*
* The input element can be accessed by the `inputElement` property if you need to access
* properties or methods that are not exposed.
* @polymerBehavior Polymer.PaperInputBehavior
*/
Polymer.PaperInputBehaviorImpl = {
properties: {
/**
* Fired when the input changes due to user interaction.
*
* @event change
*/
/**
* The label for this input. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* `<label>`'s content and `hidden` property, e.g.
* `<label hidden$="[[!label]]">[[label]]</label>` in your `template`
*/
label: {
type: String
},
/**
* The value for this input. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* the `<input is="iron-input">`'s `bindValue`
* property, or the value property of your input that is `notify:true`.
*/
value: {
notify: true,
type: String
},
/**
* Set to true to disable this input. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* both the `<paper-input-container>`'s and the input's `disabled` property.
*/
disabled: {
type: Boolean,
value: false
},
/**
* Returns true if the value is invalid. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to both the
* `<paper-input-container>`'s and the input's `invalid` property.
*
* If `autoValidate` is true, the `invalid` attribute is managed automatically,
* which can clobber attempts to manage it manually.
*/
invalid: {
type: Boolean,
value: false,
notify: true
},
/**
* Set to true to prevent the user from entering invalid input. If you're
* using PaperInputBehavior to implement your own paper-input-like element,
* bind this to `<input is="iron-input">`'s `preventInvalidInput` property.
*/
preventInvalidInput: {
type: Boolean
},
/**
* Set this to specify the pattern allowed by `preventInvalidInput`. If
* you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `allowedPattern`
* property.
*/
allowedPattern: {
type: String
},
/**
* The type of the input. The supported types are `text`, `number` and `password`.
* If you're using PaperInputBehavior to implement your own paper-input-like element,
* bind this to the `<input is="iron-input">`'s `type` property.
*/
type: {
type: String
},
/**
* The datalist of the input (if any). This should match the id of an existing `<datalist>`.
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `list` property.
*/
list: {
type: String
},
/**
* A pattern to validate the `input` with. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* the `<input is="iron-input">`'s `pattern` property.
*/
pattern: {
type: String
},
/**
* Set to true to mark the input as required. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* the `<input is="iron-input">`'s `required` property.
*/
required: {
type: Boolean,
value: false
},
/**
* The error message to display when the input is invalid. If you're using
* PaperInputBehavior to implement your own paper-input-like element,
* bind this to the `<paper-input-error>`'s content, if using.
*/
errorMessage: {
type: String
},
/**
* Set to true to show a character counter.
*/
charCounter: {
type: Boolean,
value: false
},
/**
* Set to true to disable the floating label. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* the `<paper-input-container>`'s `noLabelFloat` property.
*/
noLabelFloat: {
type: Boolean,
value: false
},
/**
* Set to true to always float the label. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* the `<paper-input-container>`'s `alwaysFloatLabel` property.
*/
alwaysFloatLabel: {
type: Boolean,
value: false
},
/**
* Set to true to auto-validate the input value. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* the `<paper-input-container>`'s `autoValidate` property.
*/
autoValidate: {
type: Boolean,
value: false
},
/**
* Name of the validator to use. If you're using PaperInputBehavior to
* implement your own paper-input-like element, bind this to
* the `<input is="iron-input">`'s `validator` property.
*/
validator: {
type: String
},
// HTMLInputElement attributes for binding if needed
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `autocomplete` property.
*/
autocomplete: {
type: String,
value: 'off'
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `autofocus` property.
*/
autofocus: {
type: Boolean,
observer: '_autofocusChanged'
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `inputmode` property.
*/
inputmode: {
type: String
},
/**
* The minimum length of the input value.
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `minlength` property.
*/
minlength: {
type: Number
},
/**
* The maximum length of the input value.
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `maxlength` property.
*/
maxlength: {
type: Number
},
/**
* The minimum (numeric or date-time) input value.
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `min` property.
*/
min: {
type: String
},
/**
* The maximum (numeric or date-time) input value.
* Can be a String (e.g. `"2000-1-1"`) or a Number (e.g. `2`).
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `max` property.
*/
max: {
type: String
},
/**
* Limits the numeric or date-time increments.
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `step` property.
*/
step: {
type: String
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `name` property.
*/
name: {
type: String
},
/**
* A placeholder string in addition to the label. If this is set, the label will always float.
*/
placeholder: {
type: String,
// need to set a default so _computeAlwaysFloatLabel is run
value: ''
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `readonly` property.
*/
readonly: {
type: Boolean,
value: false
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `size` property.
*/
size: {
type: Number
},
// Nonstandard attributes for binding if needed
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `autocapitalize` property.
*/
autocapitalize: {
type: String,
value: 'none'
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `autocorrect` property.
*/
autocorrect: {
type: String,
value: 'off'
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `autosave` property,
* used with type=search.
*/
autosave: {
type: String
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `results` property,
* used with type=search.
*/
results: {
type: Number
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the `<input is="iron-input">`'s `accept` property,
* used with type=file.
*/
accept: {
type: String
},
/**
* If you're using PaperInputBehavior to implement your own paper-input-like
* element, bind this to the`<input is="iron-input">`'s `multiple` property,
* used with type=file.
*/
multiple: {
type: Boolean
},
_ariaDescribedBy: {
type: String,
value: ''
},
_ariaLabelledBy: {
type: String,
value: ''
}
},
listeners: {
'addon-attached': '_onAddonAttached',
},
keyBindings: {
'shift+tab:keydown': '_onShiftTabDown'
},
hostAttributes: {
tabindex: 0
},
/**
* Returns a reference to the input element.
*/
get inputElement() {
return this.$.input;
},
/**
* Returns a reference to the focusable element.
*/
get _focusableElement() {
return this.inputElement;
},
registered: function() {
// These types have some default placeholder text; overlapping
// the label on top of it looks terrible. Auto-float the label in this case.
this._typesThatHaveText = ["date", "datetime", "datetime-local", "month",
"time", "week", "file"];
},
attached: function() {
this._updateAriaLabelledBy();
if (this.inputElement &&
this._typesThatHaveText.indexOf(this.inputElement.type) !== -1) {
this.alwaysFloatLabel = true;
}
},
_appendStringWithSpace: function(str, more) {
if (str) {
str = str + ' ' + more;
} else {
str = more;
}
return str;
},
_onAddonAttached: function(event) {
var target = event.path ? event.path[0] : event.target;
if (target.id) {
this._ariaDescribedBy = this._appendStringWithSpace(this._ariaDescribedBy, target.id);
} else {
var id = 'paper-input-add-on-' + Polymer.PaperInputHelper.NextAddonID++;
target.id = id;
this._ariaDescribedBy = this._appendStringWithSpace(this._ariaDescribedBy, id);
}
},
/**
* Validates the input element and sets an error style if needed.
*
* @return {boolean}
*/
validate: function() {
return this.inputElement.validate();
},
/**
* Forward focus to inputElement. Overriden from IronControlState.
*/
_focusBlurHandler: function(event) {
Polymer.IronControlState._focusBlurHandler.call(this, event);
// Forward the focus to the nested input.
if (this.focused && !this._shiftTabPressed)
this._focusableElement.focus();
},
/**
* Handler that is called when a shift+tab keypress is detected by the menu.
*
* @param {CustomEvent} event A key combination event.
*/
_onShiftTabDown: function(event) {
var oldTabIndex = this.getAttribute('tabindex');
this._shiftTabPressed = true;
this.setAttribute('tabindex', '-1');
this.async(function() {
this.setAttribute('tabindex', oldTabIndex);
this._shiftTabPressed = false;
}, 1);
},
/**
* If `autoValidate` is true, then validates the element.
*/
_handleAutoValidate: function() {
if (this.autoValidate)
this.validate();
},
/**
* Restores the cursor to its original position after updating the value.
* @param {string} newValue The value that should be saved.
*/
updateValueAndPreserveCaret: function(newValue) {
// Not all elements might have selection, and even if they have the
// right properties, accessing them might throw an exception (like for
// <input type=number>)
try {
var start = this.inputElement.selectionStart;
this.value = newValue;
// The cursor automatically jumps to the end after re-setting the value,
// so restore it to its original position.
this.inputElement.selectionStart = start;
this.inputElement.selectionEnd = start;
} catch (e) {
// Just set the value and give up on the caret.
this.value = newValue;
}
},
_computeAlwaysFloatLabel: function(alwaysFloatLabel, placeholder) {
return placeholder || alwaysFloatLabel;
},
_updateAriaLabelledBy: function() {
var label = Polymer.dom(this.root).querySelector('label');
if (!label) {
this._ariaLabelledBy = '';
return;
}
var labelledBy;
if (label.id) {
labelledBy = label.id;
} else {
labelledBy = 'paper-input-label-' + Polymer.PaperInputHelper.NextLabelID++;
label.id = labelledBy;
}
this._ariaLabelledBy = labelledBy;
},
_onChange:function(event) {
// In the Shadow DOM, the `change` event is not leaked into the
// ancestor tree, so we must do this manually.
// See https://w3c.github.io/webcomponents/spec/shadow/#events-that-are-not-leaked-into-ancestor-trees.
if (this.shadowRoot) {
this.fire(event.type, {sourceEvent: event}, {
node: this,
bubbles: event.bubbles,
cancelable: event.cancelable
});
}
},
_autofocusChanged: function() {
// Firefox doesn't respect the autofocus attribute if it's applied after
// the page is loaded (Chrome/WebKit do respect it), preventing an
// autofocus attribute specified in markup from taking effect when the
// element is upgraded. As a workaround, if the autofocus property is set,
// and the focus hasn't already been moved elsewhere, we take focus.
if (this.autofocus && this._focusableElement) {
// In IE 11, the default document.activeElement can be the page's
// outermost html element, but there are also cases (under the
// polyfill?) in which the activeElement is not a real HTMLElement, but
// just a plain object. We identify the latter case as having no valid
// activeElement.
var activeElement = document.activeElement;
var isActiveElementValid = activeElement instanceof HTMLElement;
// Has some other element has already taken the focus?
var isSomeElementActive = isActiveElementValid &&
activeElement !== document.body &&
activeElement !== document.documentElement; /* IE 11 */
if (!isSomeElementActive) {
// No specific element has taken the focus yet, so we can take it.
this._focusableElement.focus();
}
}
}
}
/** @polymerBehavior */
Polymer.PaperInputBehavior = [
Polymer.IronControlState,
Polymer.IronA11yKeysBehavior,
Polymer.PaperInputBehaviorImpl
];
</script>

View file

@ -1,99 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="paper-input-addon-behavior.html">
<!--
`<paper-input-char-counter>` is a character counter for use with `<paper-input-container>`. It
shows the number of characters entered in the input and the max length if it is specified.
<paper-input-container>
<input is="iron-input" maxlength="20">
<paper-input-char-counter></paper-input-char-counter>
</paper-input-container>
### Styling
The following mixin is available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--paper-input-char-counter` | Mixin applied to the element | `{}`
-->
<dom-module id="paper-input-char-counter">
<template>
<style>
:host {
display: inline-block;
float: right;
@apply(--paper-font-caption);
@apply(--paper-input-char-counter);
}
:host([hidden]) {
display: none !important;
}
:host-context([dir="rtl"]) {
float: left;
}
</style>
<span>[[_charCounterStr]]</span>
</template>
</dom-module>
<script>
Polymer({
is: 'paper-input-char-counter',
behaviors: [
Polymer.PaperInputAddonBehavior
],
properties: {
_charCounterStr: {
type: String,
value: '0'
}
},
/**
* This overrides the update function in PaperInputAddonBehavior.
* @param {{
* inputElement: (Element|undefined),
* value: (string|undefined),
* invalid: boolean
* }} state -
* inputElement: The input element.
* value: The input value.
* invalid: True if the input value is invalid.
*/
update: function(state) {
if (!state.inputElement) {
return;
}
state.value = state.value || '';
var counter = state.value.toString().length.toString();
if (state.inputElement.hasAttribute('maxlength')) {
counter += '/' + state.inputElement.getAttribute('maxlength');
}
this._charCounterStr = counter;
}
});
</script>

View file

@ -1,621 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../paper-styles/default-theme.html">
<link rel="import" href="../paper-styles/typography.html">
<!--
`<paper-input-container>` is a container for a `<label>`, an `<input is="iron-input">` or
`<iron-autogrow-textarea>` and optional add-on elements such as an error message or character
counter, used to implement Material Design text fields.
For example:
<paper-input-container>
<label>Your name</label>
<input is="iron-input">
</paper-input-container>
Do not wrap `<paper-input-container>` around elements that already include it, such as `<paper-input>`.
Doing so may cause events to bounce infintely between the container and its contained element.
### Listening for input changes
By default, it listens for changes on the `bind-value` attribute on its children nodes and perform
tasks such as auto-validating and label styling when the `bind-value` changes. You can configure
the attribute it listens to with the `attr-for-value` attribute.
### Using a custom input element
You can use a custom input element in a `<paper-input-container>`, for example to implement a
compound input field like a social security number input. The custom input element should have the
`paper-input-input` class, have a `notify:true` value property and optionally implements
`Polymer.IronValidatableBehavior` if it is validatable.
<paper-input-container attr-for-value="ssn-value">
<label>Social security number</label>
<ssn-input class="paper-input-input"></ssn-input>
</paper-input-container>
If you're using a `<paper-input-container>` imperatively, it's important to make sure
that you attach its children (the `iron-input` and the optional `label`) before you
attach the `<paper-input-container>` itself, so that it can be set up correctly.
### Validation
If the `auto-validate` attribute is set, the input container will validate the input and update
the container styling when the input value changes.
### Add-ons
Add-ons are child elements of a `<paper-input-container>` with the `add-on` attribute and
implements the `Polymer.PaperInputAddonBehavior` behavior. They are notified when the input value
or validity changes, and may implement functionality such as error messages or character counters.
They appear at the bottom of the input.
### Prefixes and suffixes
These are child elements of a `<paper-input-container>` with the `prefix`
or `suffix` attribute, and are displayed inline with the input, before or after.
<paper-input-container>
<div prefix>$</div>
<label>Total</label>
<input is="iron-input">
<paper-icon-button suffix icon="clear"></paper-icon-button>
</paper-input-container>
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--paper-input-container-color` | Label and underline color when the input is not focused | `--secondary-text-color`
`--paper-input-container-focus-color` | Label and underline color when the input is focused | `--primary-color`
`--paper-input-container-invalid-color` | Label and underline color when the input is is invalid | `--error-color`
`--paper-input-container-input-color` | Input foreground color | `--primary-text-color`
`--paper-input-container` | Mixin applied to the container | `{}`
`--paper-input-container-disabled` | Mixin applied to the container when it's disabled | `{}`
`--paper-input-container-label` | Mixin applied to the label | `{}`
`--paper-input-container-label-focus` | Mixin applied to the label when the input is focused | `{}`
`--paper-input-container-label-floating` | Mixin applied to the label when floating | `{}`
`--paper-input-container-input` | Mixin applied to the input | `{}`
`--paper-input-container-underline` | Mixin applied to the underline | `{}`
`--paper-input-container-underline-focus` | Mixin applied to the underline when the input is focused | `{}`
`--paper-input-container-underline-disabled` | Mixin applied to the underline when the input is disabled | `{}`
`--paper-input-prefix` | Mixin applied to the input prefix | `{}`
`--paper-input-suffix` | Mixin applied to the input suffix | `{}`
This element is `display:block` by default, but you can set the `inline` attribute to make it
`display:inline-block`.
-->
<dom-module id="paper-input-container">
<template>
<style>
:host {
display: block;
padding: 8px 0;
@apply(--paper-input-container);
}
:host([inline]) {
display: inline-block;
}
:host([disabled]) {
pointer-events: none;
opacity: 0.33;
@apply(--paper-input-container-disabled);
}
:host([hidden]) {
display: none !important;
}
.floated-label-placeholder {
@apply(--paper-font-caption);
}
.underline {
position: relative;
}
.focused-line {
@apply(--layout-fit);
background: var(--paper-input-container-focus-color, --primary-color);
height: 2px;
-webkit-transform-origin: center center;
transform-origin: center center;
-webkit-transform: scale3d(0,1,1);
transform: scale3d(0,1,1);
@apply(--paper-input-container-underline-focus);
}
.underline.is-highlighted .focused-line {
-webkit-transform: none;
transform: none;
-webkit-transition: -webkit-transform 0.25s;
transition: transform 0.25s;
@apply(--paper-transition-easing);
}
.underline.is-invalid .focused-line {
background: var(--paper-input-container-invalid-color, --error-color);
-webkit-transform: none;
transform: none;
-webkit-transition: -webkit-transform 0.25s;
transition: transform 0.25s;
@apply(--paper-transition-easing);
}
.unfocused-line {
@apply(--layout-fit);
background: var(--paper-input-container-color, --secondary-text-color);
height: 1px;
@apply(--paper-input-container-underline);
}
:host([disabled]) .unfocused-line {
border-bottom: 1px dashed;
border-color: var(--paper-input-container-color, --secondary-text-color);
background: transparent;
@apply(--paper-input-container-underline-disabled);
}
.label-and-input-container {
@apply(--layout-flex-auto);
@apply(--layout-relative);
width: 100%;
max-width: 100%;
}
.input-content {
@apply(--layout-horizontal);
@apply(--layout-center);
position: relative;
}
.input-content ::content label,
.input-content ::content .paper-input-label {
position: absolute;
top: 0;
right: 0;
left: 0;
width: 100%;
font: inherit;
color: var(--paper-input-container-color, --secondary-text-color);
-webkit-transition: -webkit-transform 0.25s, width 0.25s;
transition: transform 0.25s, width 0.25s;
-webkit-transform-origin: left top;
transform-origin: left top;
@apply(--paper-font-common-nowrap);
@apply(--paper-font-subhead);
@apply(--paper-input-container-label);
@apply(--paper-transition-easing);
}
.input-content.label-is-floating ::content label,
.input-content.label-is-floating ::content .paper-input-label {
-webkit-transform: translateY(-75%) scale(0.75);
transform: translateY(-75%) scale(0.75);
/* Since we scale to 75/100 of the size, we actually have 100/75 of the
original space now available */
width: 133%;
@apply(--paper-input-container-label-floating);
}
:host-context([dir="rtl"]) .input-content.label-is-floating ::content label,
:host-context([dir="rtl"]) .input-content.label-is-floating ::content .paper-input-label {
/* TODO(noms): Figure out why leaving the width at 133% before the animation
* actually makes
* it wider on the right side, not left side, as you would expect in RTL */
width: 100%;
-webkit-transform-origin: right top;
transform-origin: right top;
}
.input-content.label-is-highlighted ::content label,
.input-content.label-is-highlighted ::content .paper-input-label {
color: var(--paper-input-container-focus-color, --primary-color);
@apply(--paper-input-container-label-focus);
}
.input-content.is-invalid ::content label,
.input-content.is-invalid ::content .paper-input-label {
color: var(--paper-input-container-invalid-color, --error-color);
}
.input-content.label-is-hidden ::content label,
.input-content.label-is-hidden ::content .paper-input-label {
visibility: hidden;
}
.input-content ::content input,
.input-content ::content textarea,
.input-content ::content iron-autogrow-textarea,
.input-content ::content .paper-input-input {
position: relative; /* to make a stacking context */
outline: none;
box-shadow: none;
padding: 0;
width: 100%;
max-width: 100%;
background: transparent;
border: none;
color: var(--paper-input-container-input-color, --primary-text-color);
-webkit-appearance: none;
text-align: inherit;
@apply(--paper-font-subhead);
@apply(--paper-input-container-input);
}
::content [prefix] {
@apply(--paper-font-subhead);
@apply(--paper-input-prefix);
@apply(--layout-flex-none);
}
::content [suffix] {
@apply(--paper-font-subhead);
@apply(--paper-input-suffix);
@apply(--layout-flex-none);
}
/* Firefox sets a min-width on the input, which can cause layout issues */
.input-content ::content input {
min-width: 0;
}
.input-content ::content textarea {
resize: none;
}
.add-on-content {
position: relative;
}
.add-on-content.is-invalid ::content * {
color: var(--paper-input-container-invalid-color, --error-color);
}
.add-on-content.is-highlighted ::content * {
color: var(--paper-input-container-focus-color, --primary-color);
}
</style>
<template is="dom-if" if="[[!noLabelFloat]]">
<div class="floated-label-placeholder" aria-hidden="true">&nbsp;</div>
</template>
<div class$="[[_computeInputContentClass(noLabelFloat,alwaysFloatLabel,focused,invalid,_inputHasContent)]]">
<content select="[prefix]" id="prefix"></content>
<div class="label-and-input-container" id="labelAndInputContainer">
<content select=":not([add-on]):not([prefix]):not([suffix])"></content>
</div>
<content select="[suffix]"></content>
</div>
<div class$="[[_computeUnderlineClass(focused,invalid)]]">
<div class="unfocused-line"></div>
<div class="focused-line"></div>
</div>
<div class$="[[_computeAddOnContentClass(focused,invalid)]]">
<content id="addOnContent" select="[add-on]"></content>
</div>
</template>
</dom-module>
<script>
Polymer({
is: 'paper-input-container',
properties: {
/**
* Set to true to disable the floating label. The label disappears when the input value is
* not null.
*/
noLabelFloat: {
type: Boolean,
value: false
},
/**
* Set to true to always float the floating label.
*/
alwaysFloatLabel: {
type: Boolean,
value: false
},
/**
* The attribute to listen for value changes on.
*/
attrForValue: {
type: String,
value: 'bind-value'
},
/**
* Set to true to auto-validate the input value when it changes.
*/
autoValidate: {
type: Boolean,
value: false
},
/**
* True if the input is invalid. This property is set automatically when the input value
* changes if auto-validating, or when the `iron-input-validate` event is heard from a child.
*/
invalid: {
observer: '_invalidChanged',
type: Boolean,
value: false
},
/**
* True if the input has focus.
*/
focused: {
readOnly: true,
type: Boolean,
value: false,
notify: true
},
_addons: {
type: Array
// do not set a default value here intentionally - it will be initialized lazily when a
// distributed child is attached, which may occur before configuration for this element
// in polyfill.
},
_inputHasContent: {
type: Boolean,
value: false
},
_inputSelector: {
type: String,
value: 'input,textarea,.paper-input-input'
},
_boundOnFocus: {
type: Function,
value: function() {
return this._onFocus.bind(this);
}
},
_boundOnBlur: {
type: Function,
value: function() {
return this._onBlur.bind(this);
}
},
_boundOnInput: {
type: Function,
value: function() {
return this._onInput.bind(this);
}
},
_boundValueChanged: {
type: Function,
value: function() {
return this._onValueChanged.bind(this);
}
}
},
listeners: {
'addon-attached': '_onAddonAttached',
'iron-input-validate': '_onIronInputValidate'
},
get _valueChangedEvent() {
return this.attrForValue + '-changed';
},
get _propertyForValue() {
return Polymer.CaseMap.dashToCamelCase(this.attrForValue);
},
get _inputElement() {
return Polymer.dom(this).querySelector(this._inputSelector);
},
get _inputElementValue() {
return this._inputElement[this._propertyForValue] || this._inputElement.value;
},
ready: function() {
if (!this._addons) {
this._addons = [];
}
this.addEventListener('focus', this._boundOnFocus, true);
this.addEventListener('blur', this._boundOnBlur, true);
},
attached: function() {
if (this.attrForValue) {
this._inputElement.addEventListener(this._valueChangedEvent, this._boundValueChanged);
} else {
this.addEventListener('input', this._onInput);
}
// Only validate when attached if the input already has a value.
if (this._inputElementValue != '') {
this._handleValueAndAutoValidate(this._inputElement);
} else {
this._handleValue(this._inputElement);
}
},
_onAddonAttached: function(event) {
if (!this._addons) {
this._addons = [];
}
var target = event.target;
if (this._addons.indexOf(target) === -1) {
this._addons.push(target);
if (this.isAttached) {
this._handleValue(this._inputElement);
}
}
},
_onFocus: function() {
this._setFocused(true);
},
_onBlur: function() {
this._setFocused(false);
this._handleValueAndAutoValidate(this._inputElement);
},
_onInput: function(event) {
this._handleValueAndAutoValidate(event.target);
},
_onValueChanged: function(event) {
this._handleValueAndAutoValidate(event.target);
},
_handleValue: function(inputElement) {
var value = this._inputElementValue;
// type="number" hack needed because this.value is empty until it's valid
if (value || value === 0 || (inputElement.type === 'number' && !inputElement.checkValidity())) {
this._inputHasContent = true;
} else {
this._inputHasContent = false;
}
this.updateAddons({
inputElement: inputElement,
value: value,
invalid: this.invalid
});
},
_handleValueAndAutoValidate: function(inputElement) {
if (this.autoValidate) {
var valid;
if (inputElement.validate) {
valid = inputElement.validate(this._inputElementValue);
} else {
valid = inputElement.checkValidity();
}
this.invalid = !valid;
}
// Call this last to notify the add-ons.
this._handleValue(inputElement);
},
_onIronInputValidate: function(event) {
this.invalid = this._inputElement.invalid;
},
_invalidChanged: function() {
if (this._addons) {
this.updateAddons({invalid: this.invalid});
}
},
/**
* Call this to update the state of add-ons.
* @param {Object} state Add-on state.
*/
updateAddons: function(state) {
for (var addon, index = 0; addon = this._addons[index]; index++) {
addon.update(state);
}
},
_computeInputContentClass: function(noLabelFloat, alwaysFloatLabel, focused, invalid, _inputHasContent) {
var cls = 'input-content';
if (!noLabelFloat) {
var label = this.querySelector('label');
if (alwaysFloatLabel || _inputHasContent) {
cls += ' label-is-floating';
// If the label is floating, ignore any offsets that may have been
// applied from a prefix element.
this.$.labelAndInputContainer.style.position = 'static';
if (invalid) {
cls += ' is-invalid';
} else if (focused) {
cls += " label-is-highlighted";
}
} else {
// When the label is not floating, it should overlap the input element.
if (label) {
this.$.labelAndInputContainer.style.position = 'relative';
}
}
} else {
if (_inputHasContent) {
cls += ' label-is-hidden';
}
}
return cls;
},
_computeUnderlineClass: function(focused, invalid) {
var cls = 'underline';
if (invalid) {
cls += ' is-invalid';
} else if (focused) {
cls += ' is-highlighted'
}
return cls;
},
_computeAddOnContentClass: function(focused, invalid) {
var cls = 'add-on-content';
if (invalid) {
cls += ' is-invalid';
} else if (focused) {
cls += ' is-highlighted'
}
return cls;
}
});
</script>

View file

@ -1,94 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-styles/default-theme.html">
<link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="paper-input-addon-behavior.html">
<!--
`<paper-input-error>` is an error message for use with `<paper-input-container>`. The error is
displayed when the `<paper-input-container>` is `invalid`.
<paper-input-container>
<input is="iron-input" pattern="[0-9]*">
<paper-input-error>Only numbers are allowed!</paper-input-error>
</paper-input-container>
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--paper-input-container-invalid-color` | The foreground color of the error | `--error-color`
`--paper-input-error` | Mixin applied to the error | `{}`
-->
<dom-module id="paper-input-error">
<template>
<style>
:host {
display: inline-block;
visibility: hidden;
color: var(--paper-input-container-invalid-color, --error-color);
@apply(--paper-font-caption);
@apply(--paper-input-error);
position: absolute;
left:0;
right:0;
}
:host([invalid]) {
visibility: visible;
};
</style>
<content></content>
</template>
</dom-module>
<script>
Polymer({
is: 'paper-input-error',
behaviors: [
Polymer.PaperInputAddonBehavior
],
properties: {
/**
* True if the error is showing.
*/
invalid: {
readOnly: true,
reflectToAttribute: true,
type: Boolean
}
},
/**
* This overrides the update function in PaperInputAddonBehavior.
* @param {{
* inputElement: (Element|undefined),
* value: (string|undefined),
* invalid: boolean
* }} state -
* inputElement: The input element.
* value: The input value.
* invalid: True if the input value is invalid.
*/
update: function(state) {
this._setInvalid(state.invalid);
}
});
</script>

View file

@ -1,170 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
<link rel="import" href="../iron-input/iron-input.html">
<link rel="import" href="paper-input-behavior.html">
<link rel="import" href="paper-input-char-counter.html">
<link rel="import" href="paper-input-container.html">
<link rel="import" href="paper-input-error.html">
<!--
Material design: [Text fields](https://www.google.com/design/spec/components/text-fields.html)
`<paper-input>` is a single-line text field with Material Design styling.
<paper-input label="Input label"></paper-input>
It may include an optional error message or character counter.
<paper-input error-message="Invalid input!" label="Input label"></paper-input>
<paper-input char-counter label="Input label"></paper-input>
It can also include custom prefix or suffix elements, which are displayed
before or after the text input itself. In order for an element to be
considered as a prefix, it must have the `prefix` attribute (and similarly
for `suffix`).
<paper-input label="total">
<div prefix>$</div>
<paper-icon-button suffix icon="clear"></paper-icon-button>
</paper-input>
A `paper-input` can use the native `type=search` or `type=file` features.
However, since we can't control the native styling of the input (search icon,
file button, date placeholder, etc.), in these cases the label will be
automatically floated. The `placeholder` attribute can still be used for
additional informational text.
<paper-input label="search!" type="search"
placeholder="search for cats" autosave="test" results="5">
</paper-input>
See `Polymer.PaperInputBehavior` for more API docs.
### Focus
To focus a paper-input, you can call the native `focus()` method as long as the
paper input has a tab index.
### Styling
See `Polymer.PaperInputContainer` for a list of custom properties used to
style this element.
@group Paper Elements
@element paper-input
@hero hero.svg
@demo demo/index.html
-->
<dom-module id="paper-input">
<template>
<style>
:host {
display: block;
}
:host([focused]) {
outline: none;
}
:host([hidden]) {
display: none !important;
}
input::-webkit-input-placeholder {
color: var(--paper-input-container-color, --secondary-text-color);
}
input:-moz-placeholder {
color: var(--paper-input-container-color, --secondary-text-color);
}
input::-moz-placeholder {
color: var(--paper-input-container-color, --secondary-text-color);
}
input:-ms-input-placeholder {
color: var(--paper-input-container-color, --secondary-text-color);
}
label {
pointer-events: none;
}
</style>
<paper-input-container no-label-float="[[noLabelFloat]]" always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]" auto-validate$="[[autoValidate]]" disabled$="[[disabled]]" invalid="[[invalid]]">
<content select="[prefix]"></content>
<label hidden$="[[!label]]" aria-hidden="true" for="input">[[label]]</label>
<input is="iron-input" id="input"
aria-labelledby$="[[_ariaLabelledBy]]"
aria-describedby$="[[_ariaDescribedBy]]"
disabled$="[[disabled]]"
title$="[[title]]"
bind-value="{{value}}"
invalid="{{invalid}}"
prevent-invalid-input="[[preventInvalidInput]]"
allowed-pattern="[[allowedPattern]]"
validator="[[validator]]"
type$="[[type]]"
pattern$="[[pattern]]"
required$="[[required]]"
autocomplete$="[[autocomplete]]"
autofocus$="[[autofocus]]"
inputmode$="[[inputmode]]"
minlength$="[[minlength]]"
maxlength$="[[maxlength]]"
min$="[[min]]"
max$="[[max]]"
step$="[[step]]"
name$="[[name]]"
placeholder$="[[placeholder]]"
readonly$="[[readonly]]"
list$="[[list]]"
size$="[[size]]"
autocapitalize$="[[autocapitalize]]"
autocorrect$="[[autocorrect]]"
on-change="_onChange"
tabindex$="[[tabindex]]"
autosave$="[[autosave]]"
results$="[[results]]"
accept$="[[accept]]"
multiple$="[[multiple]]">
<content select="[suffix]"></content>
<template is="dom-if" if="[[errorMessage]]">
<paper-input-error aria-live="assertive">[[errorMessage]]</paper-input-error>
</template>
<template is="dom-if" if="[[charCounter]]">
<paper-input-char-counter></paper-input-char-counter>
</template>
</paper-input-container>
</template>
</dom-module>
<script>
Polymer({
is: 'paper-input',
behaviors: [
Polymer.IronFormElementBehavior,
Polymer.PaperInputBehavior
]
});
</script>

View file

@ -1,142 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-autogrow-textarea/iron-autogrow-textarea.html">
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
<link rel="import" href="paper-input-behavior.html">
<link rel="import" href="paper-input-char-counter.html">
<link rel="import" href="paper-input-container.html">
<link rel="import" href="paper-input-error.html">
<!--
`<paper-textarea>` is a multi-line text field with Material Design styling.
<paper-textarea label="Textarea label"></paper-textarea>
See `Polymer.PaperInputBehavior` for more API docs.
### Validation
Currently only `required` and `maxlength` validation is supported.
### Styling
See `Polymer.PaperInputContainer` for a list of custom properties used to
style this element.
-->
<dom-module id="paper-textarea">
<template>
<style>
:host {
display: block;
}
:host([hidden]) {
display: none !important;
}
label {
pointer-events: none;
}
</style>
<paper-input-container no-label-float$="[[noLabelFloat]]" always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]" auto-validate$="[[autoValidate]]" disabled$="[[disabled]]" invalid="[[invalid]]">
<label hidden$="[[!label]]" aria-hidden="true">[[label]]</label>
<iron-autogrow-textarea id="input" class="paper-input-input"
bind-value="{{value}}"
disabled$="[[disabled]]"
autocomplete$="[[autocomplete]]"
autofocus$="[[autofocus]]"
inputmode$="[[inputmode]]"
name$="[[name]]"
placeholder$="[[placeholder]]"
readonly$="[[readonly]]"
required$="[[required]]"
maxlength$="[[maxlength]]"
autocapitalize$="[[autocapitalize]]"
rows$="[[rows]]"
max-rows$="[[maxRows]]"
on-change="_onChange"></iron-autogrow-textarea>
<template is="dom-if" if="[[errorMessage]]">
<paper-input-error>[[errorMessage]]</paper-input-error>
</template>
<template is="dom-if" if="[[charCounter]]">
<paper-input-char-counter></paper-input-char-counter>
</template>
</paper-input-container>
</template>
</dom-module>
<script>
Polymer({
is: 'paper-textarea',
behaviors: [
Polymer.PaperInputBehavior,
Polymer.IronFormElementBehavior
],
properties: {
_ariaLabelledBy: {
observer: '_ariaLabelledByChanged',
type: String
},
_ariaDescribedBy: {
observer: '_ariaDescribedByChanged',
type: String
},
/**
* The initial number of rows.
*
* @attribute rows
* @type number
* @default 1
*/
rows: {
type: Number,
value: 1
},
/**
* The maximum number of rows this element can grow to until it
* scrolls. 0 means no maximum.
*
* @attribute maxRows
* @type number
* @default 0
*/
maxRows: {
type: Number,
value: 0
}
},
_ariaLabelledByChanged: function(ariaLabelledBy) {
this.$.input.textarea.setAttribute('aria-labelledby', ariaLabelledBy);
},
_ariaDescribedByChanged: function(ariaDescribedBy) {
this.$.input.textarea.setAttribute('aria-describedby', ariaDescribedBy);
},
get _focusableElement() {
return this.$.input.textarea;
},
});
</script>

View file

@ -1,32 +0,0 @@
<!DOCTYPE html><!--
@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
--><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>paper-input tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'paper-input.html',
'paper-textarea.html',
'paper-input-container.html',
'paper-input-error.html',
'paper-input-char-counter.html',
'paper-input.html?dom=shadow',
'paper-textarea.html?dom=shadow',
'paper-input-container.html?dom=shadow',
'paper-input-error.html?dom=shadow',
'paper-input-char-counter.html?dom=shadow'
]);
</script>
</body></html>

View file

@ -1,30 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../iron-validator-behavior/iron-validator-behavior.html">
<script>
Polymer({
is: 'letters-only',
behaviors: [
Polymer.IronValidatorBehavior
],
validate: function(value) {
return !value || value.match(/^[a-zA-Z]*$/) !== null;
}
});
</script>

View file

@ -1,109 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>
<title>paper-input-counter tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../iron-test-helpers/test-helpers.js"></script>
<link rel="import" href="../../iron-input/iron-input.html">
<link rel="import" href="../paper-input-container.html">
<link rel="import" href="../paper-input-char-counter.html">
<link rel="import" href="../paper-textarea.html">
</head>
<body>
<test-fixture id="counter">
<template>
<paper-input-container>
<label id="l">label</label>
<input id="i" value="foobar">
<paper-input-char-counter id="c"></paper-input-char-counter>
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="counter-with-max">
<template>
<paper-input-container>
<label id="l">label</label>
<input id="i" value="foobar" maxlength="10">
<paper-input-char-counter id="c"></paper-input-char-counter>
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="textarea">
<template>
<paper-textarea char-counter value="foobar"></paper-textarea>
</template>
</test-fixture>
<test-fixture id="textarea-with-max">
<template>
<paper-textarea char-counter value="foobar" maxlength="100"></paper-textarea>
</template>
</test-fixture>
<script>
suite('basic', function() {
test('character counter shows the value length', function() {
var container = fixture('counter');
var input = Polymer.dom(container).querySelector('#i');
var counter = Polymer.dom(container).querySelector('#c');
assert.equal(counter._charCounterStr, input.value.length, 'character counter shows input value length');
});
test('character counter shows the value length with maxlength', function() {
var container = fixture('counter-with-max');
var input = Polymer.dom(container).querySelector('#i');
var counter = Polymer.dom(container).querySelector('#c');
assert.equal(counter._charCounterStr, input.value.length + '/' + input.maxLength, 'character counter shows input value length and maxLength');
});
test('character counter shows the value length with maxlength', function() {
var input = fixture('textarea-with-max');
forceXIfStamp(input);
var counter = Polymer.dom(input.root).querySelector('paper-input-char-counter');
assert.ok(counter, 'paper-input-char-counter exists');
assert.equal(counter._charCounterStr, input.value.length + '/' + input.inputElement.textarea.getAttribute('maxlength'), 'character counter shows input value length and maxLength');
});
test('character counter counts new lines in textareas correctly', function() {
var input = fixture('textarea');
input.value = 'foo\nbar';
forceXIfStamp(input);
var counter = Polymer.dom(input.root).querySelector('paper-input-char-counter')
assert.ok(counter, 'paper-input-char-counter exists');
assert.equal(counter._charCounterStr, input.value.length, 'character counter shows the value length');
});
});
</script>
</body>
</html>

View file

@ -1,302 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>
<title>paper-input-container tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="../../iron-input/iron-input.html">
<link rel="import" href="../paper-input-container.html">
<link rel="import" href="letters-only.html">
</head>
<body>
<test-fixture id="basic">
<template>
<paper-input-container>
<label id="l">label</label>
<input id="i">
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="prefix">
<template>
<paper-input-container>
<div prefix>$</div>
<label id="l">label</label>
<input is="iron-input" id="i">
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="prefix-has-value">
<template>
<paper-input-container>
<div prefix>$</div>
<label id="l">label</label>
<input is="iron-input" id="i" value="foo">
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="has-value">
<template>
<paper-input-container>
<label id="l">label</label>
<input id="i" value="value">
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="no-float-has-value">
<template>
<paper-input-container no-label-float>
<label id="l">label</label>
<input id="i" value="value">
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="always-float">
<template>
<paper-input-container always-float-label>
<label id="l">label</label>
<input id="i" value="value">
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="auto-validate-numbers">
<template>
<paper-input-container auto-validate>
<label id="l">label</label>
<input is="iron-input" id="i" pattern="[0-9]*">
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="manual-validate-numbers">
<template>
<paper-input-container>
<label id="l">label</label>
<input is="iron-input" id="i" pattern="[0-9]*">
</paper-input-container>
</template>
</test-fixture>
<letters-only></letters-only>
<test-fixture id="auto-validate-validator">
<template>
<paper-input-container auto-validate>
<label id="l">label</label>
<input is="iron-input" id="i" pattern="[0-9]*" validator="letters-only">
</paper-input-container>
</template>
</test-fixture>
<test-fixture id="auto-validate-validator-has-invalid-value">
<template>
<paper-input-container auto-validate>
<label id="l">label</label>
<input is="iron-input" id="i" validator="letters-only" value="123123">
</paper-input-container>
</template>
</test-fixture>
<script>
function getTransform(node) {
var style = getComputedStyle(node);
return style.transform || style.webkitTransform;
}
suite('basic', function() {
test('can be created imperatively', function() {
var container = document.createElement('paper-input-container');
var input = document.createElement('input', 'iron-input');
input.className = 'paper-input-input';
input.id = 'input';
var label = document.createElement('label');
label.innerHTML = 'label';
Polymer.dom(container).appendChild(label);
Polymer.dom(container).appendChild(input);
document.body.appendChild(container);
assert.isOk(container);
document.body.removeChild(container);
});
});
suite('label position', function() {
test('label is visible by default', function() {
var container = fixture('basic');
assert.equal(getComputedStyle(container.querySelector('#l')).visibility, 'visible', 'label has visibility:visible');
});
test('label is floated if value is initialized to not null', function(done) {
var container = fixture('has-value');
requestAnimationFrame(function() {
assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform');
done();
});
});
test('label is invisible if no-label-float and value is initialized to not null', function() {
var container = fixture('no-float-has-value');
assert.equal(getComputedStyle(container.querySelector('#l')).visibility, 'hidden', 'label has visibility:hidden');
});
test('label is floated if always-float-label is true', function() {
var container = fixture('always-float');
assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform');
});
test('label is floated correctly with a prefix', function(done) {
var container = fixture('prefix');
var label = Polymer.dom(container).querySelector('#l');
var input = Polymer.dom(container).querySelector('#i');
// Label is initially visible.
assert.equal(getComputedStyle(label).visibility, 'visible', 'label has visibility:visible');
// After entering text, the label floats, and it is not indented.
input.bindValue = 'foobar';
requestAnimationFrame(function() {
assert.notEqual(getTransform(label), 'none', 'label has transform');
assert.equal(label.getBoundingClientRect().left, container.getBoundingClientRect().left);
done();
});
});
test('label is floated correctly with a prefix and prefilled value', function(done) {
var container = fixture('prefix-has-value');
var label = Polymer.dom(container).querySelector('#l');
// The label floats, and it is not indented.
requestAnimationFrame(function() {
assert.notEqual(getTransform(label), 'none', 'label has transform');
assert.equal(label.getBoundingClientRect().left, container.getBoundingClientRect().left);
done();
});
});
});
suite('focused styling', function() {
test('label is colored when input is focused and has value', function(done) {
var container = fixture('has-value');
var label = Polymer.dom(container).querySelector('#l');
var input = Polymer.dom(container).querySelector('#i');
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
MockInteractions.focus(input);
requestAnimationFrame(function() {
assert.isTrue(container.focused, 'focused is true');
assert.isTrue(inputContent.classList.contains('label-is-highlighted'), 'label is highlighted when input has focus');
done();
});
});
test('label is not colored when input is focused and has null value', function(done) {
var container = fixture('basic');
var label = Polymer.dom(container).querySelector('#l');
var input = Polymer.dom(container).querySelector('#i');
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
MockInteractions.focus(input);
requestAnimationFrame(function() {
assert.isFalse(inputContent.classList.contains('label-is-highlighted'), 'label is not highlighted when input has focus and has null value');
done();
});
});
test('underline is colored when input is focused', function(done) {
var container = fixture('basic');
var input = Polymer.dom(container).querySelector('#i');
var line = Polymer.dom(container.root).querySelector('.underline');
assert.isFalse(line.classList.contains('is-highlighted'), 'line is not highlighted when input is not focused');
MockInteractions.focus(input);
requestAnimationFrame(function() {
assert.isTrue(line.classList.contains('is-highlighted'), 'line is highlighted when input is focused');
done();
});
});
});
suite('validation', function() {
test('styled when the input is set to an invalid value with auto-validate', function() {
var container = fixture('auto-validate-numbers');
var input = Polymer.dom(container).querySelector('#i');
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
var line = Polymer.dom(container.root).querySelector('.underline');
input.bindValue = 'foobar';
assert.isTrue(container.invalid, 'invalid is true');
assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
});
test('styled when the input is set to an invalid value with auto-validate, with validator', function() {
var container = fixture('auto-validate-validator');
var input = Polymer.dom(container).querySelector('#i');
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
var line = Polymer.dom(container.root).querySelector('.underline');
input.bindValue = '123123';
assert.isTrue(container.invalid, 'invalid is true');
assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
});
test('styled when the input is set initially to an invalid value with auto-validate, with validator', function() {
var container = fixture('auto-validate-validator-has-invalid-value');
assert.isTrue(container.invalid, 'invalid is true');
assert.isTrue(Polymer.dom(container.root).querySelector('.underline').classList.contains('is-invalid'), 'underline has is-invalid class');
});
test('styled when the input is set to an invalid value with manual validation', function() {
var container = fixture('manual-validate-numbers');
var input = Polymer.dom(container).querySelector('#i');
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
var line = Polymer.dom(container.root).querySelector('.underline');
input.bindValue = 'foobar';
input.validate();
assert.isTrue(container.invalid, 'invalid is true');
assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
});
});
</script>
</body>
</html>

View file

@ -1,68 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>
<title>paper-input-error tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../../iron-input/iron-input.html">
<link rel="import" href="../paper-input-container.html">
<link rel="import" href="../paper-input-error.html">
</head>
<body>
<paper-input-container id="container">
<input is="iron-input">
<paper-input-error>error</paper-input-error>
</paper-input-container>
<test-fixture id="auto-validate-numbers">
<template>
<paper-input-container auto-validate attr-for-value="bind-value">
<label id="l">label</label>
<input is="iron-input" id="i" pattern="[0-9]*">
<paper-input-error id="e">error</paper-input-error>
</paper-input-container>
</template>
</test-fixture>
<script>
suite('basic', function() {
test('error message only appears when input is invalid', function() {
var container = fixture('auto-validate-numbers');
var input = Polymer.dom(container).querySelector('#i');
var error = Polymer.dom(container).querySelector('#e');
assert.equal(getComputedStyle(error).visibility, 'hidden', 'error is visibility:hidden');
input.bindValue = 'foobar';
assert.notEqual(getComputedStyle(error).visibility, 'hidden', 'error is not visibility:hidden');
});
test('error message add on is registered', function() {
var container = document.getElementById('container');
assert.isTrue(container._addons && container._addons.length === 1, 'add on is registered');
});
});
</script>
</body>
</html>

View file

@ -1,398 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>
<title>paper-input tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../iron-test-helpers/test-helpers.js"></script>
<script src="../../iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="../paper-input.html">
<link rel="import" href="letters-only.html">
</head>
<body>
<test-fixture id="basic">
<template>
<paper-input></paper-input>
</template>
</test-fixture>
<test-fixture id="has-tabindex">
<template>
<paper-input tabindex="0"></paper-input>
</template>
</test-fixture>
<test-fixture id="label">
<template>
<paper-input label="foo"></paper-input>
</template>
</test-fixture>
<test-fixture id="label-has-value">
<template>
<paper-input label="foo" value="bar"></paper-input>
</template>
</test-fixture>
<test-fixture id="error">
<template>
<paper-input auto-validate pattern="[0-9]*" value="foobar" error-message="error"></paper-input>
</template>
</test-fixture>
<test-fixture id="required">
<template>
<paper-input auto-validate required error-message="error"></paper-input>
</template>
</test-fixture>
<test-fixture id="required-no-auto-validate">
<template>
<paper-input required error-message="error"></paper-input>
</template>
</test-fixture>
<test-fixture id="required-char-counter">
<template>
<paper-input auto-validate char-counter required error-message="error"></paper-input>
</template>
</test-fixture>
<test-fixture id="char-counter">
<template>
<paper-input char-counter value="foobar"></paper-input>
</template>
</test-fixture>
<test-fixture id="type-number-char-counter">
<template>
<paper-input type="number" char-counter value="1138"></paper-input>
</template>
</test-fixture>
<test-fixture id="always-float-label">
<template>
<paper-input always-float-label label="foo"></paper-input>
</template>
</test-fixture>
<test-fixture id="placeholder">
<template>
<paper-input label="foo" placeholder="bar"></paper-input>
</template>
</test-fixture>
<test-fixture id="date">
<template>
<paper-input label="foo" type="date"></paper-input>
</template>
</test-fixture>
<letters-only></letters-only>
<test-fixture id="validator">
<template>
<paper-input value="123123" validator="letters-only" auto-validate></paper-input>
</template>
</test-fixture>
<test-fixture id="multiple-inputs">
<template>
<paper-input label="one"></paper-input>
<paper-input label="two"></paper-input>
<paper-input label="three"></paper-input>
<paper-input label="four"></paper-input>
</template>
</test-fixture>
<script>
suite('basic', function() {
test('setting value sets the input value', function() {
var input = fixture('basic');
input.value = 'foobar';
assert.equal(input.inputElement.value, input.value, 'inputElement.value equals input.value');
});
test('placeholder does not overlap label', function() {
var input = fixture('placeholder');
assert.equal(input.inputElement.placeholder, input.placeholder, 'inputElement.placeholder equals input.placeholder');
assert.equal(input.noLabelFloat, false);
var floatingLabel = Polymer.dom(Polymer.dom(input.root).querySelector('paper-input-container').root).querySelector('.label-is-floating');
assert.ok(floatingLabel);
});
test('special types autofloat the label', function() {
var input = fixture('date');
// Browsers that don't support special <input> types like `date` fallback
// to `text`, so make sure to only test if type is still preserved after
// the element is attached.
if (input.inputElement.type === "date") {
assert.equal(input.alwaysFloatLabel, true);
var floatingLabel = Polymer.dom(Polymer.dom(input.root).querySelector('paper-input-container').root).querySelector('.label-is-floating');
assert.ok(floatingLabel);
}
});
test('always-float-label attribute works without placeholder', function() {
var input = fixture('always-float-label');
var container = Polymer.dom(input.root).querySelector('paper-input-container');
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
assert.isTrue(inputContent.classList.contains('label-is-floating'), 'label is floating');
});
test('label does not receive pointer events', function() {
var input = fixture('always-float-label');
var label = Polymer.dom(input.root).querySelector('label');
assert.equal(getComputedStyle(label).pointerEvents, 'none');
});
test('error message is displayed', function() {
var input = fixture('error');
forceXIfStamp(input);
var error = Polymer.dom(input.root).querySelector('paper-input-error');
assert.ok(error, 'paper-input-error exists');
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
});
test('empty required input shows error', function() {
var input = fixture('required');
forceXIfStamp(input);
var error = Polymer.dom(input.root).querySelector('paper-input-error');
assert.ok(error, 'paper-input-error exists');
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
});
test('character counter is displayed', function() {
var input = fixture('char-counter');
forceXIfStamp(input);
var counter = Polymer.dom(input.root).querySelector('paper-input-char-counter')
assert.ok(counter, 'paper-input-char-counter exists');
assert.equal(counter._charCounterStr, input.value.length, 'character counter shows the value length');
});
test('character counter is correct for type=number', function() {
var input = fixture('type-number-char-counter');
forceXIfStamp(input);
var counter = Polymer.dom(input.root).querySelector('paper-input-char-counter')
assert.ok(counter, 'paper-input-char-counter exists');
assert.equal(counter._charCounterStr, input.value.toString().length, 'character counter shows the value length');
});
test('validator is used', function() {
var input = fixture('validator');
assert.ok(input.inputElement.invalid, 'input is invalid');
});
test('caret position is preserved', function() {
var input = fixture('basic');
var ironInput = Polymer.dom(input.root).querySelector('input[is="iron-input"]');
input.value = 'nananana';
ironInput.selectionStart = 2;
ironInput.selectionEnd = 2;
input.updateValueAndPreserveCaret('nanananabatman');
assert.equal(ironInput.selectionStart, 2, 'selectionStart is preserved');
assert.equal(ironInput.selectionEnd, 2, 'selectionEnd is preserved');
});
test('setting autofocus to true implictly acquires focus', function(done) {
var input = fixture('basic');
var inputFocusSpy = sinon.spy(input.inputElement, 'focus');
window.setTimeout(function() {
assert(inputFocusSpy.called);
done();
}, 50);
input.autofocus = true;
});
test('autofocus doesn\'t grab focus if another element already has it', function(done) {
var inputs = fixture('multiple-inputs');
var inputFocusSpies = inputs.map(function(input) {
return sinon.spy(input.inputElement, 'focus');
});
window.setTimeout(function() {
assert(inputFocusSpies[0].called, 'first autofocus input with grabbed focus');
assert(!inputFocusSpies[1].called, 'second autofocus input let first input keep focus');
done();
}, 50);
inputs[0].autofocus = true;
inputs[1].autofocus = true; // Shouldn't cause focus to change
});
});
suite('focus/blur events', function() {
var input;
setup(function() {
input = fixture('basic');
});
// At the moment, it is very hard to correctly fire exactly
// one focus/blur events on a paper-input. This is because
// when a paper-input is focused, it needs to focus
// its underlying native input, which will also fire a `blur`
// event.
test('focus events fired on host element', function() {
input.addEventListener('focus', function(event) {
assert(input.focused, 'input is focused');
});
MockInteractions.focus(input);
});
test('focus events fired on host element if nested element is focused', function() {
input.addEventListener('focus', function(event) {
assert(input.focused, 'input is focused');
});
MockInteractions.focus(input.inputElement);
});
test('blur events fired on host element', function() {
MockInteractions.focus(input);
input.addEventListener('blur', function(event) {
assert(!input.focused, 'input is blurred');
});
MockInteractions.blur(input);
});
test('blur events fired on host element nested element is blurred', function() {
MockInteractions.focus(input);
input.addEventListener('blur', function(event) {
assert(!input.focused, 'input is blurred');
});
MockInteractions.blur(input.inputElement);
});
test('focusing then bluring sets the focused attribute correctly', function() {
MockInteractions.focus(input);
assert(input.focused, 'input is focused');
MockInteractions.blur(input);
assert(!input.focused, 'input is blurred');
MockInteractions.focus(input.inputElement);
assert(input.focused, 'input is focused');
MockInteractions.blur(input.inputElement);
assert(!input.focused, 'input is blurred');
});
test('focusing then bluring with shift-tab removes the focused attribute correctly', function() {
MockInteractions.focus(input);
assert(input.focused, 'input is focused');
// Fake a shift-tab induced blur by forcing the flag.
input._shiftTabPressed = true;
MockInteractions.blur(input.inputElement);
assert(!input.focused, 'input is blurred');
});
});
suite('focused styling (integration test)', function() {
test('underline is colored when input is focused', function(done) {
var input = fixture('basic');
var container = Polymer.dom(input.root).querySelector('paper-input-container');
var line = Polymer.dom(container.root).querySelector('.underline');
assert.isFalse(line.classList.contains('is-highlighted'), 'line is not highlighted when input is not focused');
MockInteractions.focus(input.inputElement);
requestAnimationFrame(function() {
assert.isTrue(line.classList.contains('is-highlighted'), 'line is highlighted when input is focused');
done();
});
});
});
suite('validation', function() {
test('invalid attribute updated after calling validate()', function() {
var input = fixture('required-no-auto-validate');
forceXIfStamp(input);
input.validate();
var error = Polymer.dom(input.root).querySelector('paper-input-error');
assert.ok(error, 'paper-input-error exists');
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
assert.isTrue(input.invalid, 'invalid is true');
});
});
suite('a11y', function() {
test('has aria-labelledby, which is monotonically increasing', function() {
var inputs = fixture('multiple-inputs');
// Find the first index of the input in this fixture. Since the label
// ids monotonically increase every time a new input is created, and
// this fixture isn't the first one in the document, we're going to start
// at an ID > 1.
var firstLabel = Polymer.dom(inputs[0].root).querySelector('label').id;
var index = parseInt(firstLabel.substr(firstLabel.lastIndexOf('-') + 1));
for (var i = 0; i < inputs.length; i++ ) {
var input = inputs[i].inputElement;
var label = Polymer.dom(inputs[i].root).querySelector('label').id;
assert.isTrue(input.hasAttribute('aria-labelledby'));
assert.equal(label, 'paper-input-label-' + (index++));
assert.equal(input.getAttribute('aria-labelledby'), label);
}
});
test('has aria-describedby for error message', function() {
var input = fixture('required');
forceXIfStamp(input);
assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-error').id, 'aria-describedby points to the error message');
});
test('has aria-describedby for character counter', function() {
var input = fixture('char-counter');
forceXIfStamp(input);
assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-char-counter').id, 'aria-describedby points to the character counter');
});
test('has aria-describedby for character counter and error', function() {
var input = fixture('required-char-counter');
forceXIfStamp(input);
assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-error').id + ' ' + Polymer.dom(input.root).querySelector('paper-input-char-counter').id, 'aria-describedby points to the error message and character counter');
});
test('focus an input with tabindex', function(done) {
var input = fixture('has-tabindex');
flush(function() {
MockInteractions.focus(input);
flush(function() {
assert.equal(input.shadowRoot ? input.shadowRoot.activeElement :
document.activeElement, input._focusableElement);
done();
});
});
});
});
</script>
</body>
</html>

View file

@ -1,225 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>
<title>paper-textarea tests</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../iron-test-helpers/test-helpers.js"></script>
<script src="../../iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="../paper-textarea.html">
</head>
<body>
<test-fixture id="basic">
<template>
<paper-textarea></paper-textarea>
</template>
</test-fixture>
<test-fixture id="label">
<template>
<paper-textarea label="foo"></paper-textarea>
</template>
</test-fixture>
<test-fixture id="char-counter">
<template>
<paper-textarea char-counter></paper-textarea>
</template>
</test-fixture>
<test-fixture id="required">
<template>
<paper-textarea auto-validate required error-message="error"></paper-textarea>
</template>
</test-fixture>
<test-fixture id="required-char-counter">
<template>
<paper-textarea auto-validate char-counter required error-message="error"></paper-textarea>
</template>
</test-fixture>
<test-fixture id="always-float-label">
<template>
<paper-textarea always-float-label label="label"></paper-textarea>
</template>
</test-fixture>
<script>
suite('basic', function() {
test('setting value sets the input value', function() {
var input = fixture('basic');
input.value = 'foobar';
assert.equal(input.inputElement.bindValue, input.value, 'inputElement value equals input.value');
});
test('empty required input shows error', function() {
var input = fixture('required');
forceXIfStamp(input);
var error = Polymer.dom(input.root).querySelector('paper-input-error');
assert.ok(error, 'paper-input-error exists');
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
});
test('caret position is preserved', function() {
var input = fixture('basic');
var ironTextarea = Polymer.dom(input.root).querySelector('iron-autogrow-textarea');
input.value = 'nananana';
ironTextarea.selectionStart = 2;
ironTextarea.selectionEnd = 2;
input.updateValueAndPreserveCaret('nanananabatman');
assert.equal(ironTextarea.selectionStart, 2, 'selectionStart is preserved');
assert.equal(ironTextarea.selectionEnd, 2, 'selectionEnd is preserved');
});
test('input attributes are bound to textarea', function() {
var input = fixture('basic');
var attrs = {
'autocomplete': 'true',
'autofocus': true,
'inputmode': 'number',
'name': 'foo',
'placeholder': 'bar',
'readonly': true,
'required': true,
'maxlength': 3
};
for (var attr in attrs) {
input[attr] = attrs[attr];
}
for (var attr in attrs) {
var inputAttr = input.inputElement.getAttribute(attr);
if (typeof attrs[attr] === 'boolean') {
assert.equal(inputAttr !== null, attrs[attr], 'attribute "' + attr + '" is equal to property (' + attrs[attr] + ', ' + inputAttr !== null + ')');
} else {
assert.equal(inputAttr, attrs[attr], 'attribute "' + attr + '" is equal to property (' + attrs[attr] + ', ' + inputAttr + ')');
}
}
});
test('always-float-label attribute works', function() {
var input = fixture('always-float-label');
var container = Polymer.dom(input.root).querySelector('paper-input-container');
var inputContent = Polymer.dom(container.root).querySelector('.input-content');
assert.isTrue(inputContent.classList.contains('label-is-floating'), 'label is floating');
});
test('label does not receive pointer events', function() {
var input = fixture('always-float-label');
var label = Polymer.dom(input.root).querySelector('label');
assert.equal(getComputedStyle(label).pointerEvents, 'none');
});
});
suite('focus/blur events', function() {
var input;
setup(function() {
input = fixture('basic');
});
// At the moment, it is very hard to correctly fire exactly
// one focus/blur events on a paper-textarea. This is because
// when a paper-textarea is focused, it needs to focus
// its underlying native textarea, which will also fire a `blur`
// event.
test('focus events fired on host element', function() {
input.addEventListener('focus', function(event) {
assert(input.focused, 'input is focused');
});
MockInteractions.focus(input);
});
test('focus events fired on host element if nested element is focused', function() {
input.addEventListener('focus', function(event) {
assert(input.focused, 'input is focused');
});
MockInteractions.focus(input.inputElement.textarea);
});
test('blur events fired on host element', function() {
MockInteractions.focus(input);
input.addEventListener('blur', function(event) {
assert(!input.focused, 'input is blurred');
});
MockInteractions.blur(input);
});
test('blur events fired on host element nested element is blurred', function() {
MockInteractions.focus(input);
input.addEventListener('blur', function(event) {
assert(!input.focused, 'input is blurred');
});
MockInteractions.blur(input.inputElement.textarea);
});
test('focusing then bluring sets the focused attribute correctly', function() {
MockInteractions.focus(input);
assert(input.focused, 'input is focused');
MockInteractions.blur(input);
assert(!input.focused, 'input is blurred');
MockInteractions.focus(input.inputElement.textarea);
assert(input.focused, 'input is focused');
MockInteractions.blur(input.inputElement.textarea);
assert(!input.focused, 'input is blurred');
});
});
suite('a11y', function() {
test('has aria-labelledby', function() {
var input = fixture('label');
assert.isTrue(input.inputElement.textarea.hasAttribute('aria-labelledby'))
assert.equal(input.inputElement.textarea.getAttribute('aria-labelledby'), Polymer.dom(input.root).querySelector('label').id, 'aria-labelledby points to the label');
});
test('has aria-describedby for error message', function() {
var input = fixture('required');
forceXIfStamp(input);
assert.isTrue(input.inputElement.textarea.hasAttribute('aria-describedby'));
assert.equal(input.inputElement.textarea.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-error').id, 'aria-describedby points to the error message');
});
test('has aria-describedby for character counter', function() {
var input = fixture('char-counter');
forceXIfStamp(input);
assert.isTrue(input.inputElement.textarea.hasAttribute('aria-describedby'));
assert.equal(input.inputElement.textarea.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-char-counter').id, 'aria-describedby points to the character counter');
});
test('has aria-describedby for character counter and error', function() {
var input = fixture('required-char-counter');
forceXIfStamp(input);
assert.isTrue(input.inputElement.textarea.hasAttribute('aria-describedby'));
assert.equal(input.inputElement.textarea.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-error').id + ' ' + Polymer.dom(input.root).querySelector('paper-input-char-counter').id, 'aria-describedby points to the error message and character counter');
});
});
</script>
</body>
</html>

View file

@ -1,42 +0,0 @@
{
"name": "paper-progress",
"version": "1.0.10",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "A material design progress bar",
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"progress"
],
"main": "paper-progress.html",
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-progress.git"
},
"dependencies": {
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
"iron-range-behavior": "PolymerElements/iron-range-behavior#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
"polymer": "Polymer/polymer#^1.1.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"paper-button": "PolymerElements/paper-button#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"ignore": [],
"homepage": "https://github.com/PolymerElements/paper-progress",
"_release": "1.0.10",
"_resolution": {
"type": "version",
"tag": "v1.0.10",
"commit": "dfdde2b02947fb2dfd3f2d303ec17f7f4919348c"
},
"_source": "git://github.com/PolymerElements/paper-progress.git",
"_target": "^1.0.9",
"_originalSource": "PolymerElements/paper-progress"
}

View file

@ -1,33 +0,0 @@
<!-- Instructions: https://github.com/PolymerElements/paper-progress/CONTRIBUTING.md#filing-issues -->
### Description
<!-- Example: The `paper-foo` element causes the page to turn pink when clicked. -->
### Expected outcome
<!-- Example: The page stays the same color. -->
### Actual outcome
<!-- Example: The page turns pink. -->
### Live Demo
<!-- Example: https://jsbin.com/cagaye/edit?html,output -->
### Steps to reproduce
<!-- Example
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
-->
### Browsers Affected
<!-- Check all that apply -->
- [ ] Chrome
- [ ] Firefox
- [ ] Safari 9
- [ ] Safari 8
- [ ] Safari 7
- [ ] Edge
- [ ] IE 11
- [ ] IE 10

View file

@ -1 +0,0 @@
bower_components

View file

@ -1,23 +0,0 @@
language: node_js
sudo: required
before_script:
- npm install -g bower polylint web-component-tester
- bower install
- polylint
env:
global:
- secure: H1BFM+lOHi3yosJV4VpeDHO/N33EeAeQqKbWMAiGfbjMmVUa2Y9gQzpIONMtO09KMTZMw0dlE3GYNLnc44JXlnSvmp34Fh8KpxOz4BxlbIj2aw/M99FWxRAJYpV+BWWKhwwuFq6DctATljcdfvYyHxpjCAFjTIMCCAHtdVrowlxMlivu/BSlBlZ4HR0OfHr7l8PAC1hSieWr5Rpk0PMcQ6B0nEhSTRgGdxEwADnkOL3Sx966vNv3qxwIML29UrZ3mFdfrgnfwdNZTivjDaRhY4tUu7bw5vP8c4PeVR7lalhVBse5J4xKo7Xw80To+bm/0Hyo4ZgZPzEbq0EAIszRnwRo/d4YiFGkyIgFHJ8a/v2h3BWxW+9W51nKsQcFijitu2pMhKC9ankRxL23TK0rtYff6hj/bCwtfy/965PzZgiAeBgcQUZ25+unOc11VAyIEGUZeLAqzulMOn2LAcvSrVEVGpb90whvVxfG3T8hkFbIrPtD3TWrtvt4ul/25pe+eLNET2DUTqrPFfizthyaGFfavykA6PPGI58AFD2EnFmaD9eJC/eCP34FAZec8G2yMbXOYxg6B40Z1ezHo8j7jzbekEJBsHVegpart9YSxQwx5b95SsqlPbyhdLLHIZIzT9dSfbS/l0YFUYbejeMM5koi1qdqXVCdCMpbwS61WA8=
- secure: KZek5eiBlb80rC3C0pgb39C4mWskrGJdxV0Xp9WBAnJQkXN4fvKgB5QOIGVV8yP/aM824zv/nj1Z61MWcjKw5kYJBon0Hw4Qemk7KJh7kde5bhg+3dWcdfv8Hhz9wuVGxqmZ01N8LWat+dRzEqY5ZawFQ+P2M/FXxxwKKsH3GKpjgjN2G8u7nadD2p4hDIBmVVGK0dqDZDOg+YZ+jEdGyWTbjeVOnktvb6dDfcKm52VIpcgAvqa8CCFFwTE3lFrHK4UdiqxFW2YcIB1lgJADJ1B2wAjL0cuf97uu8jaCpCGMeQXz5/XH5SxLA8ah/6GV7C37+WlEPeyallUUbSn05m/xYVFEMvrw/04bFQUyiwt9/rdqA8OLNOUwIEk9hMWC3LkooE2LTLs4l1OKN2x9OuTGPTU2f4LrH4z32zSChxjI/4fqCFwDJs6MBfQFIlpV1e6F1YOvPLPOtBLLTVK1n1KeXeY9HSvk+f5lxRwS4VFZ1oG6+a/l+MoB2HMUmhEn0Wa+KS2qk5Yfea/UIlvi8IuA7zsXoeYkBuwIT7VJVdU0Oebfkam4jWR6qYs/QQF/MchzungKchhwyhsSzQvCuaHJhdA6D1L0oqkXRpPouJwkcvGu9z+wf+zPfh3h065Trg7tC4DYHnXRSTF0ocO3H+EfImRSP5jsgPz0gMl4iI0=
node_js: stable
addons:
firefox: '46.0'
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
sauce_connect: true
script:
- xvfb-run wct
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'default'; fi
dist: trusty

View file

@ -1,77 +0,0 @@
<!--
This file is autogenerated based on
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
If you edit that file, it will get updated everywhere else.
If you edit this file, your changes will get overridden :)
You can however override the jsbin link with one that's customized to this
specific element:
jsbin=https://jsbin.com/cagaye/edit?html,output
-->
# Polymer Elements
## Guide for Contributors
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
### Filing Issues
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
1. **Who will use the feature?** _“As someone filling out a form…”_
2. **When will they use the feature?** _“When I enter an invalid value…”_
3. **What is the users goal?** _“I want to be visually notified that the value needs to be corrected…”_
**If you are filing an issue to report a bug**, please provide:
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
```markdown
The `paper-foo` element causes the page to turn pink when clicked.
## Expected outcome
The page stays the same color.
## Actual outcome
The page turns pink.
## Steps to reproduce
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
```
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
### Submitting Pull Requests
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
When submitting pull requests, please provide:
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
```markdown
(For a single issue)
Fixes #20
(For multiple issues)
Fixes #32, fixes #40
```
2. **A succinct description of the design** used to fix any related issues. For example:
```markdown
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
```
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so dont be afraid to ask us if you need help with that!

View file

@ -1,32 +0,0 @@
{
"name": "paper-progress",
"version": "1.0.10",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "A material design progress bar",
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"progress"
],
"main": "paper-progress.html",
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-progress.git"
},
"dependencies": {
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
"iron-range-behavior": "PolymerElements/iron-range-behavior#^1.0.0",
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
"polymer": "Polymer/polymer#^1.1.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"paper-button": "PolymerElements/paper-button#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"ignore": []
}

View file

@ -1,127 +0,0 @@
<!--
@license
Copyright (c) 2015 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>paper-progress demo</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../paper-styles/color.html">
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
<link rel="import" href="../paper-progress.html">
<link rel="import" href="../../paper-button/paper-button.html">
<style is="custom-style" include="demo-pages-shared-styles">
paper-progress {
display: block;
width: 100%;
margin: 20px 0;
}
paper-button {
display: inline-block;
padding: 5px;
}
</style>
</head>
<body unresolved>
<div class="vertical-section-container centered">
<h3>paper-progress can be imperatively controlled</h3>
<demo-snippet class="centered-demo">
<template>
<p>Once started, loops 5 times before stopping.
<!-- View the source code to see the contents of startProgress() -->
<paper-button raised onclick="startProgress();" id="start">Start</paper-button>
</p>
<paper-progress id="progress"></paper-progress>
</template>
</demo-snippet>
<h3>paper-progress can be indeterminate with a custom duration</h3>
<demo-snippet class="centered-demo">
<template>
<style is="custom-style">
paper-progress.slow {
--paper-progress-indeterminate-cycle-duration: 20s;
}
</style>
<paper-progress indeterminate></paper-progress>
<paper-progress indeterminate class="slow"></paper-progress>
</template>
</demo-snippet>
<h3>It can be styled using custom properties</h3>
<demo-snippet class="centered-demo">
<template>
<style is="custom-style">
paper-progress.blue {
--paper-progress-active-color: var(--paper-light-blue-500);
--paper-progress-secondary-color: var(--paper-light-blue-100);
}
paper-progress.red {
--paper-progress-active-color: var(--paper-red-500);
--paper-progress-secondary-color: var(--paper-red-100);
}
paper-progress.green {
--paper-progress-active-color: var(--paper-light-green-500);
--paper-progress-secondary-color: var(--paper-light-green-100);
}
</style>
<paper-progress value="800" min="100" max="1000" class="red"></paper-progress>
<paper-progress value="60" class="green"></paper-progress>
<paper-progress value="40" secondary-progress="80" class="blue"></paper-progress>
</template>
</demo-snippet>
</div>
<script>
var progress, button;
var repeat, maxRepeat = 5, animating = false;
function nextProgress() {
animating = true;
if (progress.value < progress.max) {
progress.value += (progress.step || 1);
} else {
if (++repeat >= maxRepeat) {
animating = false;
button.disabled = false;
return;
}
progress.value = progress.min;
}
requestAnimationFrame(nextProgress);
}
function startProgress() {
repeat = 0;
progress.value = progress.min;
button.disabled = true;
if (!animating) {
nextProgress();
}
}
window.addEventListener('WebComponentsReady', function() {
progress = document.querySelector('paper-progress');
button = document.querySelector('paper-button');
});
</script>
</body>
</html>

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
<g id="background" display="none">
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
</g>
<g id="label">
</g>
<g id="art">
<rect x="57" y="59" width="20" height="2"/>
<rect x="38" y="59" width="11" height="2"/>
<rect x="84" y="59" width="40" height="2"/>
<rect x="133" y="59" width="54" height="2"/>
<g id="ic_x5F_add_x0D_">
</g>
</g>
<g id="Guides">
</g>
</svg>

Before

Width:  |  Height:  |  Size: 813 B

View file

@ -1,28 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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, initial-scale=1.0">
<title>paper-progress</title>
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
<iron-component-page></iron-component-page>
</body>
</html>

View file

@ -1,354 +0,0 @@
<!--
@license
Copyright (c) 2015 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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../iron-range-behavior/iron-range-behavior.html">
<link rel="import" href="../paper-styles/color.html">
<!--
Material design: [Progress & activity](https://www.google.com/design/spec/components/progress-activity.html)
The progress bars are for situations where the percentage completed can be
determined. They give users a quick sense of how much longer an operation
will take.
Example:
<paper-progress value="10"></paper-progress>
There is also a secondary progress which is useful for displaying intermediate
progress, such as the buffer level during a streaming playback progress bar.
Example:
<paper-progress value="10" secondary-progress="30"></paper-progress>
### Styling progress bar:
To change the active progress bar color:
paper-progress {
--paper-progress-active-color: #e91e63;
}
To change the secondary progress bar color:
paper-progress {
--paper-progress-secondary-color: #f8bbd0;
}
To change the progress bar background color:
paper-progress {
--paper-progress-container-color: #64ffda;
}
Add the class `transiting` to a paper-progress to animate the progress bar when
the value changed. You can also customize the transition:
paper-progress {
--paper-progress-transition-duration: 0.08s;
--paper-progress-transition-timing-function: ease;
--paper-progress-transition-transition-delay: 0s;
}
To change the duration of the indeterminate cycle:
paper-progress {
--paper-progress-indeterminate-cycle-duration: 2s;
}
The following mixins are available for styling:
Custom property | Description | Default
-------------------------------------------------|---------------------------------------------|--------------
`--paper-progress-container` | Mixin applied to container | `{}`
`--paper-progress-transition-duration` | Duration of the transition | `0.008s`
`--paper-progress-transition-timing-function` | The timing function for the transition | `ease`
`--paper-progress-transition-delay` | delay for the transition | `0s`
`--paper-progress-container-color` | Color of the container | `--google-grey-300`
`--paper-progress-active-color` | The color of the active bar | `--google-green-500`
`--paper-progress-secondary-color` | The color of the secondary bar | `--google-green-100`
`--paper-progress-disabled-active-color` | The color of the active bar if disabled | `--google-grey-500`
`--paper-progress-disabled-secondary-color` | The color of the secondary bar if disabled | `--google-grey-300`
`--paper-progress-height` | The height of the progress bar | `4px`
`--paper-progress-indeterminate-cycle-duration` | Duration of an indeterminate cycle | `2s`
@group Paper Elements
@element paper-progress
@hero hero.svg
@demo demo/index.html
-->
<dom-module id="paper-progress">
<template>
<style>
:host {
display: block;
width: 200px;
position: relative;
overflow: hidden;
}
:host([hidden]) {
display: none !important;
}
#progressContainer {
@apply(--paper-progress-container);
position: relative;
}
#progressContainer,
/* the stripe for the indeterminate animation*/
.indeterminate::after {
height: var(--paper-progress-height, 4px);
}
#primaryProgress,
#secondaryProgress,
.indeterminate::after {
@apply(--layout-fit);
}
#progressContainer,
.indeterminate::after {
background: var(--paper-progress-container-color, --google-grey-300);
}
:host(.transiting) #primaryProgress,
:host(.transiting) #secondaryProgress {
-webkit-transition-property: -webkit-transform;
transition-property: transform;
/* Duration */
-webkit-transition-duration: var(--paper-progress-transition-duration, 0.08s);
transition-duration: var(--paper-progress-transition-duration, 0.08s);
/* Timing function */
-webkit-transition-timing-function: var(--paper-progress-transition-timing-function, ease);
transition-timing-function: var(--paper-progress-transition-timing-function, ease);
/* Delay */
-webkit-transition-delay: var(--paper-progress-transition-delay, 0s);
transition-delay: var(--paper-progress-transition-delay, 0s);
}
#primaryProgress,
#secondaryProgress {
@apply(--layout-fit);
-webkit-transform-origin: left center;
transform-origin: left center;
-webkit-transform: scaleX(0);
transform: scaleX(0);
will-change: transform;
}
#primaryProgress {
background: var(--paper-progress-active-color, --google-green-500);
}
#secondaryProgress {
background: var(--paper-progress-secondary-color, --google-green-100);
}
:host([disabled]) #primaryProgress {
background: var(--paper-progress-disabled-active-color, --google-grey-500);
}
:host([disabled]) #secondaryProgress {
background: var(--paper-progress-disabled-secondary-color, --google-grey-300);
}
:host(:not([disabled])) #primaryProgress.indeterminate {
-webkit-transform-origin: right center;
transform-origin: right center;
-webkit-animation: indeterminate-bar var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite;
animation: indeterminate-bar var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite;
}
:host(:not([disabled])) #primaryProgress.indeterminate::after {
content: "";
-webkit-transform-origin: center center;
transform-origin: center center;
-webkit-animation: indeterminate-splitter var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite;
animation: indeterminate-splitter var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite;
}
@-webkit-keyframes indeterminate-bar {
0% {
-webkit-transform: scaleX(1) translateX(-100%);
}
50% {
-webkit-transform: scaleX(1) translateX(0%);
}
75% {
-webkit-transform: scaleX(1) translateX(0%);
-webkit-animation-timing-function: cubic-bezier(.28,.62,.37,.91);
}
100% {
-webkit-transform: scaleX(0) translateX(0%);
}
}
@-webkit-keyframes indeterminate-splitter {
0% {
-webkit-transform: scaleX(.75) translateX(-125%);
}
30% {
-webkit-transform: scaleX(.75) translateX(-125%);
-webkit-animation-timing-function: cubic-bezier(.42,0,.6,.8);
}
90% {
-webkit-transform: scaleX(.75) translateX(125%);
}
100% {
-webkit-transform: scaleX(.75) translateX(125%);
}
}
@keyframes indeterminate-bar {
0% {
transform: scaleX(1) translateX(-100%);
}
50% {
transform: scaleX(1) translateX(0%);
}
75% {
transform: scaleX(1) translateX(0%);
animation-timing-function: cubic-bezier(.28,.62,.37,.91);
}
100% {
transform: scaleX(0) translateX(0%);
}
}
@keyframes indeterminate-splitter {
0% {
transform: scaleX(.75) translateX(-125%);
}
30% {
transform: scaleX(.75) translateX(-125%);
animation-timing-function: cubic-bezier(.42,0,.6,.8);
}
90% {
transform: scaleX(.75) translateX(125%);
}
100% {
transform: scaleX(.75) translateX(125%);
}
}
</style>
<div id="progressContainer">
<div id="secondaryProgress" hidden$="[[_hideSecondaryProgress(secondaryRatio)]]"></div>
<div id="primaryProgress"></div>
</div>
</template>
</dom-module>
<script>
Polymer({
is: 'paper-progress',
behaviors: [
Polymer.IronRangeBehavior
],
properties: {
/**
* The number that represents the current secondary progress.
*/
secondaryProgress: {
type: Number,
value: 0
},
/**
* The secondary ratio
*/
secondaryRatio: {
type: Number,
value: 0,
readOnly: true
},
/**
* Use an indeterminate progress indicator.
*/
indeterminate: {
type: Boolean,
value: false,
observer: '_toggleIndeterminate'
},
/**
* True if the progress is disabled.
*/
disabled: {
type: Boolean,
value: false,
reflectToAttribute: true,
observer: '_disabledChanged'
}
},
observers: [
'_progressChanged(secondaryProgress, value, min, max)'
],
hostAttributes: {
role: 'progressbar'
},
_toggleIndeterminate: function(indeterminate) {
// If we use attribute/class binding, the animation sometimes doesn't translate properly
// on Safari 7.1. So instead, we toggle the class here in the update method.
this.toggleClass('indeterminate', indeterminate, this.$.primaryProgress);
},
_transformProgress: function(progress, ratio) {
var transform = 'scaleX(' + (ratio / 100) + ')';
progress.style.transform = progress.style.webkitTransform = transform;
},
_mainRatioChanged: function(ratio) {
this._transformProgress(this.$.primaryProgress, ratio);
},
_progressChanged: function(secondaryProgress, value, min, max) {
secondaryProgress = this._clampValue(secondaryProgress);
value = this._clampValue(value);
var secondaryRatio = this._calcRatio(secondaryProgress) * 100;
var mainRatio = this._calcRatio(value) * 100;
this._setSecondaryRatio(secondaryRatio);
this._transformProgress(this.$.secondaryProgress, secondaryRatio);
this._transformProgress(this.$.primaryProgress, mainRatio);
this.secondaryProgress = secondaryProgress;
this.setAttribute('aria-valuenow', value);
this.setAttribute('aria-valuemin', min);
this.setAttribute('aria-valuemax', max);
},
_disabledChanged: function(disabled) {
this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
},
_hideSecondaryProgress: function(secondaryRatio) {
return secondaryRatio === 0;
}
});
</script>

View file

@ -1,148 +0,0 @@
<!doctype html>
<!--
@license
Copyright (c) 2015 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>paper-progress test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="../paper-progress.html">
<link rel="import" href="../../test-fixture/test-fixture.html">
</head>
<body>
<test-fixture id="trivialProgress">
<template>
<paper-progress></paper-progress>
</template>
</test-fixture>
<test-fixture id="transitingProgress">
<template>
<paper-progress class="transiting"></paper-progress>
</template>
</test-fixture>
<script>
suite('basic features', function() {
var progress;
setup(function() {
progress = fixture('trivialProgress');
});
test('check default', function() {
assert.equal(progress.min, 0);
assert.equal(progress.max, 100);
assert.equal(progress.value, 0);
});
test('set value', function(done) {
progress.value = 50;
asyncPlatformFlush(function() {
assert.equal(progress.value, 50);
// test clamp value
progress.value = 60.1;
asyncPlatformFlush(function() {
assert.equal(progress.value, 60);
done();
});
});
});
test('set max', function(done) {
progress.max = 10;
progress.value = 11;
asyncPlatformFlush(function() {
assert.equal(progress.value, progress.max);
done();
});
});
test('test ratio', function(done) {
progress.max = 10;
progress.value = 5;
asyncPlatformFlush(function() {
assert.equal(progress.ratio, 50);
done();
});
});
test('test secondary ratio', function(done) {
progress.max = 10;
progress.secondaryProgress = 5;
asyncPlatformFlush(function() {
assert.equal(progress.secondaryRatio, 50);
done();
});
});
test('set min', function(done) {
progress.min = 10
progress.max = 50;
progress.value = 30;
asyncPlatformFlush(function() {
assert.equal(progress.ratio, 50);
progress.value = 0;
asyncPlatformFlush(function() {
assert.equal(progress.value, progress.min);
done();
});
});
});
test('set step', function(done) {
progress.min = 0;
progress.max = 10;
progress.value = 5.1;
asyncPlatformFlush(function() {
assert.equal(progress.value, 5);
progress.step = 0.1;
progress.value = 5.1;
asyncPlatformFlush(function() {
assert.equal(progress.value, 5.1);
done();
});
});
});
});
suite('transiting class', function() {
var progress;
setup(function() {
progress = fixture('transitingProgress');
});
test('progress bars', function() {
var stylesForPrimaryProgress = window.getComputedStyle(progress.$.primaryProgress);
var stylesForSecondaryProgress = window.getComputedStyle(progress.$.secondaryProgress);
var transitionProp = stylesForPrimaryProgress['transition-property'];
assert.isTrue(transitionProp === 'transform' || transitionProp === '-webkit-transform');
assert.equal(stylesForPrimaryProgress['transition-duration'], '0.08s');
transitionProp = stylesForSecondaryProgress['transition-property'];
assert.isTrue(transitionProp === 'transform' || transitionProp === '-webkit-transform');
assert.equal(stylesForSecondaryProgress['transition-duration'], '0.08s');
});
});
</script>
</body>
</html>

View file

@ -1,24 +0,0 @@
<!DOCTYPE html><!--
@license
Copyright (c) 2015 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',
'basic.html?dom=shadow'
]);
</script>
</body></html>

View file

@ -175,17 +175,12 @@ paper-checkbox #checkmark {
padding: .5em 0; padding: .5em 0;
} }
paper-input label, paper-textarea label {
font-size: 18px !important;
font-family: inherit !important;
}
.paperListLabel { .paperListLabel {
font-size: 16px; font-size: 16px;
margin-bottom: .5em; margin-bottom: .5em;
} }
paper-textarea.mono textarea { .textarea-mono {
font-family: monospace !important; font-family: monospace !important;
} }
@ -194,18 +189,6 @@ paper-textarea.mono textarea {
border-color: #52B54B; border-color: #52B54B;
} }
.ui-body-a .paper-input-container-0 .input-content.paper-input-container label, .ui-body-a .paper-input-container-0 .input-content.paper-input-container .paper-input-label, .ui-body-a paper-textarea label {
color: #555;
}
.ui-body-a .paper-input-container-0 .input-content.label-is-highlighted.paper-input-container label, .ui-body-a .paper-input-container-0 .input-content.label-is-highlighted.paper-input-container .paper-input-label {
color: green;
}
paper-input .focused-line, paper-textarea .focused-line {
background-color: #52B54B !important;
}
.paperList { .paperList {
padding: .5em 0; padding: .5em 0;
margin: 12px auto; margin: 12px auto;

View file

@ -92,8 +92,8 @@
<paper-input type="text" id="txtLoginDisclaimer" label="${LabelLoginDisclaimer}"></paper-input> <paper-input type="text" id="txtLoginDisclaimer" label="${LabelLoginDisclaimer}"></paper-input>
<div class="fieldDescription">${LabelLoginDisclaimerHelp}</div> <div class="fieldDescription">${LabelLoginDisclaimerHelp}</div>
</div> </div>
<div> <div class="inputContainer">
<paper-textarea id="txtCustomCss" label="${LabelCustomCss}" class="mono"></paper-textarea> <textarea is="emby-textarea" id="txtCustomCss" label="${LabelCustomCss}" class="textarea-mono"></textarea>
<div class="fieldDescription">${LabelCustomCssHelp}</div> <div class="fieldDescription">${LabelCustomCssHelp}</div>
</div> </div>
</div> </div>

View file

@ -1396,10 +1396,7 @@ var AppInfo = {};
define("paper-button", ["html!" + bowerPath + "/paper-button/paper-button.html"]); define("paper-button", ["html!" + bowerPath + "/paper-button/paper-button.html"]);
define("paper-icon-button", ["html!" + bowerPath + "/paper-icon-button/paper-icon-button.html"]); define("paper-icon-button", ["html!" + bowerPath + "/paper-icon-button/paper-icon-button.html"]);
define("paper-textarea", ['webcomponentsjs', "html!" + bowerPath + "/paper-input/paper-textarea.html"]);
define("paper-checkbox", ["html!" + bowerPath + "/paper-checkbox/paper-checkbox.html"]); define("paper-checkbox", ["html!" + bowerPath + "/paper-checkbox/paper-checkbox.html"]);
define("paper-progress", ["html!" + bowerPath + "/paper-progress/paper-progress.html"]);
define("paper-input", ['webcomponentsjs', "html!" + bowerPath + "/paper-input/paper-input.html"]);
define("paper-collapse-item", ["html!" + bowerPath + "/paper-collapse-item/paper-collapse-item.html"]); define("paper-collapse-item", ["html!" + bowerPath + "/paper-collapse-item/paper-collapse-item.html"]);
@ -1796,10 +1793,10 @@ var AppInfo = {};
function initAfterDependencies() { function initAfterDependencies() {
var deps = []; var list = [];
if (!window.fetch) { if (!window.fetch) {
deps.push('fetch'); list.push('fetch');
} }
if (typeof Object.assign != 'function') { if (typeof Object.assign != 'function') {
@ -1814,7 +1811,7 @@ var AppInfo = {};
list.push('functionbind'); list.push('functionbind');
} }
require(deps, function () { require(list, function () {
createConnectionManager().then(function () { createConnectionManager().then(function () {
@ -1987,7 +1984,7 @@ var AppInfo = {};
defineRoute({ defineRoute({
path: '/dashboardgeneral.html', path: '/dashboardgeneral.html',
dependencies: ['emby-collapse', 'paper-textarea', 'paper-input', 'paper-checkbox'], dependencies: ['emby-collapse', 'emby-textarea', 'emby-input', 'paper-checkbox'],
controller: 'scripts/dashboardgeneral', controller: 'scripts/dashboardgeneral',
autoFocus: false, autoFocus: false,
roles: 'admin' roles: 'admin'
@ -2176,7 +2173,7 @@ var AppInfo = {};
defineRoute({ defineRoute({
path: '/librarysettings.html', path: '/librarysettings.html',
dependencies: ['emby-collapse', 'paper-input', 'paper-checkbox', 'emby-button'], dependencies: ['emby-collapse', 'emby-input', 'paper-checkbox', 'emby-button'],
autoFocus: false, autoFocus: false,
roles: 'admin', roles: 'admin',
controller: 'scripts/librarysettings' controller: 'scripts/librarysettings'
@ -2245,7 +2242,7 @@ var AppInfo = {};
defineRoute({ defineRoute({
path: '/livetvtunerprovider-satip.html', path: '/livetvtunerprovider-satip.html',
dependencies: ['paper-input', 'paper-checkbox'], dependencies: ['emby-input', 'paper-checkbox'],
autoFocus: false, autoFocus: false,
roles: 'admin', roles: 'admin',
controller: 'scripts/livetvtunerprovider-satip' controller: 'scripts/livetvtunerprovider-satip'
@ -2788,7 +2785,7 @@ var AppInfo = {};
postInitDependencies.push('bower_components/emby-webcomponents/input/api'); postInitDependencies.push('bower_components/emby-webcomponents/input/api');
if (!browserInfo.tv && !AppInfo.isNativeApp) { if (!browserInfo.tv) {
if (navigator.serviceWorker) { if (navigator.serviceWorker) {
try { try {
navigator.serviceWorker.register('serviceworker.js'); navigator.serviceWorker.register('serviceworker.js');