Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
00882d62
Commit
00882d62
authored
Oct 23, 2014
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Open the Sky
parents
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
README.md
examples/README.md
+2
-0
radio.sky
examples/radio.sky
+78
-0
No files found.
examples/README.md
0 → 100644
View file @
00882d62
These are work-in-progress examples of how the language might look.
They won't currently work.
examples/radio.sky
0 → 100644
View file @
00882d62
SKY MODULE - radio button and radio button group
<!-- accessibility handling not implemented yet, pending mojo service -->
<import src="sky:core" as="sky"/>
<!-- <radio> -->
<template id="radio-shadow">
<style>
:host { width: 1em; height: 1em; border: solid; background: white; }
:host[checked] { background: black; }
</style>
</template>
<script>
module.exports = {};
module.exports.RadioElement = sky.registerElement('radio', class extends Element {
constructor () {
this.addEventListener('click', (event) => this.checked = true);
this.createShadowTree().appendChild(module.document.findId('radio-shadow').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 = sky.registerElement('radiogroup', class extends Element {
constructor () {
this.createShadowTree().appendChild(module.document.findId('radiogroup-shadow').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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment