Skip to content

Commit 167496d

Browse files
committed
Add initial renamed polymer-filters.
1 parent c784423 commit 167496d

13 files changed

+382
-3
lines changed

.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "../"
3+
}

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
polymer-filters
2-
===============
1+
seed-element
2+
================
33

4-
A collection of Polymer filters for formatting values of expressions for display to users
4+
See the [component page](http://polymerlabs.github.io/seed-element) for more information.
5+
6+
## Getting Started
7+
8+
We've put together a [guide to seed-element](http://www.polymer-project.org/docs/start/reusableelements.html) to help get you rolling.

bower.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "polymer-filters",
3+
"version": "0.0.1",
4+
"authors": [
5+
"Addy Osmani <[email protected]>"
6+
],
7+
"description": "Element providing solution to no problem in particular.",
8+
"keywords": "filters, polymer, web-components",
9+
"main": "polymer-filters.html",
10+
"license": "Apache 2.0",
11+
"homepage": "https://github.com/addyosmani/polymer-filters/",
12+
"ignore": [
13+
"**/.*"
14+
],
15+
"dependencies": {
16+
"polymer": "Polymer/polymer#~0.2.4",
17+
"chai": "~1.9.1",
18+
"mocha": "~1.19.0"
19+
}
20+
}

demo.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
5+
<title>polymer-filters Demo</title>
6+
7+
<script src="../platform/platform.js"></script>
8+
<link rel="import" href="polymer-filters.html">
9+
10+
</head>
11+
<body unresolved>
12+
13+
<p>An example of using <code>&lt;polymer-filters></code>:</p>
14+
15+
<polymer-filters>
16+
<h2>Hello polymer-filters</h2>
17+
</polymer-filters>
18+
19+
</body>
20+
</html>

index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<!--
3+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
5+
The complete set of authors may be found at http://polymer.github.io/AUTHORS
6+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
7+
Code distributed by Google as part of the polymer project is also
8+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
9+
-->
10+
<html>
11+
<head>
12+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
13+
<script src="../platform/platform.js"></script>
14+
<link rel="import" href="../polymer/polymer.html">
15+
<link rel="import" href="../core-component-page/core-component-page.html">
16+
17+
</head>
18+
<body unresolved>
19+
20+
<core-component-page></core-component-page>
21+
22+
</body>
23+
</html>

polymer-filters.css

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
:host {
2+
display: block;
3+
}
4+
5+
/* To ensure your styling works under the Shadow DOM polyfill, see
6+
www.polymer-project.org/docs/polymer/styling.html#directives */
7+
polyfill-next-selector { content: ':host > h2'; }
8+
::content h2 {
9+
color: blue;
10+
}

polymer-filters.html

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<link rel="import" href="../polymer/polymer.html">
2+
3+
<!--
4+
Element providing solution to no problem in particular.
5+
6+
##### Example
7+
8+
<polymer-filters></polymer-filters>
9+
10+
@element polymer-filters
11+
@blurb Element providing solution to no problem in particular.
12+
@status alpha
13+
@homepage http://polymerlabs.github.io/polymer-filters
14+
-->
15+
<polymer-element name="polymer-filters" attributes="notitle author">
16+
17+
<template>
18+
19+
<link rel="stylesheet" href="polymer-filters.css" />
20+
21+
<h1>Hello from polymer-filters</h1>
22+
<content></content>
23+
24+
</template>
25+
26+
<script>
27+
28+
Polymer('polymer-filters', {
29+
/**
30+
* The `author` attribute sets an initial author
31+
*
32+
* @attribute author
33+
* @type string
34+
*/
35+
author: 'Dimitri Glazkov',
36+
37+
/**
38+
* `fancy` is a property that does something fancy.
39+
*
40+
* @property fancy
41+
* @type bool
42+
*/
43+
fancy: false,
44+
45+
ready: function() {
46+
// Ready is a lifecycle callback.
47+
// You can do setup work in here.
48+
// More info: http://www.polymer-project.org/docs/polymer/polymer.html#lifecyclemethods
49+
},
50+
51+
/**
52+
* The `sayHello` method will return a greeting
53+
*
54+
* @method sayHello
55+
* @return {String} Returns a string greeting.
56+
* @param {String} greeting Pass in a specific greeting
57+
*/
58+
sayHello: function(greeting) {
59+
var response = greeting || 'Hello World!';
60+
return 'polymer-filters says, ' + response;
61+
},
62+
63+
/**
64+
* The `polymer-filters-lasers-success` event is fired whenever we
65+
* call fireLasers.
66+
*
67+
* @event polymer-filters-lasers-success
68+
*/
69+
70+
/**
71+
* The `fireLasers` method will fire the lasers. At least
72+
* it will dispatch an event that claims lasers were fired :)
73+
*
74+
* @method fireLasers
75+
*/
76+
fireLasers: function() {
77+
this.fire('polymer-filters-lasers-success', { sound: 'Pew pew pew!' });
78+
}
79+
80+
});
81+
82+
</script>
83+
84+
</polymer-element>

tests/runner.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!doctype html>
2+
<html>
3+
4+
<head>
5+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
6+
<title>Core Elements Test Runner</title>
7+
<meta charset="UTF-8">
8+
9+
<script src="../../platform/platform.js"></script>
10+
11+
<link rel="import" href="tests.html">
12+
13+
</head>
14+
15+
<body>
16+
17+
<div id="mocha"></div>
18+
19+
</body>
20+
21+
</html>

