Permalink
Browse files

Use Ember-Bootstrap's RadioButtonGroup

  • Loading branch information...
Jiří Zajpt
Jiří Zajpt committed Apr 20, 2012
1 parent 5672da5 commit a2d92306f27756391b7e789883c336cbdda63197
Showing with 521 additions and 19 deletions.
  1. +16 −9 app/lib/app.coffee
  2. +1 −0 app/lib/core.js
  3. +4 −10 app/templates/main_page.handlebars
  4. +500 −0 app/vendor/ember-bootstrap.js
View
@@ -11,32 +11,39 @@ App.totalsController = App.TotalsController.create()
App.appController = Em.Object.create
_data: null
+ periodOptions: [
+ { title: "Daily", value: "daily" }
+ { title: "Monthly", value: "monthly" }
+ ]
+
+ formats:
+ daily: "%d. %m. %y"
+ monthly: "%y/%m"
+
populate: (callback) ->
$.get '/data.js', ((data) =>
@_data =
monthly: new App.DataSeries(data.monthly)
daily: new App.DataSeries(data.daily)
- @daily()
@_populateDidFinish()
+ @set 'period', 'daily'
), 'json'
_populateDidFinish: ->
App.chartDataController.setup()
App.chartDataController.addSeriesController App.firstChartSeriesController
App.chartDataController.addSeriesController App.secondChartSeriesController
- daily: ->
- App.chartDataController.set 'dateFormat', "%d. %m. %y"
- @_setData @_data.daily
-
- monthly: ->
- App.chartDataController.set 'dateFormat', "%y/%m"
- @_setData @_data.monthly
-
_setData: (data) ->
App.chartDataController.setData data
App.totalsController.populate data
+ _periodDidChange: ( ->
+ period = @get 'period'
+ @_setData @_data[period]
+ App.chartDataController.set 'dateFormat', @formats[period]
+ ).observes('period')
+
$ ->
App.appController.populate()
View
@@ -1,6 +1,7 @@
require('jquery');
require('jquery.flot.min');
require('ember');
+require('ember-bootstrap');
require('bootstrap.min');
require('ember-analytics/ext');
@@ -1,15 +1,9 @@
<div class="pull-right">
<div class="pull-right">
- <div class="btn-group" data-toggle="buttons-radio">
- <button class="btn"
- {{action "monthly" target="App.appController" on="click"}}>
- Monthly
- </button>
- <button class="btn active"
- {{action "daily" target="App.appController" on="click"}}>
- Daily
- </button>
- </div>
+ {{view Bootstrap.RadioButtonGroup
+ selectionBinding="App.appController.period"
+ contentBinding="App.appController.periodOptions"
+ itemTitleKey="title" itemValueKey="value"}}
</div>
</div>
<h2 class="page_title">Overview <small>{{App.chartDataController.period}}</small></h2>
Oops, something went wrong.

0 comments on commit a2d9230

Please sign in to comment.