Created
November 7, 2012 18:46
-
-
Save webOS101/4033554 to your computer and use it in GitHub Desktop.
Sample fiddle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
new Car().renderInto(document.body); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enyo.kind({ | |
name: "Car", | |
kind: enyo.Control, | |
running: false, | |
lights: false, | |
components: [ | |
{ name: "LeftHeadlight", content: "O", style: "display: inline;" }, | |
{ name: "RightHeadlight", content: "O", style: "display: inline;" }, | |
{ tag: "br" }, | |
{ name: "Ignition", kind: "Button", content: "Start Car", ontap: "ignition" }, | |
{ name: "LightSwitch", kind: "Button", content: "Turn on Lights", ontap: "lightswitch" }, | |
{ tag: "br" }, | |
{ name: "State", content: "Car is off" }, | |
{ name: "test" } | |
], | |
ignition: function(inSender, inEvent) { | |
this.running = !this.running; | |
if(this.running) { | |
this.$.State.setContent("Car is on"); | |
this.$.Ignition.setContent("Stop car"); | |
} | |
else { | |
this.$.State.setContent("Car is off"); | |
this.$.Ignition.setContent("Start car"); | |
} | |
}, | |
lightswitch: function(inSender, inEvent) { | |
var light; | |
this.lights = !this.lights; | |
light = this.lights ? '@' : 'O'; | |
this.$.LeftHeadlight.setContent(light); | |
this.$.RightHeadlight.setContent(light); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sample fiddle | |
description: It's a car, sorta | |
authors: | |
- Roy Sutton | |
normalize_css: no |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsfiddle.net/gh/gist/enyo/2.1/4033554/