tests/seed-element-basic.html

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
5+
<title>seed-element</title>
6+
7+
<script src="../../platform/platform.js"></script>
8+
<link rel="import" href="tools/tools.html">
9+
<script src="tools/htmltest.js"></script>
10+
11+
<!-- Step 1: import the element to test -->
12+
<link rel="import" href="../seed-element.html">
13+
14+
</head>
15+
<body>
16+
17+
<seed-element></seed-element>
18+
19+
<script>
20+
21+
document.addEventListener('polymer-ready', function() {
22+
// Test a property
23+
var myEl = document.querySelector('seed-element');
24+
assert.equal(myEl.author, 'Dimitri Glazkov');
25+
26+
// Test a method
27+
var hello = myEl.sayHello();
28+
assert.equal(hello, 'My element says, Hello World!');
29+
var greetings = myEl.sayHello('greetings Earthlings');
30+
assert.equal(greetings, 'My element says, greetings Earthlings');
31+
32+
// Test an event
33+
myEl.addEventListener('seed-element-lasers-success', function(event) {
34+
assert.equal(event.detail.sound, 'Pew pew pew!');
35+
// IMPORTANT:
36+
// Make sure to call done() at the end of every test suite!
37+
done();
38+
});
39+
myEl.fireLasers();
40+
});
41+
42+
</script>
43+
44+
</body>
45+
</html>

tests/tests.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<link rel="import" href="tools/tools.html">
2+
3+
<script src="tools/mocha-htmltest.js"></script>
4+
5+
<script>
6+
7+
mocha.setup({ui: 'tdd', slow: 1000, timeout: 5000, htmlbase: ''});
8+
9+
// Below is a set of sample element test suites.
10+
// Replace these with your own suites of tests.
11+
12+
htmlSuite('seed-element', function() {
13+
htmlTest('seed-element-basic.html');
14+
});
15+
16+
// End sample test suites
17+
18+
mocha.run();
19+
20+
</script>

tests/tools/htmltest.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6+
* Code distributed by Google as part of the polymer project is also
7+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8+
*/
9+
10+
// if standalone
11+
if (window.top === window) {
12+
// if standalone
13+
var failed = false;
14+
window.done = function() {
15+
window.onerror = null;
16+
if (!failed) {
17+
var d = document.createElement('pre');
18+
d.style.cssText = 'padding: 6px; background-color: lightgreen;';
19+
d.textContent = 'Passed';
20+
document.body.appendChild(d);
21+
}
22+
};
23+
window.onerror = function(x) {
24+
failed = true;
25+
var d = document.createElement('pre');
26+
d.style.cssText = 'padding: 6px; background-color: #FFE0E0;';
27+
d.textContent = 'FAILED: ' + x;
28+
document.body.appendChild(d);
29+
};
30+
} else
31+
// if part of a test suite
32+
{
33+
window.done = function() {
34+
window.onerror = null;
35+
parent.postMessage('ok', '*');
36+
};
37+
38+
window.onerror = function(x) {
39+
parent.postMessage({error: x}, '*');
40+
};
41+
}
42+

tests/tools/mocha-htmltest.js

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6+
* Code distributed by Google as part of the polymer project is also
7+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8+
*/
9+
10+
(function() {
11+
var thisFile = 'lib/mocha-htmltest.js';
12+
var base = '';
13+
14+
mocha.htmlbase = function(htmlbase) {
15+
base = htmlbase;
16+
};
17+
18+
(function() {
19+
var s$ = document.querySelectorAll('script[src]');
20+
Array.prototype.forEach.call(s$, function(s) {
21+
var src = s.getAttribute('src');
22+
var re = new RegExp(thisFile + '[^\\\\]*');
23+
var match = src.match(re);
24+
if (match) {
25+
base = src.slice(0, -match[0].length);
26+
}
27+
});
28+
})();
29+
30+
var next, iframe;
31+
32+
var listener = function(event) {
33+
if (event.data === 'ok') {
34+
next();
35+
} else if (event.data && event.data.error) {
36+
// errors cannot be cloned via postMessage according to spec, so we re-errorify them
37+
throw new Error(event.data.error);
38+
}
39+
};
40+
41+
function htmlSetup() {
42+
window.addEventListener("message", listener);
43+
iframe = document.createElement('iframe');
44+
iframe.style.cssText = 'position: absolute; left: -9000em; width:768px; height: 1024px';
45+
document.body.appendChild(iframe);
46+
}
47+
48+
function htmlTeardown() {
49+
window.removeEventListener('message', listener);
50+
document.body.removeChild(iframe);
51+
}
52+
53+
function htmlTest(src) {
54+
test(src, function(done) {
55+
next = done;
56+
var url = base + src;
57+
var delimiter = url.indexOf('?') < 0 ? '?' : '&';
58+
var docSearch = location.search.slice(1);
59+
iframe.src = url + delimiter + Math.random() + '&' + docSearch;
60+
});
61+
};
62+
63+
function htmlSuite(inName, inFn) {
64+
suite(inName, function() {
65+
setup(htmlSetup);
66+
teardown(htmlTeardown);
67+
inFn();
68+
});
69+
};
70+
71+
window.htmlTest = htmlTest;
72+
window.htmlSuite = htmlSuite;
73+
})();

0 commit comments

Comments
 (0)