Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

BarView: bind bar's width to percent property

  • Loading branch information...
commit f85c308ccef773c5ca941b92f613326bbb44bf57 1 parent cc4e58f
James Alexander Rosen jamesarosen authored

Showing 2 changed files with 12 additions and 1 deletion. Show diff stats Hide diff stats

  1. +6 1 lib/BarView.js
  2. +6 0 spec/javascripts/BarView.spec.js
7 lib/BarView.js
... ... @@ -1,5 +1,10 @@
1 1 Ember.ProgressBars = Ember.ProgressBars || {};
2 2
3 3 Ember.ProgressBars.Bar = Ember.View.extend({
4   - template: Em.Handlebars.compile('<div class="progress"><div class="bar"></div></div>')
  4 + template: Em.Handlebars.compile('<div class="progress"><div class="bar"></div></div>'),
  5 + percent: 0,
  6 + onPercentChange: function() {
  7 + var percent = this.get('percent') || 0;
  8 + this.$('.bar').css('width', "%@%".fmt(percent) );
  9 + }.observes('percent')
5 10 });
6 spec/javascripts/BarView.spec.js
@@ -27,6 +27,12 @@ describe('ProgressBars.Bar', function() {
27 27 it('renders a progress bar', function() {
28 28 expect( $fixture.find('.progress .bar').length ).toBe(1);
29 29 });
  30 +
  31 + it("binds the bar's width to percent", function() {
  32 + bar.set('percent', 52);
  33 + var style = bar.$('.bar').attr('style');
  34 + expect( style ).toMatch( /\bwidth:\s*52%;/ );
  35 + });
30 36 });
31 37
32 38 });

0 comments on commit f85c308

Please sign in to comment.
Something went wrong with that request. Please try again.