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

Side by Side Diff: polymer_1.0.4/bower_components/iron-validator-behavior/demo/index.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <!--
3 @license
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
8 Code distributed by Google as part of the polymer project is also
9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
10 -->
11 <html>
12 <head>
13
14 <meta charset="utf-8">
15 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
16 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial- scale=1, user-scalable=yes">
17
18 <title>iron-validator-behavior demo</title>
19
20 <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
21
22 <link rel="import" href="../../iron-meta/iron-meta.html">
23 <link rel="import" href="../../paper-styles/paper-styles.html">
24 <link rel="import" href="cats-only.html">
25
26 <link rel="stylesheet" href="../../paper-styles/demo.css">
27
28 <style>
29
30 .valid {
31 color: limegreen;
32 }
33
34 .invalid {
35 color: red;
36 }
37
38 </style>
39
40 </head>
41 <body>
42
43 <template is="dom-bind">
44
45 <cats-only></cats-only>
46
47 <section>
48
49 <p>
50 only type <code>cats</code>:
51
52 <input on-input="_onInput">
53
54 <span class="valid" hidden$="[[!valid]]">valid</span>
55 <span class="invalid" hidden$="[[valid]]">invalid</span>
56 </p>
57
58 </section>
59
60 <section>
61
62 <p>
63 only type <code>cats</code> across both input fields:
64
65 <span on-input="_onInputMulti">
66 <input>
67 <input>
68 </span>
69
70 <span class="valid" hidden$="[[!validMulti]]">valid</span>
71 <span class="invalid" hidden$="[[validMulti]]">invalid</span>
72 </p>
73
74 </section>
75
76 <section>
77
78 <p>
79 only type <code>cats</code> in the form:
80
81 <form on-submit="_onSubmit">
82 <label>
83 Type something: <input name="something">
84 </label>
85 <br>
86 <label>
87 Your favorite pet:
88 <select name="pet">
89 <option>iguanas</option>
90 <option>cats</option>
91 <option>pancakes</option>
92 </select>
93 </label>
94 <br>
95 <button type="submit">submit!</button>
96 <span class="valid" hidden$="[[!validForm]]">valid</span>
97 <span class="invalid" hidden$="[[validForm]]">invalid</span>
98 </form>
99
100 </p>
101
102 </section>
103
104 </template>
105
106 <script>
107
108 document.addEventListener('WebComponentsReady', function() {
109
110 var validator = new Polymer.IronMeta({type: 'validator'}).byKey('cats-only ');
111
112 var scope = document.querySelector('template[is=dom-bind]');
113 scope.valid = scope.validMulti = scope.validForm = true;
114
115 scope._onInput = function(event) {
116 this.valid = validator.validate(event.target.value);
117 };
118
119 scope._onInputMulti = function(event) {
120 var values = [];
121 var nodes = Polymer.dom(event.currentTarget).querySelectorAll('input');
122 for (var node, i = 0; node = nodes[i]; i++) {
123 values.push(node.value);
124 }
125 this.validMulti = validator.validate(values);
126 };
127
128 scope._onSubmit = function(event) {
129 event.preventDefault();
130
131 var data = {};
132 for (var el, i = 0; el = event.target.elements[i]; i++) {
133 if (el.name) {
134 data[el.name] = el.value;
135 }
136 }
137 this.validForm = validator.validate(data);
138 };
139
140 });
141
142 </script>
143
144 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698