Skip to content

Instantly share code, notes, and snippets.

@webOS101
Created November 7, 2012 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webOS101/4033554 to your computer and use it in GitHub Desktop.
Save webOS101/4033554 to your computer and use it in GitHub Desktop.
Sample fiddle
<script>
new Car().renderInto(document.body);
</script>
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);
}
});
name: Sample fiddle
description: It's a car, sorta
authors:
- Roy Sutton
normalize_css: no
@webOS101
Copy link
Author

webOS101 commented Nov 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment