This is an audio-enabled presentation.
Make sure you have your volume up, your headphones on, and click that highlighted arrow in the lower-right corner after the audio has loaded.
autoplay the presentation
For more information about how you can digitally copy this and how it won't probably hurt my economy, please visit
Creative Commons Attribution-NonCommercial 4.0 International License
ambience: look and sound
mechanics: application interaction
throughput: information presentation
var prototype = Object.create(HTMLDivElement.prototype, {
uri: { value: undefined },
data: { value: undefined },
attachedCallback: function () {
this.uri = this.getAttribute('uri');
// Do some AJAXy stuff here...
this.data = content;
// Fire a data-received event
}
});
document.registerElement('declarative-ajax', HTMLDivElement.prototype);
<body>
<declarative-ajax uri="http://example.com/api"></declarative-ajax>
</body>
<template id="example-template">
<img src="http://example.com/dummy.png">
<div>Bacon ipsum dolor amet brisket boudin</div>
<script>alert('HELLO!');</script>
</template>
function appendTemplate(imgSrc, content) {
// Get the template and set the image's source
var t = document.querySelector("template");
t.querySelector('img').src = imgSrc;
t.querySelector('div').innerHTML = content;
// Clone the content and put it in the DOM
var clone = document.importNode(t.content, true);
document.querySelector("#template-example").appendNode(clone);
}
<link id="my-tag-link" rel="import" href="/components/my-tag.html">
var link = document.getElementById('my-tag-link');
var content = link.import;
var clone = content.cloneNode(true);
document.body.appendChild(clone);
<div id="hostElement"></div>
<p>This is in the normal DOM</p>
var shadow = document.querySelector("#hostElement").createShadowRoot();
shadow.innerHTML = '<p id="my-paragraph">Here is some new text</p>' +
'<style>p { color: red };</style>';
document.getElementById('my-paragraph'); // Returns undefined
Here is some new textThis is in the normal DOM
Technology | IE | Chrome | FF |
---|---|---|---|
custom elements | maybe | yep | off |
<template> | in dev | yep | yep |
HTML Imports | maybe | yep | never |
Shadow DOM | maybe | yep | off |
<dumb-button>Push me</dumb-button>
<link rel="import" href="../polymer/polymer.html">
<dom-module id="dumb-button">
</dom-module>
<style>
:host {
display: inline-block;
}
button {
font-size: 24px;
padding: 0.2em 0.4em;
border: 0;
background-color: white;
}
button:active {
background-color: green;
}
</style>
<template>
<button id="clickable"><content></content></button>
<audio id="sound" src="./button-sound.wav"></audio>
</template>
<script>
Polymer({
is: "dumb-button",
ready: function () {
var self = this;
this.$.clickable.addEventListener('click', function () {
self.$.sound.play();
});
}
});
</script>