Skip to content

Commit

Permalink
Basic functional app
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed Apr 6, 2015
1 parent f79ea4e commit 10eb7ab
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions TipCalcPanel.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@

var TipCalcPanel = flocks.createClass({

fmt: function(Tip) {
return ((this.fctx.bill || 0) * Tip).toFixed(2);
},

setTotal: function(Becomes) {
var fset = this.fset,
fmt = this.fmt;
return function() { fset('total', fmt(Becomes)); };
},

update: function() {
var NewBill = parseFloat(document.getElementById('billAmount').value);
this.fset('bill', NewBill);
this.fset('total', NewBill); // TEMPORARY AND WRONG
this.fset('total', '');
},

render: function() {
Expand All @@ -18,9 +28,9 @@ var TipCalcPanel = flocks.createClass({
</label>

<div id="howHappy">
<input type="button" value={"25%"}/>
<input type="button" value={"20%"}/>
<input type="button" value={"15%"}/>
<input type="button" value={"25%"} onClick={this.setTotal(1.25)}/>
<input type="button" value={"20%"} onClick={this.setTotal(1.20)}/>
<input type="button" value={"15%"} onClick={this.setTotal(1.15)}/>
</div>

<div id="result">
Expand Down

0 comments on commit 10eb7ab

Please sign in to comment.