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

Updating Polymer app implementation

parent 019057d0
# Contributing See https://github.com/Polymer/polymer/blob/master/CONTRIBUTING.md
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.
...@@ -10,9 +10,9 @@ The [Polymer website](http://www.polymer-project.org) is a great resource for ge ...@@ -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: Here are some links you may find helpful:
* [Getting Started](http://www.polymer-project.org/getting-started.html) * [Getting Started](http://www.polymer-project.org/docs/start/everything.html)
* [FAQ](http://www.polymer-project.org/faq.html) * [FAQ](http://www.polymer-project.org/resources/faq.html)
* [Browser Compatibility](http://www.polymer-project.org/compatibility.html) * [Browser Compatibility](http://www.polymer-project.org/resources/compatibility.html)
Get help from Polymer devs and users: Get help from Polymer devs and users:
...@@ -23,13 +23,13 @@ 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: 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. * 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. * 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 ## 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 ## Running this sample
......
...@@ -9,7 +9,7 @@ body { ...@@ -9,7 +9,7 @@ body {
body { body {
font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif;
line-height: 1.4em; line-height: 1.4em;
background: #eaeaea url('../bower_components/todomvc-common/bg.png'); background: #eaeaea url('../components/todomvc-common/bg.png');
color: #4d4d4d; color: #4d4d4d;
width: 550px; width: 550px;
margin: 0 auto; margin: 0 auto;
......
{ {
"name": "todomvc-polymer", "name": "todomvc-template",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"todomvc-common": "~0.1.4", "todomvc-common": "~0.1.4",
"director": "*", "polymer-selector": "Polymer/polymer-selector",
"polymer": "*" "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 (exports) {
/*
* browser.js: Browser specific functionality for director.
*
* (C) 2011, Nodejitsu Inc.
* MIT LICENSE
*
*/
if (!Array.prototype.filter) {
Array.prototype.filter = function(filter, that) {
var other = [], v;
for (var i = 0, n = this.length; i < n; i++) {
if (i in this && filter.call(that, v = this[i], i, this)) {
other.push(v);
}
}
return other;
};
}
if (!Array.isArray){
Array.isArray = function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
}
var dloc = document.location;
function dlocHashEmpty() {
// Non-IE browsers return '' when the address bar shows '#'; Director's logic
// assumes both mean empty.
return dloc.hash === '' || dloc.hash === '#';
}
var listener = {
mode: 'modern',
hash: dloc.hash,
history: false,
check: function () {
var h = dloc.hash;
if (h != this.hash) {
this.hash = h;
this.onHashChanged();
}
},
fire: function () {
if (this.mode === 'modern') {
this.history === true ? window.onpopstate() : window.onhashchange();
}
else {
this.onHashChanged();
}
},
init: function (fn, history) {
var self = this;
this.history = history;
if (!Router.listeners) {
Router.listeners = [];
}
function onchange(onChangeEvent) {
for (var i = 0, l = Router.listeners.length; i < l; i++) {
Router.listeners[i](onChangeEvent);
}
}
//note IE8 is being counted as 'modern' because it has the hashchange event
if ('onhashchange' in window && (document.documentMode === undefined
|| document.documentMode > 7)) {
// At least for now HTML5 history is available for 'modern' browsers only
if (this.history === true) {
// There is an old bug in Chrome that causes onpopstate to fire even
// upon initial page load. Since the handler is run manually in init(),
// this would cause Chrome to run it twise. Currently the only
// workaround seems to be to set the handler after the initial page load
// http://code.google.com/p/chromium/issues/detail?id=63040
setTimeout(function() {
window.onpopstate = onchange;
}, 500);
}
else {
window.onhashchange = onchange;
}
this.mode = 'modern';
}
else {
//
// IE support, based on a concept by Erik Arvidson ...
//
var frame = document.createElement('iframe');
frame.id = 'state-frame';
frame.style.display = 'none';
document.body.appendChild(frame);
this.writeFrame('');
if ('onpropertychange' in document && 'attachEvent' in document) {
document.attachEvent('onpropertychange', function () {
if (event.propertyName === 'location') {
self.check();
}
});
}
window.setInterval(function () { self.check(); }, 50);
this.onHashChanged = onchange;
this.mode = 'legacy';
}
Router.listeners.push(fn);
return this.mode;
},
destroy: function (fn) {
if (!Router || !Router.listeners) {
return;
}
var listeners = Router.listeners;
for (var i = listeners.length - 1; i >= 0; i--) {
if (listeners[i] === fn) {
listeners.splice(i, 1);
}
}
},
setHash: function (s) {
// Mozilla always adds an entry to the history
if (this.mode === 'legacy') {
this.writeFrame(s);
}
if (this.history === true) {
window.history.pushState({}, document.title, s);
// Fire an onpopstate event manually since pushing does not obviously
// trigger the pop event.
this.fire();
} else {
dloc.hash = (s[0] === '/') ? s : '/' + s;
}
return this;
},
writeFrame: function (s) {
// IE support...
var f = document.getElementById('state-frame');
var d = f.contentDocument || f.contentWindow.document;
d.open();
d.write("<script>_hash = '" + s + "'; onload = parent.listener.syncHash;<script>");
d.close();
},
syncHash: function () {
// IE support...
var s = this._hash;
if (s != dloc.hash) {
dloc.hash = s;
}
return this;
},
onHashChanged: function () {}
};
var Router = exports.Router = function (routes) {
if (!(this instanceof Router)) return new Router(routes);
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(routes || {});
};
Router.prototype.init = function (r) {
var self = this;
this.handler = function(onChangeEvent) {
var newURL = onChangeEvent && onChangeEvent.newURL || window.location.hash;
var url = self.history === true ? self.getPath() : newURL.replace(/.*#/, '');
self.dispatch('on', url);
};
listener.init(this.handler, this.history);
if (this.history === false) {
if (dlocHashEmpty() && r) {
dloc.hash = r;
} else if (!dlocHashEmpty()) {
self.dispatch('on', dloc.hash.replace(/^#/, ''));
}
}
else {
var routeTo = dlocHashEmpty() && r ? r : !dlocHashEmpty() ? dloc.hash.replace(/^#/, '') : null;
if (routeTo) {
window.history.replaceState({}, document.title, routeTo);
}
// Router has been initialized, but due to the chrome bug it will not
// yet actually route HTML5 history state changes. Thus, decide if should route.
if (routeTo || this.run_in_init === true) {
this.handler();
}
}
return this;
};
Router.prototype.explode = function () {
var v = this.history === true ? this.getPath() : dloc.hash;
if (v.charAt(1) === '/') { v=v.slice(1) }
return v.slice(1, v.length).split("/");
};
Router.prototype.setRoute = function (i, v, val) {
var url = this.explode();
if (typeof i === 'number' && typeof v === 'string') {
url[i] = v;
}
else if (typeof val === 'string') {
url.splice(i, v, s);
}
else {
url = [i];
}
listener.setHash(url.join('/'));
return url;
};
//
// ### function insertEx(method, path, route, parent)
// #### @method {string} Method to insert the specific `route`.
// #### @path {Array} Parsed path to insert the `route` at.
// #### @route {Array|function} Route handlers to insert.
// #### @parent {Object} **Optional** Parent "routes" to insert into.
// insert a callback that will only occur once per the matched route.
//
Router.prototype.insertEx = function(method, path, route, parent) {
if (method === "once") {
method = "on";
route = function(route) {
var once = false;
return function() {
if (once) return;
once = true;
return route.apply(this, arguments);
};
}(route);
}
return this._insert(method, path, route, parent);
};
Router.prototype.getRoute = function (v) {
var ret = v;
if (typeof v === "number") {
ret = this.explode()[v];
}
else if (typeof v === "string"){
var h = this.explode();
ret = h.indexOf(v);
}
else {
ret = this.explode();
}
return ret;
};
Router.prototype.destroy = function () {
listener.destroy(this.handler);
return this;
};
Router.prototype.getPath = function () {
var path = window.location.pathname;
if (path.substr(0, 1) !== '/') {
path = '/' + path;
}
return path;
};
function _every(arr, iterator) {
for (var i = 0; i < arr.length; i += 1) {
if (iterator(arr[i], i, arr) === false) {
return;
}
}
}
function _flatten(arr) {
var flat = [];
for (var i = 0, n = arr.length; i < n; i++) {
flat = flat.concat(arr[i]);
}
return flat;
}
function _asyncEverySeries(arr, iterator, callback) {
if (!arr.length) {
return callback();
}
var completed = 0;
(function iterate() {
iterator(arr[completed], function(err) {
if (err || err === false) {
callback(err);
callback = function() {};
} else {
completed += 1;
if (completed === arr.length) {
callback();
} else {
iterate();
}
}
});
})();
}
function paramifyString(str, params, mod) {
mod = str;
for (var param in params) {
if (params.hasOwnProperty(param)) {
mod = params[param](str);
if (mod !== str) {
break;
}
}
}
return mod === str ? "([._a-zA-Z0-9-]+)" : mod;
}
function regifyString(str, params) {
var matches, last = 0, out = "";
while (matches = str.substr(last).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/)) {
last = matches.index + matches[0].length;
matches[0] = matches[0].replace(/^\*/, "([_.()!\\ %@&a-zA-Z0-9-]+)");
out += str.substr(0, matches.index) + matches[0];
}
str = out += str.substr(last);
var captures = str.match(/:([^\/]+)/ig), length;
if (captures) {
length = captures.length;
for (var i = 0; i < length; i++) {
str = str.replace(captures[i], paramifyString(captures[i], params));
}
}
return str;
}
function terminator(routes, delimiter, start, stop) {
var last = 0, left = 0, right = 0, start = (start || "(").toString(), stop = (stop || ")").toString(), i;
for (i = 0; i < routes.length; i++) {
var chunk = routes[i];
if (chunk.indexOf(start, last) > chunk.indexOf(stop, last) || ~chunk.indexOf(start, last) && !~chunk.indexOf(stop, last) || !~chunk.indexOf(start, last) && ~chunk.indexOf(stop, last)) {
left = chunk.indexOf(start, last);
right = chunk.indexOf(stop, last);
if (~left && !~right || !~left && ~right) {
var tmp = routes.slice(0, (i || 1) + 1).join(delimiter);
routes = [ tmp ].concat(routes.slice((i || 1) + 1));
}
last = (right > left ? right : left) + 1;
i = 0;
} else {
last = 0;
}
}
return routes;
}
Router.prototype.configure = function(options) {
options = options || {};
for (var i = 0; i < this.methods.length; i++) {
this._methods[this.methods[i]] = true;
}
this.recurse = options.recurse || this.recurse || false;
this.async = options.async || false;
this.delimiter = options.delimiter || "/";
this.strict = typeof options.strict === "undefined" ? true : options.strict;
this.notfound = options.notfound;
this.resource = options.resource;
this.history = options.html5history && this.historySupport || false;
this.run_in_init = this.history === true && options.run_handler_in_init !== false;
this.every = {
after: options.after || null,
before: options.before || null,
on: options.on || null
};
return this;
};
Router.prototype.param = function(token, matcher) {
if (token[0] !== ":") {
token = ":" + token;
}
var compiled = new RegExp(token, "g");
this.params[token] = function(str) {
return str.replace(compiled, matcher.source || matcher);
};
};
Router.prototype.on = Router.prototype.route = function(method, path, route) {
var self = this;
if (!route && typeof path == "function") {
route = path;
path = method;
method = "on";
}
if (Array.isArray(path)) {
return path.forEach(function(p) {
self.on(method, p, route);
});
}
if (path.source) {
path = path.source.replace(/\\\//ig, "/");
}
if (Array.isArray(method)) {
return method.forEach(function(m) {
self.on(m.toLowerCase(), path, route);
});
}
path = path.split(new RegExp(this.delimiter));
path = terminator(path, this.delimiter);
this.insert(method, this.scope.concat(path), route);
};
Router.prototype.dispatch = function(method, path, callback) {
var self = this, fns = this.traverse(method, path, this.routes, ""), invoked = this._invoked, after;
this._invoked = true;
if (!fns || fns.length === 0) {
this.last = [];
if (typeof this.notfound === "function") {
this.invoke([ this.notfound ], {
method: method,
path: path
}, callback);
}
return false;
}
if (this.recurse === "forward") {
fns = fns.reverse();
}
function updateAndInvoke() {
self.last = fns.after;
self.invoke(self.runlist(fns), self, callback);
}
after = this.every && this.every.after ? [ this.every.after ].concat(this.last) : [ this.last ];
if (after && after.length > 0 && invoked) {
if (this.async) {
this.invoke(after, this, updateAndInvoke);
} else {
this.invoke(after, this);
updateAndInvoke();
}
return true;
}
updateAndInvoke();
return true;
};
Router.prototype.invoke = function(fns, thisArg, callback) {
var self = this;
if (this.async) {
_asyncEverySeries(fns, function apply(fn, next) {
if (Array.isArray(fn)) {
return _asyncEverySeries(fn, apply, next);
} else if (typeof fn == "function") {
fn.apply(thisArg, fns.captures.concat(next));
}
}, function() {
if (callback) {
callback.apply(thisArg, arguments);
}
});
} else {
_every(fns, function apply(fn) {
if (Array.isArray(fn)) {
return _every(fn, apply);
} else if (typeof fn === "function") {
return fn.apply(thisArg, fns.captures || []);
} else if (typeof fn === "string" && self.resource) {
self.resource[fn].apply(thisArg, fns.captures || []);
}
});
}
};
Router.prototype.traverse = function(method, path, routes, regexp, filter) {
var fns = [], current, exact, match, next, that;
function filterRoutes(routes) {
if (!filter) {
return routes;
}
function deepCopy(source) {
var result = [];
for (var i = 0; i < source.length; i++) {
result[i] = Array.isArray(source[i]) ? deepCopy(source[i]) : source[i];
}
return result;
}
function applyFilter(fns) {
for (var i = fns.length - 1; i >= 0; i--) {
if (Array.isArray(fns[i])) {
applyFilter(fns[i]);
if (fns[i].length === 0) {
fns.splice(i, 1);
}
} else {
if (!filter(fns[i])) {
fns.splice(i, 1);
}
}
}
}
var newRoutes = deepCopy(routes);
newRoutes.matched = routes.matched;
newRoutes.captures = routes.captures;
newRoutes.after = routes.after.filter(filter);
applyFilter(newRoutes);
return newRoutes;
}
if (path === this.delimiter && routes[method]) {
next = [ [ routes.before, routes[method] ].filter(Boolean) ];
next.after = [ routes.after ].filter(Boolean);
next.matched = true;
next.captures = [];
return filterRoutes(next);
}
for (var r in routes) {
if (routes.hasOwnProperty(r) && (!this._methods[r] || this._methods[r] && typeof routes[r] === "object" && !Array.isArray(routes[r]))) {
current = exact = regexp + this.delimiter + r;
if (!this.strict) {
exact += "[" + this.delimiter + "]?";
}
match = path.match(new RegExp("^" + exact));
if (!match) {
continue;
}
if (match[0] && match[0] == path && routes[r][method]) {
next = [ [ routes[r].before, routes[r][method] ].filter(Boolean) ];
next.after = [ routes[r].after ].filter(Boolean);
next.matched = true;
next.captures = match.slice(1);
if (this.recurse && routes === this.routes) {
next.push([ routes.before, routes.on ].filter(Boolean));
next.after = next.after.concat([ routes.after ].filter(Boolean));
}
return filterRoutes(next);
}
next = this.traverse(method, path, routes[r], current);
if (next.matched) {
if (next.length > 0) {
fns = fns.concat(next);
}
if (this.recurse) {
fns.push([ routes[r].before, routes[r].on ].filter(Boolean));
next.after = next.after.concat([ routes[r].after ].filter(Boolean));
if (routes === this.routes) {
fns.push([ routes["before"], routes["on"] ].filter(Boolean));
next.after = next.after.concat([ routes["after"] ].filter(Boolean));
}
}
fns.matched = true;
fns.captures = next.captures;
fns.after = next.after;
return filterRoutes(fns);
}
}
}
return false;
};
Router.prototype.insert = function(method, path, route, parent) {
var methodType, parentType, isArray, nested, part;
path = path.filter(function(p) {
return p && p.length > 0;
});
parent = parent || this.routes;
part = path.shift();
if (/\:|\*/.test(part) && !/\\d|\\w/.test(part)) {
part = regifyString(part, this.params);
}
if (path.length > 0) {
parent[part] = parent[part] || {};
return this.insert(method, path, route, parent[part]);
}
if (!part && !path.length && parent === this.routes) {
methodType = typeof parent[method];
switch (methodType) {
case "function":
parent[method] = [ parent[method], route ];
return;
case "object":
parent[method].push(route);
return;
case "undefined":
parent[method] = route;
return;
}
return;
}
parentType = typeof parent[part];
isArray = Array.isArray(parent[part]);
if (parent[part] && !isArray && parentType == "object") {
methodType = typeof parent[part][method];
switch (methodType) {
case "function":
parent[part][method] = [ parent[part][method], route ];
return;
case "object":
parent[part][method].push(route);
return;
case "undefined":
parent[part][method] = route;
return;
}
} else if (parentType == "undefined") {
nested = {};
nested[method] = route;
parent[part] = nested;
return;
}
throw new Error("Invalid route context: " + parentType);
};
Router.prototype.extend = function(methods) {
var self = this, len = methods.length, i;
function extend(method) {
self._methods[method] = true;
self[method] = function() {
var extra = arguments.length === 1 ? [ method, "" ] : [ method ];
self.on.apply(self, extra.concat(Array.prototype.slice.call(arguments)));
};
}
for (i = 0; i < len; i++) {
extend(methods[i]);
}
};
Router.prototype.runlist = function(fns) {
var runlist = this.every && this.every.before ? [ this.every.before ].concat(_flatten(fns)) : _flatten(fns);
if (this.every && this.every.on) {
runlist.push(this.every.on);
}
runlist.captures = fns.captures;
runlist.source = fns.source;
return runlist;
};
Router.prototype.mount = function(routes, path) {
if (!routes || typeof routes !== "object" || Array.isArray(routes)) {
return;
}
var self = this;
path = path || [];
if (!Array.isArray(path)) {
path = path.split(self.delimiter);
}
function insertOrMount(route, local) {
var rename = route, parts = route.split(self.delimiter), routeType = typeof routes[route], isRoute = parts[0] === "" || !self._methods[parts[0]], event = isRoute ? "on" : rename;
if (isRoute) {
rename = rename.slice((rename.match(new RegExp(self.delimiter)) || [ "" ])[0].length);
parts.shift();
}
if (isRoute && routeType === "object" && !Array.isArray(routes[route])) {
local = local.concat(parts);
self.mount(routes[route], local);
return;
}
if (isRoute) {
local = local.concat(rename.split(self.delimiter));
local = terminator(local, self.delimiter);
}
self.insert(event, local, routes[route]);
}
for (var route in routes) {
if (routes.hasOwnProperty(route)) {
insertOrMount(route, path.slice(0));
}
}
};
}(typeof exports === "object" ? exports : window));
\ No newline at end of file
//
// 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.
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>
{
"project": {
"name": "Docs",
"description": "Docs"
},
"files": {
"../../polymer-selector/polymer-selector.html": {
"name": "../../polymer-selector/polymer-selector.html",
"modules": {
"Polymer Elements": 1
},
"classes": {
"polymer-selector": 1
},
"fors": {},
"namespaces": {}
}
},
"modules": {
"Polymer Elements": {
"name": "Polymer Elements",
"submodules": {},
"classes": {
"polymer-selector": 1
},
"fors": {},
"namespaces": {},
"tag": "module",
"file": "../../polymer-selector/polymer-selector.html",
"line": 10
}
},
"classes": {
"polymer-selector": {
"name": "polymer-selector",
"shortname": "polymer-selector",
"classitems": [],
"plugins": [],
"extensions": [],
"plugin_for": [],
"extension_for": [],
"module": "Polymer Elements",
"namespace": "",
"file": "../../polymer-selector/polymer-selector.html",
"line": 10,
"description": "polymer-selector is used to manage a list of elements that can be selected.\nThe attribute \"selected\" indicates which item element is being selected.\nThe attribute \"multi\" indicates if multiple items can be selected at once.\nTapping on the item element would fire \"polymer-activate\" event. Use\n\"polymer-select\" event to listen for selection changes.\n\nExample:\n\n <polymer-selector selected=\"0\">\n <div>Item 1</div>\n <div>Item 2</div>\n <div>Item 3</div>\n </polymer-selector>\n\npolymer-selector is not styled. So one needs to use \"polymer-selected\" CSS\nclass to style the selected element.\n\n <style>\n .item.polymer-selected {\n background: #eee;\n }\n </style>\n ...\n <polymer-selector>\n <div class=\"item\">Item 1</div>\n <div class=\"item\">Item 2</div>\n <div class=\"item\">Item 3</div>\n </polymer-selector>"
}
},
"classitems": [
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 42,
"description": "Fired when an item's selection state is changed. This event is fired both\nwhen an item is selected or deselected. The `isSelected` detail property\ncontains the selection state.",
"itemtype": "event",
"name": "polymer-select",
"params": [
{
"name": "detail",
"description": "",
"type": "Object",
"props": [
{
"name": "isSelected",
"description": "true for selection and false for deselection",
"type": "Boolean"
},
{
"name": "item",
"description": "the item element",
"type": "Object"
}
]
}
],
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 52,
"description": "Fired when an item element is tapped.",
"itemtype": "event",
"name": "polymer-activate",
"params": [
{
"name": "detail",
"description": "",
"type": "Object",
"props": [
{
"name": "item",
"description": "the item element",
"type": "Object"
}
]
}
],
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 71,
"description": "Gets or sets the selected element. Default to use the index\nof the item element.\n\nIf you want a specific attribute value of the element to be\nused instead of index, set \"valueattr\" to that attribute name.\n\nExample:\n\n <polymer-selector valueattr=\"label\" selected=\"foo\">\n <div label=\"foo\"></div>\n <div label=\"bar\"></div>\n <div label=\"zot\"></div>\n </polymer-selector>\n\nIn multi-selection this should be an array of values.\n\nExample:\n\n <polymer-selector id=\"selector\" valueattr=\"label\" multi>\n <div label=\"foo\"></div>\n <div label=\"bar\"></div>\n <div label=\"zot\"></div>\n </polymer-selector>\n\n this.$.selector.selected = ['foo', 'zot'];",
"itemtype": "attribute",
"name": "selected",
"type": "Object",
"default": "null",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 103,
"description": "If true, multiple selections are allowed.",
"itemtype": "attribute",
"name": "multi",
"type": "boolean",
"default": "false",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 111,
"description": "Specifies the attribute to be used for \"selected\" attribute.",
"itemtype": "attribute",
"name": "valueattr",
"type": "string",
"default": "'name'",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 119,
"description": "Specifies the CSS class to be used to add to the selected element.",
"itemtype": "attribute",
"name": "selectedClass",
"type": "string",
"default": "'polymer-selected'",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 127,
"description": "Specifies the property to be used to set on the selected element\nto indicate its active state.",
"itemtype": "attribute",
"name": "selectedProperty",
"type": "string",
"default": "'active'",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 136,
"description": "Returns the currently selected element. In multi-selection this returns\nan array of selected elements.",
"itemtype": "attribute",
"name": "selectedItem",
"type": "Object",
"default": "null",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 145,
"description": "In single selection, this returns the model associated with the\nselected element.",
"itemtype": "attribute",
"name": "selectedModel",
"type": "Object",
"default": "null",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 154,
"description": "In single selection, this returns the selected index.",
"itemtype": "attribute",
"name": "selectedIndex",
"type": "number",
"default": "-1",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 162,
"description": "The target element that contains items. If this is not set \npolymer-selector is the container.",
"itemtype": "attribute",
"name": "target",
"type": "Object",
"default": "null",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 171,
"description": "This can be used to query nodes from the target node to be used for \nselection items. Note this only works if the 'target' property is set.\n\nExample:\n\n <polymer-selector target=\"{{$.myForm}}\" itemsSelector=\"input[type=radio]\"></polymer-selector>\n <form id=\"myForm\">\n <label><input type=\"radio\" name=\"color\" value=\"red\"> Red</label> <br>\n <label><input type=\"radio\" name=\"color\" value=\"green\"> Green</label> <br>\n <label><input type=\"radio\" name=\"color\" value=\"blue\"> Blue</label> <br>\n <p>color = {{color}}</p>\n </form>",
"itemtype": "attribute",
"name": "itemSelector",
"type": "string",
"default": "''",
"class": "polymer-selector",
"module": "Polymer Elements"
},
{
"file": "../../polymer-selector/polymer-selector.html",
"line": 190,
"description": "The event that would be fired from the item element to indicate\nit is being selected.",
"itemtype": "attribute",
"name": "activateEvent",
"type": "string",
"default": "'tap'",
"class": "polymer-selector",
"module": "Polymer Elements"
}
],
"warnings": []
}
\ No newline at end of file
<!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
*/
/**
* polymer-selector is used to manage a list of elements that can be selected.
* The attribute "selected" indicates which item element is being selected.
* The attribute "multi" indicates if multiple items can be selected at once.
* Tapping on the item element would fire "polymer-activate" event. Use
* "polymer-select" event to listen for selection changes.
*
* Example:
*
* <polymer-selector selected="0">
* <div>Item 1</div>
* <div>Item 2</div>
* <div>Item 3</div>
* </polymer-selector>
*
* polymer-selector is not styled. So one needs to use "polymer-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
* @status stable
*/
/**
* 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
*/
/**
* Fired when an item element is tapped.
*
* @event polymer-activate
* @param {Object} detail
* @param {Object} detail.item the item element
*/
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../polymer-selection/polymer-selection.html">
<polymer-element name="polymer-selector"
attributes="selected multi valueattr selectedClass selectedProperty selectedAttribute selectedItem selectedModel selectedIndex notap target itemsSelector activateEvent">
<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 to use the index
* of the item element.
*
* If you want a specific attribute value of the 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>
*
* In multi-selection this should be an array of values.
*
* Example:
*
* <polymer-selector id="selector" valueattr="label" multi>
* <div label="foo"></div>
* <div label="bar"></div>
* <div label="zot"></div>
* </polymer-selector>
*
* this.$.selector.selected = ['foo', 'zot'];
*
* @attribute selected
* @type Object
* @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 ''
*/
selectedProperty: '',
/**
* Specifies the property to be used to set on the selected element
* to indicate its active state.
*
* @attribute selectedProperty
* @type string
* @default 'active'
*/
selectedAttribute: 'active',
/**
* Returns the currently selected element. In multi-selection this returns
* an array of selected elements.
*
* @attribute selectedItem
* @type Object
* @default null
*/
selectedItem: null,
/**
* In single selection, this returns the model associated with the
* selected element.
*
* @attribute selectedModel
* @type Object
* @default null
*/
selectedModel: null,
/**
* In single selection, this returns the selected index.
*
* @attribute selectedIndex
* @type number
* @default -1
*/
selectedIndex: -1,
/**
* The target element that contains items. If this is not set
* polymer-selector is the container.
*
* @attribute target
* @type Object
* @default null
*/
target: null,
/**
* This can be used to query nodes from the target node to be used for
* selection items. Note this only works if the 'target' property is set.
*
* Example:
*
* <polymer-selector target="{{$.myForm}}" itemsSelector="input[type=radio]"></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>
*
* @attribute itemSelector
* @type string
* @default ''
*/
itemsSelector: '',
/**
* The event that would be fired from the item element to indicate
* it is being selected.
*
* @attribute activateEvent
* @type string
* @default 'tap'
*/
activateEvent: 'tap',
notap: false,
ready: function() {
this.activateListener = this.activateHandler.bind(this);
this.observer = new MutationObserver(this.updateSelected.bind(this));
if (!this.target) {
this.target = this;
}
},
get items() {
var nodes = this.target !== this ? (this.itemsSelector ?
this.target.querySelectorAll(this.itemsSelector) :
this.target.children) : this.$.items.getDistributedNodes();
return Array.prototype.filter.call(nodes || [], function(n) {
return n && n.localName !== 'template';
});
},
targetChanged: function(old) {
if (old) {
this.removeListener(old);
this.observer.disconnect();
}
if (this.target) {
this.addListener(this.target);
this.observer.observe(this.target, {childList: true});
}
},
addListener: function(node) {
node.addEventListener(this.activateEvent, this.activateListener);
},
removeListener: function(node) {
node.removeEventListener(this.activateEvent, this.activateListener);
},
get selection() {
return this.$.selection.getSelection();
},
selectedChanged: function() {
this.updateSelected();
},
updateSelected: function() {
this.validateSelected();
if (this.multi) {
this.clearSelection();
this.selected && this.selected.forEach(function(s) {
this.valueToSelection(s);
}, this);
} else {
this.valueToSelection(this.selected);
}
},
validateSelected: function() {
// convert to an array for multi-selection
if (this.multi && !Array.isArray(this.selected) &&
this.selected !== null && this.selected !== undefined) {
this.selected = [this.selected];
}
},
clearSelection: function() {
if (this.multi) {
this.selection.slice().forEach(function(s) {
this.$.selection.setItemSelected(s, false);
}, this);
} else {
this.$.selection.setItemSelected(this.selection, false);
}
this.selectedItem = null;
this.$.selection.clear();
},
valueToSelection: function(value) {
var item = (value === null || value === undefined) ?
null : this.items[this.valueToIndex(value)];
this.$.selection.select(item);
},
updateSelectedItem: function() {
this.selectedItem = this.selection;
},
selectedItemChanged: function() {
if (this.selectedItem) {
var t = this.selectedItem.templateInstance;
this.selectedModel = t ? t.model : undefined;
} else {
this.selectedModel = null;
}
this.selectedIndex = this.selectedItem ?
parseInt(this.valueToIndex(this.selected)) : -1;
},
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) {
this.updateSelectedItem();
if (detail.item) {
this.applySelection(detail.item, detail.isSelected);
}
},
applySelection: function(item, isSelected) {
if (this.selectedClass) {
item.classList.toggle(this.selectedClass, isSelected);
}
if (this.selectedProperty) {
item[this.selectedProperty] = isSelected;
}
if (this.selectedAttribute && item.setAttribute) {
if (isSelected) {
item.setAttribute(this.selectedAttribute, '');
} else {
item.removeAttribute(this.selectedAttribute);
}
}
},
// event fired from host
activateHandler: function(e) {
if (!this.notap) {
var i = this.findDistributedTarget(e.target, this.items);
if (i >= 0) {
var item = this.items[i];
var s = this.valueForNode(item) || i;
if (this.multi) {
if (this.selected) {
this.addRemoveSelected(s);
} else {
this.selected = [s];
}
} else {
this.selected = s;
}
this.asyncFire('polymer-activate', {item: item});
}
}
},
addRemoveSelected: function(value) {
var i = this.selected.indexOf(value);
if (i >= 0) {
this.selected.splice(i, 1);
} else {
this.selected.push(value);
}
this.valueToSelection(value);
},
findDistributedTarget: function(target, nodes) {
// find first ancestor of target (including itself) that
// is in nodes, 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>
<!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
/**
* @license
* Copyright (c) 2012-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.
*/
// @version: 0.2.1
Polymer={},"function"==typeof window.Polymer&&(Polymer={}),function(a){function b(a,b){return a&&b&&Object.getOwnPropertyNames(b).forEach(function(c){var d=Object.getOwnPropertyDescriptor(b,c);d&&(Object.defineProperty(a,c,d),"function"==typeof d.value&&(d.value.nom=c))}),a}a.extend=b}(Polymer),function(a){function b(a,b,d){return a?a.stop():a=new c(this),a.go(b,d),a}var c=function(a){this.context=a,this.boundComplete=this.complete.bind(this)};c.prototype={go:function(a,b){this.callback=a;var c;b?(c=setTimeout(this.boundComplete,b),this.handle=function(){clearTimeout(c)}):(c=requestAnimationFrame(this.boundComplete),this.handle=function(){cancelAnimationFrame(c)})},stop:function(){this.handle&&(this.handle(),this.handle=null)},complete:function(){this.handle&&(this.stop(),this.callback.call(this.context))}},a.job=b}(Polymer),function(){var a={};HTMLElement.register=function(b,c){a[b]=c},HTMLElement.getPrototypeForTag=function(b){var c=b?a[b]:HTMLElement.prototype;return c||Object.getPrototypeOf(document.createElement(b))};var b=Event.prototype.stopPropagation;Event.prototype.stopPropagation=function(){this.cancelBubble=!0,b.apply(this,arguments)}}(Polymer),function(a){function b(a){var c=b.caller,g=c.nom,h=c._super;if(h||(g||(g=c.nom=e.call(this,c)),g||console.warn("called super() on a method not installed declaratively (has no .nom property)"),h=d(c,g,f(this))),h){var i=h[g];return i._super||d(i,g,h),i.apply(this,a||[])}}function c(a,b,c){for(;a;){if(a[b]!==c&&a[b])return a;a=f(a)}}function d(a,b,d){return a._super=c(d,b,a),a._super&&(a._super[b].nom=b),a._super}function e(a){for(var b=this.__proto__;b&&b!==HTMLElement.prototype;){for(var c,d=Object.getOwnPropertyNames(b),e=0,f=d.length;f>e&&(c=d[e]);e++){var g=Object.getOwnPropertyDescriptor(b,c);if("function"==typeof g.value&&g.value===a)return c}b=b.__proto__}}function f(a){return a.__proto__}a.super=b}(Polymer),function(a){function b(a,b){var d=typeof b;return b instanceof Date&&(d="date"),c[d](a,b)}var c={string:function(a){return a},date:function(a){return new Date(Date.parse(a)||Date.now())},"boolean":function(a){return""===a?!0:"false"===a?!1:!!a},number:function(a){var b=parseFloat(a);return 0===b&&(b=parseInt(a)),isNaN(b)?a:b},object:function(a,b){if(null===b)return a;try{return JSON.parse(a.replace(/'/g,'"'))}catch(c){return a}},"function":function(a,b){return b}};a.deserializeValue=b}(Polymer),function(a){var b=a.extend,c={};c.declaration={},c.instance={},c.publish=function(a,c){for(var d in a)b(c,a[d])},a.api=c}(Polymer),function(a){var b={async:function(a,b,c){Platform.flush(),b=b&&b.length?b:[b];var d=function(){(this[a]||a).apply(this,b)}.bind(this),e=c?setTimeout(d,c):requestAnimationFrame(d);return c?e:1/e},cancelAsync:function(a){1>a?cancelAnimationFrame(Math.round(1/a)):clearTimeout(a)},fire:function(a,b,c,d,e){var f=c||this,b=b||{},g=new CustomEvent(a,{bubbles:void 0!==d?d:!0,cancelable:void 0!==e?e:!0,detail:b});return f.dispatchEvent(g),g},asyncFire:function(){this.async("fire",arguments)},classFollows:function(a,b,c){b&&b.classList.remove(c),a&&a.classList.add(c)}},c=function(){},d={};b.asyncMethod=b.async,a.api.instance.utils=b,a.nop=c,a.nob=d}(Polymer),function(a){var b=window.logFlags||{},c="on-",d={EVENT_PREFIX:c,addHostListeners:function(){var a=this.eventDelegates;b.events&&Object.keys(a).length>0&&console.log("[%s] addHostListeners:",this.localName,a);var d,e,f=this;for(var g in a)e=c+g,(d=PolymerExpressions.prepareEventBinding(Path.get(a[g]),e,{resolveEventHandler:function(a,b){var c=b.getValueFrom(f);return c?c.bind(f):void 0}}))(this,this,!1)},dispatchMethod:function(a,c,d){if(a){b.events&&console.group("[%s] dispatch [%s]",a.localName,c);var e="function"==typeof c?c:a[c];e&&e[d?"apply":"call"](a,d),b.events&&console.groupEnd(),Platform.flush()}}};a.api.instance.events=d}(Polymer),function(a){var b={copyInstanceAttributes:function(){var a=this._instanceAttributes;for(var b in a)this.hasAttribute(b)||this.setAttribute(b,a[b])},takeAttributes:function(){if(this._publishLC)for(var a,b=0,c=this.attributes,d=c.length;(a=c[b])&&d>b;b++)this.attributeToProperty(a.name,a.value)},attributeToProperty:function(b,c){var b=this.propertyForAttribute(b);if(b){if(c&&c.search(a.bindPattern)>=0)return;var d=this[b],c=this.deserializeValue(c,d);c!==d&&(this[b]=c)}},propertyForAttribute:function(a){var b=this._publishLC&&this._publishLC[a];return b},deserializeValue:function(b,c){return a.deserializeValue(b,c)},serializeValue:function(a,b){return"boolean"===b?a?"":void 0:"object"!==b&&"function"!==b&&void 0!==a?a:void 0},reflectPropertyToAttribute:function(a){var b=typeof this[a],c=this.serializeValue(this[a],b);void 0!==c?this.setAttribute(a,c):"boolean"===b&&this.removeAttribute(a)}};a.api.instance.attributes=b}(Polymer),function(a){function b(a,b,d){c.bind&&console.log(e,inB.localName||"object",inPath,a.localName,b);var f=d.discardChanges();return(null===f||void 0===f)&&d.setValue(a[b]),Observer.defineComputedProperty(a,b,d)}var c=window.logFlags||{},d={observeProperties:function(){var a=this._observeNames,b=this._publishNames;if(a&&a.length||b&&b.length){for(var c,d=this._propertyObserver=new CompoundObserver,e=0,f=a.length;f>e&&(c=a[e]);e++){d.addPath(this,c);var g=Object.getOwnPropertyDescriptor(this.__proto__,c);g&&g.value&&this.observeArrayValue(c,g.value,null)}for(var c,e=0,f=b.length;f>e&&(c=b[e]);e++)this.observe&&void 0!==this.observe[c]||d.addPath(this,c);d.open(this.notifyPropertyChanges,this)}},notifyPropertyChanges:function(a,b,c){var d,e,f={};for(var g in b)d=c[2*g+1],void 0!==this.publish[d]&&this.reflectPropertyToAttribute(d),e=this.observe[d],e&&(this.observeArrayValue(d,a[g],b[g]),f[e]||(f[e]=!0,this.invokeMethod(e,[b[g],a[g],arguments])))},observeArrayValue:function(a,b,d){var e=this.observe[a];if(e&&(Array.isArray(d)&&(c.observe&&console.log("[%s] observeArrayValue: unregister observer [%s]",this.localName,a),this.unregisterObserver(a+"__array")),Array.isArray(b))){c.observe&&console.log("[%s] observeArrayValue: register observer [%s]",this.localName,a,b);var f=new ArrayObserver(b);f.open(function(a,b){this.invokeMethod(e,[b])},this),this.registerObserver(a+"__array",f)}},bindProperty:function(a,c){return b(this,a,c)},unbindAllProperties:function(){this._propertyObserver&&this._propertyObserver.close(),this.unregisterObservers()},unbindProperty:function(a){return this.unregisterObserver(a)},invokeMethod:function(a,b){var c=this[a]||a;"function"==typeof c&&c.apply(this,b)},registerObserver:function(a,b){var c=this._observers||(this._observers={});c[a]=b},unregisterObserver:function(a){var b=this._observers;return b&&b[a]?(b[a].close(),b[a]=null,!0):void 0},unregisterObservers:function(){if(this._observers){for(var a,b,c=Object.keys(this._observers),d=0,e=c.length;e>d&&(a=c[d]);d++)b=this._observers[a],b.close();this._observers={}}}},e="[%s]: bindProperties: [%s] to [%s].[%s]";a.api.instance.properties=d}(Polymer),function(a){function b(a){for(;a.parentNode;){if(a.lightDomController)return a;a=a.parentNode}return a.host}function c(a){e(a,d)}function d(a){a.unbindAll()}function e(a,b){if(a){b(a);for(var c=a.firstChild;c;c=c.nextSibling)e(c,b)}}var f=window.logFlags||0,g=(a.api.instance.events,new PolymerExpressions);g.resolveEventHandler=function(a,c,d){var e=b(d);if(e){var f=c.getValueFrom(e);if(f)return f.bind(e)}};var h={syntax:g,instanceTemplate:function(a){return a.createInstance(this,this.syntax)},bind:function(a,b){this._elementPrepared||this.prepareElement();var c=this.propertyForAttribute(a);if(c){this.unbind(a);var d=this.bindProperty(c,b);return d.path=b.path_,this.reflectPropertyToAttribute(c),this.bindings[a]=d}return this.mixinSuper(arguments)},asyncUnbindAll:function(){this._unbound||(f.unbind&&console.log("[%s] asyncUnbindAll",this.localName),this._unbindAllJob=this.job(this._unbindAllJob,this.unbindAll,0))},unbindAll:function(){if(!this._unbound){this.unbindAllProperties(),this.super();for(var a=this.shadowRoot;a;)c(a),a=a.olderShadowRoot;this._unbound=!0}},cancelUnbindAll:function(a){return this._unbound?void(f.unbind&&console.warn("[%s] already unbound, cannot cancel unbindAll",this.localName)):(f.unbind&&console.log("[%s] cancelUnbindAll",this.localName),this._unbindAllJob&&(this._unbindAllJob=this._unbindAllJob.stop()),void(a||e(this.shadowRoot,function(a){a.cancelUnbindAll&&a.cancelUnbindAll()})))}},i=/\{\{([^{}]*)}}/;a.bindPattern=i,a.api.instance.mdv=h}(Polymer),function(a){function b(a){return a.hasOwnProperty("PolymerBase")}function c(){}var d=0,e={PolymerBase:!0,job:Polymer.job,"super":Polymer.super,created:function(){},ready:function(){},createdCallback:function(){this.created(),(this.ownerDocument.defaultView||this.alwaysPrepare||d>0)&&this.prepareElement()},prepareElement:function(){this._elementPrepared=!0,this.shadowRoots={},this.observeProperties(),this.copyInstanceAttributes(),this.takeAttributes(),this.addHostListeners(),d++,this.parseDeclarations(this.__proto__),d--,this.removeAttribute("unresolved"),this.ready()},attachedCallback:function(){this._elementPrepared||this.prepareElement(),this.cancelUnbindAll(!0),this.attached&&this.attached(),this.enteredView&&this.enteredView(),this.hasBeenAttached||(this.hasBeenAttached=!0,this.domReady&&this.async("domReady"))},detachedCallback:function(){this.preventDispose||this.asyncUnbindAll(),this.detached&&this.detached(),this.leftView&&this.leftView()},enteredViewCallback:function(){this.attachedCallback()},leftViewCallback:function(){this.detachedCallback()},enteredDocumentCallback:function(){this.attachedCallback()},leftDocumentCallback:function(){this.detachedCallback()},parseDeclarations:function(a){a&&a.element&&(this.parseDeclarations(a.__proto__),a.parseDeclaration.call(this,a.element))},parseDeclaration:function(a){var b=this.fetchTemplate(a);if(b){var c=this.shadowFromTemplate(b);this.shadowRoots[a.name]=c}},fetchTemplate:function(a){return a.querySelector("template")},shadowFromTemplate:function(a){if(a){var b=this.createShadowRoot();b.resetStyleInheritance=this.resetStyleInheritance;var c=this.instanceTemplate(a);return b.appendChild(c),this.shadowRootReady(b,a),b}},lightFromTemplate:function(a){if(a){this.lightDomController=!0;var b=this.instanceTemplate(a);return this.appendChild(b),this.shadowRootReady(this,a),b}},shadowRootReady:function(a){this.marshalNodeReferences(a),PointerGestures.register(a)},marshalNodeReferences:function(a){var b=this.$=this.$||{};if(a)for(var c,d=a.querySelectorAll("[id]"),e=0,f=d.length;f>e&&(c=d[e]);e++)b[c.id]=c},attributeChangedCallback:function(a){"class"!==a&&"style"!==a&&this.attributeToProperty(a,this.getAttribute(a)),this.attributeChanged&&this.attributeChanged.apply(this,arguments)},onMutation:function(a,b){var c=new MutationObserver(function(a){b.call(this,c,a),c.disconnect()}.bind(this));c.observe(a,{childList:!0,subtree:!0})}};c.prototype=e,e.constructor=c,a.Base=c,a.isBase=b,a.api.instance.base=e}(Polymer),function(a){function b(a){return a.__proto__}function c(a,b){var c="",d=!1;b&&(c=b.localName,d=b.hasAttribute("is"));var e=Platform.ShadowCSS.makeScopeSelector(c,d);return Platform.ShadowCSS.shimCssText(a,e)}var d=(window.logFlags||{},"element"),e="controller",f={STYLE_SCOPE_ATTRIBUTE:d,installControllerStyles:function(){var a=this.findStyleScope();if(a&&!this.scopeHasNamedStyle(a,this.localName)){for(var c=b(this),d="";c&&c.element;)d+=c.element.cssTextForScope(e),c=b(c);d&&this.installScopeCssText(d,a)}},installScopeStyle:function(a,b){var c=this.findStyleScope(),b=b||"";if(c&&!this.scopeHasNamedStyle(c,this.localName+b)){var d="";if(a instanceof Array)for(var e,f=0,g=a.length;g>f&&(e=a[f]);f++)d+=e.textContent+"\n\n";else d=a.textContent;this.installScopeCssText(d,c,b)}},installScopeCssText:function(a,b,d){if(b=b||this.findStyleScope(),d=d||"",b){window.ShadowDOMPolyfill&&(a=c(a,b.host));var f=this.element.cssTextToScopeStyle(a,e);Polymer.applyStyleToScope(f,b),b._scopeStyles[this.localName+d]=!0}},findStyleScope:function(){for(var a=this;a.parentNode;)a=a.parentNode;return a},scopeHasNamedStyle:function(a,b){return a._scopeStyles=a._scopeStyles||{},a._scopeStyles[b]}};a.api.instance.styles=f}(Polymer),function(a){function b(a,b){if(f[a])throw"Already registered (Polymer) prototype for element "+a;e(a,b),d(a)}function c(a,b){h[a]=b}function d(a){h[a]&&(h[a].registerWhenReady(),delete h[a])}function e(a,b){return i[a]=b||{}}function f(a){return i[a]}var g=a.extend,h=(a.api,{}),i={};a.getRegisteredPrototype=f,a.waitingForPrototype=c,window.Polymer=b,g(Polymer,a);var j=Platform.deliverDeclarations();if(j)for(var k,l=0,m=j.length;m>l&&(k=j[l]);l++)b.apply(null,k)}(Polymer),function(a){var b={resolveElementPaths:function(a){Platform.urlResolver.resolveDom(a)},addResolvePathApi:function(){var a=this.getAttribute("assetpath")||"",b=new URL(a,this.ownerDocument.baseURI);this.prototype.resolvePath=function(a,c){var d=new URL(a,c||b);return d.href}}};a.api.declaration.path=b}(Polymer),function(a){function b(a,b){var c=new URL(a.getAttribute("href"),b).href;return"@import '"+c+"';"}function c(a,b){if(a){b===document&&(b=document.head),window.ShadowDOMPolyfill&&(b=document.head);var c=d(a.textContent),e=a.getAttribute(h);e&&c.setAttribute(h,e),b.appendChild(c)}}function d(a,b){b=b||document,b=b.createElement?b:b.ownerDocument;var c=b.createElement("style");return c.textContent=a,c}function e(a){return a&&a.__resource||""}function f(a,b){return p?p.call(a,b):void 0}var g=(window.logFlags||{},a.api.instance.styles),h=g.STYLE_SCOPE_ATTRIBUTE,i="style",j="@import",k="link[rel=stylesheet]",l="global",m="polymer-scope",n={loadStyles:function(a){var b=this.templateContent();b&&this.convertSheetsToStyles(b);var c=this.findLoadableStyles(b);c.length?Platform.styleResolver.loadStyles(c,a):a&&a()},convertSheetsToStyles:function(a){for(var c,e,f=a.querySelectorAll(k),g=0,h=f.length;h>g&&(c=f[g]);g++)e=d(b(c,this.ownerDocument.baseURI),this.ownerDocument),this.copySheetAttributes(e,c),c.parentNode.replaceChild(e,c)},copySheetAttributes:function(a,b){for(var c,d=0,e=b.attributes,f=e.length;(c=e[d])&&f>d;d++)"rel"!==c.name&&"href"!==c.name&&a.setAttribute(c.name,c.value)},findLoadableStyles:function(a){var b=[];if(a)for(var c,d=a.querySelectorAll(i),e=0,f=d.length;f>e&&(c=d[e]);e++)c.textContent.match(j)&&b.push(c);return b},installSheets:function(){this.cacheSheets(),this.cacheStyles(),this.installLocalSheets(),this.installGlobalStyles()},cacheSheets:function(){this.sheets=this.findNodes(k),this.sheets.forEach(function(a){a.parentNode&&a.parentNode.removeChild(a)})},cacheStyles:function(){this.styles=this.findNodes(i+"["+m+"]"),this.styles.forEach(function(a){a.parentNode&&a.parentNode.removeChild(a)})},installLocalSheets:function(){var a=this.sheets.filter(function(a){return!a.hasAttribute(m)}),b=this.templateContent();if(b){var c="";if(a.forEach(function(a){c+=e(a)+"\n"}),c){var f=d(c,this.ownerDocument);b.insertBefore(f,b.firstChild)}}},findNodes:function(a,b){var c=this.querySelectorAll(a).array(),d=this.templateContent();if(d){var e=d.querySelectorAll(a).array();c=c.concat(e)}return b?c.filter(b):c},templateContent:function(){var a=this.querySelector("template");return a&&templateContent(a)},installGlobalStyles:function(){var a=this.styleForScope(l);c(a,document.head)},cssTextForScope:function(a){var b="",c="["+m+"="+a+"]",d=function(a){return f(a,c)},g=this.sheets.filter(d);g.forEach(function(a){b+=e(a)+"\n\n"});var h=this.styles.filter(d);return h.forEach(function(a){b+=a.textContent+"\n\n"}),b},styleForScope:function(a){var b=this.cssTextForScope(a);return this.cssTextToScopeStyle(b,a)},cssTextToScopeStyle:function(a,b){if(a){var c=d(a);return c.setAttribute(h,this.getAttribute("name")+"-"+b),c}}},o=HTMLElement.prototype,p=o.matches||o.matchesSelector||o.webkitMatchesSelector||o.mozMatchesSelector;a.api.declaration.styles=n,a.applyStyleToScope=c}(Polymer),function(a){var b=(window.logFlags||{},a.api.instance.events),c=b.EVENT_PREFIX,d={parseHostEvents:function(){var a=this.prototype.eventDelegates;this.addAttributeDelegates(a)},addAttributeDelegates:function(a){for(var b,c=0;b=this.attributes[c];c++)this.hasEventPrefix(b.name)&&(a[this.removeEventPrefix(b.name)]=b.value.replace("{{","").replace("}}","").trim())},hasEventPrefix:function(a){return a&&"o"===a[0]&&"n"===a[1]&&"-"===a[2]},removeEventPrefix:function(a){return a.slice(e)}},e=c.length;a.api.declaration.events=d}(Polymer),function(a){var b={inferObservers:function(a){var b,c=a.observe;for(var d in a)"Changed"===d.slice(-7)&&(c||(c=a.observe={}),b=d.slice(0,-7),c[b]=c[b]||d)},explodeObservers:function(a){var b=a.observe;if(b){var c={};for(var d in b)for(var e,f=d.split(" "),g=0;e=f[g];g++)c[e]=b[d];a.observe=c}},optimizePropertyMaps:function(a){if(a.observe){var b=a._observeNames=[];for(var c in a.observe)for(var d,e=c.split(" "),f=0;d=e[f];f++)b.push(d)}if(a.publish){var b=a._publishNames=[];for(var c in a.publish)b.push(c)}},publishProperties:function(a,b){var c=a.publish;c&&(this.requireProperties(c,a,b),a._publishLC=this.lowerCaseMap(c))},requireProperties:function(a,b,c){for(var d in a)void 0===b[d]&&void 0===c[d]&&(b[d]=a[d])},lowerCaseMap:function(a){var b={};for(var c in a)b[c.toLowerCase()]=c;return b}};a.api.declaration.properties=b}(Polymer),function(a){var b="attributes",c=/\s|,/,d={inheritAttributesObjects:function(a){this.inheritObject(a,"publishLC"),this.inheritObject(a,"_instanceAttributes")},publishAttributes:function(a,d){var e=this.getAttribute(b);if(e)for(var f,g=a.publish||(a.publish={}),h=e.split(c),i=0,j=h.length;j>i;i++)f=h[i].trim(),f&&void 0===g[f]&&void 0===d[f]&&(g[f]=null)},accumulateInstanceAttributes:function(){for(var a,b=this.prototype._instanceAttributes,c=this.attributes,d=0,e=c.length;e>d&&(a=c[d]);d++)this.isInstanceAttribute(a.name)&&(b[a.name]=a.value)},isInstanceAttribute:function(a){return!this.blackList[a]&&"on-"!==a.slice(0,3)},blackList:{name:1,"extends":1,constructor:1,noscript:1,assetpath:1,"cache-csstext":1}};d.blackList[b]=1,a.api.declaration.attributes=d}(Polymer),function(a){function b(a){if(!Object.__proto__){var b=Object.getPrototypeOf(a);a.__proto__=b,d(b)&&(b.__proto__=Object.getPrototypeOf(b))}}var c=a.api,d=a.isBase,e=a.extend,f={register:function(a,b){this.buildPrototype(a,b),this.registerPrototype(a,b),this.publishConstructor()},buildPrototype:function(b,c){var d=a.getRegisteredPrototype(b),e=this.generateBasePrototype(c);this.desugarBeforeChaining(d,e),this.prototype=this.chainPrototypes(d,e),this.desugarAfterChaining(b,c)},desugarBeforeChaining:function(a,b){a.element=this,this.publishAttributes(a,b),this.publishProperties(a,b),this.inferObservers(a),this.explodeObservers(a)},chainPrototypes:function(a,c){this.inheritMetaData(a,c);var d=this.chainObject(a,c);return b(d),d},inheritMetaData:function(a,b){this.inheritObject("observe",a,b),this.inheritObject("publish",a,b),this.inheritObject("_publishLC",a,b),this.inheritObject("_instanceAttributes",a,b),this.inheritObject("eventDelegates",a,b)},desugarAfterChaining:function(a,b){this.optimizePropertyMaps(this.prototype),this.installSheets(),this.resolveElementPaths(this),this.accumulateInstanceAttributes(),this.parseHostEvents(),this.addResolvePathApi(),window.ShadowDOMPolyfill&&Platform.ShadowCSS.shimStyling(this.templateContent(),a,b),this.prototype.registerCallback&&this.prototype.registerCallback(this)},publishConstructor:function(){var a=this.getAttribute("constructor");a&&(window[a]=this.ctor)},generateBasePrototype:function(a){var b=this.findBasePrototype(a);if(!b){var b=HTMLElement.getPrototypeForTag(a);b=this.ensureBaseApi(b),g[a]=b}return b},findBasePrototype:function(a){return g[a]},ensureBaseApi:function(a){if(a.PolymerBase)return a;var b=Object.create(a);return c.publish(c.instance,b),this.mixinMethod(b,a,c.instance.mdv,"bind"),b},mixinMethod:function(a,b,c,d){var e=function(a){return b[d].apply(this,a)};a[d]=function(){return this.mixinSuper=e,c[d].apply(this,arguments)}},inheritObject:function(a,b,c){var d=b[a]||{};b[a]=this.chainObject(d,c[a])},registerPrototype:function(a,b){var c={prototype:this.prototype},d=this.findTypeExtension(b);d&&(c.extends=d),HTMLElement.register(a,this.prototype),this.ctor=document.registerElement(a,c)},findTypeExtension:function(a){if(a&&a.indexOf("-")<0)return a;var b=this.findBasePrototype(a);return b.element?this.findTypeExtension(b.element.extends):void 0}},g={};f.chainObject=Object.__proto__?function(a,b){return a&&b&&a!==b&&(a.__proto__=b),a}:function(a,b){if(a&&b&&a!==b){var c=Object.create(b);a=e(c,a)}return a},c.declaration.prototype=f}(Polymer),function(a){function b(a){return document.contains(a)?g:f}function c(){return f.length?f[0]:g[0]}function d(a){e.waitToReady=!0,CustomElements.ready=!1,HTMLImports.whenImportsReady(function(){e.addReadyCallback(a),e.waitToReady=!1,e.check()})}var e={wait:function(a,b,c){return-1===this.indexOf(a)&&(this.add(a),a.__check=b,a.__go=c),0!==this.indexOf(a)},add:function(a){b(a).push(a)},indexOf:function(a){var c=b(a).indexOf(a);return c>=0&&document.contains(a)&&(c+=HTMLImports.useNative||HTMLImports.ready?f.length:1e9),c},go:function(a){var b=this.remove(a);b&&(b.__go.call(b),b.__check=b.__go=null,this.check())},remove:function(a){var c=this.indexOf(a);if(0===c)return b(a).shift()},check:function(){var a=this.nextElement();return a&&a.__check.call(a),this.canReady()?(this.ready(),!0):void 0},nextElement:function(){return c()},canReady:function(){return!this.waitToReady&&this.isEmpty()},isEmpty:function(){return!f.length&&!g.length},ready:function(){if(CustomElements.ready===!1&&(CustomElements.upgradeDocumentTree(document),CustomElements.ready=!0),h)for(var a;h.length;)(a=h.shift())()},addReadyCallback:function(a){a&&h.push(a)},waitToReady:!0},f=[],g=[],h=[];document.addEventListener("WebComponentsReady",function(){CustomElements.ready=!1}),a.queue=e,a.whenPolymerReady=d}(Polymer),function(a){function b(a,b){a?(document.head.appendChild(a),d(b)):b&&b()}function c(a,c){if(a&&a.length){for(var d,e,f=document.createDocumentFragment(),g=0,h=a.length;h>g&&(d=a[g]);g++)e=document.createElement("link"),e.rel="import",e.href=d,f.appendChild(e);b(f,c)}else c&&c()}var d=a.whenPolymerReady;a.import=c,a.importElements=b}(Polymer),function(a){function b(a){return Boolean(HTMLElement.getPrototypeForTag(a))}function c(a){return a&&a.indexOf("-")>=0}var d=a.extend,e=a.api,f=a.queue,g=a.whenPolymerReady,h=a.getRegisteredPrototype,i=a.waitingForPrototype,j=d(Object.create(HTMLElement.prototype),{createdCallback:function(){this.getAttribute("name")&&this.init()},init:function(){this.name=this.getAttribute("name"),this.extends=this.getAttribute("extends"),this.loadResources(),this.registerWhenReady()},registerWhenReady:function(){this.registered||this.waitingForPrototype(this.name)||this.waitingForQueue()||this.waitingForResources()||f.go(this)},_register:function(){c(this.extends)&&!b(this.extends)&&console.warn("%s is attempting to extend %s, an unregistered element or one that was not registered with Polymer.",this.name,this.extends),this.register(this.name,this.extends),this.registered=!0},waitingForPrototype:function(a){return h(a)?void 0:(i(a,this),this.handleNoScript(a),!0)},handleNoScript:function(a){if(this.hasAttribute("noscript")&&!this.noscript)if(this.noscript=!0,window.CustomElements&&!CustomElements.useNative)Polymer(a);else{var b=document.createElement("script");b.textContent="Polymer('"+a+"');",this.appendChild(b)}},waitingForResources:function(){return this._needsResources},waitingForQueue:function(){return f.wait(this,this.registerWhenReady,this._register)},loadResources:function(){this._needsResources=!0,this.loadStyles(function(){this._needsResources=!1,this.registerWhenReady()}.bind(this))}});e.publish(e.declaration,j),a.getRegisteredPrototype=h,g(function(){document.body.removeAttribute("unresolved"),document.dispatchEvent(new CustomEvent("polymer-ready",{bubbles:!0}))}),document.registerElement("polymer-element",{prototype:j})}(Polymer);
//# sourceMappingURL=polymer.js.map
\ 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> <script>
(function() { (function() {
var ENTER_KEY = 13; var ENTER_KEY = 13;
var ESC_KEY = 27; var ESC_KEY = 27;
Polymer('td-input', { Polymer('td-input', {
keypressAction: function (e, detail, sender) { keypressAction: function(e, detail, sender) {
// Listen for enter on keypress but esc on keyup, because // Listen for enter on keypress but esc on keyup, because
// IE doesn't fire keyup for enter. // IE doesn't fire keyup for enter.
if (e.keyCode === ENTER_KEY) { if (e.keyCode === ENTER_KEY) {
this.fire('td-input-commit'); this.fire('td-input-commit');
} }
}, },
keyupAction: function (e, detail, sender) { keyupAction: function(e, detail, sender) {
if (e.keyCode === ESC_KEY) { if (e.keyCode === ESC_KEY) {
this.fire('td-input-cancel'); this.fire('td-input-cancel');
} }
......
/* base.css overrides */ /* base.css overrides */
@host { :host {
.editing { .editing {
border-bottom: none; border-bottom: none;
padding: 0; padding: 0;
...@@ -124,7 +124,8 @@ label { ...@@ -124,7 +124,8 @@ label {
} }
.destroy:hover { .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); -webkit-transform: scale(1.3);
-moz-transform: scale(1.3); -moz-transform: scale(1.3);
-ms-transform: scale(1.3); -ms-transform: scale(1.3);
...@@ -147,11 +148,11 @@ label { ...@@ -147,11 +148,11 @@ label {
@media screen and (-webkit-min-device-pixel-ratio:0) { @media screen and (-webkit-min-device-pixel-ratio:0) {
.toggle { .toggle {
background: none; background: none;
/* /*
ShadowDOM Polyfill work around for webkit/blink bug ShadowDOM Polyfill work around for webkit/blink bug
https://code.google.com/p/chromium/issues/detail?id=251510 https://code.google.com/p/chromium/issues/detail?id=251510
*/ */
background-color: transparent; background-color: transparent;
} }
.toggle { .toggle {
......
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="td-input.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> <template>
<link rel="stylesheet" href="td-item.css"> <link rel="stylesheet" href="td-item.css">
<div class="view {{completed: item.completed; editing: editing}}" hidden?="{{editing}}" on-dblclick="editAction"> <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"> <input type="checkbox" class="toggle" checked="{{item.completed}}" on-click="{{itemChangeAction}}">
<label>{{item.title}}</label> <label>{{item.title}}</label>
<button class="destroy" on-click="destroyAction"></button> <button class="destroy" on-click="{{destroyAction}}"></button>
</div> </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> </template>
<script> <script>
(function () { (function() {
var ENTER_KEY = 13;
var ESC_KEY = 27;
Polymer('td-item', { Polymer('td-item', {
editing: false, editing: false,
editAction: function () { editAction: function() {
this.editing = true; this.editing = true;
this.$.edit.value = this.title = this.item.title;
// schedule focus for the end of microtask, when the input will be visible // schedule focus for the end of microtask, when the input will be visible
Platform.flush(); this.asyncMethod(function() {
this.asyncMethod(function () {
this.$.edit.focus(); this.$.edit.focus();
}); });
}, },
commitAction: function () { commitAction: function() {
this.title = this.$.edit.value;
if (this.editing) { if (this.editing) {
this.editing = false; this.editing = false;
this.item.title = this.title.trim(); this.item.title = this.item.title.trim();
if (this.item.title === '') { if (this.item.title === '') {
this.destroyAction(); this.destroyAction();
} }
......
<link rel="import" href="../bower_components/polymer/polymer.html">
<polymer-element name="td-model" attributes="filter items storageId"> <polymer-element name="td-model" attributes="filter items storageId">
<script> <script>
Polymer('td-model', { Polymer('td-model', {
...@@ -5,15 +7,15 @@ ...@@ -5,15 +7,15 @@
completedCount: 0, completedCount: 0,
activeCount: 0, activeCount: 0,
allCompleted: false, allCompleted: false,
ready: function () { ready: function() {
this.asyncMethod(function () { this.asyncMethod(function() {
this.items = this.items || []; this.items = this.items || [];
}); });
}, },
filterChanged: function () { filterChanged: function() {
this.filterItems(); this.filterItems();
}, },
itemsChanged: function () { itemsChanged: function() {
this.completedCount = this.completedCount =
this.items.filter(this.filters.completed).length; this.items.filter(this.filters.completed).length;
this.activeCount = this.items.length - this.completedCount; this.activeCount = this.items.length - this.completedCount;
...@@ -24,17 +26,15 @@ ...@@ -24,17 +26,15 @@
this.storage.save(); this.storage.save();
} }
}, },
storageIdChanged: function () { storageIdChanged: function() {
this.storage = document.querySelector('#' + this.storageId); this.storage = document.querySelector('#' + this.storageId);
if (this.storage) { this.storage && (this.items = this.storage.value);
this.items = this.storage.value;
}
}, },
filterItems: function () { filterItems: function() {
var fn = this.filters[this.filter]; var fn = this.filters[this.filter];
this.filtered = fn ? this.items.filter(fn) : this.items; this.filtered = fn ? this.items.filter(fn) : this.items;
}, },
newItem: function (title) { newItem: function(title) {
title = String(title).trim(); title = String(title).trim();
if (title) { if (title) {
var item = { var item = {
...@@ -45,27 +45,27 @@ ...@@ -45,27 +45,27 @@
this.itemsChanged(); this.itemsChanged();
} }
}, },
destroyItem: function (item) { destroyItem: function(item) {
var i = this.items.indexOf(item); var i = this.items.indexOf(item);
if (i >= 0) { if (i >= 0) {
this.items.splice(i, 1); this.items.splice(i, 1);
} }
this.itemsChanged(); this.itemsChanged();
}, },
clearItems: function () { clearItems: function(){
this.items = this.items.filter(this.filters.active); this.items = this.items.filter(this.filters.active);
}, },
setItemsCompleted: function (completed) { setItemsCompleted: function(completed) {
this.items.forEach(function (item) { this.items.forEach(function(item) {
item.completed = completed; item.completed = completed;
}); });
this.itemsChanged(); this.itemsChanged();
}, },
filters: { filters: {
active: function (item) { active: function(item) {
return !item.completed; return !item.completed;
}, },
completed: function (item) { completed: function(item) {
return item.completed; return item.completed;
} }
} }
......
/* base.css overrides */ /* base.css overrides */
@host { :host {
* { * {
display: block; display: block;
position: relative; position: relative;
} }
...@@ -17,6 +17,7 @@ button { ...@@ -17,6 +17,7 @@ button {
font-family: inherit; font-family: inherit;
color: inherit; color: inherit;
-webkit-appearance: none; -webkit-appearance: none;
/*-moz-appearance: none;*/
-ms-appearance: none; -ms-appearance: none;
-o-appearance: none; -o-appearance: none;
appearance: none; appearance: none;
...@@ -39,6 +40,7 @@ input:-ms-input-placeholder, #new-todo:-ms-input-placeholder { ...@@ -39,6 +40,7 @@ input:-ms-input-placeholder, #new-todo:-ms-input-placeholder {
#todoapp { #todoapp {
background: #fff; background: #fff;
background: rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.9);
/*margin: 130px 0 40px 0;*/
margin: 0 0 40px 0; margin: 0 0 40px 0;
border: 1px solid #ccc; border: 1px solid #ccc;
position: relative; position: relative;
...@@ -245,11 +247,11 @@ label[for='toggle-all'] { ...@@ -245,11 +247,11 @@ label[for='toggle-all'] {
@media screen and (-webkit-min-device-pixel-ratio:0) { @media screen and (-webkit-min-device-pixel-ratio:0) {
#toggle-all { #toggle-all {
background: none; background: none;
/* /*
ShadowDOM Polyfill work around for webkit/blink bug ShadowDOM Polyfill work around for webkit/blink bug
https://code.google.com/p/chromium/issues/detail?id=251510 https://code.google.com/p/chromium/issues/detail?id=251510
*/ */
background-color: transparent; background-color: transparent;
} }
#toggle-all { #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-input.html">
<link rel="import" href="td-item.html"> <link rel="import" href="td-item.html">
...@@ -9,12 +11,12 @@ ...@@ -9,12 +11,12 @@
<flatiron-director route="{{route}}"></flatiron-director> <flatiron-director route="{{route}}"></flatiron-director>
<section id="todoapp"> <section id="todoapp">
<header id="header"> <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> </header>
<section id="main" hidden?="{{model.items.length == 0}}"> <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> <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}}"> <template repeat="{{model.filtered}}">
<li is="td-item" item="{{}}"></li> <li is="td-item" item="{{}}"></li>
</template> </template>
...@@ -33,45 +35,41 @@ ...@@ -33,45 +35,41 @@
<a href="../#/completed">Completed</a> <a href="../#/completed">Completed</a>
</li> </li>
</polymer-selector> </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> </footer>
</section> </section>
</template> </template>
<script> <script>
(function () { (function() {
var ENTER_KEY = 13; var ENTER_KEY = 13;
var ESC_KEY = 27; var ESC_KEY = 27;
Polymer('td-todos', { Polymer('td-todos', {
modelIdChanged: function () { modelIdChanged: function() {
this.model = document.querySelector('#' + this.modelId); this.model = document.querySelector('#' + this.modelId);
}, },
routeChanged: function () { routeChanged: function() {
if (this.model) { this.model && (this.model.filter = this.route);
this.model.filter = this.route;
}
}, },
addTodoAction: function () { addTodoAction: function() {
this.model.newItem(this.$['new-todo'].value); this.model.newItem(this.$['new-todo'].value);
// when polyfilling Object.observe, make sure we update immediately // when polyfilling Object.observe, make sure we update immediately
Platform.flush(); Platform.flush();
this.$['new-todo'].value = ''; this.$['new-todo'].value = '';
}, },
cancelAddTodoAction: function () { cancelAddTodoAction: function() {
this.$['new-todo'].value = ''; this.$['new-todo'].value = '';
}, },
itemChangedAction: function () { itemChangedAction: function() {
if (this.model) { this.model && this.model.itemsChanged();
this.model.itemsChanged();
}
}, },
destroyItemAction: function (e, detail) { destroyItemAction: function(e, detail) {
this.model.destroyItem(detail); this.model.destroyItem(detail);
}, },
toggleAllCompletedAction: function (e, detail, sender) { toggleAllCompletedAction: function(e, detail, sender) {
this.model.setItemsCompleted(sender.checked); this.model.setItemsCompleted(sender.checked);
}, },
clearCompletedAction: function () { clearCompletedAction: function() {
this.model.clearItems(); this.model.clearItems();
} }
}); });
......
...@@ -4,25 +4,23 @@ ...@@ -4,25 +4,23 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>Polymer • TodoMVC</title> <title>Polymer • TodoMVC</title>
<link rel="stylesheet" href="app/app.css"> <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-model.html">
<link rel="import" href="elements/td-todos.html"> <link rel="import" href="elements/td-todos.html">
</head> </head>
<body> <body>
<section id="todoapp"> <header>
<header id="header"> <h1>todos</h1>
<h1>todos</h1> </header>
</header> <polymer-localstorage id="storage" name="todos-polymer"></polymer-localstorage>
<polymer-localstorage id="storage" name="todos-polymer"></polymer-localstorage> <td-model id="model" storageId="storage"></td-model>
<td-model id="model" storageId="storage"></td-model> <td-todos modelId="model"></td-todos>
<td-todos modelId="model"></td-todos>
</section>
<footer id="info"> <footer id="info">
<p>Double-click to edit a todo</p> <p>Double-click to edit a todo</p>
<p>Created by <a href="http://www.polymer-project.org">The Polymer Authors</a></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> <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer> </footer>
<script src="bower_components/todomvc-common/base.js"></script> <script src="bower_components/todomvc-common/base.js"></script>
<script src="bower_components/polymer/polymer.min.js"></script>
</body> </body>
</html> </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