Added Polymer

This commit is contained in:
Thaum
2014-11-26 10:18:35 +00:00
parent 5eea4714b2
commit 3408ba9e8d
1210 changed files with 394645 additions and 47 deletions

View File

@@ -0,0 +1,18 @@
{
"name": "core-media-query",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"version": "0.5.1",
"homepage": "https://github.com/Polymer/core-media-query",
"_release": "0.5.1",
"_resolution": {
"type": "version",
"tag": "0.5.1",
"commit": "c9eb313a8efb925b45644c2866b11228fc36ee84"
},
"_source": "git://github.com/Polymer/core-media-query.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/core-media-query"
}

View File

@@ -0,0 +1,4 @@
core-media-query
================
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-media-query) for more information.

View File

@@ -0,0 +1,8 @@
{
"name": "core-media-query",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^0.5.0"
},
"version": "0.5.1"
}

View File

@@ -0,0 +1,87 @@
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!--
/**
* @group Polymer Core Elements
* @element core-media-query
* @status beta
* @homepage github.io
*
* core-media-query can be used to data bind to a CSS media query.
* The "query" property is a bare CSS media query.
* The "queryMatches" property will be a boolean representing if the page matches that media query.
*
* core-media-query uses media query listeners to dynamically update the "queryMatches" property.
* A "core-media-change" event also fires when queryMatches changes.
*
* Example:
*
* <core-media-query query="max-width: 640px" queryMatches="{{phoneScreen}}"></core-media-query>
*
*/
/**
* Fired when the media query state changes
*
* @event core-media-change
*/
-->
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="core-media-query" attributes="query queryMatches">
<template>
<style>
:host {
display: none;
}
</style>
</template>
<script>
Polymer('core-media-query', {
/**
* The Boolean return value of the media query
*
* @attribute queryMatches
* @type Boolean
* @default false
*/
queryMatches: false,
/**
* The CSS media query to evaulate
*
* @attribute query
* @type string
* @default ''
*/
query: '',
ready: function() {
this._mqHandler = this.queryHandler.bind(this);
this._mq = null;
},
queryChanged: function() {
if (this._mq) {
this._mq.removeListener(this._mqHandler);
}
var query = this.query;
if (query[0] !== '(') {
query = '(' + this.query + ')';
}
this._mq = window.matchMedia(query);
this._mq.addListener(this._mqHandler);
this.queryHandler(this._mq);
},
queryHandler: function(mq) {
this.queryMatches = mq.matches;
this.asyncFire('core-media-change', mq);
}
});
</script>
</polymer-element>

View File

@@ -0,0 +1,44 @@
<!DOCTYPE html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Polymer match media</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="core-media-query.html" />
</head>
<body>
<polymer-element name="match-example">
<template>
<core-media-query query="{{query}}" queryMatches="{{qMatches}}"></core-media-query>
My query of "{{query}}" {{qMatches ? "matches" : "doesn't match"}}
</template>
<script>
Polymer('match-example', {
query: 'min-width: 600px'
});
</script>
</polymer-element>
<match-example id="me"></match-example>
<pre id="output">
Log of 'mediachange' events on document, from polymer-match-media:
</pre>
<script>
var output = document.querySelector('#output');
// on-mediachange would give true or false as second param to the handler
document.addEventListener('core-media-change', function(e) {
output.textContent += '\nevent: ' + e.type + ' query: ' + e.detail.media + ' matches: ' + e.detail.matches;
});
</script>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>