Skip to content

Commit

Permalink
Radio Group with Active Descendant Example: Remove unused keycodes an…
Browse files Browse the repository at this point in the history
…d fix linting issues (pull #1064)
  • Loading branch information
jongund authored and mcking65 committed Jul 5, 2019
1 parent d94c880 commit c51978d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
21 changes: 2 additions & 19 deletions examples/radio/radio-2/js/radioButtonActiveDescendant.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,18 @@
*
*/
var RadioButtonActiveDescendant = function (domNode, groupObj) {

this.domNode = domNode;
this.radioGroup = groupObj;

this.keyCode = Object.freeze({
'TAB': 9,
'RETURN': 13,
'ESC': 27,
'SPACE': 32,
'PAGEUP': 33,
'PAGEDOWN': 34,
'END': 35,
'HOME': 36,
'LEFT': 37,
'UP': 38,
'RIGHT': 39,
'DOWN': 40
});
};

RadioButtonActiveDescendant.prototype.init = function () {
this.domNode.setAttribute('aria-checked', 'false');
this.domNode.addEventListener('click', this.handleClick.bind(this));
this.domNode.addEventListener('click', this.handleClick.bind(this));

};

/* EVENT HANDLERS */

RadioButtonActiveDescendant.prototype.handleClick = function (event) {
console.log('click');
RadioButtonActiveDescendant.prototype.handleClick = function () {
this.radioGroup.setChecked(this);
};
12 changes: 3 additions & 9 deletions examples/radio/radio-2/js/radioGroupActiveDescendant.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ RadioGroup.prototype.init = function () {
var rb = new RadioButtonActiveDescendant(rbs[i], this);
rb.init();
this.radioButtons.push(rb);

console.log(rb);

if (!this.firstRadioButton) {
this.firstRadioButton = rb;
}
Expand Down Expand Up @@ -118,14 +115,11 @@ RadioGroup.prototype.getCurrentRadioButton = function () {
// Event Handlers

RadioGroup.prototype.handleKeydown = function (event) {
var tgt = event.currentTarget,
flag = false,
clickEvent;
var flag = false;

var currentItem = this.getCurrentRadioButton();
switch (event.keyCode) {
case this.keyCode.SPACE:
case this.keyCode.RETURN:
this.setChecked(currentItem);
flag = true;
break;
Expand Down Expand Up @@ -160,12 +154,12 @@ RadioGroup.prototype.handleKeydown = function (event) {
}
};

RadioGroup.prototype.handleFocus = function (event) {
RadioGroup.prototype.handleFocus = function () {
var currentItem = this.getCurrentRadioButton();
currentItem.domNode.classList.add('focus');
};

RadioGroup.prototype.handleBlur = function (event) {
RadioGroup.prototype.handleBlur = function () {
var currentItem = this.getCurrentRadioButton();
currentItem.domNode.classList.remove('focus');
};

0 comments on commit c51978d

Please sign in to comment.