Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BarView: accept extra classes

  • Loading branch information...
commit a368ee32dc030f75bcf07e007e03d5b6640f6ac0 1 parent f85c308
James A. Rosen authored
Showing with 14 additions and 2 deletions.
  1. +7 −1 lib/BarView.js
  2. +7 −1 spec/javascripts/BarView.spec.js
View
8 lib/BarView.js
@@ -1,8 +1,14 @@
Ember.ProgressBars = Ember.ProgressBars || {};
Ember.ProgressBars.Bar = Ember.View.extend({
- template: Em.Handlebars.compile('<div class="progress"><div class="bar"></div></div>'),
+ template: Em.Handlebars.compile('<div class="bar"></div>'),
percent: 0,
+ init: function() {
+ var classNames = this.get('classNames') || [];
+ classNames.push('progress');
+ this.set('classNames', classNames);
+ return this._super.apply(this, arguments);
+ },
onPercentChange: function() {
var percent = this.get('percent') || 0;
this.$('.bar').css('width', "%@%".fmt(percent) );
View
8 spec/javascripts/BarView.spec.js
@@ -9,7 +9,9 @@ describe('ProgressBars.Bar', function() {
beforeEach(function() {
$fixture = $('<div />').appendTo('body');
- bar = Em.ProgressBars.Bar.create();
+ bar = Em.ProgressBars.Bar.create({
+ classNames: [ 'foo', 'baz' ]
+ });
Em.run(function() {
bar.appendTo( $fixture );
@@ -33,6 +35,10 @@ describe('ProgressBars.Bar', function() {
var style = bar.$('.bar').attr('style');
expect( style ).toMatch( /\bwidth:\s*52%;/ );
});
+
+ it('accepts extra classes for the container', function() {
+ expect( bar.$().is('.progress.foo.baz') ).toBe(true);
+ });
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.