Skip to content

Commit

Permalink
Merge pull request #21 from dobtco/2.0.0
Browse files Browse the repository at this point in the history
use an <a> tag for keyboard nav
  • Loading branch information
ajb committed Apr 8, 2016
2 parents b8f5dc4 + cf0e423 commit aa22f97
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions dist/starrr.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.starrr {
display: inline-block; }
.starrr i {
.starrr a {
font-size: 16px;
padding: 0 1px;
cursor: pointer;
color: #FFD119; }
color: #FFD119;
text-decoration: none; }
8 changes: 4 additions & 4 deletions dist/starrr.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var slice = [].slice;
if (this.options.readOnly) {
return;
}
this.$el.on('mouseover.starrr', 'i', (function(_this) {
this.$el.on('mouseover.starrr', 'a', (function(_this) {
return function(e) {
return _this.syncRating(_this.getStars().index(e.currentTarget) + 1);
};
Expand All @@ -30,7 +30,7 @@ var slice = [].slice;
return _this.syncRating();
};
})(this));
this.$el.on('click.starrr', 'i', (function(_this) {
this.$el.on('click.starrr', 'a', (function(_this) {
return function(e) {
return _this.setRating(_this.getStars().index(e.currentTarget) + 1);
};
Expand All @@ -39,14 +39,14 @@ var slice = [].slice;
}

Starrr.prototype.getStars = function() {
return this.$el.find('i');
return this.$el.find('a');
};

Starrr.prototype.createStars = function() {
var j, ref, results;
results = [];
for (j = 1, ref = this.options.max; 1 <= ref ? j <= ref : j >= ref; 1 <= ref ? j++ : j--) {
results.push(this.$el.append('<i />'));
results.push(this.$el.append("<a href='#' />"));
}
return results;
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "starrr",
"version": "1.0.0",
"version": "2.0.0",
"main": "Gruntfile.coffee",
"author": "ajb <adam@dobt.co>",
"license": "MIT",
Expand Down
8 changes: 4 additions & 4 deletions src/starrr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@

return if @options.readOnly

@$el.on 'mouseover.starrr', 'i', (e) =>
@$el.on 'mouseover.starrr', 'a', (e) =>
@syncRating(@getStars().index(e.currentTarget) + 1)

@$el.on 'mouseout.starrr', =>
@syncRating()

@$el.on 'click.starrr', 'i', (e) =>
@$el.on 'click.starrr', 'a', (e) =>
@setRating(@getStars().index(e.currentTarget) + 1)

@$el.on 'starrr:change', @options.change

getStars: ->
@$el.find('i')
@$el.find('a')

createStars: ->
@$el.append('<i />') for [1..@options.max]
@$el.append("<a href='#' />") for [1..@options.max]

setRating: (rating) ->
rating = undefined if @options.rating == rating
Expand Down
3 changes: 2 additions & 1 deletion src/starrr.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ $starrrColor: #FFD119 !default;
.starrr {
display: inline-block;

i {
a {
font-size: 16px;
padding: 0 1px;
cursor: pointer;
color: $starrrColor;
text-decoration: none;
}
}

0 comments on commit aa22f97

Please sign in to comment.