Skip to content

Commit

Permalink
Update from consolidated repo
Browse files Browse the repository at this point in the history
  • Loading branch information
robbear committed May 12, 2015
1 parent 848334a commit 7b4d439
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 137 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

25 changes: 12 additions & 13 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
The MIT License (MIT)

Copyright (c) 2014 Basic Web Components
Copyright (c) 2015 Component Kitchen, 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:
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.
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.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Note: This release of this particular component requires an **older version of Polymer (v0.5.5)**.

-----

The organization of these web component files is tuned for the component's
inclusion in other projects via [Bower](http://bower.io). If you'd like to run
this component's demo on your own machine, please see these
[instructions](https://github.com/basic-web-components/components-dev/wiki/Running-Basic-Web-Component-demos).
[instructions](https://github.com/basic-web-components/components-dev/wiki/Running-Basic-Web-Component-demos).
97 changes: 52 additions & 45 deletions basic-framed-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,41 @@
@demo ../packages/sample/basic-seamless-iframe/index.html
-->

<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../bower_components/polymer/polymer.html">
<script src="../basic-shared/ContentChanged.js"></script>

<polymer-element name="basic-framed-content">

<template>
<dom-module id="basic-framed-content">
<style>
:host {
display: block;
}
</style>
<content></content>
</template>
<template>
<content></content>
</template>
</dom-module>

<script>
Polymer({

attached: function() {
// This is similar to what basic-element does to observe content changes,
// but here we also want to observe attribute changes.
var observer = new MutationObserver(function() {
this._contentChanged();
}.bind(this));
observer.observe(this, {
attributes: true,
characterData: true,
childList: true,
subtree: true
});
if (this.childNodes.length > 0) {
this._contentChanged();
}
},
// attached: function() {
// // This is similar to what basic-element does to observe content changes,
// // but here we also want to observe attribute changes.
// var observer = new MutationObserver(function() {
// this._contentChanged();
// }.bind(this));
// observer.observe(this, {
// attributes: true,
// characterData: true,
// childList: true,
// subtree: true
// });
// if (this.childNodes.length > 0) {
// this._contentChanged();
// }
// },

behaviors: [Basic.ContentChanged],

/**
* Broadcast the element's current content to the contained page.
Expand All @@ -72,10 +75,33 @@
this._postMessageToParent('framedHeightResponse', this._lastHeight);
},

// Our content is changed. Broadcast the new content and the height (if the
// height changed too).
// TODO: Add support Basic.ContentChanged to observe attribute changes in
// children (but not attribute changes on the top-level element).
contentChanged: function() {
this.broadcastContent();

// The loading of data will *not* count as a DOM mutation event, so we have
// to explicitly listen for load events on elements that have them.
this._listenForLoadEvents('img');
this._listenForLoadEvents('iframe');

// If the height changed, broadcast that too. Our own height won't be
// available immediately; wait a tick to give the browser a chance to re-
// render first.
window.setTimeout(function() {
this._checkForHeightChange();
}.bind(this), 1);
},

is: 'basic-framed-content',

ready: function() {

window.addEventListener('polymer-ready', function() {
this._postMessageToParent('framedPolymerReady');
window.addEventListener('WebComponentsReady', function() {
this._postMessageToParent('framedPolymerReady'); // For backward compat
this._postMessageToParent('framedWebComponentsReady');
}.bind(this));

window.addEventListener('message', function(event) {
Expand All @@ -86,7 +112,7 @@
case 'setContent':
this.innerHTML = event.data.detail;
// Promote any links to document head.
var links = this.querySelectorAll('link');
var links = Polymer.dom(this).querySelectorAll('link');
Array.prototype.forEach.call(links, function(link) {
document.head.appendChild(link);
});
Expand All @@ -111,24 +137,6 @@
}
},

// Our content is changed. Broadcast the new content and the height (if the
// height changed too).
_contentChanged: function() {
this.broadcastContent();

// The loading of data will *not* count as a DOM mutation event, so we have
// to explicitly listen for load events on elements that have them.
this._listenForLoadEvents('img');
this._listenForLoadEvents('iframe');

// If the height changed, broadcast that too. Our own height won't be
// available immediately; wait a tick to give the browser a chance to re-
// render first.
window.setTimeout(function() {
this._checkForHeightChange();
}.bind(this), 1);
},

_getHeight: function() {
return Math.ceil(this.offsetHeight);
},
Expand All @@ -138,7 +146,7 @@

// Listen for load events on children of the specified tag type.
_listenForLoadEvents: function(tag) {
var elements = this.querySelectorAll(tag);
var elements = Polymer.dom(this).querySelectorAll(tag);
Array.prototype.forEach.call(elements, function(element) {
element.addEventListener('load', function() {
this._checkForHeightChange();
Expand All @@ -164,4 +172,3 @@

});
</script>
</polymer-element>
14 changes: 10 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
{
"name": "basic-framed-content",
"description": "Communicates across a frame boundary to an outer element",
"version": "0.5.0",
"version": "0.6.0-preview",
"license": "MIT",
"main": "basic-framed-content.html",
"dependencies": {
"polymer": "Polymer/polymer#^0.5.5"
"basic-shared": "basic-web-components/basic-shared#master",
"iron-icons": "PolymerElements/iron-icons",
"polymer": "Polymer/polymer#^0.8.0-rc.7"
},
"devDependencies": {
"web-component-tester": "*"
},
"keywords": [
"basic-web-components",
"web-components"
],
"ignore": [
"**/.*"
"**/.*",
"/test/"
]
}
}
43 changes: 43 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>

<meta charset="utf-8">
<title>Sample framed page</title>

<script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="basic-framed-content.html">

<style>
body,
button,
input {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 15px;
}

body {
margin: 0;
}

basic-framed-content {
padding: 1em;
}
</style>

<script>
document.addEventListener('WebComponentsReady', function() {
document.body.removeAttribute('unresolved');
});
</script>

</head>

<body unresolved>
<basic-framed-content>
This is a framed page, so this content isn't normaly available to the
outside page.
</basic-framed-content>
</body>

</html>
Binary file removed preview.png
Binary file not shown.
41 changes: 0 additions & 41 deletions test/basic.tests.js

This file was deleted.

28 changes: 0 additions & 28 deletions test/index.html

This file was deleted.

0 comments on commit 7b4d439

Please sign in to comment.