Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added themes for basic stars in flavors for css, fontawesome and boot… #35

Merged
merged 1 commit into from
Jun 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var lessFiles = [
var cssPath = path.join(__dirname, 'examples', 'css'),
distPath = 'dist';

var themePath = path.join(__dirname, 'dist', 'themes');

gulp.task('jshint', function() {
return gulp.src(srcFile)
Expand Down Expand Up @@ -50,13 +51,20 @@ gulp.task('less', function() {
.pipe(gulp.dest(cssPath));
});

gulp.task('themes', function() {
return gulp.src(['themes/*.less', '!themes/variables.less'])
.pipe(less())
.pipe(gulp.dest(themePath));
});

gulp.task('build', function() {
runSequence('jshint', 'test', 'uglify');
runSequence('jshint', 'test', 'themes', 'uglify');
});

gulp.task('watch', function() {
gulp.watch(srcFile, ['jshint']);
gulp.watch(lessFiles, ['less']);
gulp.watch(themeLessFiles, ['themes']);
});

gulp.task('default', ['build']);
9 changes: 8 additions & 1 deletion jquery.barrating.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@

// wrap element in a wrapper div
var wrapElement = function() {
var classes = [self.options.wrapperClass];

if (self.options.theme !== '') {
classes.push('br-theme-' + self.options.theme);
}

self.$elem.wrap($('<div />', {
'class': self.options.wrapperClass
'class': classes.join(' ')
}));
};

Expand Down Expand Up @@ -388,6 +394,7 @@
};

$.fn.barrating.defaults = {
theme:'',
initialRating:null, // initial rating
showValues:false, // display rating values on the bars?
showSelectedRating:true, // append a div with a rating to the widget?
Expand Down
22 changes: 22 additions & 0 deletions test/jquery.barrating-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('bar rating plugin on init with custom options', function () {
showValues: false
});
expect(BarRating.options).to.be.a('object');
expect(BarRating.options.theme).to.equal('');
expect(BarRating.options.initialRating).to.equal(null);
expect(BarRating.options.showValues).to.equal(false);
expect(BarRating.options.showSelectedRating).to.equal(true);
Expand Down Expand Up @@ -105,6 +106,27 @@ describe('bar rating plugin on show', function () {

});

describe('bar rating themes', function() {

before(function () {
createSelect();
});

after(function () {
$('#rating').barrating('destroy');
destroySelect();
});

it('should set the theme class', function() {
$('#rating').barrating({
theme: 'bootstrap-stars'
});

expect($('.br-wrapper').hasClass('br-theme-bootstrap-stars')).to.be.true;
});

});


describe('bar rating plugin on show and rating selected', function () {

Expand Down
34 changes: 34 additions & 0 deletions themes/bootstrap-stars.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@import "variables.less";

.br-theme-bootstrap-stars {

.br-widget {
height: 28px;

a {
font: normal normal normal 18px/1 'Glyphicons Halflings';
text-rendering: auto;
-webkit-font-smoothing: antialiased;
text-decoration: none;
margin-right: 2px;
}

a:after {
content: '\e006';
color: @star-default;
}

a.br-active:after {
color: @star-active;
}

a.br-selected:after {
color: @star-selected;
}

.br-current-rating {
display: none;
}
}

}
36 changes: 36 additions & 0 deletions themes/css-stars.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@import "variables.less";

.br-theme-css-stars {

.br-widget {
height: 28px;

a {
text-decoration: none;
height: 18px;
width: 18px;
float: left;
font-size: 23px;
margin-right: 2px;
}

a:after {
content: "\2605";
position: absolute;
color: @star-default;
}

a.br-active:after {
color: @star-active;
}

a.br-selected:after {
color: @star-selected;
}

.br-current-rating {
display: none;
}
}

}
34 changes: 34 additions & 0 deletions themes/fontawesome-stars.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@import "variables.less";

.br-theme-fontawesome-stars {

.br-widget {
height: 28px;

a {
font: normal normal normal 18px/1 FontAwesome;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
text-decoration: none;
margin-right: 2px;
}

a:after {
content: '\f005';
color: @star-default;
}

a.br-active:after {
color: @star-active;
}

a.br-selected:after {
color: @star-selected;
}

.br-current-rating {
display: none;
}
}

}
4 changes: 4 additions & 0 deletions themes/variables.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Stars
@star-default: #ddd;
@star-active: #ffdf88;
@star-selected: #ffdf88;