Skip to content

Commit

Permalink
start of "controls" demo
Browse files Browse the repository at this point in the history
  • Loading branch information
dgreensp committed Jun 5, 2012
1 parent 0e7f3c5 commit 373c703
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/unfinished/controls/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
6 changes: 6 additions & 0 deletions examples/unfinished/controls/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

autopublish
43 changes: 43 additions & 0 deletions examples/unfinished/controls/client/controls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var SPEW = function(str) {
SPEW.lines.push(str);
// use counter to signal invalidation
Session.set("SPEW_V", (Session.get("SPEW_V") || 0)+1);
};
SPEW.lines = [];

Template.radios.events = {
'change input': function(event) {
//SPEW("change "+event.target.value);
if (event.target.checked) {
Session.set("current_band", event.target.value);
}
}
};

Template.radios.current_band = function() {
return Session.get("current_band");
};

Template.radios.band_checked = function(b) {
return Session.equals("current_band", b) ?
'checked="checked"' : '';
};

Template.checkboxes.events = {
'change input': function(event) {
Session.set("dst", event.target.checked);
}
};

Template.checkboxes.dst_checked = function() {
return Session.get("dst") ? 'checked="checked"' : '';
};

Template.checkboxes.dst = function() {
return Session.get("dst") ? 'Yes' : 'No';
};

Template.spew.lines = function() {
Session.get("SPEW_V");
return SPEW.lines;
};
1 change: 1 addition & 0 deletions examples/unfinished/controls/controls.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* CSS declarations go here */
35 changes: 35 additions & 0 deletions examples/unfinished/controls/controls.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<head>
<title>controls</title>
</head>

<body>
{{> radios}}
{{> checkboxes}}
{{> spew}}
</body>

<template name="radios">
<div>
Band:
<input type="radio" name="bands" value="AM" {{band_checked "AM"}}/>
<input type="radio" name="bands" value="FM" {{band_checked "FM"}}/>
<input type="radio" name="bands" value="XM" {{band_checked "XM"}}/>
{{current_band}}
</div>
</template>

<template name="checkboxes">
<div>
Daylight Savings Time:
<input type="checkbox" name="dst" value="yes" {{dst_checked}}/>
{{dst}}
</div>
</template>

<template name="spew">
<div>
{{#each lines}}
<br>{{this}}
{{/each}}
</div>
</template>

0 comments on commit 373c703

Please sign in to comment.