Skip to content

Commit

Permalink
Merge pull request #23 from MPolleke/master
Browse files Browse the repository at this point in the history
tabindex="0" gets only added in readonly mode. When keyboard tabbing,…
  • Loading branch information
gjunge authored Mar 26, 2019
2 parents 937fff8 + 9854898 commit 1d25576
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/jquery.rateit.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@
var element = item[0].nodeName == 'DIV' ? 'div' : 'span';
index++;

var html = '<button id="rateit-reset-{{index}}" type="button" data-role="none" class="rateit-reset" aria-label="' + $.rateit.aria.resetLabel + '" aria-controls="rateit-range-{{index}}"><span></span></button><{{element}} id="rateit-range-{{index}}" class="rateit-range" tabindex="0" role="slider" aria-label="' + $.rateit.aria.ratingLabel + '" aria-owns="rateit-reset-{{index}}" aria-valuemin="' + itemdata('min') + '" aria-valuemax="' + itemdata('max') + '" aria-valuenow="' + itemdata('value') + '"><{{element}} class="rateit-empty"></{{element}}><{{element}} class="rateit-selected"></{{element}}><{{element}} class="rateit-hover"></{{element}}></{{element}}>';
// tabindex="0" gets only added in readonly mode. When keyboard tabbing, no focus is needed in readonly mode.
var html = '<button id="rateit-reset-{{index}}" type="button" data-role="none" class="rateit-reset" aria-label="' + $.rateit.aria.resetLabel + '" aria-controls="rateit-range-{{index}}"><span></span></button><{{element}} id="rateit-range-{{index}}" class="rateit-range"' + (itemdata('readonly') == true ? '' : ' tabindex="0"') + ' role="slider" aria-label="' + $.rateit.aria.ratingLabel + '" aria-owns="rateit-reset-{{index}}" aria-valuemin="' + itemdata('min') + '" aria-valuemax="' + itemdata('max') + '" aria-valuenow="' + itemdata('value') + '"><{{element}} class="rateit-empty"></{{element}}><{{element}} class="rateit-selected"></{{element}}><{{element}} class="rateit-hover"></{{element}}></{{element}}>';
item.append(html.replace(/{{index}}/gi, index).replace(/{{element}}/gi, element));

//if we are in RTL mode, we have to change the float of the "reset button"
Expand Down Expand Up @@ -409,4 +410,4 @@
//invoke it on all .rateit elements. This could be removed if not wanted.
$(function () { $('div.rateit, span.rateit').rateit(); });

})(jQuery);
})(jQuery);

0 comments on commit 1d25576

Please sign in to comment.