Commit 854f02ee authored by Addy Osmani's avatar Addy Osmani

Merge pull request #1426 from tastejs/sjs/polymer-1.0

🍕🌟Polymer 1.0 🌟🍕
parents 224134ae 11ba30e8
bower_components/iron-localstorage/.bower.json
bower_components/iron-localstorage/.gitignore
bower_components/iron-localstorage/README.md
bower_components/iron-localstorage/bower.json
bower_components/iron-localstorage/hero.svg
bower_components/iron-localstorage/index.html
bower_components/iron-localstorage/demo/
bower_components/iron-localstorage/test/
!bower_components/iron-localstorage/iron-localstorage.html
!bower_components/iron-localstorage/direcdirector.min.js
bower_components/iron-selector
!bower_components/iron-selector/iron-selector.html
!bower_components/iron-selector/iron-selection.html
!bower_components/iron-selector/iron-selectable.html
!bower_components/iron-selector/iron-multi-selectable.html
bower_components/flatiron-director
!bower_components/flatiron-director/flatiron-director.html
bower_components/webcomponentsjs
!bower_components/webcomponentsjs/webcomponents.js
bower_components/polymer/.bower.json
bower_components/polymer/LICENSE.txt
bower_components/polymer/bower.json
bower_components/polymer/build.log
bower_components/polymer/polymer.html
bower_components/todomvc-common
!bower_components/todomvc-common/base.css
!bower_components/todomvc-common/base.js
!bower_components/todomvc-common/bg.png
bower_components/todomvc-app-css
!bower_components/todomvc-app-css/index.css
/* base.css overrides */
html,
body {
margin: 0;
padding: 0;
}
body {
font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif;
line-height: 1.4em;
background: #eaeaea url('../bower_components/todomvc-common/bg.png');
color: #4d4d4d;
width: 550px;
margin: 0 auto;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
-ms-font-smoothing: antialiased;
-o-font-smoothing: antialiased;
font-smoothing: antialiased;
}
body > header {
padding-top: 22px;
margin-bottom: -5px;
}
h1 {
/* position: absolute;
top: -120px;*/
width: 100%;
font-size: 70px;
font-weight: bold;
text-align: center;
color: #b3b3b3;
color: rgba(255, 255, 255, 0.3);
text-shadow: -1px -1px rgba(0, 0, 0, 0.2);
-webkit-text-rendering: optimizeLegibility;
-moz-text-rendering: optimizeLegibility;
-ms-text-rendering: optimizeLegibility;
-o-text-rendering: optimizeLegibility;
text-rendering: optimizeLegibility;
}
#info {
margin: 65px auto 0;
color: #a6a6a6;
font-size: 12px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
text-align: center;
}
#info a {
color: inherit;
}
.hidden{
display:none;
}
hr {
margin: 20px 0;
border: 0;
border-top: 1px dashed #C5C5C5;
border-bottom: 1px dashed #F7F7F7;
}
.learn a {
font-weight: normal;
text-decoration: none;
color: #b83f45;
}
.learn a:hover {
text-decoration: underline;
color: #787e7e;
}
.learn h3,
.learn h4,
.learn h5 {
margin: 10px 0;
font-weight: 500;
line-height: 1.2;
color: #000;
}
.learn h3 {
font-size: 24px;
}
.learn h4 {
font-size: 18px;
}
.learn h5 {
margin-bottom: 0;
font-size: 14px;
}
.learn ul {
padding: 0;
margin: 0 0 30px 25px;
}
.learn li {
line-height: 20px;
}
.learn p {
font-size: 15px;
font-weight: 300;
line-height: 1.3;
margin-top: 0;
margin-bottom: 0;
}
.quote {
border: none;
margin: 20px 0 60px 0;
}
.quote p {
font-style: italic;
}
.quote p:before {
content: '“';
font-size: 50px;
opacity: .15;
position: absolute;
top: -20px;
left: 3px;
}
.quote p:after {
content: '”';
font-size: 50px;
opacity: .15;
position: absolute;
bottom: -42px;
right: 3px;
}
.quote footer {
position: absolute;
bottom: -40px;
right: 0;
}
.quote footer img {
border-radius: 3px;
}
.quote footer a {
margin-left: 5px;
vertical-align: middle;
}
.speech-bubble {
position: relative;
padding: 10px;
background: rgba(0, 0, 0, .04);
border-radius: 5px;
}
.speech-bubble:after {
content: '';
position: absolute;
top: 100%;
right: 30px;
border: 13px solid transparent;
border-top-color: rgba(0, 0, 0, .04);
}
/**body*/.learn-bar > .learn {
position: absolute;
width: 272px;
top: 8px;
left: -300px;
padding: 10px;
border-radius: 5px;
background-color: rgba(255, 255, 255, .6);
transition-property: left;
transition-duration: 500ms;
}
body /deep/ #todoapp {
width: 550px;
margin: 0 auto;
}
/* IE doesn't support the hidden attribute */
[hidden] {
display: none;
}
@media (min-width: 899px) {
/**body*/.learn-bar {
width: auto;
margin: 0 0 0 300px;
}
/**body*/.learn-bar > .learn {
left: 8px;
}
/**body*/.learn-bar #todoapp {
width: 550px;
margin: 130px auto 40px auto;
}
}
......@@ -2,10 +2,11 @@
"name": "todomvc-polymer",
"version": "0.0.1",
"dependencies": {
"todomvc-common": "~0.3.0",
"polymer": "Polymer/polymer#~0.5.2",
"core-selector": "Polymer/core-selector",
"flatiron-director": "Polymer/flatiron-director",
"core-localstorage": "Polymer/core-localstorage"
"todomvc-common": "^1.0.1",
"todomvc-app-css": "^1.0.0",
"polymer": "Polymer/polymer#1.1.0",
"iron-selector": "polymerelements/iron-selector",
"flatiron-director": "PolymerLabs/flatiron-director#1.0.0",
"iron-localstorage": "polymerelements/iron-localstorage"
}
}
{
"name": "core-component-page",
"private": true,
"dependencies": {
"webcomponentsjs": "Polymer/webcomponentsjs#^0.5.0",
"polymer": "Polymer/polymer#^0.5.0"
},
"version": "0.5.2",
"homepage": "https://github.com/Polymer/core-component-page",
"_release": "0.5.2",
"_resolution": {
"type": "version",
"tag": "0.5.2",
"commit": "443d8dcbcb1b203ed88c6af64c98f76e6434ba53"
},
"_source": "git://github.com/Polymer/core-component-page.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/core-component-page"
}
\ No newline at end of file
core-component-page
===================
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-component-page) for more information.
Note: this is the vulcanized version of [`core-component-page-dev`](https://github.com/Polymer/core-component-page-dev) (the source).
{
"name": "core-component-page",
"private": true,
"dependencies": {
"webcomponentsjs": "Polymer/webcomponentsjs#^0.5.0",
"polymer": "Polymer/polymer#^0.5.0"
},
"version": "0.5.2"
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>
{
"name": "core-localstorage",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.1.0"
},
"version": "0.5.2",
"homepage": "https://github.com/Polymer/core-localstorage",
"_release": "0.5.2",
"_resolution": {
"type": "version",
"tag": "0.5.2",
"commit": "5654dae8929b7fb04178bfc816e9d58c115a8bf2"
},
"_source": "git://github.com/Polymer/core-localstorage.git",
"_target": "*",
"_originalSource": "Polymer/core-localstorage"
}
\ No newline at end of file
core-localstorage
=================
See the [component landing page](http://polymer-project.org/docs/elements/core-elements.html#core-localstorage) for more information.
{
"name": "core-localstorage",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.1.0"
},
"version": "0.5.2"
}
\ No newline at end of file
<!--
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
-->
<!--
Element access to localStorage. The "name" property
is the key to the data ("value" property) stored in localStorage.
`core-localstorage` automatically saves the value to localStorage when
value is changed. Note that if value is an object auto-save will be
triggered only when value is a different instance.
<core-localstorage name="my-app-storage" value="{{value}}"></core-localstorage>
@group Polymer Core Elements
@element core-localstorage
@blurb Element access to localStorage.
@url github.io
@categories Data
-->
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="core-localstorage" attributes="name value useRaw autoSaveDisabled" hidden>
<script>
Polymer('core-localstorage', {
/**
* Fired when a value is loaded from localStorage.
* @event core-localstorage-load
*/
/**
* The key to the data stored in localStorage.
*
* @attribute name
* @type string
* @default null
*/
name: '',
/**
* The data associated with the specified name.
*
* @attribute value
* @type object
* @default null
*/
value: null,
/**
* If true, the value is stored and retrieved without JSON processing.
*
* @attribute useRaw
* @type boolean
* @default false
*/
useRaw: false,
/**
* If true, auto save is disabled.
*
* @attribute autoSaveDisabled
* @type boolean
* @default false
*/
autoSaveDisabled: false,
valueChanged: function() {
if (this.loaded && !this.autoSaveDisabled) {
this.save();
}
},
nameChanged: function() {
this.load();
},
load: function() {
var v = localStorage.getItem(this.name);
if (this.useRaw) {
this.value = v;
} else {
// localStorage has a flaw that makes it difficult to determine
// if a key actually exists or not (getItem returns null if the
// key doesn't exist, which is not distinguishable from a stored
// null value)
// however, if not `useRaw`, an (unparsed) null value unambiguously
// signals that there is no value in storage (a stored null value would
// be escaped, i.e. "null")
// in this case we save any non-null current (default) value
if (v === null) {
if (this.value != null) {
this.save();
}
} else {
try {
v = JSON.parse(v);
} catch(x) {
}
this.value = v;
}
}
this.loaded = true;
this.asyncFire('core-localstorage-load');
},
/**
* Saves the value to localStorage.
*
* @method save
*/
save: function() {
var v = this.useRaw ? this.value : JSON.stringify(this.value);
localStorage.setItem(this.name, v);
}
});
</script>
</polymer-element>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
<title>polymer-localstorage</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="core-localstorage.html">
</head>
<body>
<x-test1></x-test1>
<polymer-element name="x-test1" noscript>
<template>
string entered below will be stored in localStorage and automatically retrived from localStorage when the page is reloaded<br>
<input value="{{value}}">
<core-localstorage name="polymer-localstorage-x-test1" value="{{value}}"></core-localstorage>
</template>
</polymer-element>
<br><br>
<x-test2></x-test2>
<polymer-element name="x-test2">
<template>
<input type="checkbox" checked="{{mode}}">
<core-localstorage name="polymer-localstorage-x-test2" value="{{mode}}"></core-localstorage>
</template>
<script>
Polymer('x-test2', {
mode: false
});
</script>
</polymer-element>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-localstorage-basic</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-localstorage.html">
</head>
<body>
<core-localstorage id="localstorage" name="core-localstorage-test"></core-localstorage>
<script>
window.localStorage.setItem('core-localstorage-test', '{"foo":"bar"}');
var storage = document.querySelector('#localstorage');
suite('basic', function() {
test('load', function() {
assert.isNotNull(storage.value);
assert.equal(storage.value.foo, 'bar');
});
test('save', function(done) {
var newValue = {'foo': 'zot'};
storage.value = newValue;
asyncPlatformFlush(function() {
var v = window.localStorage.getItem(storage.name);
v = JSON.parse(v);
assert.equal(v.foo, newValue.foo);
done();
});
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'basic.html',
'raw.html',
'value-binding.html'
]);
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-localstorage-raw</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-localstorage.html">
</head>
<body>
<core-localstorage id="localstorage" useRaw name="core-localstorage-test"></core-localstorage>
<script>
window.localStorage.setItem('core-localstorage-test', 'hello world');
var storage = document.querySelector('#localstorage');
suite('basic', function() {
test('load', function() {
assert.equal(storage.value, 'hello world');
});
test('save', function(done) {
var m = 'goodbye';
storage.value = m;
asyncPlatformFlush(function() {
var v = window.localStorage.getItem(storage.name);
assert.equal(v, m);
done();
});
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-localstorage-value-binding</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-localstorage.html">
</head>
<body>
<polymer-element name="x-foo" attributes="value" noscript>
<template>
<div>{{value.foo}}</div>
</template>
</polymer-element>
<polymer-element name="x-test" attributes="value" noscript>
<template>
<x-foo value="{{value}}"></x-foo>
<core-localstorage id="localstorage" name="core-localstorage-test" value="{{value}}"></core-localstorage>
</template>
</polymer-element>
<x-test></x-test>
<script>
window.localStorage.setItem('core-localstorage-test', '{"foo":"bar"}');
var xtest = document.querySelector('x-test');
suite('basic', function() {
test('initial value', function() {
assert.isNotNull(xtest.value);
assert.equal(xtest.value.foo, 'bar');
});
test('set value', function(done) {
var newValue = {'foo': 'zot'};
xtest.value = newValue;
asyncPlatformFlush(function() {
var v = window.localStorage.getItem(xtest.$.localstorage.name);
v = JSON.parse(v);
assert.equal(v.foo, newValue.foo);
done();
});
});
test('save', function(done) {
xtest.value.foo = 'quux';
xtest.$.localstorage.save();
asyncPlatformFlush(function() {
var v = window.localStorage.getItem(xtest.$.localstorage.name);
v = JSON.parse(v);
assert.equal(v.foo, 'quux');
done();
});
});
});
</script>
</body>
</html>
{
"name": "core-selection",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.1.0"
},
"version": "0.5.2",
"homepage": "https://github.com/Polymer/core-selection",
"_release": "0.5.2",
"_resolution": {
"type": "version",
"tag": "0.5.2",
"commit": "26eeb0c0098cfcf4e57fbc10c6e4d0c9279d7510"
},
"_source": "git://github.com/Polymer/core-selection.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/core-selection"
}
\ No newline at end of file
core-selection
==============
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-selection) for more information.
{
"name": "core-selection",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.1.0"
},
"version": "0.5.2"
}
\ No newline at end of file
<!--
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
-->
<!--
@group Polymer Core Elements
The `<core-selection>` element is used to manage selection state. It has no
visual appearance and is typically used in conjunction with another element.
For example, [core-selector](#core-selector)
uses a `<core-selection>` to manage selection.
To mark an item as selected, call the `select(item)` method on
`<core-selection>`. The item itself is an argument to this method.
The `<core-selection>`element manages selection state for any given set of
items. When an item is selected, the `core-select` event is fired.
The attribute `multi` indicates if multiple items can be selected at once.
Example:
<polymer-element name="selection-example">
<template>
<style>
polyfill-next-selector { content: ':host > .selected'; }
::content > .selected {
font-weight: bold;
font-style: italic;
}
</style>
<ul on-tap="{{itemTapAction}}">
<content></content>
</ul>
<core-selection id="selection" multi
on-core-select="{{selectAction}}"></core-selection>
</template>
<script>
Polymer('selection-example', {
itemTapAction: function(e, detail, sender) {
this.$.selection.select(e.target);
},
selectAction: function(e, detail, sender) {
detail.item.classList.toggle('selected', detail.isSelected);
}
});
</script>
</polymer-element>
<selection-example>
<li>Red</li>
<li>Green</li>
<li>Blue</li>
</selection-example>
@element core-selection
-->
<!--
Fired when an item's selection state is changed. This event is fired both
when an item is selected or deselected. The `isSelected` detail property
contains the selection state.
@event core-select
@param {Object} detail
@param {boolean} detail.isSelected true for selection and false for de-selection
@param {Object} detail.item the item element
-->
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="core-selection" attributes="multi" hidden>
<script>
Polymer('core-selection', {
/**
* If true, multiple selections are allowed.
*
* @attribute multi
* @type boolean
* @default false
*/
multi: false,
ready: function() {
this.clear();
},
clear: function() {
this.selection = [];
},
/**
* Retrieves the selected item(s).
* @method getSelection
* @returns Returns the selected item(s). If the multi property is true,
* getSelection will return an array, otherwise it will return
* the selected item or undefined if there is no selection.
*/
getSelection: function() {
return this.multi ? this.selection : this.selection[0];
},
/**
* Indicates if a given item is selected.
* @method isSelected
* @param {any} item The item whose selection state should be checked.
* @returns Returns true if `item` is selected.
*/
isSelected: function(item) {
return this.selection.indexOf(item) >= 0;
},
setItemSelected: function(item, isSelected) {
if (item !== undefined && item !== null) {
if (isSelected) {
this.selection.push(item);
} else {
var i = this.selection.indexOf(item);
if (i >= 0) {
this.selection.splice(i, 1);
}
}
this.fire("core-select", {isSelected: isSelected, item: item});
}
},
/**
* Set the selection state for a given `item`. If the multi property
* is true, then the selected state of `item` will be toggled; otherwise
* the `item` will be selected.
* @method select
* @param {any} item: The item to select.
*/
select: function(item) {
if (this.multi) {
this.toggle(item);
} else if (this.getSelection() !== item) {
this.setItemSelected(this.getSelection(), false);
this.setItemSelected(item, true);
}
},
/**
* Toggles the selection state for `item`.
* @method toggle
* @param {any} item: The item to toggle.
*/
toggle: function(item) {
this.setItemSelected(item, !this.isSelected(item));
}
});
</script>
</polymer-element>
<!DOCTYPE html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<title>Selection</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="core-selection.html">
</head>
<body unresolved>
<polymer-element name="selection-example">
<template>
<style>
polyfill-next-selector { content: 'ul > *'; }
::content > * {
cursor: pointer;
}
polyfill-next-selector { content: 'ul > .selected'; }
::content > .selected {
font-weight: bold;
font-style: italic;
}
</style>
<ul on-tap="{{itemTapAction}}">
<content></content>
</ul>
<core-selection id="selection" multi on-core-select="{{selectAction}}"></core-selection>
</template>
<script>
Polymer('selection-example', {
itemTapAction: function(e, detail, sender) {
this.$.selection.select(e.target);
},
selectAction: function(e, detail, sender) {
detail.item.classList.toggle('selected', detail.isSelected);
}
});
</script>
</polymer-element>
<selection-example>
<li>Red</li>
<li>Green</li>
<li>Blue</li>
</selection-example>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selection-basic</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selection.html">
</head>
<body>
<core-selection></core-selection>
<script>
var s = document.querySelector('core-selection');
suite('basic', function() {
test('select item', function(done) {
var func = function(event) {
assert.isTrue(event.detail.isSelected);
assert.equal(event.detail.item, '(item)');
assert.isTrue(s.isSelected(event.detail.item));
assert.isFalse(s.isSelected('(some_item_not_selected)'));
s.removeEventListener('core-select', func);
done();
}
s.addEventListener('core-select', func);
s.select('(item)');
});
test('select null', function(done) {
var func = function(event) {
assert.isFalse(event.detail.isSelected);
assert.equal(event.detail.item, '(item)');
assert.isFalse(s.isSelected(event.detail.item));
s.removeEventListener("core-select", func);
done();
}
s.addEventListener("core-select", func);
s.select(null);
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'basic.html',
'multi.html'
]);
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selection-multi</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selection.html">
</head>
<body>
<core-selection multi></core-selection>
<script>
var s = document.querySelector('core-selection');
suite('basic', function() {
test('select item', function(done) {
var func = function(event) {
assert.isTrue(event.detail.isSelected);
assert.equal(event.detail.item, '(item1)');
assert.isTrue(s.isSelected(event.detail.item));
assert.equal(s.getSelection().length, 1);
s.removeEventListener('core-select', func);
done();
}
s.addEventListener('core-select', func);
s.select('(item1)');
});
test('select null', function(done) {
var func = function(event) {
assert.isTrue(event.detail.isSelected);
assert.equal(event.detail.item, '(item2)');
assert.isTrue(s.isSelected(event.detail.item));
assert.equal(s.getSelection().length, 2);
s.removeEventListener("core-select", func);
done();
}
s.addEventListener("core-select", func);
s.select('(item2)');
});
});
</script>
</body>
</html>
{
"name": "core-selector",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0",
"core-selection": "Polymer/core-selection#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.4.2"
},
"version": "0.5.2",
"homepage": "https://github.com/Polymer/core-selector",
"_release": "0.5.2",
"_resolution": {
"type": "version",
"tag": "0.5.2",
"commit": "abe95a14ffb805fcacbd2369c937a3b16cac734d"
},
"_source": "git://github.com/Polymer/core-selector.git",
"_target": "*",
"_originalSource": "Polymer/core-selector"
}
\ No newline at end of file
core-selector
==============
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-selector) for more information.
{
"name": "core-selector",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0",
"core-selection": "Polymer/core-selection#^0.5.0"
},
"devDependencies": {
"web-component-tester": "Polymer/web-component-tester#^1.4.2"
},
"version": "0.5.2"
}
\ No newline at end of file
<!DOCTYPE html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<title>Selector</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="core-selector.html">
</head>
<body unresolved>
<polymer-element name="selector-examples">
<template>
<style>
.list {
display: block;
border: 1px solid #ccc;
border-bottom: none;
background: #666;
color: white;
list-style: none;
margin: 0;
padding: 0;
}
.list > * {
height: 40px;
line-height: 40px;
padding: 0 20px;
border-bottom: 1px solid #ccc;
}
.list > *.core-selected {
background: #333;
}
li {
height: 30px;
}
li.core-selected:after {
content: "\2713";
position: absolute;
padding-left: 10px;
}
</style>
<h2>basic</h2>
<core-selector class="list" selected="0">
<div>Item 0</div>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
</core-selector>
<h2>multi-selection</h2>
<core-selector class="list" selected="{{multiSelected}}" multi>
<div>Item 0</div>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
</core-selector>
<h2>list</h2>
<core-selector target="{{$.list}}" selected="0"></core-selector>
<ul id="list">
<li>Item 0</li>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>
<h2>binding of a group of radio buttons to a variable</h2>
<core-selector target="{{$.myForm}}" itemsSelector="input[type=radio]"
selected="{{color}}" valueattr="value" selectedProperty="checked"
activateEvent="change"></core-selector>
<form id="myForm">
<label><input type="radio" name="color" value="red"> Red</label> <br>
<label><input type="radio" name="color" value="green"> Green</label> <br>
<label><input type="radio" name="color" value="blue"> Blue</label> <br>
<p>color = {{color}}</p>
</form>
</template>
<script>
Polymer('selector-examples', {
ready: function() {
this.multiSelected = [1, 3];
this.color = 'green';
}
});
</script>
</polymer-element>
<selector-examples></selector-examples>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>
<!--
@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
-->
<x-meta id="core-selector" label="Selector" group="Core" isContainer>
<template>
<core-selector selected="0" style="width:100%;height:50px;"></core-selector>
</template>
<template>
<link rel="import" href="core-selector.html">
</template>
</x-meta>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selector-activate-event</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selector.html">
<style>
.core-selected {
background: #ccc;
}
</style>
</head>
<body>
<core-selector id="selector" selected="0">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</core-selector>
<script>
var s = document.querySelector('#selector');
suite('activate event', function() {
test('activates on tap', function(done) {
assert.equal(s.selected, '0');
async.nextTick(function() {
// select Item 2
s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
});
s.addEventListener("core-activate", function(event) {
assert.equal(event.detail.item, s.children[1]);
assert.equal(s.selected, 1);
done();
});
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selector-basic</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selector.html">
<style>
.core-selected {
background: #ccc;
}
.my-selected {
background: red;
}
</style>
</head>
<body>
<core-selector id="selector1">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</core-selector>
<br><br>
<core-selector id="selector2" selected="item3" selectedClass="my-selected" valueattr="id">
<div id="item1">Item 1</div>
<div id="item2">Item 2</div>
<div id="item3">Item 3</div>
<div id="item4">Item 4</div>
<div id="item5">Item 5</div>
</core-selector>
<script>
var s1 = document.querySelector('#selector1');
var s2 = document.querySelector('#selector2');
suite('basic', function() {
suite('defaults', function() {
test('to nothing selected', function() {
assert.equal(s1.selected, null);
});
test('to core-selected as selectedClass', function() {
assert.equal(s1.selectedClass, 'core-selected');
});
test('to a single-select', function() {
assert.isFalse(s1.multi);
});
test('to name as valueattr', function() {
assert.equal(s1.valueattr, 'name');
});
test('as many items as children', function() {
assert.equal(s1.items.length, 5);
});
});
test('honors the selected attribute', function() {
assert.equal(s2.selected, 'item3');
assert.equal(s2.selectedIndex, 2);
assert.equal(s2.selectedItem, document.querySelector('#item3'));
});
test('honors the selectedClass attribute', function() {
assert.equal(s2.selectedClass, 'my-selected');
assert.isTrue(document.querySelector('#item3').classList.contains('my-selected'));
});
test('allows assignment to selected', function(done) {
// setup listener for core-select event
var selectEventCounter = 0;
s2.addEventListener('core-select', function(e) {
if (e.detail.isSelected) {
selectEventCounter++;
// selectedItem and detail.item should be the same
assert.equal(e.detail.item, s2.selectedItem);
}
});
// set selected
s2.selected = 'item5';
asyncPlatformFlush(function() {
// check core-select event
assert.equal(selectEventCounter, 1);
// check selected class
assert.isTrue(s2.children[4].classList.contains('my-selected'));
// check selectedItem
assert.equal(s2.selectedItem, s2.children[4]);
// selecting the same value shouldn't fire core-select
selectEventCounter = 0;
s2.selected = 'item5';
flush(function() {
assert.equal(selectEventCounter, 0);
done();
});
});
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selector-content</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selector.html">
<style>
.core-selected {
background: #ccc;
}
</style>
</head>
<body>
<polymer-element name="test-core-selector" noscript attributes="selected">
<template>
<core-selector id="selector" selected="{{selected}}" valueattr="id">
<content></content>
</core-selector>
</template>
</polymer-element>
<test-core-selector selected="item0">
<div id="item0">item0</div>
<div id="item1">item1</div>
<div id="item2">item2</div>
<div id="item3">item3</div>
</test-core-selector>
<script>
var s = document.querySelector('test-core-selector');
suite('content', function() {
test('get selected', function(done) {
asyncPlatformFlush(function() {
// check selected class
assert.isTrue(s.children[0].classList.contains('core-selected'));
done();
});
});
test('set selected', function(done) {
// set selected
s.selected = 'item1';
asyncPlatformFlush(function() {
// check selected class
assert.isTrue(s.children[1].classList.contains('core-selected'));
done();
});
});
test('get items', function() {
assert.equal(s.$.selector.items.length, s.children.length);
});
test('activate event', function(done) {
s.children[2].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
asyncPlatformFlush(function() {
// check selected class
assert.isTrue(s.children[2].classList.contains('core-selected'));
done();
});
});
test('add item dynamically', function(done) {
var item = document.createElement('div');
item.id = 'item4';
item.textContent = 'item4';
s.appendChild(item);
// set selected
s.selected = 'item4';
asyncPlatformFlush(function() {
// check selected class
assert.isTrue(s.children[4].classList.contains('core-selected'));
done();
});
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'activate-event.html',
'basic.html',
'multi.html',
'next-previous.html',
'selected-attr-prop.html',
'template-repeat.html',
'content.html'
]);
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selector-multi</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selector.html">
<style>
.core-selected {
background: #ccc;
}
</style>
</head>
<body>
<core-selector id="selector" multi>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</core-selector>
<script>
var s = document.querySelector('#selector');
suite('multi', function() {
test('honors the multi attribute', function() {
assert.isTrue(s.multi);
});
test('has sane defaults', function() {
assert.equal(s.selected, null);
assert.equal(s.selectedClass, 'core-selected');
assert.equal(s.valueattr, 'name');
assert.equal(s.items.length, 5);
});
test('allows multi-selection', function(done) {
// setup listener for core-select event
var selectEventCounter = 0;
s.addEventListener('core-select', function(e) {
if (e.detail.isSelected) {
selectEventCounter++;
} else {
selectEventCounter--;
}
});
// set selected
s.selected = [0, 2];
asyncPlatformFlush(function() {
// check core-select event
assert.equal(selectEventCounter, 2);
// check selected class
assert.isTrue(s.children[0].classList.contains('core-selected'));
assert.isTrue(s.children[2].classList.contains('core-selected'));
// check selectedItem
assert.equal(s.selectedItem.length, 2);
assert.equal(s.selectedItem[0], s.children[0]);
assert.equal(s.selectedItem[1], s.children[2]);
// tap on already selected element should unselect it
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
// check selected
assert.equal(s.selected.length, 1);
asyncPlatformFlush(function() {
assert.equal(selectEventCounter, 1);
assert.isFalse(s.children[0].classList.contains('core-selected'));
// add selected
s.selected.push(3);
s.selected.push(4);
// check core-select event
asyncPlatformFlush(function() {
assert.equal(selectEventCounter, 3);
done();
});
});
});
});
test('toggle multi to false', function(done) {
// set selected
s.selected = [0, 2];
var first = s.selected[0];
// set mutli to false, so to make it single-selection
s.multi = false;
asyncPlatformFlush(function() {
// selected should not be an array
assert.isNotArray(s.selected);
// selected should be the first value in the old array
assert.equal(s.selected, first);
done();
});
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selector-next-previous-wrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selector.html">
<style>
.core-selected {
background: #ccc;
}
</style>
</head>
<body unresolved>
<core-selector id="selector" selected="0">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</core-selector>
<script>
var s = document.querySelector('#selector');
function assertAndSelect(method, expectedIndex, wrap) {
return function(done) {
assert.equal(s.selected, expectedIndex);
s[method](wrap);
flush(done);
}
}
suite('next/previous', function() {
test('selectNext(true) wraps', function(done) {
assert.equal(s.selected, 0);
async.series([
assertAndSelect('selectNext', 0, true),
assertAndSelect('selectNext', 1, true),
assertAndSelect('selectNext', 2, true),
function(done) {
assert.equal(s.selected, 0);
done();
}
], done);
});
test('selectPrevious(true) wraps', function(done) {
assert.equal(s.selected, 0);
async.series([
assertAndSelect('selectPrevious', 0, true),
assertAndSelect('selectPrevious', 2, true),
assertAndSelect('selectPrevious', 1, true),
function(done) {
assert.equal(s.selected, 0);
done();
}
], done);
});
test('selectNext() does not wrap', function(done) {
assert.equal(s.selected, 0);
async.series([
assertAndSelect('selectNext', 0),
assertAndSelect('selectNext', 1),
assertAndSelect('selectNext', 2),
assertAndSelect('selectNext', 2),
assertAndSelect('selectNext', 2),
function(done) {
s.selected = 0;
asyncPlatformFlush(done);
}
], done);
});
test('selectPrevious() does not wrap', function(done) {
assert.equal(s.selected, 0);
s.selected = 2;
async.series([
asyncPlatformFlush,
assertAndSelect('selectPrevious', 2),
assertAndSelect('selectPrevious', 1),
assertAndSelect('selectPrevious', 0),
assertAndSelect('selectPrevious', 0),
assertAndSelect('selectPrevious', 0),
], done);
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selector-selected-attr-prop</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selector.html">
<style>
.core-selected {
background: #ccc;
}
</style>
</head>
<body>
<core-selector id="selector" selected="2" selectedProperty="myprop">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</core-selector>
<script>
var s = document.querySelector('#selector');
suite('selected attributes', function() {
test('custom selectedProperty', function(done) {
s.selected = 4;
asyncPlatformFlush(function() {
// check Item2's attribute and property (should be unselect)
assert.isFalse(s.children[2].hasAttribute('active'));
assert.notEqual(s.children[2].myprop, true);
// check Item4's attribute and property
assert.isTrue(s.children[4].hasAttribute('active'));
assert.isTrue(s.children[4].myprop);
done();
});
});
});
</script>
</body>
</html>
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<title>core-selector-template-repeat</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../core-selector.html">
<style>
.core-selected {
background: #ccc;
}
</style>
</head>
<body>
<core-selector id="selector" selected="1">
<template id="itemsTemplate" repeat="{{items}}">
<div name="{{}}">{{}}</div>
</template>
</core-selector>
<script>
var s = document.querySelector('#selector');
var t = document.querySelector('#itemsTemplate');
suite('<template repeat...>', function() {
test('supports repeated children', function(done) {
t.model = {items: ['Item1', 'Item2', 'Item3', "Item4"]};
asyncPlatformFlush(function() {
// check items
assert.equal(s.items.length, 4);
assert.equal(s.selected, 1);
// check selectedItem
var item = s.selectedItem;
assert.equal(s.items[1], item);
// check selected class
assert.isTrue(item.classList.contains('core-selected'));
done();
});
});
});
</script>
</body>
</html>
{
"name": "flatiron-director",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"version": "0.5.0",
"homepage": "https://github.com/Polymer/flatiron-director",
"_release": "0.5.0",
"_resolution": {
"type": "version",
"tag": "0.5.0",
"commit": "acddce5aebb2d22367e670aff8cbd902f18c6a50"
},
"_source": "git://github.com/Polymer/flatiron-director.git",
"_target": "*",
"_originalSource": "Polymer/flatiron-director"
}
\ No newline at end of file
# Names should be added to this file with this pattern:
#
# For individuals:
# Name <email address>
#
# For organizations:
# Organization <fnmatch pattern>
#
Google Inc. <*@google.com>
See https://github.com/Polymer/polymer/blob/master/CONTRIBUTING.md
// Copyright (c) 2011 Nodejitsu Inc.
// Copyright (c) 2012 The Polymer Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Additional IP Rights Grant (Patents)
"This implementation" means the copyrightable works distributed by
Google as part of the Polymer project.
Google hereby grants to You a perpetual, worldwide, non-exclusive,
no-charge, royalty-free, irrevocable (except as stated in this section)
patent license to make, have made, use, offer to sell, sell, import,
transfer and otherwise run, modify and propagate the contents of this
implementation of Polymer, where such license applies only to those
patent claims, both currently owned or controlled by Google and acquired
in the future, licensable by Google that are necessarily infringed by
this implementation of Polymer. This grant does not include claims
that would be infringed only as a consequence of further modification of
this implementation. If you or your agent or exclusive licensee
institute or order or agree to the institution of patent litigation
against any entity (including a cross-claim or counterclaim in a
lawsuit) alleging that this implementation of Polymer or any code
incorporated within this implementation of Polymer constitutes
direct or contributory patent infringement, or inducement of patent
infringement, then any patent rights granted to you under this License
for this implementation of Polymer shall terminate as of the date
such litigation is filed.
{
"name": "flatiron-director",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"version": "0.5.0"
}
\ No newline at end of file
<!DOCTYPE html>
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
<head>
<title>Director</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="flatiron-director.html">
</head>
<body>
<polymer-element name="x-test">
<template>
<flatiron-director route="{{route}}" autoHash></flatiron-director>
hash: <input value="{{route}}">
<a href="#barnacle">Relocate</a>
</template>
<script>
Polymer('x-test', {
route: 'hello'
});
</script>
</polymer-element>
<x-test></x-test>
</body>
</html>
Copyright (c) 2011 Nodejitsu Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\ No newline at end of file
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
@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 src="director/director.min.js"></script>
<polymer-element name="flatiron-director" attributes="route autoHash" hidden>
<script>
(function() {
var private_router;
Polymer('flatiron-director', {
autoHash: false,
ready: function() {
this.router.on(/(.*)/, function(route) {
this.route = route;
}.bind(this));
this.route = this.router.getRoute() ?
this.router.getRoute().join(this.router.delimiter): '';
},
routeChanged: function() {
if (this.autoHash) {
window.location.hash = this.route;
}
this.fire('director-route', this.route);
},
get router() {
if (!private_router) {
private_router = new Router();
private_router.init();
}
return private_router;
}
});
})();
</script>
</polymer-element>
<script>
/**
`flatiron-director` is a web component for routing that wraps the flatiron director JS library.
### Example
<flatiron-director route="{{route}}" auto-hash></flatiron-director>
@element flatiron-director
@demo demo/index.html
```
*/
Polymer({
is: 'flatiron-director',
properties: {
/**
* When set to `true`, changing `route` will update the URL hash to the same value.
*/
autoHash: {
type: Boolean,
value: false
},
/**
* Gets or sets the current route.
*/
route: {
type: String,
value: '',
notify: true
}
},
observers: [
'_routeChanged(route)'
],
_routingIsReady: false,
ready: function() {
this._router.on(/(.*)/, function(route) {
this.route = route;
}.bind(this));
this.route = this._router.getRoute() ?
this._router.getRoute().join(this._router.delimiter): '';
this._routingIsReady = true;
},
_routeChanged: function() {
if (this.autoHash && this._routingIsReady) {
window.location.hash = this.route ? this.route : '';
}
this.fire('director-route', this.route);
},
get _router() {
if (!window.FlatironDirectorPolymer) {
window.FlatironDirectorPolymer = new Router();
window.FlatironDirectorPolymer.init();
}
return window.FlatironDirectorPolymer;
}
});
</script>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
<title>polymer api</title>
<style>
html, body {
font-family: Arial, sans-serif;
white-space: nowrap;
overflow: hidden;
}
[noviewer] [ifnoviewer] {
display: block;
}
[detector], [ifnoviewer], [noviewer] [ifviewer] {
display: none;
}
[ifviewer], [ifnoviewer] {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
iframe {
border: none;
margin: 0;
width: 100%;
height: 100%;
}
#remote {
position: absolute;
top: 0;
right: 0;
}
</style>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../polymer-home-page/polymer-home-page.html">
</head>
<body>
<img detector src="../polymer-home-page/bowager-logo.png" onerror="noviewer()">
<polymer-home-page ifviewer></polymer-home-page>
<div ifnoviewer>
<span id="remote">[remote]</span>
<iframe></iframe>
</div>
<!-- -->
<script>
var remoteDocs = 'http://turbogadgetry.com/bowertopia/components/';
// if no local info viewer, load it remotely
function noviewer() {
document.body.setAttribute('noviewer', '');
var path = location.pathname.split('/');
var module = path.pop() || path.pop();
document.querySelector('iframe').src = remoteDocs + module;
document.querySelector('title').textContent = module;
}
// for testing only
var opts = window.location.search;
if (opts.indexOf('noviewer') >= 0) {
noviewer();
}
</script>
</body>
</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
-->
<link rel="import" href="../polymer/polymer.html">
<!--
Element access to Web Storage API (window.localStorage).
Keeps `value` property in sync with localStorage.
Value is saved as json by default.
###Usage:
`ls-sample` will automatically save changes to its value.
<dom-module id="ls-sample">
<iron-localstorage name="my-app-storage"
value="{{cartoon}}"
on-iron-localstorage-load-empty="initializeDefaultCartoon"
></iron-localstorage>
</dom-module>
<script>
Polymer({
is: 'ls-sample',
properties: {
cartoon: {
type: Object
}
},
// initializes default if nothing has been stored
initializeDefaultCartoon: function() {
this.cartoon = {
name: "Mickey",
hasEars: true
}
},
// use path set api to propagate changes to localstorage
makeModifications: function() {
this.set('cartoon.name', "Minions");
this.set('cartoon.hasEars', false);
}
});
</script>
###Tech notes:
* * `value.*` is observed, and saved on modifications. You must use
property notification methods to modify value for changes to be observed.
* * Set `auto-save-disabled` to prevent automatic saving.
* * Value is saved as JSON by default.
* * To delete a key, set value to null
* Element listens to StorageAPI `storage` event, and will reload upon receiving it.
* **Warning**: do not bind value to sub-properties until Polymer
[bug 1550](https://github.com/Polymer/polymer/issues/1550)
is resolved. Local storage will be blown away.
`<iron-localstorage value="{{foo.bar}}"` will cause **data loss**.
@demo demo/index.html
@hero hero.svg
-->
<dom-module id="iron-localstorage"></dom-module>
<script>
Polymer({
is: 'iron-localstorage',
properties: {
/**
* localStorage item key
*/
name: {
type: String,
value: ''
},
/**
* The data associated with this storage.
* If set to null item will be deleted.
* @type {*}
*/
value: {
type: Object,
notify: true
},
/**
* If true: do not convert value to JSON on save/load
*/
useRaw: {
type: Boolean,
value: false
},
/**
* Value will not be saved automatically if true. You'll have to do it manually with `save()`
*/
autoSaveDisabled: {
type: Boolean,
value: false
},
/**
* Last error encountered while saving/loading items
*/
errorMessage: {
type: String,
notify: true
},
/** True if value has been loaded */
_loaded: {
type: Boolean,
value: false
}
},
observers: [
'_debounceReload(name,useRaw)',
'_trySaveValue(autoSaveDisabled)',
'_trySaveValue(value.*)'
],
ready: function() {
this._boundHandleStorage = this._handleStorage.bind(this);
},
attached: function() {
window.addEventListener('storage', this._boundHandleStorage);
},
detached: function() {
window.removeEventListener('storage', this._boundHandleStorage);
},
_handleStorage: function(ev) {
if (ev.key == this.name) {
this._load(true);
}
},
_trySaveValue: function() {
if (this._doNotSave) {
return;
}
if (this._loaded && !this.autoSaveDisabled) {
this.debounce('save', this.save);
}
},
_debounceReload: function() {
this.debounce('reload', this.reload);
},
/**
* Loads the value again. Use if you modify
* localStorage using DOM calls, and want to
* keep this element in sync.
*/
reload: function() {
this._loaded = false;
this._load();
},
/**
* loads value from local storage
* @param {boolean=} externalChange true if loading changes from a different window
*/
_load: function(externalChange) {
var v = window.localStorage.getItem(this.name);
if (v === null) {
this._loaded = true;
this._doNotSave = true; // guard for save watchers
this.value = null;
this._doNotSave = false;
this.fire('iron-localstorage-load-empty', { externalChange: externalChange});
} else {
if (!this.useRaw) {
try { // parse value as JSON
v = JSON.parse(v);
} catch(x) {
this.errorMessage = "Could not parse local storage value";
console.error("could not parse local storage value", v);
v = null;
}
}
this._loaded = true;
this._doNotSave = true;
this.value = v;
this._doNotSave = false;
this.fire('iron-localstorage-load', { externalChange: externalChange});
}
},
/**
* Saves the value to localStorage. Call to save if autoSaveDisabled is set.
* If `value` is null, deletes localStorage.
*/
save: function() {
var v = this.useRaw ? this.value : JSON.stringify(this.value);
try {
if (this.value === null) {
window.localStorage.removeItem(this.name);
} else {
window.localStorage.setItem(this.name, /** @type {string} */ (v));
}
}
catch(ex) {
// Happens in Safari incognito mode,
this.errorMessage = ex.message;
console.error("localStorage could not be saved. Safari incoginito mode?", ex);
}
}
/**
* Fired when value loads from localStorage.
*
* @event iron-localstorage-load
* @param {{externalChange:boolean}} detail -
* externalChange: true if change occured in different window.
*/
/**
* Fired when loaded value does not exist.
* Event handler can be used to initialize default value.
*
* @event iron-localstorage-load-empty
* @param {{externalChange:boolean}} detail -
* externalChange: true if change occured in different window.
*/
});
</script>
<!--
@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-selectable.html">
<script>
/** @polymerBehavior Polymer.IronMultiSelectableBehavior */
Polymer.IronMultiSelectableBehaviorImpl = {
properties: {
/**
* If true, multiple selections are allowed.
*/
multi: {
type: Boolean,
value: false,
observer: 'multiChanged'
},
/**
* Gets or sets the selected elements. This is used instead of `selected` when `multi`
* is true.
*/
selectedValues: {
type: Array,
notify: true
},
/**
* Returns an array of currently selected items.
*/
selectedItems: {
type: Array,
readOnly: true,
notify: true
},
},
observers: [
'_updateSelected(attrForSelected, selectedValues)'
],
/**
* Selects the given value. If the `multi` property is true, then the selected state of the
* `value` will be toggled; otherwise the `value` will be selected.
*
* @method select
* @param {string} value the value to select.
*/
select: function(value) {
if (this.multi) {
if (this.selectedValues) {
this._toggleSelected(value);
} else {
this.selectedValues = [value];
}
} else {
this.selected = value;
}
},
multiChanged: function(multi) {
this._selection.multi = multi;
},
_updateSelected: function() {
if (this.multi) {
this._selectMulti(this.selectedValues);
} else {
this._selectSelected(this.selected);
}
},
_selectMulti: function(values) {
this._selection.clear();
if (values) {
for (var i = 0; i < values.length; i++) {
this._selection.setItemSelected(this._valueToItem(values[i]), true);
}
}
},
_selectionChange: function() {
var s = this._selection.get();
if (this.multi) {
this._setSelectedItems(s);
} else {
this._setSelectedItems([s]);
this._setSelectedItem(s);
}
},
_toggleSelected: function(value) {
var i = this.selectedValues.indexOf(value);
var unselected = i < 0;
if (unselected) {
this.selectedValues.push(value);
} else {
this.selectedValues.splice(i, 1);
}
this._selection.setItemSelected(this._valueToItem(value), unselected);
}
};
/** @polymerBehavior */
Polymer.IronMultiSelectableBehavior = [
Polymer.IronSelectableBehavior,
Polymer.IronMultiSelectableBehaviorImpl
];
</script>
<!--
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-selection.html">
<script>
/** @polymerBehavior */
Polymer.IronSelectableBehavior = {
properties: {
/**
* If you want to use the attribute value of an element for `selected` instead of the index,
* set this to the name of the attribute.
*
* @attribute attrForSelected
* @type {string}
*/
attrForSelected: {
type: String,
value: null
},
/**
* Gets or sets the selected element. The default is to use the index of the item.
*
* @attribute selected
* @type {string}
*/
selected: {
type: String,
notify: true
},
/**
* Returns the currently selected item.
*
* @attribute selectedItem
* @type {Object}
*/
selectedItem: {
type: Object,
readOnly: true,
notify: true
},
/**
* The event that fires from items when they are selected. Selectable
* will listen for this event from items and update the selection state.
* Set to empty string to listen to no events.
*
* @attribute activateEvent
* @type {string}
* @default 'tap'
*/
activateEvent: {
type: String,
value: 'tap',
observer: '_activateEventChanged'
},
/**
* This is a CSS selector sting. If this is set, only items that matches the CSS selector
* are selectable.
*
* @attribute selectable
* @type {string}
*/
selectable: String,
/**
* The class to set on elements when selected.
*
* @attribute selectedClass
* @type {string}
*/
selectedClass: {
type: String,
value: 'iron-selected'
},
/**
* The attribute to set on elements when selected.
*
* @attribute selectedAttribute
* @type {string}
*/
selectedAttribute: {
type: String,
value: null
}
},
observers: [
'_updateSelected(attrForSelected, selected)'
],
excludedLocalNames: {
'template': 1
},
created: function() {
this._bindFilterItem = this._filterItem.bind(this);
this._selection = new Polymer.IronSelection(this._applySelection.bind(this));
},
attached: function() {
this._observer = this._observeItems(this);
this._contentObserver = this._observeContent(this);
},
detached: function() {
if (this._observer) {
this._observer.disconnect();
}
if (this._contentObserver) {
this._contentObserver.disconnect();
}
this._removeListener(this.activateEvent);
},
/**
* Returns an array of selectable items.
*
* @property items
* @type Array
*/
get items() {
var nodes = Polymer.dom(this).queryDistributedElements(this.selectable || '*');
return Array.prototype.filter.call(nodes, this._bindFilterItem);
},
/**
* Returns the index of the given item.
*
* @method indexOf
* @param {Object} item
* @returns Returns the index of the item
*/
indexOf: function(item) {
return this.items.indexOf(item);
},
/**
* Selects the given value.
*
* @method select
* @param {string} value the value to select.
*/
select: function(value) {
this.selected = value;
},
/**
* Selects the previous item.
*
* @method selectPrevious
*/
selectPrevious: function() {
var length = this.items.length;
var index = (Number(this._valueToIndex(this.selected)) - 1 + length) % length;
this.selected = this._indexToValue(index);
},
/**
* Selects the next item.
*
* @method selectNext
*/
selectNext: function() {
var index = (Number(this._valueToIndex(this.selected)) + 1) % this.items.length;
this.selected = this._indexToValue(index);
},
_addListener: function(eventName) {
this.listen(this, eventName, '_activateHandler');
},
_removeListener: function(eventName) {
// There is no unlisten yet...
// https://github.com/Polymer/polymer/issues/1639
//this.removeEventListener(eventName, this._bindActivateHandler);
},
_activateEventChanged: function(eventName, old) {
this._removeListener(old);
this._addListener(eventName);
},
_updateSelected: function() {
this._selectSelected(this.selected);
},
_selectSelected: function(selected) {
this._selection.select(this._valueToItem(this.selected));
},
_filterItem: function(node) {
return !this.excludedLocalNames[node.localName];
},
_valueToItem: function(value) {
return (value == null) ? null : this.items[this._valueToIndex(value)];
},
_valueToIndex: function(value) {
if (this.attrForSelected) {
for (var i = 0, item; item = this.items[i]; i++) {
if (this._valueForItem(item) == value) {
return i;
}
}
} else {
return Number(value);
}
},
_indexToValue: function(index) {
if (this.attrForSelected) {
var item = this.items[index];
if (item) {
return this._valueForItem(item);
}
} else {
return index;
}
},
_valueForItem: function(item) {
return item[this.attrForSelected] || item.getAttribute(this.attrForSelected);
},
_applySelection: function(item, isSelected) {
if (this.selectedClass) {
this.toggleClass(this.selectedClass, isSelected, item);
}
if (this.selectedAttribute) {
this.toggleAttribute(this.selectedAttribute, isSelected, item);
}
this._selectionChange();
this.fire('iron-' + (isSelected ? 'select' : 'deselect'), {item: item});
},
_selectionChange: function() {
this._setSelectedItem(this._selection.get());
},
// observe content changes under the given node.
_observeContent: function(node) {
var content = node.querySelector('content');
if (content && content.parentElement === node) {
return this._observeItems(node.domHost);
}
},
// observe items change under the given node.
_observeItems: function(node) {
var observer = new MutationObserver(function() {
if (this.selected != null) {
this._updateSelected();
}
}.bind(this));
observer.observe(node, {
childList: true,
subtree: true
});
return observer;
},
_activateHandler: function(e) {
// TODO: remove this when https://github.com/Polymer/polymer/issues/1639 is fixed so we
// can just remove the old event listener.
if (e.type !== this.activateEvent) {
return;
}
var t = e.target;
var items = this.items;
while (t && t != this) {
var i = items.indexOf(t);
if (i >= 0) {
var value = this._indexToValue(i);
this._itemActivate(value, t);
return;
}
t = t.parentNode;
}
},
_itemActivate: function(value, item) {
if (!this.fire('iron-activate',
{selected: value, item: item}, {cancelable: true}).defaultPrevented) {
this.select(value);
}
}
};
</script>
<!--
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>
/**
* @param {!Function} selectCallback
* @constructor
*/
Polymer.IronSelection = function(selectCallback) {
this.selection = [];
this.selectCallback = selectCallback;
};
Polymer.IronSelection.prototype = {
/**
* Retrieves the selected item(s).
*
* @method get
* @returns Returns the selected item(s). If the multi property is true,
* `get` will return an array, otherwise it will return
* the selected item or undefined if there is no selection.
*/
get: function() {
return this.multi ? this.selection : this.selection[0];
},
/**
* Clears all the selection except the ones indicated.
*
* @method clear
* @param {Array} excludes items to be excluded.
*/
clear: function(excludes) {
this.selection.slice().forEach(function(item) {
if (!excludes || excludes.indexOf(item) < 0) {
this.setItemSelected(item, false);
}
}, this);
},
/**
* Indicates if a given item is selected.
*
* @method isSelected
* @param {*} item The item whose selection state should be checked.
* @returns Returns true if `item` is selected.
*/
isSelected: function(item) {
return this.selection.indexOf(item) >= 0;
},
/**
* Sets the selection state for a given item to either selected or deselected.
*
* @method setItemSelected
* @param {*} item The item to select.
* @param {boolean} isSelected True for selected, false for deselected.
*/
setItemSelected: function(item, isSelected) {
if (item != null) {
if (isSelected) {
this.selection.push(item);
} else {
var i = this.selection.indexOf(item);
if (i >= 0) {
this.selection.splice(i, 1);
}
}
if (this.selectCallback) {
this.selectCallback(item, isSelected);
}
}
},
/**
* Sets the selection state for a given item. If the `multi` property
* is true, then the selected state of `item` will be toggled; otherwise
* the `item` will be selected.
*
* @method select
* @param {*} item The item to select.
*/
select: function(item) {
if (this.multi) {
this.toggle(item);
} else if (this.get() !== item) {
this.setItemSelected(this.get(), false);
this.setItemSelected(item, true);
}
},
/**
* Toggles the selection state for `item`.
*
* @method toggle
* @param {*} item The item to toggle.
*/
toggle: function(item) {
this.setItemSelected(item, !this.isSelected(item));
}
};
</script>
<!--
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-multi-selectable.html">
<script>
/**
`iron-selector` is an element which can be used to manage a list of elements
that can be selected. Tapping on the item will make the item selected. The `selected` indicates
which item is being selected. The default is to use the index of the item.
Example:
<iron-selector selected="0">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</iron-selector>
If you want to use the attribute value of an element for `selected` instead of the index,
set `attrForSelected` to the name of the attribute. For example, if you want to select item by
`name`, set `attrForSelected` to `name`.
Example:
<iron-selector attr-for-selected="name" selected="foo">
<div name="foo">Foo</div>
<div name="bar">Bar</div>
<div name="zot">Zot</div>
</iron-selector>
`iron-selector` is not styled. Use the `iron-selected` CSS class to style the selected element.
Example:
<style>
.iron-selected {
background: #eee;
}
</style>
...
<iron-selector selected="0">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</iron-selector>
@demo demo/index.html
*/
Polymer({
is: 'iron-selector',
behaviors: [
Polymer.IronMultiSelectableBehavior
]
});
</script>
{
"name": "polymer",
"description": "Polymer is a new type of library for the web, built on top of Web Components, and designed to leverage the evolving web platform on modern browsers.",
"homepage": "http://www.polymer-project.org/",
"keywords": [
"util",
"client",
"browser",
"web components",
"web-components"
],
"author": "Polymer Authors <polymer-dev@googlegroups.com>",
"private": true,
"dependencies": {
"core-component-page": "Polymer/core-component-page#^0.5.0",
"webcomponentsjs": "Polymer/webcomponentsjs#^0.5.0"
},
"devDependencies": {
"tools": "Polymer/tools#master",
"web-component-tester": "Polymer/web-component-tester#^1.4.2"
},
"version": "0.5.2",
"_release": "0.5.2",
"_resolution": {
"type": "version",
"tag": "0.5.2",
"commit": "2a9ca53fa79ca09907e818f1adf806765409ec9c"
},
"_source": "git://github.com/Polymer/polymer.git",
"_target": "~0.5.2",
"_originalSource": "Polymer/polymer"
}
\ No newline at end of file
# Polymer
[![Polymer build status](http://www.polymer-project.org/build/polymer-dev/status.png "Polymer build status")](http://build.chromium.org/p/client.polymer/waterfall)
## Brief Overview
For more detailed info goto [http://polymer-project.org/](http://polymer-project.org/).
Polymer is a new type of library for the web, designed to leverage the existing browser infrastructure to provide the encapsulation and extendability currently only available in JS libraries.
Polymer is based on a set of future technologies, including [Shadow DOM](http://w3c.github.io/webcomponents/spec/shadow/), [Custom Elements](http://w3c.github.io/webcomponents/spec/custom/) and Model Driven Views. Currently these technologies are implemented as polyfills or shims, but as browsers adopt these features natively, the platform code that drives Polymer evacipates, leaving only the value-adds.
## Tools & Testing
For running tests or building minified files, consult the [tooling information](https://www.polymer-project.org/resources/tooling-strategy.html).
## Releases
[Release (tagged) versions](https://github.com/Polymer/polymer/releases) of Polymer include concatenated and minified sources for your convenience.
[![Analytics](https://ga-beacon.appspot.com/UA-39334307-2/Polymer/polymer/README)](https://github.com/igrigorik/ga-beacon)
{
"name": "polymer",
"description": "Polymer is a new type of library for the web, built on top of Web Components, and designed to leverage the evolving web platform on modern browsers.",
"homepage": "http://www.polymer-project.org/",
"keywords": [
"util",
"client",
"browser",
"web components",
"web-components"
],
"author": "Polymer Authors <polymer-dev@googlegroups.com>",
"private": true,
"dependencies": {
"core-component-page": "Polymer/core-component-page#^0.5.0",
"webcomponentsjs": "Polymer/webcomponentsjs#^0.5.0"
},
"devDependencies": {
"tools": "Polymer/tools#master",
"web-component-tester": "Polymer/web-component-tester#^1.4.2"
},
"version": "0.5.2"
}
\ No newline at end of file
BUILD LOG
---------
Build Time: 2014-12-11T12:46:30
NODEJS INFORMATION
==================
nodejs: v0.10.33
grunt: 0.4.5
grunt-audit: 1.0.0
grunt-contrib-concat: 0.5.0
grunt-contrib-copy: 0.7.0
grunt-contrib-uglify: 0.6.0
grunt-string-replace: 1.0.0
REPO REVISIONS
==============
polymer-expressions: 197c3a0150e7a13374cfcc72e7066113723a623d
polymer-gestures: 17a6304916521be39409af292e8adf899bae0ce7
polymer: a74e9f36526361dccb6df91be439ff9c3e043f41
BUILD HASHES
============
dist/polymer.js: b9ad4c86af79c748cf4ea722f6d56671079fadf7
dist/polymer.min.js: 2f2021ba9682b0bb702ee7fb68fb6fbfd288eac2
dist/layout.html: 348d358a91712ecc2f8811efa430fcd954b4590c
\ No newline at end of file
<!--
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
-->
<style shim-shadowdom>
/*******************************
Flex Layout
*******************************/
html /deep/ [layout][horizontal], html /deep/ [layout][vertical] {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
html /deep/ [layout][horizontal][inline], html /deep/ [layout][vertical][inline] {
display: -ms-inline-flexbox;
display: -webkit-inline-flex;
display: inline-flex;
}
html /deep/ [layout][horizontal] {
-ms-flex-direction: row;
-webkit-flex-direction: row;
flex-direction: row;
}
html /deep/ [layout][horizontal][reverse] {
-ms-flex-direction: row-reverse;
-webkit-flex-direction: row-reverse;
flex-direction: row-reverse;
}
html /deep/ [layout][vertical] {
-ms-flex-direction: column;
-webkit-flex-direction: column;
flex-direction: column;
}
html /deep/ [layout][vertical][reverse] {
-ms-flex-direction: column-reverse;
-webkit-flex-direction: column-reverse;
flex-direction: column-reverse;
}
html /deep/ [layout][wrap] {
-ms-flex-wrap: wrap;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
html /deep/ [layout][wrap-reverse] {
-ms-flex-wrap: wrap-reverse;
-webkit-flex-wrap: wrap-reverse;
flex-wrap: wrap-reverse;
}
html /deep/ [flex] {
-ms-flex: 1 1 0.000000001px;
-webkit-flex: 1;
flex: 1;
-webkit-flex-basis: 0.000000001px;
flex-basis: 0.000000001px;
}
html /deep/ [vertical][layout] > [flex][auto-vertical], html /deep/ [vertical][layout]::shadow [flex][auto-vertical] {
-ms-flex: 1 1 auto;
-webkit-flex-basis: auto;
flex-basis: auto;
}
html /deep/ [flex][auto] {
-ms-flex: 1 1 auto;
-webkit-flex-basis: auto;
flex-basis: auto;
}
html /deep/ [flex][none] {
-ms-flex: none;
-webkit-flex: none;
flex: none;
}
html /deep/ [flex][one] {
-ms-flex: 1;
-webkit-flex: 1;
flex: 1;
}
html /deep/ [flex][two] {
-ms-flex: 2;
-webkit-flex: 2;
flex: 2;
}
html /deep/ [flex][three] {
-ms-flex: 3;
-webkit-flex: 3;
flex: 3;
}
html /deep/ [flex][four] {
-ms-flex: 4;
-webkit-flex: 4;
flex: 4;
}
html /deep/ [flex][five] {
-ms-flex: 5;
-webkit-flex: 5;
flex: 5;
}
html /deep/ [flex][six] {
-ms-flex: 6;
-webkit-flex: 6;
flex: 6;
}
html /deep/ [flex][seven] {
-ms-flex: 7;
-webkit-flex: 7;
flex: 7;
}
html /deep/ [flex][eight] {
-ms-flex: 8;
-webkit-flex: 8;
flex: 8;
}
html /deep/ [flex][nine] {
-ms-flex: 9;
-webkit-flex: 9;
flex: 9;
}
html /deep/ [flex][ten] {
-ms-flex: 10;
-webkit-flex: 10;
flex: 10;
}
html /deep/ [flex][eleven] {
-ms-flex: 11;
-webkit-flex: 11;
flex: 11;
}
html /deep/ [flex][twelve] {
-ms-flex: 12;
-webkit-flex: 12;
flex: 12;
}
/* alignment in cross axis */
html /deep/ [layout][start] {
-ms-flex-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
}
html /deep/ [layout][center], html /deep/ [layout][center-center] {
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
html /deep/ [layout][end] {
-ms-flex-align: end;
-webkit-align-items: flex-end;
align-items: flex-end;
}
/* alignment in main axis */
html /deep/ [layout][start-justified] {
-ms-flex-pack: start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
}
html /deep/ [layout][center-justified], html /deep/ [layout][center-center] {
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
html /deep/ [layout][end-justified] {
-ms-flex-pack: end;
-webkit-justify-content: flex-end;
justify-content: flex-end;
}
html /deep/ [layout][around-justified] {
-ms-flex-pack: distribute;
-webkit-justify-content: space-around;
justify-content: space-around;
}
html /deep/ [layout][justified] {
-ms-flex-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
}
/* self alignment */
html /deep/ [self-start] {
-ms-align-self: flex-start;
-webkit-align-self: flex-start;
align-self: flex-start;
}
html /deep/ [self-center] {
-ms-align-self: center;
-webkit-align-self: center;
align-self: center;
}
html /deep/ [self-end] {
-ms-align-self: flex-end;
-webkit-align-self: flex-end;
align-self: flex-end;
}
html /deep/ [self-stretch] {
-ms-align-self: stretch;
-webkit-align-self: stretch;
align-self: stretch;
}
/*******************************
Other Layout
*******************************/
html /deep/ [block] {
display: block;
}
/* ie support for hidden */
html /deep/ [hidden] {
display: none !important;
}
html /deep/ [relative] {
position: relative;
}
html /deep/ [fit] {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
body[fullbleed] {
margin: 0;
height: 100vh;
}
/*******************************
Other
*******************************/
html /deep/ [segment], html /deep/ segment {
display: block;
position: relative;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
margin: 1em 0.5em;
padding: 1em;
background-color: white;
-webkit-box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.1);
border-radius: 5px 5px 5px 5px;
}
</style>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "todomvc-common",
"description": "Common TodoMVC utilities used by our apps",
"license": "MIT",
"authors": [
"TasteJS team"
],
"main": [
"base.js",
"base.css"
],
"keywords": [
"todomvc",
"tastejs",
"util",
"utilities"
],
"ignore": [
"package.json",
"readme.md"
],
"homepage": "https://github.com/tastejs/todomvc-common",
"version": "0.3.1",
"_release": "0.3.1",
"_resolution": {
"type": "version",
"tag": "v0.3.1",
"commit": "c9c45cb1af95121686d71ae5f1e6c3a8d3ea7ddb"
},
"_source": "git://github.com/tastejs/todomvc-common.git",
"_target": "~0.3.0",
"_originalSource": "todomvc-common"
}
\ No newline at end of file
/* global _ */
(function () {
'use strict';
/* jshint ignore:start */
// Underscore's Template Module
// Courtesy of underscorejs.org
var _ = (function (_) {
......@@ -112,8 +114,14 @@
})({});
if (location.hostname === 'todomvc.com') {
window._gaq = [['_setAccount','UA-31081062-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'));
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-31081062-1', 'auto');
ga('send', 'pageview');
}
/* jshint ignore:end */
function redirect() {
if (location.hostname === 'tastejs.github.io') {
......@@ -175,13 +183,17 @@
if (learnJSON.backend) {
this.frameworkJSON = learnJSON.backend;
this.frameworkJSON.issueLabel = framework;
this.append({
backend: true
});
} else if (learnJSON[framework]) {
this.frameworkJSON = learnJSON[framework];
this.frameworkJSON.issueLabel = framework;
this.append();
}
this.fetchIssueCount();
}
Learn.prototype.append = function (opts) {
......@@ -212,6 +224,26 @@
document.body.insertAdjacentHTML('afterBegin', aside.outerHTML);
};
Learn.prototype.fetchIssueCount = function () {
var issueLink = document.getElementById('issue-count-link');
if (issueLink) {
var url = issueLink.href.replace('https://github.com', 'https://api.github.com/repos');
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function (e) {
var parsedResponse = JSON.parse(e.target.responseText);
if (parsedResponse instanceof Array) {
var count = parsedResponse.length;
if (count !== 0) {
issueLink.innerHTML = 'This app has ' + count + ' open issues';
document.getElementById('issue-count').style.display = 'inline';
}
}
};
xhr.send();
}
};
redirect();
getFile('learn.json', Learn);
})();
{
"name": "todomvc-common",
"description": "Common TodoMVC utilities used by our apps",
"license": "MIT",
"authors": [
"TasteJS team"
],
"main": [
"base.js",
"base.css"
],
"keywords": [
"todomvc",
"tastejs",
"util",
"utilities"
],
"ignore": [
"package.json",
"readme.md"
]
}
{
"name": "webcomponentsjs",
"main": "webcomponents.js",
"version": "0.5.2",
"homepage": "http://webcomponents.org",
"authors": [
"The Polymer Authors"
],
"keywords": [
"webcomponents"
],
"license": "BSD",
"ignore": [],
"_release": "0.5.2",
"_resolution": {
"type": "version",
"tag": "0.5.2",
"commit": "4f469f65d3fa3c03a44326d138331003fa340337"
},
"_source": "git://github.com/Polymer/webcomponentsjs.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/webcomponentsjs"
}
\ No newline at end of file
{
"name": "webcomponentsjs",
"main": "webcomponents.js",
"version": "0.5.2",
"homepage": "http://webcomponents.org",
"authors": [
"The Polymer Authors"
],
"keywords": [
"webcomponents"
],
"license": "BSD",
"ignore": []
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -10,8 +10,6 @@ var excludedFrameworks = [
// this implementation deviates from the specification to such an extent that they are
// not worth testing via a generic mechanism
'gwt',
// selenium webdriver cannot see the shadow dom
'polymer',
// these implementations cannot be run offline, because they are hosted
'firebase-angular', 'meteor', 'socketstream',
// YUI is a special case here, it is not hosted, but fetches JS files dynamically
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment