Commit 465de9a0 authored by Adam Barth's avatar Adam Barth

Remove outdated examples and framework pieces

None of this code runs in the current Sky. Some of it never ran.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/951673003
parent 377cd1be
<sky>
<div id="test">
Hello, Sky
</div>
<script>
window.addEventListener('load', function() {
var div = document.getElementById('test');
div.animate([
{ backgroundColor: 'red', opacity: 1 },
{ backgroundColor: 'green', opacity: 0}],
{
duration: 1000,
iterations: 2
});
});
</script>
</sky>
SKY MODULE - button widgets for calculator
<!-- TODO(ianh): implement accessibility handling once the ax service exists -->
<script>
class AbstractButton extends Element {
constructor (hostModule) {
super(hostModule);
let selector = new SelectorQuery('.dynamic');
this.addEventListener('pointer-down', (event) => {
selector.findAll(this.shadowRoot).every((element) => element.setAttribute('clicked'));
// TODO(ianh): track the pointer; if it leaves the button, cancel the click
// TOOD(ianh): if the pointer doesn't leave the button before being released, then fire some event on ourselves
module.application.document.addEventListener('pointer-up', function upHandler (event) {
module.application.document.removeEventListener('pointer-up', upHandler);
selector.findAll(this.shadowRoot).every((element) => element.removeAttribute('clicked'));
});
});
}
}
</script>
<template id="threed-button-shadow-tree">
<style>
/* TODO(ianh): make this shrink-wrap the contents */
div { border: solid 1px; }
#a { border-color: #666666 #333333 #333333 #666666; }
#b { border-color: #EEEEEE #666666 #666666 #EEEEEE; }
#c { border-color: #EEEEEE #666666 #666666 #EEEEEE; }
#d { border-color: #EEEEEE #999999 #999999 #EEEEEE; padding: 2px 0 0 0; background: #DDDDDD; color: black; text-align: center; }
#a[clicked] { border-color: #666666 #333333 #333333 #666666; width: 6em; }
#b[clicked] { border-color: #666666 #DDDDDD #DDDDDD #666666; border-width: 1px 0 0 1px; }
#c[clicked] { border-color: #666666 #DDDDDD #DDDDDD #666666; border-width: 1px 0 0 1px; }
#d[clicked] { border-color: #999999 #DDDDDD #DDDDDD #999999; padding: 4px 0 0 2px; }
</style>
<div class="dynamic" id="a">
<div class="dynamic" id="b">
<div class="dynamic" id="c">
<div class="dynamic" id="d">
<content/>
</div>
</div>
</div>
</div>
</template>
<template id="flat-button-shadow-tree">
<style>
div { background: green; color: yellow; }
div[clicked] { background: yellow; color: green; }
</style>
<div class=dynamic>
<content/>
</div>
</template>
<script>
module.exports = {
ThreeDButtonElement: module.registerElement(
class extends AbstractButton {
static get tagName() { return 'graybutton'; }
static get shadow() { return true; }
constructor (hostModule) {
super(hostModule);
this.shadowRoot.append(module.document.findId('threed-button-shadow-tree').cloneNode(true));
}
}
),
FlatButtonElement: module.registerElement(
class extends AbstractButton {
static get tagName() { return 'flatbutton'; }
static get shadow() { return true; }
constructor (hostModule) {
super(hostModule);
this.shadowRoot.append(module.document.findId('flat-shadow-tree').cloneNode(true));
}
}
),
};
</script>
<div>
<script>
getPlace() {
return "world";
}
</script>
</div>
#!mojo mojo:sky_viewer
<sky>
<import src="dart-library.sky" as="library" />
<script>
import "dart:sky" as sky;
main() {
var text = new sky.Text("Hello");
print(text.data);
// print(text.firstChild);
}
</script>
</sky>
w
#!mojo mojo:sky_viewer
<!--
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-->
<import src="../framework/sky-element/sky-element.sky" as="SkyElement" />
<import src="../framework/xmlhttprequest.sky" as="XMLHttpRequest" />
<sky-element name="file-browser">
<template>
<style>
heading {
font-size: 16px;
}
</style>
<heading>File browser for {{ url }}</heading>
<template repeat="{{ directories }}">
<a href="{{}}">{{}}</a>
</template>
<template repeat="{{ files }}">
<a href="{{}}">{{}}</a>
</template>
</template>
<script>
module.exports = class extends SkyElement {
created() {
this.url = '';
this.files = [];
this.directories = [];
}
attached() {
this.url = this.ownerDocument.URL;
var xhr = new XMLHttpRequest();
xhr.open('GET', this.url + '?format=json');
xhr.onload = (function() {
var listing = JSON.parse(xhr.responseText);
this.files = listing.files;
this.directories = listing.directories;
}).bind(this);
xhr.send();
}
}.register();
</script>
</sky-element>
SKY MODULE - radio button and radio button group
<!-- accessibility handling not implemented yet, pending mojo service -->
<!-- <radio> -->
<template id="radio-shadow">
<style>
:host { width: 1em; height: 1em; border: solid; background: white; }
:host[checked] { background: black; }
</style>
</template>
<script>
module.exports.RadioElement = module.registerElement(
class extends Element {
static get tagName() { return 'radio'; }
static get shadow() { return true; }
constructor (hostModule) {
super(hostModule);
this.addEventListener('click', (event) => this.checked = true);
this.shadowRoot.append(module.document.findId('radio-shadow').content.cloneNode(true));
}
get checked () {
return this.hasAttribute('checked');
}
set checked (value) {
if (value)
this.setAttribute('checked', '');
else
this.removeAttribute('checked');
}
get value () {
return this.getAttribute('name');
}
set value (value) {
this.setAttribute('value', value);
}
attributeChanged(name, oldValue, newValue) {
if ((name == 'checked') && (newValue != null))
if (this.parentNode instanceof module.exports.RadioGroupElement)
this.parentNode.setChecked(this);
}
}
);
</script>
<!-- <radiogroup> -->
<template id="radiogroup-shadow">
<style>
:host { padding: 1em; border: thin solid; }
</style>
</template>
<script>
module.exports.RadioGroupElement = module.registerElement(
class extends Element {
static get tagName() { return 'radiogroup'; }
static get shadow() { return true; }
constructor (hostModule) {
super(hostModule);
this.shadowRoot.append(module.document.findId('radiogroup-shadow').content.cloneNode(true));
}
get value () {
let children = this.getChildNodes();
for (let child of children)
if (child instanceof module.exports.RadioElement)
if (child.checked)
return child.name;
return '';
}
set value (name) {
let children = this.getChildNodes();
for (let child of children)
if (child instanceof module.exports.RadioElement)
if (child.value == name)
child.checked = true;
}
setChecked(radio) {
if (!((radio instanceof module.exports.Radio) && radio.parentNode == this))
throw;
let children = this.getChildNodes();
for (let child of children)
if (child instanceof module.exports.RadioElement)
if (child != radio)
child.checked = false;
}
}
);
</script>
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