Commit 174bbc42 authored by Addy Osmani's avatar Addy Osmani

Updating Polymer app implementation

parent 019057d0
# Contributing
Want to contribute to Polymer? Great!
We are more than happy to accept external contributions to the project in the form of [feedback](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev), [bug reports](../../issues), and pull requests.
## Contributor License Agreement
Before we can accept patches, there's a quick web form you need to fill out.
- If you're contributing as and individual (e.g. you own the intellectual property), fill out [this form](http://code.google.com/legal/individual-cla-v1.0.html).
- If you're contributing under a company, fill out [this form](http://code.google.com/legal/corporate-cla-v1.0.html) instead.
This CLA asserts that contributions are owned by you and that we can license all work under our [license](LICENSE).
Other projects require a similar agreement: jQuery, Firefox, Apache, Node, and many more.
[More about CLAs](https://www.google.com/search?q=Contributor%20License%20Agreement)
## Initial setup
Here's an easy guide that should get you up and running:
1. Fork the project on github and pull down your copy.
> replace the {{ username }} with your username and {{ repository }} with the repository name
git clone git@github.com:{{ username }}/{{ repository }}.git --recursive
Note the `--recursive`. This is necessary for submodules to initialize properly. If you don't do a recursive clone, you'll have to init them manually:
git submodule init
git submodule update
2. Development happens on the `master` branch. Get yourself on it!
git checkout master
That's it for the one time setup. Now you're ready to make a change.
## Submitting a pull request
We iterate fast! To avoid potential merge conflicts, it's a good idea to pull from the main project before making a change and submitting a pull request. The easiest way to do this is setup a remote called `upstream` and do a pull before working on a change:
git remote add upstream git://github.com/Polymer/{{ repository }}.git
Then before making a change, do a pull from the upstream `master` branch:
git pull upstream master
To make life easier, add a "pull upstream" alias in your `.gitconfig`:
[alias]
pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
That will pull in changes from your forked repo, the main (upstream) repo, and merge the two. Then it's just a matter of running `git pu` before a change and pushing to your repo:
git checkout master
git pu
# make change
git commit -a -m 'Awesome things.'
git push
Lastly, don't forget to submit the pull request.
See https://github.com/Polymer/polymer/blob/master/CONTRIBUTING.md
......@@ -10,9 +10,9 @@ The [Polymer website](http://www.polymer-project.org) is a great resource for ge
Here are some links you may find helpful:
* [Getting Started](http://www.polymer-project.org/getting-started.html)
* [FAQ](http://www.polymer-project.org/faq.html)
* [Browser Compatibility](http://www.polymer-project.org/compatibility.html)
* [Getting Started](http://www.polymer-project.org/docs/start/everything.html)
* [FAQ](http://www.polymer-project.org/resources/faq.html)
* [Browser Compatibility](http://www.polymer-project.org/resources/compatibility.html)
Get help from Polymer devs and users:
......@@ -23,13 +23,13 @@ Get help from Polymer devs and users:
The Polymer implementation of TodoMVC has a few key differences with other implementations:
* Since [Web Components](https://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html) allow you to create new types of DOM elements, the DOM tree is very different from other implementations.
* Since [Web Components](http://w3c.github.io/webcomponents/explainer/) allow you to create new types of DOM elements, the DOM tree is very different from other implementations.
* The template, styling, and behavior are fully encapsulated in each custom element. Instead of having an overall stylesheet (`base.css` or `app.css`), each element that needs styling has its own stylesheet.
* Non-visual elements such as the router and the model are also implemented as custom elements and appear in the DOM. Implementing them as custom elements instead of plain objects allows you to take advantage of Polymer data binding and event handling throughout the app.
## Compatibility
Polymer and its polyfills are intended to work in the latest version of [evergreen browsers](http://tomdale.net/2013/05/evergreen-browsers/). IE9 is not supported. Please refer to [Browser Compatibility](http://www.polymer-project.org/compatibility.html) for more details.
Polymer and its polyfills are intended to work in the latest version of [evergreen browsers](http://tomdale.net/2013/05/evergreen-browsers/). IE9 is not supported. Please refer to [Browser Compatibility](http://www.polymer-project.org/resources/compatibility.html) for more details.
## Running this sample
......
......@@ -9,7 +9,7 @@ body {
body {
font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif;
line-height: 1.4em;
background: #eaeaea url('../bower_components/todomvc-common/bg.png');
background: #eaeaea url('../components/todomvc-common/bg.png');
color: #4d4d4d;
width: 550px;
margin: 0 auto;
......
{
"name": "todomvc-polymer",
"version": "0.0.0",
"dependencies": {
"todomvc-common": "~0.1.4",
"director": "*",
"polymer": "*"
}
"name": "todomvc-template",
"version": "0.0.0",
"dependencies": {
"todomvc-common": "~0.1.4",
"polymer-selector": "Polymer/polymer-selector",
"flatiron-director": "Polymer/flatiron-director",
"polymer-localstorage": "Polymer/polymer-localstorage"
}
}
//
// Generated on Sun Dec 16 2012 22:47:05 GMT-0500 (EST) by Nodejitsu, Inc (Using Codesurgeon).
// Version 1.1.9
//
(function(a){function k(a,b,c,d){var e=0,f=0,g=0,c=(c||"(").toString(),d=(d||")").toString(),h;for(h=0;h<a.length;h++){var i=a[h];if(i.indexOf(c,e)>i.indexOf(d,e)||~i.indexOf(c,e)&&!~i.indexOf(d,e)||!~i.indexOf(c,e)&&~i.indexOf(d,e)){f=i.indexOf(c,e),g=i.indexOf(d,e);if(~f&&!~g||!~f&&~g){var j=a.slice(0,(h||1)+1).join(b);a=[j].concat(a.slice((h||1)+1))}e=(g>f?g:f)+1,h=0}else e=0}return a}function j(a,b){var c,d=0,e="";while(c=a.substr(d).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/))d=c.index+c[0].length,c[0]=c[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),e+=a.substr(0,c.index)+c[0];a=e+=a.substr(d);var f=a.match(/:([^\/]+)/ig),g;if(f){g=f.length;for(var h=0;h<g;h++)a=a.replace(f[h],i(f[h],b))}return a}function i(a,b,c){c=a;for(var d in b)if(b.hasOwnProperty(d)){c=b[d](a);if(c!==a)break}return c===a?"([._a-zA-Z0-9-]+)":c}function h(a,b,c){if(!a.length)return c();var d=0;(function e(){b(a[d],function(b){b||b===!1?(c(b),c=function(){}):(d+=1,d===a.length?c():e())})})()}function g(a){var b=[];for(var c=0,d=a.length;c<d;c++)b=b.concat(a[c]);return b}function f(a,b){for(var c=0;c<a.length;c+=1)if(b(a[c],c,a)===!1)return}function c(){return b.hash===""||b.hash==="#"}Array.prototype.filter||(Array.prototype.filter=function(a,b){var c=[],d;for(var e=0,f=this.length;e<f;e++)e in this&&a.call(b,d=this[e],e,this)&&c.push(d);return c}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"});var b=document.location,d={mode:"modern",hash:b.hash,history:!1,check:function(){var a=b.hash;a!=this.hash&&(this.hash=a,this.onHashChanged())},fire:function(){this.mode==="modern"?this.history===!0?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(a,b){function d(a){for(var b=0,c=e.listeners.length;b<c;b++)e.listeners[b](a)}var c=this;this.history=b,e.listeners||(e.listeners=[]);if("onhashchange"in window&&(document.documentMode===undefined||document.documentMode>7))this.history===!0?setTimeout(function(){window.onpopstate=d},500):window.onhashchange=d,this.mode="modern";else{var f=document.createElement("iframe");f.id="state-frame",f.style.display="none",document.body.appendChild(f),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){event.propertyName==="location"&&c.check()}),window.setInterval(function(){c.check()},50),this.onHashChanged=d,this.mode="legacy"}e.listeners.push(a);return this.mode},destroy:function(a){if(!!e&&!!e.listeners){var b=e.listeners;for(var c=b.length-1;c>=0;c--)b[c]===a&&b.splice(c,1)}},setHash:function(a){this.mode==="legacy"&&this.writeFrame(a),this.history===!0?(window.history.pushState({},document.title,a),this.fire()):b.hash=a[0]==="/"?a:"/"+a;return this},writeFrame:function(a){var b=document.getElementById("state-frame"),c=b.contentDocument||b.contentWindow.document;c.open(),c.write("<script>_hash = '"+a+"'; onload = parent.listener.syncHash;<script>"),c.close()},syncHash:function(){var a=this._hash;a!=b.hash&&(b.hash=a);return this},onHashChanged:function(){}},e=a.Router=function(a){if(this instanceof e)this.params={},this.routes={},this.methods=["on","once","after","before"],this.scope=[],this._methods={},this._insert=this.insert,this.insert=this.insertEx,this.historySupport=(window.history!=null?window.history.pushState:null)!=null,this.configure(),this.mount(a||{});else return new e(a)};e.prototype.init=function(a){var e=this;this.handler=function(a){var b=a&&a.newURL||window.location.hash,c=e.history===!0?e.getPath():b.replace(/.*#/,"");e.dispatch("on",c)},d.init(this.handler,this.history);if(this.history===!1)c()&&a?b.hash=a:c()||e.dispatch("on",b.hash.replace(/^#/,""));else{var f=c()&&a?a:c()?null:b.hash.replace(/^#/,"");f&&window.history.replaceState({},document.title,f),(f||this.run_in_init===!0)&&this.handler()}return this},e.prototype.explode=function(){var a=this.history===!0?this.getPath():b.hash;a.charAt(1)==="/"&&(a=a.slice(1));return a.slice(1,a.length).split("/")},e.prototype.setRoute=function(a,b,c){var e=this.explode();typeof a=="number"&&typeof b=="string"?e[a]=b:typeof c=="string"?e.splice(a,b,s):e=[a],d.setHash(e.join("/"));return e},e.prototype.insertEx=function(a,b,c,d){a==="once"&&(a="on",c=function(a){var b=!1;return function(){if(!b){b=!0;return a.apply(this,arguments)}}}(c));return this._insert(a,b,c,d)},e.prototype.getRoute=function(a){var b=a;if(typeof a=="number")b=this.explode()[a];else if(typeof a=="string"){var c=this.explode();b=c.indexOf(a)}else b=this.explode();return b},e.prototype.destroy=function(){d.destroy(this.handler);return this},e.prototype.getPath=function(){var a=window.location.pathname;a.substr(0,1)!=="/"&&(a="/"+a);return a},e.prototype.configure=function(a){a=a||{};for(var b=0;b<this.methods.length;b++)this._methods[this.methods[b]]=!0;this.recurse=a.recurse||this.recurse||!1,this.async=a.async||!1,this.delimiter=a.delimiter||"/",this.strict=typeof a.strict=="undefined"?!0:a.strict,this.notfound=a.notfound,this.resource=a.resource,this.history=a.html5history&&this.historySupport||!1,this.run_in_init=this.history===!0&&a.run_handler_in_init!==!1,this.every={after:a.after||null,before:a.before||null,on:a.on||null};return this},e.prototype.param=function(a,b){a[0]!==":"&&(a=":"+a);var c=new RegExp(a,"g");this.params[a]=function(a){return a.replace(c,b.source||b)}},e.prototype.on=e.prototype.route=function(a,b,c){var d=this;!c&&typeof b=="function"&&(c=b,b=a,a="on");if(Array.isArray(b))return b.forEach(function(b){d.on(a,b,c)});b.source&&(b=b.source.replace(/\\\//ig,"/"));if(Array.isArray(a))return a.forEach(function(a){d.on(a.toLowerCase(),b,c)});b=b.split(new RegExp(this.delimiter)),b=k(b,this.delimiter),this.insert(a,this.scope.concat(b),c)},e.prototype.dispatch=function(a,b,c){function h(){d.last=e.after,d.invoke(d.runlist(e),d,c)}var d=this,e=this.traverse(a,b,this.routes,""),f=this._invoked,g;this._invoked=!0;if(!e||e.length===0){this.last=[],typeof this.notfound=="function"&&this.invoke([this.notfound],{method:a,path:b},c);return!1}this.recurse==="forward"&&(e=e.reverse()),g=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last];if(g&&g.length>0&&f){this.async?this.invoke(g,this,h):(this.invoke(g,this),h());return!0}h();return!0},e.prototype.invoke=function(a,b,c){var d=this;this.async?h(a,function e(c,d){if(Array.isArray(c))return h(c,e,d);typeof c=="function"&&c.apply(b,a.captures.concat(d))},function(){c&&c.apply(b,arguments)}):f(a,function g(c){if(Array.isArray(c))return f(c,g);if(typeof c=="function")return c.apply(b,a.captures||[]);typeof c=="string"&&d.resource&&d.resource[c].apply(b,a.captures||[])})},e.prototype.traverse=function(a,b,c,d,e){function l(a){function c(a){for(var b=a.length-1;b>=0;b--)Array.isArray(a[b])?(c(a[b]),a[b].length===0&&a.splice(b,1)):e(a[b])||a.splice(b,1)}function b(a){var c=[];for(var d=0;d<a.length;d++)c[d]=Array.isArray(a[d])?b(a[d]):a[d];return c}if(!e)return a;var d=b(a);d.matched=a.matched,d.captures=a.captures,d.after=a.after.filter(e),c(d);return d}var f=[],g,h,i,j,k;if(b===this.delimiter&&c[a]){j=[[c.before,c[a]].filter(Boolean)],j.after=[c.after].filter(Boolean),j.matched=!0,j.captures=[];return l(j)}for(var m in c)if(c.hasOwnProperty(m)&&(!this._methods[m]||this._methods[m]&&typeof c[m]=="object"&&!Array.isArray(c[m]))){g=h=d+this.delimiter+m,this.strict||(h+="["+this.delimiter+"]?"),i=b.match(new RegExp("^"+h));if(!i)continue;if(i[0]&&i[0]==b&&c[m][a]){j=[[c[m].before,c[m][a]].filter(Boolean)],j.after=[c[m].after].filter(Boolean),j.matched=!0,j.captures=i.slice(1),this.recurse&&c===this.routes&&(j.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)));return l(j)}j=this.traverse(a,b,c[m],g);if(j.matched){j.length>0&&(f=f.concat(j)),this.recurse&&(f.push([c[m].before,c[m].on].filter(Boolean)),j.after=j.after.concat([c[m].after].filter(Boolean)),c===this.routes&&(f.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)))),f.matched=!0,f.captures=j.captures,f.after=j.after;return l(f)}}return!1},e.prototype.insert=function(a,b,c,d){var e,f,g,h,i;b=b.filter(function(a){return a&&a.length>0}),d=d||this.routes,i=b.shift(),/\:|\*/.test(i)&&!/\\d|\\w/.test(i)&&(i=j(i,this.params));if(b.length>0){d[i]=d[i]||{};return this.insert(a,b,c,d[i])}{if(!!i||!!b.length||d!==this.routes){f=typeof d[i],g=Array.isArray(d[i]);if(d[i]&&!g&&f=="object"){e=typeof d[i][a];switch(e){case"function":d[i][a]=[d[i][a],c];return;case"object":d[i][a].push(c);return;case"undefined":d[i][a]=c;return}}else if(f=="undefined"){h={},h[a]=c,d[i]=h;return}throw new Error("Invalid route context: "+f)}e=typeof d[a];switch(e){case"function":d[a]=[d[a],c];return;case"object":d[a].push(c);return;case"undefined":d[a]=c;return}}},e.prototype.extend=function(a){function e(a){b._methods[a]=!0,b[a]=function(){var c=arguments.length===1?[a,""]:[a];b.on.apply(b,c.concat(Array.prototype.slice.call(arguments)))}}var b=this,c=a.length,d;for(d=0;d<c;d++)e(a[d])},e.prototype.runlist=function(a){var b=this.every&&this.every.before?[this.every.before].concat(g(a)):g(a);this.every&&this.every.on&&b.push(this.every.on),b.captures=a.captures,b.source=a.source;return b},e.prototype.mount=function(a,b){function d(b,d){var e=b,f=b.split(c.delimiter),g=typeof a[b],h=f[0]===""||!c._methods[f[0]],i=h?"on":e;h&&(e=e.slice((e.match(new RegExp(c.delimiter))||[""])[0].length),f.shift());h&&g==="object"&&!Array.isArray(a[b])?(d=d.concat(f),c.mount(a[b],d)):(h&&(d=d.concat(e.split(c.delimiter)),d=k(d,c.delimiter)),c.insert(i,d,a[b]))}if(!!a&&typeof a=="object"&&!Array.isArray(a)){var c=this;b=b||[],Array.isArray(b)||(b=b.split(c.delimiter));for(var e in a)a.hasOwnProperty(e)&&d(e,b.slice(0))}}})(typeof exports=="object"?exports:window)
\ No newline at end of file
{
"name": "flatiron-director",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#0.2.1"
},
"version": "0.2.1",
"homepage": "https://github.com/Polymer/flatiron-director",
"_release": "0.2.1",
"_resolution": {
"type": "version",
"tag": "0.2.1",
"commit": "d01427ec016607908f939aad6b7ab4164b355a73"
},
"_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.2.1"
},
"version": "0.2.1"
}
\ 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="../platform/platform.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
//
// Generated on Fri Dec 27 2013 12:02:11 GMT-0500 (EST) by Nodejitsu, Inc (Using Codesurgeon).
// Version 1.2.2
//
(function(a){function k(a,b,c,d){var e=0,f=0,g=0,c=(c||"(").toString(),d=(d||")").toString(),h;for(h=0;h<a.length;h++){var i=a[h];if(i.indexOf(c,e)>i.indexOf(d,e)||~i.indexOf(c,e)&&!~i.indexOf(d,e)||!~i.indexOf(c,e)&&~i.indexOf(d,e)){f=i.indexOf(c,e),g=i.indexOf(d,e);if(~f&&!~g||!~f&&~g){var j=a.slice(0,(h||1)+1).join(b);a=[j].concat(a.slice((h||1)+1))}e=(g>f?g:f)+1,h=0}else e=0}return a}function j(a,b){var c,d=0,e="";while(c=a.substr(d).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/))d=c.index+c[0].length,c[0]=c[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),e+=a.substr(0,c.index)+c[0];a=e+=a.substr(d);var f=a.match(/:([^\/]+)/ig),g,h;if(f){h=f.length;for(var j=0;j<h;j++)g=f[j],g.slice(0,2)==="::"?a=g.slice(1):a=a.replace(g,i(g,b))}return a}function i(a,b,c){c=a;for(var d in b)if(b.hasOwnProperty(d)){c=b[d](a);if(c!==a)break}return c===a?"([._a-zA-Z0-9-]+)":c}function h(a,b,c){if(!a.length)return c();var d=0;(function e(){b(a[d],function(b){b||b===!1?(c(b),c=function(){}):(d+=1,d===a.length?c():e())})})()}function g(a){var b=[];for(var c=0,d=a.length;c<d;c++)b=b.concat(a[c]);return b}function f(a,b){for(var c=0;c<a.length;c+=1)if(b(a[c],c,a)===!1)return}function c(){return b.hash===""||b.hash==="#"}Array.prototype.filter||(Array.prototype.filter=function(a,b){var c=[],d;for(var e=0,f=this.length;e<f;e++)e in this&&a.call(b,d=this[e],e,this)&&c.push(d);return c}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"});var b=document.location,d={mode:"modern",hash:b.hash,history:!1,check:function(){var a=b.hash;a!=this.hash&&(this.hash=a,this.onHashChanged())},fire:function(){this.mode==="modern"?this.history===!0?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(a,b){function d(a){for(var b=0,c=e.listeners.length;b<c;b++)e.listeners[b](a)}var c=this;this.history=b,e.listeners||(e.listeners=[]);if("onhashchange"in window&&(document.documentMode===undefined||document.documentMode>7))this.history===!0?setTimeout(function(){window.onpopstate=d},500):window.onhashchange=d,this.mode="modern";else{var f=document.createElement("iframe");f.id="state-frame",f.style.display="none",document.body.appendChild(f),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){event.propertyName==="location"&&c.check()}),window.setInterval(function(){c.check()},50),this.onHashChanged=d,this.mode="legacy"}e.listeners.push(a);return this.mode},destroy:function(a){if(!!e&&!!e.listeners){var b=e.listeners;for(var c=b.length-1;c>=0;c--)b[c]===a&&b.splice(c,1)}},setHash:function(a){this.mode==="legacy"&&this.writeFrame(a),this.history===!0?(window.history.pushState({},document.title,a),this.fire()):b.hash=a[0]==="/"?a:"/"+a;return this},writeFrame:function(a){var b=document.getElementById("state-frame"),c=b.contentDocument||b.contentWindow.document;c.open(),c.write("<script>_hash = '"+a+"'; onload = parent.listener.syncHash;<script>"),c.close()},syncHash:function(){var a=this._hash;a!=b.hash&&(b.hash=a);return this},onHashChanged:function(){}},e=a.Router=function(a){if(this instanceof e)this.params={},this.routes={},this.methods=["on","once","after","before"],this.scope=[],this._methods={},this._insert=this.insert,this.insert=this.insertEx,this.historySupport=(window.history!=null?window.history.pushState:null)!=null,this.configure(),this.mount(a||{});else return new e(a)};e.prototype.init=function(a){var e=this;this.handler=function(a){var b=a&&a.newURL||window.location.hash,c=e.history===!0?e.getPath():b.replace(/.*#/,"");e.dispatch("on",c.charAt(0)==="/"?c:"/"+c)},d.init(this.handler,this.history);if(this.history===!1)c()&&a?b.hash=a:c()||e.dispatch("on","/"+b.hash.replace(/^(#\/|#|\/)/,""));else{var f=c()&&a?a:c()?null:b.hash.replace(/^#/,"");f&&window.history.replaceState({},document.title,f),(f||this.run_in_init===!0)&&this.handler()}return this},e.prototype.explode=function(){var a=this.history===!0?this.getPath():b.hash;a.charAt(1)==="/"&&(a=a.slice(1));return a.slice(1,a.length).split("/")},e.prototype.setRoute=function(a,b,c){var e=this.explode();typeof a=="number"&&typeof b=="string"?e[a]=b:typeof c=="string"?e.splice(a,b,s):e=[a],d.setHash(e.join("/"));return e},e.prototype.insertEx=function(a,b,c,d){a==="once"&&(a="on",c=function(a){var b=!1;return function(){if(!b){b=!0;return a.apply(this,arguments)}}}(c));return this._insert(a,b,c,d)},e.prototype.getRoute=function(a){var b=a;if(typeof a=="number")b=this.explode()[a];else if(typeof a=="string"){var c=this.explode();b=c.indexOf(a)}else b=this.explode();return b},e.prototype.destroy=function(){d.destroy(this.handler);return this},e.prototype.getPath=function(){var a=window.location.pathname;a.substr(0,1)!=="/"&&(a="/"+a);return a},e.prototype.configure=function(a){a=a||{};for(var b=0;b<this.methods.length;b++)this._methods[this.methods[b]]=!0;this.recurse=a.recurse||this.recurse||!1,this.async=a.async||!1,this.delimiter=a.delimiter||"/",this.strict=typeof a.strict=="undefined"?!0:a.strict,this.notfound=a.notfound,this.resource=a.resource,this.history=a.html5history&&this.historySupport||!1,this.run_in_init=this.history===!0&&a.run_handler_in_init!==!1,this.every={after:a.after||null,before:a.before||null,on:a.on||null};return this},e.prototype.param=function(a,b){a[0]!==":"&&(a=":"+a);var c=new RegExp(a,"g");this.params[a]=function(a){return a.replace(c,b.source||b)}},e.prototype.on=e.prototype.route=function(a,b,c){var d=this;!c&&typeof b=="function"&&(c=b,b=a,a="on");if(Array.isArray(b))return b.forEach(function(b){d.on(a,b,c)});b.source&&(b=b.source.replace(/\\\//ig,"/"));if(Array.isArray(a))return a.forEach(function(a){d.on(a.toLowerCase(),b,c)});b=b.split(new RegExp(this.delimiter)),b=k(b,this.delimiter),this.insert(a,this.scope.concat(b),c)},e.prototype.dispatch=function(a,b,c){function h(){d.last=e.after,d.invoke(d.runlist(e),d,c)}var d=this,e=this.traverse(a,b,this.routes,""),f=this._invoked,g;this._invoked=!0;if(!e||e.length===0){this.last=[],typeof this.notfound=="function"&&this.invoke([this.notfound],{method:a,path:b},c);return!1}this.recurse==="forward"&&(e=e.reverse()),g=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last];if(g&&g.length>0&&f){this.async?this.invoke(g,this,h):(this.invoke(g,this),h());return!0}h();return!0},e.prototype.invoke=function(a,b,c){var d=this,e;this.async?(e=function(c,d){if(Array.isArray(c))return h(c,e,d);typeof c=="function"&&c.apply(b,a.captures.concat(d))},h(a,e,function(){c&&c.apply(b,arguments)})):(e=function(c){if(Array.isArray(c))return f(c,e);if(typeof c=="function")return c.apply(b,a.captures||[]);typeof c=="string"&&d.resource&&d.resource[c].apply(b,a.captures||[])},f(a,e))},e.prototype.traverse=function(a,b,c,d,e){function l(a){function c(a){for(var b=a.length-1;b>=0;b--)Array.isArray(a[b])?(c(a[b]),a[b].length===0&&a.splice(b,1)):e(a[b])||a.splice(b,1)}function b(a){var c=[];for(var d=0;d<a.length;d++)c[d]=Array.isArray(a[d])?b(a[d]):a[d];return c}if(!e)return a;var d=b(a);d.matched=a.matched,d.captures=a.captures,d.after=a.after.filter(e),c(d);return d}var f=[],g,h,i,j,k;if(b===this.delimiter&&c[a]){j=[[c.before,c[a]].filter(Boolean)],j.after=[c.after].filter(Boolean),j.matched=!0,j.captures=[];return l(j)}for(var m in c)if(c.hasOwnProperty(m)&&(!this._methods[m]||this._methods[m]&&typeof c[m]=="object"&&!Array.isArray(c[m]))){g=h=d+this.delimiter+m,this.strict||(h+="["+this.delimiter+"]?"),i=b.match(new RegExp("^"+h));if(!i)continue;if(i[0]&&i[0]==b&&c[m][a]){j=[[c[m].before,c[m][a]].filter(Boolean)],j.after=[c[m].after].filter(Boolean),j.matched=!0,j.captures=i.slice(1),this.recurse&&c===this.routes&&(j.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)));return l(j)}j=this.traverse(a,b,c[m],g);if(j.matched){j.length>0&&(f=f.concat(j)),this.recurse&&(f.push([c[m].before,c[m].on].filter(Boolean)),j.after=j.after.concat([c[m].after].filter(Boolean)),c===this.routes&&(f.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)))),f.matched=!0,f.captures=j.captures,f.after=j.after;return l(f)}}return!1},e.prototype.insert=function(a,b,c,d){var e,f,g,h,i;b=b.filter(function(a){return a&&a.length>0}),d=d||this.routes,i=b.shift(),/\:|\*/.test(i)&&!/\\d|\\w/.test(i)&&(i=j(i,this.params));if(b.length>0){d[i]=d[i]||{};return this.insert(a,b,c,d[i])}{if(!!i||!!b.length||d!==this.routes){f=typeof d[i],g=Array.isArray(d[i]);if(d[i]&&!g&&f=="object"){e=typeof d[i][a];switch(e){case"function":d[i][a]=[d[i][a],c];return;case"object":d[i][a].push(c);return;case"undefined":d[i][a]=c;return}}else if(f=="undefined"){h={},h[a]=c,d[i]=h;return}throw new Error("Invalid route context: "+f)}e=typeof d[a];switch(e){case"function":d[a]=[d[a],c];return;case"object":d[a].push(c);return;case"undefined":d[a]=c;return}}},e.prototype.extend=function(a){function e(a){b._methods[a]=!0,b[a]=function(){var c=arguments.length===1?[a,""]:[a];b.on.apply(b,c.concat(Array.prototype.slice.call(arguments)))}}var b=this,c=a.length,d;for(d=0;d<c;d++)e(a[d])},e.prototype.runlist=function(a){var b=this.every&&this.every.before?[this.every.before].concat(g(a)):g(a);this.every&&this.every.on&&b.push(this.every.on),b.captures=a.captures,b.source=a.source;return b},e.prototype.mount=function(a,b){function d(b,d){var e=b,f=b.split(c.delimiter),g=typeof a[b],h=f[0]===""||!c._methods[f[0]],i=h?"on":e;h&&(e=e.slice((e.match(new RegExp("^"+c.delimiter))||[""])[0].length),f.shift());h&&g==="object"&&!Array.isArray(a[b])?(d=d.concat(f),c.mount(a[b],d)):(h&&(d=d.concat(e.split(c.delimiter)),d=k(d,c.delimiter)),c.insert(i,d,a[b]))}if(!!a&&typeof a=="object"&&!Array.isArray(a)){var c=this;b=b||[],Array.isArray(b)||(b=b.split(c.delimiter));for(var e in a)a.hasOwnProperty(e)&&d(e,b.slice(0))}}})(typeof exports=="object"?exports:window)
\ 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.
-->
<link rel="import" href="../polymer/polymer.html">
<script src="director/director.min.js"></script>
<polymer-element name="flatiron-director" attributes="route autoHash">
<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(0) || '';
},
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>
<!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="../platform/platform.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>
\ No newline at end of file
{
"name": "platform",
"main": "platform.js",
"homepage": "https://github.com/Polymer/platform",
"authors": [
"The Polymer Authors"
],
"description": "Integrate platform polyfills: load, build, test",
"keywords": [
"polymer",
"web",
"components"
],
"license": "BSD",
"private": true,
"version": "0.2.1",
"_release": "0.2.1",
"_resolution": {
"type": "version",
"tag": "0.2.1",
"commit": "961d6f68848b9479d4d778466c37c0835837bc1c"
},
"_source": "git://github.com/Polymer/platform.git",
"_target": "0.2.1",
"_originalSource": "Polymer/platform"
}
\ 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>
# Contributing
Want to contribute to Polymer? Great!
We are more than happy to accept external contributions to the project in the form of [feedback](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev), [bug reports](../../issues), and pull requests.
## Contributor License Agreement
Before we can accept patches, there's a quick web form you need to fill out.
- If you're contributing as an individual (e.g. you own the intellectual property), fill out [this form](http://code.google.com/legal/individual-cla-v1.0.html).
- If you're contributing under a company, fill out [this form](http://code.google.com/legal/corporate-cla-v1.0.html) instead.
This CLA asserts that contributions are owned by you and that we can license all work under our [license](LICENSE).
Other projects require a similar agreement: jQuery, Firefox, Apache, Node, and many more.
[More about CLAs](https://www.google.com/search?q=Contributor%20License%20Agreement)
## Initial setup
Here's an easy guide that should get you up and running:
1. Setup Grunt: `sudo npm install -g grunt-cli`
1. Fork the project on github and pull down your copy.
> replace the {{ username }} with your username and {{ repository }} with the repository name
git clone git@github.com:{{ username }}/{{ repository }}.git --recursive
Note the `--recursive`. This is necessary for submodules to initialize properly. If you don't do a recursive clone, you'll have to init them manually:
git submodule init
git submodule update
Download and run the `pull-all.sh` script to install the sibling dependencies.
git clone git://github.com/Polymer/tools.git && tools/bin/pull-all.sh
1. Test your change
> in the repo you've made changes to, run the tests:
cd $REPO
npm install
grunt test
1. Commit your code and make a pull request.
That's it for the one time setup. Now you're ready to make a change.
## Submitting a pull request
We iterate fast! To avoid potential merge conflicts, it's a good idea to pull from the main project before making a change and submitting a pull request. The easiest way to do this is setup a remote called `upstream` and do a pull before working on a change:
git remote add upstream git://github.com/Polymer/{{ repository }}.git
Then before making a change, do a pull from the upstream `master` branch:
git pull upstream master
To make life easier, add a "pull upstream" alias in your `.gitconfig`:
[alias]
pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
That will pull in changes from your forked repo, the main (upstream) repo, and merge the two. Then it's just a matter of running `git pu` before a change and pushing to your repo:
git checkout master
git pu
# make change
git commit -a -m 'Awesome things.'
git push
Lastly, don't forget to submit the pull request.
// 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.
Platform
========
Aggregated polyfills the Polymer platform.
[![Analytics](https://ga-beacon.appspot.com/UA-39334307-2/Polymer/platform/README)](https://github.com/igrigorik/ga-beacon)
{
"name": "platform",
"main": "platform.js",
"homepage": "https://github.com/Polymer/platform",
"authors": [
"The Polymer Authors"
],
"description": "Integrate platform polyfills: load, build, test",
"keywords": [
"polymer",
"web",
"components"
],
"license": "BSD",
"private": true,
"version": "0.2.1"
}
\ No newline at end of file
BUILD LOG
---------
Build Time: 2014-03-07T10:33:27
NODEJS INFORMATION
==================
nodejs: v0.10.26
chai: 1.9.0
─ assertion-error: 1.0.0
┬ deep-eql: 0.1.3
└── type-detect: 0.1.1
grunt: 0.4.2
─ async: 0.1.22
─ coffee-script: 1.3.3
─ colors: 0.6.2
─ dateformat: 1.0.2-1.2.3
─ eventemitter2: 0.4.13
─ exit: 0.1.2
┬ findup-sync: 0.1.2
└── lodash: 1.0.1
─ getobject: 0.1.0
┬ glob: 3.1.21
├── graceful-fs: 1.2.3
└── inherits: 1.0.0
─ hooker: 0.2.3
─ iconv-lite: 0.2.11
┬ js-yaml: 2.0.5
├─┬ argparse: 0.1.15
│ ├── underscore: 1.4.4
│ └── underscore.string: 2.3.3
└── esprima: 1.0.4
─ lodash: 0.9.2
┬ minimatch: 0.2.14
├── lru-cache: 2.5.0
└── sigmund: 1.0.0
┬ nopt: 1.0.10
└── abbrev: 1.0.4
┬ rimraf: 2.0.3
└── graceful-fs: 1.1.14
─ underscore.string: 2.2.1
─ which: 1.0.5
grunt-audit: 0.0.2
grunt-concat-sourcemap: 0.4.1
┬ source-map: 0.1.32
└── amdefine: 0.1.0
grunt-contrib-concat: 0.3.0
grunt-contrib-uglify: 0.3.2
┬ chalk: 0.4.0
├── ansi-styles: 1.0.0
├── has-color: 0.1.4
└── strip-ansi: 0.1.1
┬ grunt-lib-contrib: 0.6.1
└── zlib-browserify: 0.0.1
┬ uglify-js: 2.4.12
├── async: 0.2.10
├─┬ optimist: 0.3.7
│ └── wordwrap: 0.0.2
├─┬ source-map: 0.1.32
│ └── amdefine: 0.1.0
└── uglify-to-browserify: 1.0.2
grunt-contrib-yuidoc: 0.5.0
┬ yuidocjs: 0.3.47
├─┬ express: 3.1.2
│ ├── buffer-crc32: 0.2.1
│ ├── commander: 0.6.1
│ ├─┬ connect: 2.7.5
│ │ ├── buffer-crc32: 0.1.1
│ │ ├── bytes: 0.2.0
│ │ ├── formidable: 1.0.11
│ │ ├── pause: 0.0.1
│ │ └── qs: 0.5.1
│ ├── cookie: 0.0.5
│ ├── cookie-signature: 1.0.0
│ ├── debug: 0.7.4
│ ├── fresh: 0.1.0
│ ├── methods: 0.0.1
│ ├── mkdirp: 0.3.5
│ ├── range-parser: 0.0.4
│ └─┬ send: 0.1.0
│ └── mime: 1.2.6
├── graceful-fs: 2.0.1
├── marked: 0.2.10
├─┬ minimatch: 0.2.14
│ ├── lru-cache: 2.5.0
│ └── sigmund: 1.0.0
├─┬ rimraf: 2.0.3
│ └── graceful-fs: 1.1.14
└─┬ yui: 3.9.1
└─┬ request: 2.12.0
├─┬ form-data: 0.0.3
│ ├── async: 0.1.9
│ └─┬ combined-stream: 0.0.3
│ └── delayed-stream: 0.0.5
└── mime: 1.2.7
grunt-karma: 0.6.2
┬ optimist: 0.6.1
├── minimist: 0.0.7
└── wordwrap: 0.0.2
karma: 0.10.9
┬ chokidar: 0.8.1
├── fsevents: 0.1.6 extraneous
└── recursive-readdir: 0.0.2 extraneous
─ coffee-script: 1.6.3
─ colors: 0.6.0-1
┬ connect: 2.8.8
├── buffer-crc32: 0.2.1
├── bytes: 0.2.0
├── cookie: 0.1.0
├── cookie-signature: 1.0.1
├── debug: 0.7.4
├── formidable: 1.0.14
├── fresh: 0.2.0
├── methods: 0.0.1
├── pause: 0.0.1
├── qs: 0.6.5
├─┬ send: 0.1.4
│ └── range-parser: 0.0.4
└── uid2: 0.0.2
─ di: 0.0.1
┬ glob: 3.1.21
└── inherits: 1.0.0
─ graceful-fs: 1.2.3
┬ http-proxy: 0.10.4
├─┬ optimist: 0.6.1
│ ├── minimist: 0.0.7
│ └── wordwrap: 0.0.2
├── pkginfo: 0.3.0
└─┬ utile: 0.2.1
├── async: 0.2.10
├── deep-equal: 0.2.1
├── i: 0.3.2
├── mkdirp: 0.3.5
└── ncp: 0.4.2
─ lodash: 1.1.1
┬ log4js: 0.6.10
├── async: 0.1.15
├─┬ readable-stream: 1.0.25
│ └── string_decoder: 0.10.25-1
└── semver: 1.1.4
─ mime: 1.2.11
┬ minimatch: 0.2.14
├── lru-cache: 2.5.0
└── sigmund: 1.0.0
┬ optimist: 0.3.7
└── wordwrap: 0.0.2
─ q: 0.9.7
─ rimraf: 2.1.4
┬ socket.io: 0.9.16
├── base64id: 0.1.0
├── policyfile: 0.0.4
├── redis: 0.7.3
└─┬ socket.io-client: 0.9.16
├─┬ active-x-obfuscator: 0.0.1
│ └── zeparser: 0.0.5
├── uglify-js: 1.2.5
├─┬ ws: 0.4.31
│ ├── commander: 0.6.1
│ ├── nan: 0.3.2
│ ├── options: 0.0.5
│ └── tinycolor: 0.0.1
└── xmlhttprequest: 1.4.2
┬ useragent: 2.0.7
└── lru-cache: 2.2.4
karma-chrome-launcher: 0.0.2 (git://github.com/morethanreal/karma-chrome-launcher#aaaef751f4c39b4671447f4b62a3462101f8a3c4)
karma-coffee-preprocessor: 0.1.2
─ coffee-script: 1.6.3
karma-crbot-reporter: 0.0.4
karma-firefox-launcher: 0.1.3
karma-html2js-preprocessor: 0.1.0
karma-ie-launcher: 0.1.1
karma-jasmine: 0.1.5
karma-mocha: 0.1.1
karma-phantomjs-launcher: 0.1.2
┬ phantomjs: 1.9.7-1
├── adm-zip: 0.2.1
├── kew: 0.1.7
├── mkdirp: 0.3.5
├── ncp: 0.4.2
├─┬ npmconf: 0.0.24
│ ├─┬ config-chain: 1.1.8
│ │ └── proto-list: 1.2.2
│ ├── inherits: 1.0.0
│ ├── ini: 1.1.0
│ ├─┬ nopt: 2.1.2
│ │ └── abbrev: 1.0.4
│ ├── once: 1.1.1
│ ├── osenv: 0.0.3
│ └── semver: 1.1.4
├── rimraf: 2.2.6
└── which: 1.0.5
karma-requirejs: 0.2.1
karma-safari-launcher: 0.1.1
karma-script-launcher: 0.1.0
mocha: 1.17.1
─ commander: 2.0.0
─ debug: 0.7.4
─ diff: 1.0.7
┬ glob: 3.2.3
├── graceful-fs: 2.0.1
├── inherits: 2.0.1
└─┬ minimatch: 0.2.14
├── lru-cache: 2.5.0
└── sigmund: 1.0.0
─ growl: 1.7.0
┬ jade: 0.26.3
├── commander: 0.6.1
└── mkdirp: 0.3.0
─ mkdirp: 0.3.5
requirejs: 2.1.10
REPO REVISIONS
==============
CustomElements: 7be9e6e758903f62df6ba73a5ea82777c37dc273
HTMLImports: cae0c94f3be4b492c0db686ffdd0288b49dbdfe7
NodeBind: 62f7e53baee55d5821747227de9b407da1c261ec
PointerEvents: f2964bcc070231c41391cb864fa0c6578031592c
PointerGestures: f645ec49a0b2fa2e0d4dee40722bb0dab24ae59f
ShadowDOM: 4c2f646faa3fe5e5f2625bc16753be11ef2a026e
TemplateBinding: 08008af605298aaf2d56ef34d4af4df70679ea61
WeakMap: a0947a9a0f58f5733f464755c3b86de624b00a5d
observe-js: 3d7b5aa5eb7b403ee7be398280113f7cc36e448a
platform: 59d0c0d8307e9433d0dcd9943c627ab3ba45ac10
polymer-expressions: 470cced7cf167bd164f0b924ceb088dd7a8240b9
BUILD HASHES
============
build/platform.js: 2dd0f0a8ebdaaffd6fecc70158cc3cefce3ad67a
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "polymer-localstorage",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#0.2.1"
},
"version": "0.2.1",
"homepage": "https://github.com/Polymer/polymer-localstorage",
"_release": "0.2.1",
"_resolution": {
"type": "version",
"tag": "0.2.1",
"commit": "19e87468b2a977bf79db60db247e0b4e8672e920"
},
"_source": "git://github.com/Polymer/polymer-localstorage.git",
"_target": "*",
"_originalSource": "Polymer/polymer-localstorage"
}
\ 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) 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": "polymer-localstorage",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#0.2.1"
},
"version": "0.2.1"
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>polymer-localstorage</title>
<script src="../platform/platform.js"></script>
<link rel="import" href="polymer-localstorage.html">
<link rel="import" href="../polymer-ui-toggle-button/polymer-ui-toggle-button.html">
</head>
<body>
<polymer-element name="x-test1">
<template>
string entered below will be stored in localStorage and automatically retrived from localStorage when the page is reloaded<br>
<input value="{{value}}">
<polymer-localstorage name="polymer-localstorage-x-test1" value="{{value}}"></polymer-localstorage>
</template>
<script>
Polymer('x-test1');
</script>
</polymer-element>
<x-test1></x-test1>
<br><br>
<polymer-element name="x-test2">
<template>
<polymer-ui-toggle-button value="{{mode}}"></polymer-ui-toggle-button>
<polymer-localstorage name="polymer-localstorage-x-test2" value="{{mode}}"></polymer-localstorage>
</template>
<script>
Polymer('x-test2', {
mode: false
});
</script>
</polymer-element>
<x-test2></x-test2>
</body>
</html>
<!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="../platform/platform.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>
\ 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.
-->
<!--
/**
* @module Polymer Elements
*/
/**
* Element access to localStorage. The "name" property
* is the key to the data ("value" property) stored in localStorage.
*
* polymer-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.
*
* Example:
*
* <polymer-localstorage name="my-app-storage" value="{{value}}"></polymer-localstorage>
*
* @class polymer-localstorage
* @blurb Element access to localStorage.
* @snap http://polymer.github.io/polymer-localstorage/snap.png
* @author The Polymer Authors
* @categories Data
*
*/
/**
* Fired after it is loaded from localStorage.
*
* @event polymer-localstorage-load
*/
-->
<link rel="import" href="../polymer/polymer.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.
-->
<!--
/**
* @module Polymer Elements
*/
/**
* polymer-localstorage provides access to localStorage.
*
* Example:
*
* <polymer-localstorage name="my-app-storage" value="{{value}}"></polymer-localstorage>
*
* @class polymer-localstorage
*/
-->
<polymer-element name="polymer-localstorage" attributes="name value useRaw">
<template>
<style>
@host {
* {
display: none;
}
}
</style>
</template>
<script>
Polymer('polymer-localstorage', {
useRaw: false,
ready: function() {
this.load();
},
valueChanged: function() {
this.save();
},
load: function() {
var s = window.localStorage.getItem(this.name);
if (s && !this.useRaw) {
this.value = JSON.parse(s);
} else {
this.value = s;
}
},
save: function() {
window.localStorage.setItem(this.name,
this.useRaw ? this.value : JSON.stringify(this.value));
}
});
</script>
</polymer-element>
\ No newline at end of file
<!doctype html>
<html>
<head>
<title>polymer-localstorage</title>
<script src="../../../platform/platform.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="../../polymer-localstorage.html">
</head>
<body>
<polymer-localstorage id="localstorage" name="polymer-localstorage-test" useRaw></polymer-localstorage>
<script>
var assert = chai.assert;
document.addEventListener('polymer-ready', function() {
var s = document.querySelector('#localstorage');
var m = 'hello wold';
window.localStorage.setItem(s.name, m);
s.load();
assert.equal(s.value, m);
s.value = 'goodbye';
assert.equal(window.localStorage.getItem(s.name), m);
done();
});
</script>
</body>
</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.
*/
htmlSuite('polymer-localstorage', function() {
htmlTest('html/polymer-localstorage.html');
});
\ 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>polymer-localstorage Test Runner (Mocha)</title>
<meta charset="UTF-8">
<!-- -->
<link rel="stylesheet" href="../../tools/test/mocha/mocha.css" />
<script src="../../tools/test/mocha/mocha.js"></script>
<script src="../../tools/test/chai/chai.js"></script>
<script src="../../tools/test/mocha-htmltest.js"></script>
<!-- -->
<script src="../../platform/platform.js"></script>
</head>
<body>
<div id="mocha"></div>
<script>
mocha.setup({ui: 'tdd', slow: 1000, htmlbase: ''});
</script>
<!-- -->
<script src="js/polymer-localstorage.js"></script>
<!-- -->
<script>
mocha.run();
</script>
</body>
</html>
{
"name": "polymer-selection",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#0.2.1"
},
"version": "0.2.1",
"homepage": "https://github.com/Polymer/polymer-selection",
"_release": "0.2.1",
"_resolution": {
"type": "version",
"tag": "0.2.1",
"commit": "414b5314477367acb821fc515279f18bc66e4897"
},
"_source": "git://github.com/Polymer/polymer-selection.git",
"_target": "0.2.1",
"_originalSource": "Polymer/polymer-selection"
}
\ 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) 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": "polymer-selection",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#0.2.1"
},
"version": "0.2.1"
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Selection</title>
<script src="../platform/platform.js"></script>
<link rel="import" href="polymer-selection.html">
</head>
<body>
<polymer-element name="selection-example">
<template>
<style>
/* @polyfill ul > * */
::-webkit-distributed(> *) {
cursor: pointer;
}
/* @polyfill ul > .selected */
::-webkit-distributed(> .selected) {
font-weight: bold;
font-style: italic;
}
</style>
<ul on-tap="{{itemTapAction}}">
<content></content>
</ul>
<polymer-selection id="selection" multi on-polymer-select="{{selectAction}}"></polymer-selection>
</template>
<script>
Polymer('selection-example', {
itemTapAction: function(e) {
this.$.selection.select(e.target);
},
selectAction: function(e, detail) {
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>
<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="../platform/platform.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>
\ 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.
-->
<!--
/**
* @module Polymer Elements
*/
-->
<!--
/**
* The polymer-selection element is used to manage selection state. It has no
* visual appearance and is typically used in conjuneciton with another element.
* For example, <a href="polymer-selector.html">polymer-selector</a>
* use a polymer-selection to manage selection.
*
* To mark an item as selected, call the select(item) method on
* polymer-selection. Notice that the item itself is an argument to this method.
* The polymer-selection element manages selection state for any given set of
* items. When an item is selected, the `polymer-select` event is fired.
* The attribute "multi" indicates if multiple items can be selected at once.
*
* Example:
*
* <polymer-element name="selection-example">
* <template>
* <style>
* ::-webkit-distributed(> .selected) {
* font-weight: bold;
* font-style: italic;
* }
* </style>
* <ul on-tap="{{itemTapAction}}">
* <content></content>
* </ul>
* <polymer-selection id="selection" multi on-polymer-select="{{selectAction}}"></polymer-selection>
* </template>
* <script>
* Polymer('selection-example', {
* itemTapAction: function(e) {
* this.$.selection.select(e.target);
* },
* selectAction: function(e, detail) {
* detail.item.classList.toggle('selected', detail.isSelected);
* }
* });
* </script>
* </polymer-element>
*
* <selection-example>
* <li>Red</li>
* <li>Green</li>
* <li>Blue</li>
* </selection-example>
*
* @class polymer-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 polymer-select
* @param {Object} detail
* @param {boolean} detail.isSelected true for selection and false for deselection
* @param {Object} detail.item the item element
*/
-->
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="polymer-selection" attributes="multi">
<template>
<style>
:host {
display: none !important;
}
</style>
</template>
<script>
Polymer('polymer-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("polymer-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>
<html>
<head>
<title>polymer-selection-multi</title>
<script src="../../../platform/platform.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="../../polymer-selection.html">
</head>
<body>
<polymer-selection multi></polymer-selection>
<script>
var assert = chai.assert;
document.addEventListener('polymer-ready', function() {
var s = document.querySelector('polymer-selection');
s.addEventListener("polymer-select", function(event) {
if (test === 1) {
// check test1
assert.isTrue(event.detail.isSelected);
assert.equal(event.detail.item, '(item1)');
assert.isTrue(s.isSelected(event.detail.item));
assert.equal(s.getSelection().length, 1);
// test2
test++;
s.select('(item2)');
} else if (test === 2) {
// check test2
assert.isTrue(event.detail.isSelected);
assert.equal(event.detail.item, '(item2)');
assert.isTrue(s.isSelected(event.detail.item));
assert.equal(s.getSelection().length, 2);
done();
}
});
// test1
var test = 1;
s.select('(item1)');
});
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<title>polymer-selection</title>
<script src="../../../platform/platform.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="../../polymer-selection.html">
</head>
<body>
<polymer-selection></polymer-selection>
<script>
var assert = chai.assert;
document.addEventListener('polymer-ready', function() {
var s = document.querySelector('polymer-selection');
s.addEventListener("polymer-select", function(event) {
if (test === 1) {
// check test1
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)'));
// test2
test++;
s.select(null);
} else if (test === 2) {
// check test2
assert.isFalse(event.detail.isSelected);
assert.equal(event.detail.item, '(item)');
assert.isFalse(s.isSelected(event.detail.item));
done();
}
});
// test1
var test = 1;
s.select('(item)');
});
</script>
</body>
</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.
*/
htmlSuite('polymer-selection', function() {
htmlTest('html/polymer-selection.html');
htmlTest('html/polymer-selection-multi.html');
});
\ 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>polymer-selection Test Runner (Mocha)</title>
<meta charset="UTF-8">
<!-- -->
<link rel="stylesheet" href="../../tools/test/mocha/mocha.css" />
<script src="../../tools/test/mocha/mocha.js"></script>
<script src="../../tools/test/chai/chai.js"></script>
<script src="../../tools/test/mocha-htmltest.js"></script>
<!-- -->
<script src="../../platform/platform.js"></script>
</head>
<body>
<div id="mocha"></div>
<script>
mocha.setup({ui: 'tdd', slow: 1000, htmlbase: ''});
</script>
<!-- -->
<script src="js/polymer-selection.js"></script>
<!-- -->
<script>
mocha.run();
</script>
</body>
</html>
{
"name": "polymer-selector",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#0.2.1",
"polymer-selection": "Polymer/polymer-selection#0.2.1"
},
"version": "0.2.1",
"homepage": "https://github.com/Polymer/polymer-selector",
"_release": "0.2.1",
"_resolution": {
"type": "version",
"tag": "0.2.1",
"commit": "cd84d37c050e2badb90fd621061866bcdde48515"
},
"_source": "git://github.com/Polymer/polymer-selector.git",
"_target": "*",
"_originalSource": "Polymer/polymer-selector"
}
\ 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) 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.
polymer-selector
================
[LICENSE](https://raw.github.com/Polymer/polymer/master/LICENSE)
[PATENTS](https://raw.github.com/Polymer/polymer/master/PATENTS)
[CONTRIBUTING](https://github.com/Polymer/polymer/blob/master/CONTRIBUTING.md)
{
"name": "polymer-selector",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#0.2.1",
"polymer-selection": "Polymer/polymer-selection#0.2.1"
},
"version": "0.2.1"
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Selector</title>
<script src="../platform/platform.js"></script>
<link rel="import" href="polymer-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 > *.polymer-selected {
background: #333;
}
li {
height: 30px;
}
li.polymer-selected:after {
content: "\2713";
position: absolute;
padding-left: 10px;
}
</style>
<h2>basic</h2>
<polymer-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>
</polymer-selector>
<h2>multi-selection</h2>
<polymer-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>
</polymer-selector>
<h2>list</h2>
<polymer-selector target="{{$.list}}" selected="0"></polymer-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>
<polymer-selector target="{{$.myForm}}" itemsSelector="input[type=radio]"
selected="{{color}}" valueattr="value" selectedProperty="checked"
activateEvent="change"></polymer-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>
<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="../platform/platform.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>
\ No newline at end of file
<!doctype html>
<html>
<head>
<title>polymer-selector-activate-event</title>
<script src="../../../platform/platform.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="../../polymer-selector.html">
<style>
.polymer-selected {
background: #ccc;
}
</style>
</head>
<body>
<polymer-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>
</polymer-selector>
<script>
var assert = chai.assert;
document.addEventListener('polymer-ready', function() {
var s = document.querySelector('#selector');
s.addEventListener("polymer-activate", function(event) {
assert.equal(event.detail.item, s.children[1]);
assert.equal(s.selected, 1);
done();
});
assert.equal(s.selected, '0');
requestAnimationFrame(function() {
s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
});
});
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<title>polymer-selector-basic</title>
<script src="../../../platform/platform.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="../../polymer-selector.html">
<style>
.polymer-selected {
background: #ccc;
}
.my-selected {
background: red;
}
</style>
</head>
<body>
<polymer-selector id="selector1">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</polymer-selector>
<br><br>
<polymer-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>
</polymer-selector>
<script>
var assert = chai.assert;
var async = requestAnimationFrame;
function oneMutation(node, options, cb) {
var o = new MutationObserver(function() {
cb();
o.disconnect();
});
o.observe(node, options);
}
document.addEventListener('polymer-ready', function() {
// selector1
var s = document.querySelector('#selector1');
assert.equal(s.selected, null);
assert.equal(s.selectedClass, 'polymer-selected');
assert.isFalse(s.multi);
assert.equal(s.valueattr, 'name');
assert.equal(s.items.length, 5);
// selector2
s = document.querySelector('#selector2');
assert.equal(s.selected, "item3");
assert.equal(s.selectedClass, 'my-selected');
// setup listener for polymer-select event
var selectEventCounter = 0;
s.addEventListener('polymer-select', function(e) {
if (e.detail.isSelected) {
selectEventCounter++;
// selectedItem and detail.item should be the same
assert.equal(e.detail.item, s.selectedItem);
}
});
// set selected
s.selected = 'item5';
Platform.flush();
oneMutation(s, {attributes: true}, function() {
// check polymer-select event
assert.equal(selectEventCounter, 1);
// check selected class
assert.isTrue(s.children[4].classList.contains('my-selected'));
// check selectedItem
assert.equal(s.selectedItem, s.children[4]);
// selecting the same value shouldn't fire polymer-select
selectEventCounter = 0;
s.selected = 'item5';
Platform.flush();
// TODO(ffu): would be better to wait for something to happen
// instead of not to happen
setTimeout(function() {
assert.equal(selectEventCounter, 0);
done();
}, 50);
});
});
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<title>polymer-selector-multi</title>
<script src="../../../platform/platform.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="../../polymer-selector.html">
<style>
.polymer-selected {
background: #ccc;
}
</style>
</head>
<body>
<polymer-selector id="selector" multi>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</polymer-selector>
<script>
var assert = chai.assert;
function oneMutation(node, options, cb) {
var o = new MutationObserver(function() {
cb();
o.disconnect();
});
o.observe(node, options);
}
document.addEventListener('polymer-ready', function() {
//
var s = document.querySelector('#selector');
assert.equal(s.selected, null);
assert.equal(s.selectedClass, 'polymer-selected');
assert.isTrue(s.multi);
assert.equal(s.valueattr, 'name');
assert.equal(s.items.length, 5);
// setup listener for polymer-select event
var selectEventCounter = 0;
s.addEventListener('polymer-select', function(e) {
if (e.detail.isSelected) {
selectEventCounter++;
} else {
selectEventCounter--;
}
// check selectedItem in polymer-select event
assert.equal(this.selectedItem.length, selectEventCounter);
});
// set selected
s.selected = [0, 2];
Platform.flush();
oneMutation(s, {attributes: true}, function() {
// check polymer-select event
assert.equal(selectEventCounter, 2);
// check selected class
assert.isTrue(s.children[0].classList.contains('polymer-selected'));
assert.isTrue(s.children[2].classList.contains('polymer-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);
assert.isFalse(s.children[0].classList.contains('polymer-selected'));
done();
});
});
</script>
</body>
</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.
*/
htmlSuite('polymer-selector', function() {
htmlTest('html/polymer-selector-basic.html');
htmlTest('html/polymer-selector-activate-event.html');
htmlTest('html/polymer-selector-multi.html');
});
\ 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>polymer-selector Test Runner (Mocha)</title>
<meta charset="UTF-8">
<!-- -->
<link rel="stylesheet" href="../../tools/test/mocha/mocha.css" />
<script src="../../tools/test/mocha/mocha.js"></script>
<script src="../../tools/test/chai/chai.js"></script>
<script src="../../tools/test/mocha-htmltest.js"></script>
<!-- -->
<script src="../../platform/platform.js"></script>
</head>
<body>
<div id="mocha"></div>
<script>
mocha.setup({ui: 'tdd', slow: 1000, htmlbase: ''});
</script>
<!-- -->
<script src="js/polymer-selector.js"></script>
<!-- -->
<script>
mocha.run();
</script>
</body>
</html>
{
"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>",
"main": [
"polymer.js"
],
"dependencies": {
"platform": "Polymer/platform#0.2.1"
},
"version": "0.2.1",
"_release": "0.2.1",
"_resolution": {
"type": "version",
"tag": "0.2.1",
"commit": "62ec4216813ccd9344cf419da846b623892f0884"
},
"_source": "git://github.com/Polymer/polymer.git",
"_target": "0.2.1",
"_originalSource": "Polymer/polymer"
}
\ 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>
# Contributing
Want to contribute to Polymer? Great!
We are more than happy to accept external contributions to the project in the form of [feedback](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev), [bug reports](../../issues), and pull requests.
## Contributor License Agreement
Before we can accept patches, there's a quick web form you need to fill out.
- If you're contributing as an individual (e.g. you own the intellectual property), fill out [this form](http://code.google.com/legal/individual-cla-v1.0.html).
- If you're contributing under a company, fill out [this form](http://code.google.com/legal/corporate-cla-v1.0.html) instead.
This CLA asserts that contributions are owned by you and that we can license all work under our [license](LICENSE).
Other projects require a similar agreement: jQuery, Firefox, Apache, Node, and many more.
[More about CLAs](https://www.google.com/search?q=Contributor%20License%20Agreement)
## Initial setup
Here's an easy guide that should get you up and running:
1. Setup Grunt: `sudo npm install -g grunt-cli`
1. Fork the project on github and pull down your copy.
> replace the {{ username }} with your username and {{ repository }} with the repository name
git clone git@github.com:{{ username }}/{{ repository }}.git --recursive
Note the `--recursive`. This is necessary for submodules to initialize properly. If you don't do a recursive clone, you'll have to init them manually:
git submodule init
git submodule update
Download and run the `pull-all.sh` script to install the sibling dependencies.
git clone git://github.com/Polymer/tools.git && tools/bin/pull-all.sh
1. Test your change
> in the repo you've made changes to, run the tests:
cd $REPO
npm install
grunt test
1. Commit your code and make a pull request.
That's it for the one time setup. Now you're ready to make a change.
## Submitting a pull request
We iterate fast! To avoid potential merge conflicts, it's a good idea to pull from the main project before making a change and submitting a pull request. The easiest way to do this is setup a remote called `upstream` and do a pull before working on a change:
git remote add upstream git://github.com/Polymer/{{ repository }}.git
Then before making a change, do a pull from the upstream `master` branch:
git pull upstream master
To make life easier, add a "pull upstream" alias in your `.gitconfig`:
[alias]
pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
That will pull in changes from your forked repo, the main (upstream) repo, and merge the two. Then it's just a matter of running `git pu` before a change and pushing to your repo:
git checkout master
git pu
# make change
git commit -a -m 'Awesome things.'
git push
Lastly, don't forget to submit the pull request.
// Copyright (c) 2014 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.
# Polymer
[![Analytics](https://ga-beacon.appspot.com/UA-39334307-2/Polymer/polymer/README)](https://github.com/igrigorik/ga-beacon)
Build Status: [http://build.chromium.org/p/client.polymer/waterfall](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](https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html), [Custom Elements](https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html) 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](http://www.polymer-project.org/resources/tooling-strategy.html).
{
"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>",
"main": [
"polymer.js"
],
"dependencies": {
"platform": "Polymer/platform#0.2.1"
},
"version": "0.2.1"
}
\ No newline at end of file
BUILD LOG
---------
Build Time: 2014-03-07T11:16:41
NODEJS INFORMATION
==================
nodejs: v0.10.26
chai: 1.9.0
─ assertion-error: 1.0.0
┬ deep-eql: 0.1.3
└── type-detect: 0.1.1
grunt: 0.4.2
─ async: 0.1.22
─ coffee-script: 1.3.3
─ colors: 0.6.2
─ dateformat: 1.0.2-1.2.3
─ eventemitter2: 0.4.13
─ exit: 0.1.2
┬ findup-sync: 0.1.2
├─┬ glob: 3.1.21
│ ├── graceful-fs: 1.2.3
│ ├── inherits: 1.0.0
│ └─┬ minimatch: 0.2.14
│ ├── lru-cache: 2.5.0
│ └── sigmund: 1.0.0
└── lodash: 1.0.1
─ getobject: 0.1.0
┬ glob: 3.1.21
├── graceful-fs: 1.2.3
└── inherits: 1.0.0
─ hooker: 0.2.3
─ iconv-lite: 0.2.11
┬ js-yaml: 2.0.5
├─┬ argparse: 0.1.15
│ ├── underscore: 1.4.4
│ └── underscore.string: 2.3.3
└── esprima: 1.0.4
─ lodash: 0.9.2
┬ minimatch: 0.2.14
├── lru-cache: 2.5.0
└── sigmund: 1.0.0
┬ nopt: 1.0.10
└── abbrev: 1.0.4
┬ rimraf: 2.0.3
└── graceful-fs: 1.1.14
─ underscore.string: 2.2.1
─ which: 1.0.5
grunt-audit: 0.0.2
grunt-concat-sourcemap: 0.3.2 extraneous
┬ source-map: 0.1.31
└── amdefine: 0.1.0
grunt-contrib-uglify: 0.3.2
┬ chalk: 0.4.0
├── ansi-styles: 1.0.0
├── has-color: 0.1.4
└── strip-ansi: 0.1.1
┬ grunt-lib-contrib: 0.6.1
└── zlib-browserify: 0.0.1
┬ uglify-js: 2.4.12
├── async: 0.2.10
├─┬ optimist: 0.3.7
│ └── wordwrap: 0.0.2
├─┬ source-map: 0.1.32
│ └── amdefine: 0.1.0
└── uglify-to-browserify: 1.0.2
grunt-contrib-yuidoc: 0.5.0
┬ yuidocjs: 0.3.47
├─┬ express: 3.1.2
│ ├── buffer-crc32: 0.2.1
│ ├── commander: 0.6.1
│ ├─┬ connect: 2.7.5
│ │ ├── buffer-crc32: 0.1.1
│ │ ├── bytes: 0.2.0
│ │ ├── formidable: 1.0.11
│ │ ├── pause: 0.0.1
│ │ └── qs: 0.5.1
│ ├── cookie: 0.0.5
│ ├── cookie-signature: 1.0.0
│ ├── debug: 0.7.4
│ ├── fresh: 0.1.0
│ ├── methods: 0.0.1
│ ├── mkdirp: 0.3.5
│ ├── range-parser: 0.0.4
│ └─┬ send: 0.1.0
│ └── mime: 1.2.6
├── graceful-fs: 2.0.1
├── marked: 0.2.10
├─┬ minimatch: 0.2.14
│ ├── lru-cache: 2.5.0
│ └── sigmund: 1.0.0
├─┬ rimraf: 2.0.3
│ └── graceful-fs: 1.1.14
└─┬ yui: 3.9.1
└─┬ request: 2.12.0
├─┬ form-data: 0.0.3
│ ├── async: 0.1.9
│ └─┬ combined-stream: 0.0.3
│ └── delayed-stream: 0.0.5
└── mime: 1.2.7
grunt-karma: 0.6.2
┬ optimist: 0.6.1
├── minimist: 0.0.7
└── wordwrap: 0.0.2
karma: 0.10.8
─ chokidar: 0.7.1
─ coffee-script: 1.6.3
─ colors: 0.6.0-1
┬ connect: 2.8.8
├── buffer-crc32: 0.2.1
├── bytes: 0.2.0
├── cookie: 0.1.0
├── cookie-signature: 1.0.1
├── debug: 0.7.4
├── formidable: 1.0.14
├── fresh: 0.2.0
├── methods: 0.0.1
├── pause: 0.0.1
├── qs: 0.6.5
├─┬ send: 0.1.4
│ └── range-parser: 0.0.4
└── uid2: 0.0.2
─ di: 0.0.1
┬ glob: 3.1.21
└── inherits: 1.0.0
─ graceful-fs: 1.2.3
┬ http-proxy: 0.10.3
├── pkginfo: 0.2.3
└─┬ utile: 0.1.7
├── async: 0.1.22
├── deep-equal: 0.1.0
├── i: 0.3.2
├── mkdirp: 0.3.5
├── ncp: 0.2.7
└── rimraf: 1.0.9
─ lodash: 1.1.1
┬ log4js: 0.6.9
├── async: 0.1.15
├── readable-stream: 1.0.17
└── semver: 1.1.4
─ mime: 1.2.11
┬ minimatch: 0.2.12
├── lru-cache: 2.5.0
└── sigmund: 1.0.0
┬ optimist: 0.3.7
└── wordwrap: 0.0.2
─ q: 0.9.7
─ rimraf: 2.1.4
┬ socket.io: 0.9.16
├── base64id: 0.1.0
├── policyfile: 0.0.4
├── redis: 0.7.3
└─┬ socket.io-client: 0.9.16
├─┬ active-x-obfuscator: 0.0.1
│ └── zeparser: 0.0.5
├── uglify-js: 1.2.5
├─┬ ws: 0.4.31
│ ├── commander: 0.6.1
│ ├── nan: 0.3.2
│ ├── options: 0.0.5
│ └── tinycolor: 0.0.1
└── xmlhttprequest: 1.4.2
┬ useragent: 2.0.7
└── lru-cache: 2.2.4
karma-chrome-launcher: 0.0.2 (git://github.com/morethanreal/karma-chrome-launcher#aaaef751f4c39b4671447f4b62a3462101f8a3c4)
karma-coffee-preprocessor: 0.1.1
─ coffee-script: 1.6.3
karma-crbot-reporter: 0.0.4
karma-firefox-launcher: 0.1.2
karma-html2js-preprocessor: 0.1.0
karma-ie-launcher: 0.1.1
karma-jasmine: 0.1.4
karma-mocha: 0.1.1
karma-phantomjs-launcher: 0.1.1
┬ phantomjs: 1.9.2-5
├── adm-zip: 0.2.1
├── kew: 0.1.7
├── mkdirp: 0.3.5
├── ncp: 0.4.2
├─┬ npmconf: 0.0.24
│ ├─┬ config-chain: 1.1.8
│ │ └── proto-list: 1.2.2
│ ├── inherits: 1.0.0
│ ├── ini: 1.1.0
│ ├─┬ nopt: 2.1.2
│ │ └── abbrev: 1.0.4
│ ├── once: 1.1.1
│ ├── osenv: 0.0.3
│ └── semver: 1.1.4
├── rimraf: 2.2.5
└── which: 1.0.5
karma-requirejs: 0.2.0
karma-safari-launcher: 0.1.1
karma-script-launcher: 0.1.0
mocha: 1.17.1
─ commander: 2.0.0
─ debug: 0.7.4
─ diff: 1.0.7
┬ glob: 3.2.3
├── graceful-fs: 2.0.1
├── inherits: 2.0.1
└─┬ minimatch: 0.2.14
├── lru-cache: 2.5.0
└── sigmund: 1.0.0
─ growl: 1.7.0
┬ jade: 0.26.3
├── commander: 0.6.1
└── mkdirp: 0.3.0
─ mkdirp: 0.3.5
requirejs: 2.1.9
REPO REVISIONS
==============
polymer-dev: 8be93c301aa9ebe36723311f65f0d6cb91f2d8f0
BUILD HASHES
============
build/polymer.js: 23e9b01c3c219c34092ef0ecde69f65df59f8df4
\ No newline at end of file
<polymer-element name="polymer-body" extends="body">
<script>
// upgrade polymer-body last so that it can contain other imported elements
document.addEventListener('polymer-ready', function() {
Polymer('polymer-body', Platform.mixin({
created: function() {
this.template = document.createElement('template');
var body = wrap(document).body;
var c$ = body.childNodes.array();
for (var i=0, c; (c=c$[i]); i++) {
if (c.localName !== 'script') {
this.template.content.appendChild(c);
}
}
// snarf up user defined model
window.model = this;
},
parseDeclaration: function(elementElement) {
this.lightFromTemplate(this.template);
}
}, window.model));
});
</script>
</polymer-element>
\ 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.
-->
<script src="polymer.js"></script>
<!-- <link rel="import" href="../polymer-dev/polymer.html"> -->
<link rel="import" href="polymer-body.html">
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "todomvc-common",
"version": "0.1.9",
"homepage": "https://github.com/tastejs/todomvc-common",
"_release": "0.1.9",
"_resolution": {
"type": "version",
"tag": "v0.1.9",
"commit": "7dd61b0ebf56c020e719a69444442cc7ae7242ff"
},
"_source": "git://github.com/tastejs/todomvc-common.git",
"_target": "~0.1.4",
"_originalSource": "todomvc-common"
}
\ No newline at end of file
# todomvc-common
> Bower component for some common utilities we use in every app
## License
MIT
<polymer-element name="td-input" extends="input" on-keyup="keyupAction" on-keypress="keypressAction">
<link rel="import" href="../bower_components/polymer/polymer.html">
<polymer-element name="td-input" extends="input" on-keyup="{{keyupAction}}" on-keypress="{{keypressAction}}">
<script>
(function() {
var ENTER_KEY = 13;
var ESC_KEY = 27;
Polymer('td-input', {
keypressAction: function (e, detail, sender) {
keypressAction: function(e, detail, sender) {
// Listen for enter on keypress but esc on keyup, because
// IE doesn't fire keyup for enter.
if (e.keyCode === ENTER_KEY) {
this.fire('td-input-commit');
}
},
keyupAction: function (e, detail, sender) {
keyupAction: function(e, detail, sender) {
if (e.keyCode === ESC_KEY) {
this.fire('td-input-cancel');
}
......
/* base.css overrides */
@host {
:host {
.editing {
border-bottom: none;
padding: 0;
......@@ -124,7 +124,8 @@ label {
}
.destroy:hover {
text-shadow: 0 0 1px #000, 0 0 10px rgba(199, 107, 107, 0.8);
text-shadow: 0 0 1px #000,
0 0 10px rgba(199, 107, 107, 0.8);
-webkit-transform: scale(1.3);
-moz-transform: scale(1.3);
-ms-transform: scale(1.3);
......@@ -147,11 +148,11 @@ label {
@media screen and (-webkit-min-device-pixel-ratio:0) {
.toggle {
background: none;
/*
ShadowDOM Polyfill work around for webkit/blink bug
https://code.google.com/p/chromium/issues/detail?id=251510
*/
background-color: transparent;
/*
ShadowDOM Polyfill work around for webkit/blink bug
https://code.google.com/p/chromium/issues/detail?id=251510
*/
background-color: transparent;
}
.toggle {
......
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="td-input.html">
<polymer-element name="td-item" extends="li" attributes="item editing" on-blur="commitAction">
<polymer-element name="td-item" extends="li" attributes="item editing" on-blur="{{commitAction}}">
<template>
<link rel="stylesheet" href="td-item.css">
<div class="view {{completed: item.completed; editing: editing}}" hidden?="{{editing}}" on-dblclick="editAction">
<input type="checkbox" class="toggle" checked="{{item.completed}}" on-click="itemChangeAction">
<div class="view {{ {completed: item.completed, editing: editing} | tokenList }}" hidden?="{{editing}}" on-dblclick="{{editAction}}">
<input type="checkbox" class="toggle" checked="{{item.completed}}" on-click="{{itemChangeAction}}">
<label>{{item.title}}</label>
<button class="destroy" on-click="destroyAction"></button>
<button class="destroy" on-click="{{destroyAction}}"></button>
</div>
<input is="td-input" id="edit" class="edit" value="{{title}}" hidden?="{{!editing}}" on-td-input-commit="commitAction" on-td-input-cancel="cancelAction">
<input is="td-input" id="edit" class="edit" value="{{item.title}}" hidden?="{{!editing}}" on-td-input-commit="{{commitAction}}" on-td-input-cancel="{{cancelAction}}">
</template>
<script>
(function () {
var ENTER_KEY = 13;
var ESC_KEY = 27;
(function() {
Polymer('td-item', {
editing: false,
editAction: function () {
editAction: function() {
this.editing = true;
this.$.edit.value = this.title = this.item.title;
// schedule focus for the end of microtask, when the input will be visible
Platform.flush();
this.asyncMethod(function () {
this.asyncMethod(function() {
this.$.edit.focus();
});
},
commitAction: function () {
this.title = this.$.edit.value;
commitAction: function() {
if (this.editing) {
this.editing = false;
this.item.title = this.title.trim();
this.item.title = this.item.title.trim();
if (this.item.title === '') {
this.destroyAction();
}
......
<link rel="import" href="../bower_components/polymer/polymer.html">
<polymer-element name="td-model" attributes="filter items storageId">
<script>
Polymer('td-model', {
......@@ -5,15 +7,15 @@
completedCount: 0,
activeCount: 0,
allCompleted: false,
ready: function () {
this.asyncMethod(function () {
ready: function() {
this.asyncMethod(function() {
this.items = this.items || [];
});
},
filterChanged: function () {
filterChanged: function() {
this.filterItems();
},
itemsChanged: function () {
itemsChanged: function() {
this.completedCount =
this.items.filter(this.filters.completed).length;
this.activeCount = this.items.length - this.completedCount;
......@@ -24,17 +26,15 @@
this.storage.save();
}
},
storageIdChanged: function () {
storageIdChanged: function() {
this.storage = document.querySelector('#' + this.storageId);
if (this.storage) {
this.items = this.storage.value;
}
this.storage && (this.items = this.storage.value);
},
filterItems: function () {
filterItems: function() {
var fn = this.filters[this.filter];
this.filtered = fn ? this.items.filter(fn) : this.items;
},
newItem: function (title) {
newItem: function(title) {
title = String(title).trim();
if (title) {
var item = {
......@@ -45,27 +45,27 @@
this.itemsChanged();
}
},
destroyItem: function (item) {
destroyItem: function(item) {
var i = this.items.indexOf(item);
if (i >= 0) {
this.items.splice(i, 1);
}
this.itemsChanged();
},
clearItems: function () {
clearItems: function(){
this.items = this.items.filter(this.filters.active);
},
setItemsCompleted: function (completed) {
this.items.forEach(function (item) {
setItemsCompleted: function(completed) {
this.items.forEach(function(item) {
item.completed = completed;
});
this.itemsChanged();
},
filters: {
active: function (item) {
active: function(item) {
return !item.completed;
},
completed: function (item) {
completed: function(item) {
return item.completed;
}
}
......
/* base.css overrides */
@host {
* {
:host {
* {
display: block;
position: relative;
}
......@@ -17,6 +17,7 @@ button {
font-family: inherit;
color: inherit;
-webkit-appearance: none;
/*-moz-appearance: none;*/
-ms-appearance: none;
-o-appearance: none;
appearance: none;
......@@ -39,6 +40,7 @@ input:-ms-input-placeholder, #new-todo:-ms-input-placeholder {
#todoapp {
background: #fff;
background: rgba(255, 255, 255, 0.9);
/*margin: 130px 0 40px 0;*/
margin: 0 0 40px 0;
border: 1px solid #ccc;
position: relative;
......@@ -245,11 +247,11 @@ label[for='toggle-all'] {
@media screen and (-webkit-min-device-pixel-ratio:0) {
#toggle-all {
background: none;
/*
ShadowDOM Polyfill work around for webkit/blink bug
https://code.google.com/p/chromium/issues/detail?id=251510
*/
background-color: transparent;
/*
ShadowDOM Polyfill work around for webkit/blink bug
https://code.google.com/p/chromium/issues/detail?id=251510
*/
background-color: transparent;
}
#toggle-all {
......
<link rel="import" href="../lib-elements/polymer-selector.html">
<link rel="import" href="../lib-elements/flatiron-director.html">
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/polymer-selector/polymer-selector.html">
<link rel="import" href="../bower_components/flatiron-director/flatiron-director.html">
<link rel="import" href="td-input.html">
<link rel="import" href="td-item.html">
......@@ -9,12 +11,12 @@
<flatiron-director route="{{route}}"></flatiron-director>
<section id="todoapp">
<header id="header">
<input is="td-input" id="new-todo" placeholder="What needs to be done?" autofocus on-td-input-commit="addTodoAction" on-td-input-cancel="cancelAddTodoAction">
<input is="td-input" id="new-todo" placeholder="What needs to be done?" autofocus on-td-input-commit="{{addTodoAction}}" on-td-input-cancel="{{cancelAddTodoAction}}">
</header>
<section id="main" hidden?="{{model.items.length == 0}}">
<input id="toggle-all" type="checkbox" on-change="toggleAllCompletedAction" checked="{{model.allCompleted}}">
<input id="toggle-all" type="checkbox" on-change="{{toggleAllCompletedAction}}" checked="{{model.allCompleted}}">
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list" on-td-item-changed="itemChangedAction" on-td-destroy-item="destroyItemAction">
<ul id="todo-list" on-td-item-changed="{{itemChangedAction}}" on-td-destroy-item="{{destroyItemAction}}">
<template repeat="{{model.filtered}}">
<li is="td-item" item="{{}}"></li>
</template>
......@@ -33,45 +35,41 @@
<a href="../#/completed">Completed</a>
</li>
</polymer-selector>
<button hidden?="{{model.completedCount == 0}}" id="clear-completed" on-click="clearCompletedAction">Clear completed ({{model.completedCount}})</button>
<button hidden?="{{model.completedCount == 0}}" id="clear-completed" on-click="{{clearCompletedAction}}">Clear completed ({{model.completedCount}})</button>
</footer>
</section>
</template>
<script>
(function () {
(function() {
var ENTER_KEY = 13;
var ESC_KEY = 27;
Polymer('td-todos', {
modelIdChanged: function () {
modelIdChanged: function() {
this.model = document.querySelector('#' + this.modelId);
},
routeChanged: function () {
if (this.model) {
this.model.filter = this.route;
}
routeChanged: function() {
this.model && (this.model.filter = this.route);
},
addTodoAction: function () {
addTodoAction: function() {
this.model.newItem(this.$['new-todo'].value);
// when polyfilling Object.observe, make sure we update immediately
Platform.flush();
this.$['new-todo'].value = '';
},
cancelAddTodoAction: function () {
cancelAddTodoAction: function() {
this.$['new-todo'].value = '';
},
itemChangedAction: function () {
if (this.model) {
this.model.itemsChanged();
}
itemChangedAction: function() {
this.model && this.model.itemsChanged();
},
destroyItemAction: function (e, detail) {
destroyItemAction: function(e, detail) {
this.model.destroyItem(detail);
},
toggleAllCompletedAction: function (e, detail, sender) {
toggleAllCompletedAction: function(e, detail, sender) {
this.model.setItemsCompleted(sender.checked);
},
clearCompletedAction: function () {
clearCompletedAction: function() {
this.model.clearItems();
}
});
......
......@@ -4,25 +4,23 @@
<meta charset="utf-8">
<title>Polymer • TodoMVC</title>
<link rel="stylesheet" href="app/app.css">
<link rel="import" href="lib-elements/polymer-localstorage.html">
<script src="bower_components/platform/platform.js"></script>
<link rel="import" href="bower_components/polymer-localstorage/polymer-localstorage.html">
<link rel="import" href="elements/td-model.html">
<link rel="import" href="elements/td-todos.html">
</head>
<body>
<section id="todoapp">
<header id="header">
<h1>todos</h1>
</header>
<polymer-localstorage id="storage" name="todos-polymer"></polymer-localstorage>
<td-model id="model" storageId="storage"></td-model>
<td-todos modelId="model"></td-todos>
</section>
<header>
<h1>todos</h1>
</header>
<polymer-localstorage id="storage" name="todos-polymer"></polymer-localstorage>
<td-model id="model" storageId="storage"></td-model>
<td-todos modelId="model"></td-todos>
<footer id="info">
<p>Double-click to edit a todo</p>
<p>Created by <a href="http://www.polymer-project.org">The Polymer Authors</a></p>
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
<script src="bower_components/todomvc-common/base.js"></script>
<script src="bower_components/polymer/polymer.min.js"></script>
</body>
</html>
<script src="../bower_components/director/build/director.min.js"></script>
<polymer-element name="flatiron-director" attributes="route">
<script>
(function() {
var private_router;
Polymer('flatiron-director', {
ready: function() {
this.router.on(/(\w*)/, function(route) {
this.route = route;
}.bind(this));
this.asyncMethod(function() {
var initialRoute = this.router.getRoute(0);
this.route = initialRoute || '';
// flush to here to render the initial route synchronously.
Platform.flush();
});
},
get router() {
if (!private_router) {
private_router = new Router();
private_router.init();
}
return private_router;
},
routeChanged: function() {
this.fire('route', this.route);
}
});
})();
</script>
</polymer-element>
<!--
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.
-->
<!--
/**
* @module Polymer Elements
*/
/**
* polymer-localstorage provides access to localStorage.
*
* Example:
*
* <polymer-localstorage name="my-app-storage" value="{{value}}"></polymer-localstorage>
*
* @class polymer-localstorage
*/
-->
<polymer-element name="polymer-localstorage" attributes="name value useRaw">
<template>
<style>
@host {
* {
display: none;
}
}
</style>
</template>
<script>
Polymer('polymer-localstorage', {
useRaw: false,
ready: function() {
this.load();
},
valueChanged: function() {
this.save();
},
load: function() {
var s = window.localStorage.getItem(this.name);
if (s && !this.useRaw) {
this.value = JSON.parse(s);
} else {
this.value = s;
}
},
save: function() {
window.localStorage.setItem(this.name,
this.useRaw ? this.value : JSON.stringify(this.value));
}
});
</script>
</polymer-element>
<!--
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.
-->
<!--
/**
* @module Polymer Elements
*/
-->
<polymer-element name="polymer-selection" attributes="multi">
<template>
<style>
@host {
* {
display: none !important;
}
}
</style>
</template>
<script>
Polymer('polymer-selection', {
multi: false,
ready: function() {
this.clear();
},
clear: function() {
this.selection = [];
},
getSelection: function() {
return this.multi ? this.selection : this.selection[0];
},
isSelected: function(item) {
return this.selection.indexOf(item) >= 0;
},
setItemSelected: function(item, isSelected) {
if (item) {
if (isSelected) {
this.selection.push(item);
} else {
var i = this.selection.indexOf(item);
if (i >= 0) {
this.selection.splice(i, 1);
}
}
// TODO(sjmiles): consider replacing with summary
// notifications (asynchronous job)
this.asyncFire("polymer-select", {isSelected: isSelected, item: item});
}
},
select: function(item) {
if (this.multi) {
this.toggle(item);
} else if (this.getSelection() !== item) {
this.setItemSelected(this.getSelection(), false);
this.setItemSelected(item, true);
}
},
toggle: function(item) {
this.setItemSelected(item, !this.isSelected(item));
}
});
</script>
</polymer-element>
<!--
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.
-->
<!--
/**
* @module Polymer Elements
*/
/**
* polymer-selector is used to display a list of elements that can be selected.
* The attribute "selected" indicates which element is being selected.
* Tapping on the element to change selection would fire "polymer-activate"
* event.
*
* Example:
*
* <polymer-selector selected="0" on-polymer-activate="activateAction">
* <div>Item 1</div>
* <div>Item 2</div>
* <div>Item 3</div>
* </polymer-selector>
*
* polymer-selector is not styled. So one needs to use "selected" CSS class
* to style the selected element.
*
* <style>
* .item.polymer-selected {
* background: #eee;
* }
* </style>
* ...
* <polymer-selector>
* <div class="item">Item 1</div>
* <div class="item">Item 2</div>
* <div class="item">Item 3</div>
* </polymer-selector>
*
* @class polymer-selector
*/
/**
* Fired when an element is selected via tap.
*
* @event activate
* @param {Object} detail
* @param {Object} detail.item the selected element
*/
-->
<link rel="import" href="polymer-selection.html">
<polymer-element name="polymer-selector" on-tap="activateHandler" touch-action="none"
attributes="selected multi valueattr selectedClass setectedProperty selectedModel notap">
<template>
<polymer-selection id="selection" multi="{{multi}}" on-polymer-select="selectionSelect"></polymer-selection>
<content id="items" select="*"></content>
</template>
<script>
Polymer('polymer-selector', {
/**
* Gets or sets the selected element. Default is to use the index
* of the currently selected element.
*
* If you want a specific attribute value of the selected element to be
* used instead of index, set "valueattr" to that attribute name.
*
* Example:
*
* <polymer-selector valueattr="label" selected="foo">
* <div label="foo"></div>
* <div label="bar"></div>
* <div label="zot"></div>
* </polymer-selector>
*
* @attribute selected
* @type string
* @default null
*/
selected: null,
/**
* If true, multiple selections are allowed.
*
* @attribute multi
* @type boolean
* @default false
*/
multi: false,
/**
* Specifies the attribute to be used for "selected" attribute.
*
* @attribute valueattr
* @type string
* @default 'name'
*/
valueattr: 'name',
/**
* Specifies the CSS class to be used to add to the selected element.
*
* @attribute selectedClass
* @type string
* @default 'polymer-selected'
*/
selectedClass: 'polymer-selected',
/**
* Specifies the property to be used to set on the selected element
* to indicate its active state.
*
* @attribute selectedProperty
* @type string
* @default 'active'
*/
setectedProperty: 'active',
/**
* Returns the model associated with the selected element.
*
* @attribute selectedModel
* @type Object
* @default null
*/
selectedModel: null,
get items() {
var nodes = this.$.items.getDistributedNodes();
return Array.prototype.filter.call(nodes, function(n) {
return n && n.localName !== 'template';
});
},
get selection() {
return this.$.selection.getSelection();
},
selectedChanged: function() {
this.valueToSelection(this.selected);
},
valueToSelection: function(value) {
var item = this.items[this.valueToIndex(value)];
this.selectedItem = item;
this.$.selection.select(item);
this.updateSelectedModel();
},
updateSelectedModel: function() {
if (this.selectedItem) {
var t = this.selectedItem.templateInstance;
this.selectedModel = t ? t.model : undefined;
} else {
this.selectedModel = null;
}
},
valueToIndex: function(value) {
// find an item with value == value and return it's index
for (var i=0, items=this.items, c; (c=items[i]); i++) {
if (this.valueForNode(c) == value) {
return i;
}
}
// if no item found, the value itself is probably the index
return value;
},
valueForNode: function(node) {
return node[this.valueattr] || node.getAttribute(this.valueattr);
},
// events fired from <polymer-selection> object
selectionSelect: function(e, detail) {
if (detail.item) {
if (this.selectedClass) {
detail.item.classList.toggle(this.selectedClass, detail.isSelected);
}
if (this.setectedProperty) {
detail.item[this.setectedProperty] = detail.isSelected;
}
}
},
// event fired from host
activateHandler: function(e) {
if (!this.notap) {
var i = this.findDistributedTarget(e.target, this.items);
if (i >= 0) {
var selected = this.valueForNode(this.items[i]) || i;
if (this.multi) {
this.valueToSelection(selected);
} else {
this.selected = selected;
}
this.asyncFire('polymer-activate', {item: this.items[i]});
}
}
},
findDistributedTarget: function(target, nodes) {
// find first ancestor of target (including itself) that
// is in inNodes, if any
while (target && target != this) {
var i = Array.prototype.indexOf.call(nodes, target);
if (i >= 0) {
return i;
}
target = target.parentNode;
}
}
});
</script>
</polymer-element>
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