diff --git a/.eslintrc.json b/.eslintrc.json index 758c7b9c19..fa8effad54 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,109 +1,11 @@ { + "extends": "eslint:recommended", + "env": { + "browser": true + }, "rules": { - "no-with": 2, - "no-mixed-spaces-and-tabs": 2, - "no-multiple-empty-lines": 2, - "no-multi-spaces": 0, - "operator-linebreak": [ - 2, - "after" - ], - "quote-props": 0, - "key-spacing": [ - 2, - { - "afterColon": true - } - ], - "space-unary-ops": [ - 2, - { - "words": false, - "nonwords": false - } - ], - "no-spaced-func": 2, - "array-bracket-spacing": [ - 2, - "never", - { - "singleValue": true - } - ], - "space-in-parens": [ - 2, - "never" - ], - "comma-dangle": [ - 2, - "never" - ], - "no-trailing-spaces": 2, - "yoda": [ - 2, - "never" - ], - "camelcase": [ - 2, - { - "properties": "always" - } - ], - "comma-style": [ - 2, - "last" - ], - "curly": [ - 2, - "all" - ], - "dot-notation": 2, - "brace-style": [ - 2, - "stroustrup", - { - "allowSingleLine": true - } - ], - "eol-last": 2, - "wrap-iife": 2, - "semi": [ - 2, - "always" - ], - "space-infix-ops": 2, - "keyword-spacing": [ - 2, - {} - ], - "spaced-comment": [ - 2, - "always" - ], - "space-before-blocks": [ - 2, - "always" - ], - "space-before-function-paren": [ - 2, - "always" - ], - "consistent-this": [ - 2, - "self" - ], - "indent": [ - 2, - 2, - { - "SwitchCase": 1 - } - ], - "quotes": [ - 2, - "single" - ], - "no-eval": "error", - "no-implied-eval": "error" + "no-unused-vars": 0, + "no-undef": 0, + "no-fallthrough": 0 } } diff --git a/examples/combobox/aria1.0pattern/js/listbox.js b/examples/combobox/aria1.0pattern/js/listbox.js index 4b3500b207..eba6f5a9a5 100644 --- a/examples/combobox/aria1.0pattern/js/listbox.js +++ b/examples/combobox/aria1.0pattern/js/listbox.js @@ -7,7 +7,7 @@ var Listbox = function (domNode, comboboxObj) { msgPrefix = 'Listbox constructor argument domNode '; // Check whether domNode is a DOM element - if (!domNode instanceof Element) { + if (!(domNode instanceof Element)) { throw new TypeError(msgPrefix + 'is not a DOM Element.'); } @@ -65,7 +65,7 @@ Listbox.prototype.init = function () { optionElement = optionElements[i]; if (!optionElement.firstElementChild && optionElement.getAttribute('role') != 'separator') { - option = new Option(optionElement, this); + option = new ListboxOption(optionElement, this); option.init(); this.allOptions.push(option); } diff --git a/examples/combobox/aria1.0pattern/js/listboxOption.js b/examples/combobox/aria1.0pattern/js/listboxOption.js index 8dd00dbfd1..0707760d0c 100644 --- a/examples/combobox/aria1.0pattern/js/listboxOption.js +++ b/examples/combobox/aria1.0pattern/js/listboxOption.js @@ -2,7 +2,7 @@ * This content is licensed according to the W3C Software License at * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document */ -var Option = function (domNode, listboxObj) { +var ListboxOption = function (domNode, listboxObj) { this.domNode = domNode; this.listbox = listboxObj; @@ -11,7 +11,7 @@ var Option = function (domNode, listboxObj) { }; -Option.prototype.init = function () { +ListboxOption.prototype.init = function () { if (!this.domNode.getAttribute('role')) { this.domNode.setAttribute('role', 'option'); @@ -25,18 +25,18 @@ Option.prototype.init = function () { /* EVENT HANDLERS */ -Option.prototype.handleClick = function (event) { +ListboxOption.prototype.handleClick = function (event) { this.listbox.setOption(this); this.listbox.close(true); }; -Option.prototype.handleMouseover = function (event) { +ListboxOption.prototype.handleMouseover = function (event) { this.listbox.hasHover = true; this.listbox.open(); }; -Option.prototype.handleMouseout = function (event) { +ListboxOption.prototype.handleMouseout = function (event) { this.listbox.hasHover = false; setTimeout(this.listbox.close.bind(this.listbox, false), 300); }; diff --git a/examples/dialog-modal/js/dialog.js b/examples/dialog-modal/js/dialog.js index c067433fe2..fbf95d5280 100644 --- a/examples/dialog-modal/js/dialog.js +++ b/examples/dialog-modal/js/dialog.js @@ -70,6 +70,7 @@ aria.Utils = aria.Utils || {}; element.focus(); } catch (e) { + // continue regardless of error } aria.Utils.IgnoreUtilFocusChanges = false; return (document.activeElement === element); diff --git a/examples/disclosure/js/disclosureMenu.js b/examples/disclosure/js/disclosureMenu.js index 718048ac5a..a97170ac06 100644 --- a/examples/disclosure/js/disclosureMenu.js +++ b/examples/disclosure/js/disclosureMenu.js @@ -1,185 +1,185 @@ -/* -* This content is licensed according to the W3C Software License at -* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document -* -* Supplemental JS for the disclosure menu keyboard behavior -*/ - - -var DisclosureNav = function (domNode) { - this.rootNode = domNode; - this.triggerNodes = []; - this.controlledNodes = []; - this.openIndex = null; - this.useArrowKeys = true; -}; - -DisclosureNav.prototype.init = function () { - var buttons = this.rootNode.querySelectorAll('button[aria-expanded][aria-controls]'); - for (var i = 0; i < buttons.length; i++) { - var button = buttons[i]; - var menu = button.parentNode.querySelector('ul'); - if (menu) { - // save ref to button and controlled menu - this.triggerNodes.push(button); - this.controlledNodes.push(menu); - - // collapse menus - button.setAttribute('aria-expanded', 'false'); - this.toggleMenu(menu, false); - - // attach event listeners - menu.addEventListener('keydown', this.handleMenuKeyDown.bind(this)); - button.addEventListener('click', this.handleButtonClick.bind(this)); - button.addEventListener('keydown', this.handleButtonKeyDown.bind(this)); - } - } - - this.rootNode.addEventListener('focusout', this.handleBlur.bind(this)); -}; - -DisclosureNav.prototype.toggleMenu = function (domNode, show) { - if (domNode) { - domNode.style.display = show ? 'block' : 'none'; - } -}; - -DisclosureNav.prototype.toggleExpand = function (index, expanded) { - // close open menu, if applicable - if (this.openIndex !== index) { - this.toggleExpand(this.openIndex, false); - } - - // handle menu at called index - if (this.triggerNodes[index]) { - this.openIndex = expanded ? index : null; - this.triggerNodes[index].setAttribute('aria-expanded', expanded); - this.toggleMenu(this.controlledNodes[index], expanded); - } -}; - -DisclosureNav.prototype.controlFocusByKey = function (keyboardEvent, nodeList, currentIndex) { - switch (keyboardEvent.key) { - case 'ArrowUp': - case 'ArrowLeft': - keyboardEvent.preventDefault(); - if (currentIndex > -1) { - var prevIndex = Math.max(0, currentIndex - 1); - nodeList[prevIndex].focus(); - } - break; - case 'ArrowDown': - case 'ArrowRight': - keyboardEvent.preventDefault(); - if (currentIndex > -1) { - var nextIndex = Math.min(nodeList.length - 1, currentIndex + 1); - nodeList[nextIndex].focus(); - } - break; - case 'Home': - keyboardEvent.preventDefault(); - nodeList[0].focus(); - break; - case 'End': - keyboardEvent.preventDefault(); - nodeList[nodeList.length - 1].focus(); - break; - } -}; - -/* Event Handlers */ -DisclosureNav.prototype.handleBlur = function (event) { - var menuContainsFocus = this.rootNode.contains(event.relatedTarget); - if (!menuContainsFocus && this.openIndex !== null) { - this.toggleExpand(this.openIndex, false); - } -}; - -DisclosureNav.prototype.handleButtonKeyDown = function (event) { - var targetButtonIndex = this.triggerNodes.indexOf(document.activeElement); - - // close on escape - if (event.key === 'Escape') { - this.toggleExpand(this.openIndex, false); - } - - // move focus into the open menu if the current menu is open - else if (this.useArrowKeys && this.openIndex === targetButtonIndex && event.key === 'ArrowDown') { - event.preventDefault(); - this.controlledNodes[this.openIndex].querySelector('a').focus(); - } - - // handle arrow key navigation between top-level buttons, if set - else if (this.useArrowKeys) { - this.controlFocusByKey(event, this.triggerNodes, targetButtonIndex); - } -}; - -DisclosureNav.prototype.handleButtonClick = function (event) { - var button = event.target; - var buttonIndex = this.triggerNodes.indexOf(button); - var buttonExpanded = button.getAttribute('aria-expanded') === 'true'; - this.toggleExpand(buttonIndex, !buttonExpanded); -}; - -DisclosureNav.prototype.handleMenuKeyDown = function (event) { - if (this.openIndex === null) { - return; - } - - var menuLinks = Array.prototype.slice.call(this.controlledNodes[this.openIndex].querySelectorAll('a')); - var currentIndex = menuLinks.indexOf(document.activeElement); - - // close on escape - if (event.key === 'Escape') { - this.triggerNodes[this.openIndex].focus(); - this.toggleExpand(this.openIndex, false); - } - - // handle arrow key navigation within menu links, if set - else if (this.useArrowKeys) { - this.controlFocusByKey(event, menuLinks, currentIndex); - } -}; - -// switch on/off arrow key navigation -DisclosureNav.prototype.updateKeyControls = function (useArrowKeys) { - this.useArrowKeys = useArrowKeys; -}; - -/* Initialize Disclosure Menus */ - -window.addEventListener('load', function (event) { - var menus = document.querySelectorAll('.disclosure-nav'); - var disclosureMenus = []; - - for (var i = 0; i < menus.length; i++) { - disclosureMenus[i] = new DisclosureNav(menus[i]); - disclosureMenus[i].init(); - } - - // listen to arrow key checkbox - var arrowKeySwitch = document.getElementById('arrow-behavior-switch'); - arrowKeySwitch.addEventListener('change', function (event) { - var checked = arrowKeySwitch.checked; - for (var i = 0; i < disclosureMenus.length; i++) { - disclosureMenus[i].updateKeyControls(checked); - } - }); - - // fake link behavior - var links = document.querySelectorAll('[href="#mythical-page-content"]'); - var examplePageHeading = document.getElementById('mythical-page-heading'); - for (var i = 0; i < links.length; i++) { - links[i].addEventListener('click', function (event) { - var pageTitle = event.target.innerText; - examplePageHeading.innerText = pageTitle; - - // handle aria-current - for (var n = 0; n < links.length; n++) { - links[n].removeAttribute('aria-current'); - } - this.setAttribute('aria-current', 'page'); - }); - } -}, false); +/* +* This content is licensed according to the W3C Software License at +* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document +* +* Supplemental JS for the disclosure menu keyboard behavior +*/ + + +var DisclosureNav = function (domNode) { + this.rootNode = domNode; + this.triggerNodes = []; + this.controlledNodes = []; + this.openIndex = null; + this.useArrowKeys = true; +}; + +DisclosureNav.prototype.init = function () { + var buttons = this.rootNode.querySelectorAll('button[aria-expanded][aria-controls]'); + for (var i = 0; i < buttons.length; i++) { + var button = buttons[i]; + var menu = button.parentNode.querySelector('ul'); + if (menu) { + // save ref to button and controlled menu + this.triggerNodes.push(button); + this.controlledNodes.push(menu); + + // collapse menus + button.setAttribute('aria-expanded', 'false'); + this.toggleMenu(menu, false); + + // attach event listeners + menu.addEventListener('keydown', this.handleMenuKeyDown.bind(this)); + button.addEventListener('click', this.handleButtonClick.bind(this)); + button.addEventListener('keydown', this.handleButtonKeyDown.bind(this)); + } + } + + this.rootNode.addEventListener('focusout', this.handleBlur.bind(this)); +}; + +DisclosureNav.prototype.toggleMenu = function (domNode, show) { + if (domNode) { + domNode.style.display = show ? 'block' : 'none'; + } +}; + +DisclosureNav.prototype.toggleExpand = function (index, expanded) { + // close open menu, if applicable + if (this.openIndex !== index) { + this.toggleExpand(this.openIndex, false); + } + + // handle menu at called index + if (this.triggerNodes[index]) { + this.openIndex = expanded ? index : null; + this.triggerNodes[index].setAttribute('aria-expanded', expanded); + this.toggleMenu(this.controlledNodes[index], expanded); + } +}; + +DisclosureNav.prototype.controlFocusByKey = function (keyboardEvent, nodeList, currentIndex) { + switch (keyboardEvent.key) { + case 'ArrowUp': + case 'ArrowLeft': + keyboardEvent.preventDefault(); + if (currentIndex > -1) { + var prevIndex = Math.max(0, currentIndex - 1); + nodeList[prevIndex].focus(); + } + break; + case 'ArrowDown': + case 'ArrowRight': + keyboardEvent.preventDefault(); + if (currentIndex > -1) { + var nextIndex = Math.min(nodeList.length - 1, currentIndex + 1); + nodeList[nextIndex].focus(); + } + break; + case 'Home': + keyboardEvent.preventDefault(); + nodeList[0].focus(); + break; + case 'End': + keyboardEvent.preventDefault(); + nodeList[nodeList.length - 1].focus(); + break; + } +}; + +/* Event Handlers */ +DisclosureNav.prototype.handleBlur = function (event) { + var menuContainsFocus = this.rootNode.contains(event.relatedTarget); + if (!menuContainsFocus && this.openIndex !== null) { + this.toggleExpand(this.openIndex, false); + } +}; + +DisclosureNav.prototype.handleButtonKeyDown = function (event) { + var targetButtonIndex = this.triggerNodes.indexOf(document.activeElement); + + // close on escape + if (event.key === 'Escape') { + this.toggleExpand(this.openIndex, false); + } + + // move focus into the open menu if the current menu is open + else if (this.useArrowKeys && this.openIndex === targetButtonIndex && event.key === 'ArrowDown') { + event.preventDefault(); + this.controlledNodes[this.openIndex].querySelector('a').focus(); + } + + // handle arrow key navigation between top-level buttons, if set + else if (this.useArrowKeys) { + this.controlFocusByKey(event, this.triggerNodes, targetButtonIndex); + } +}; + +DisclosureNav.prototype.handleButtonClick = function (event) { + var button = event.target; + var buttonIndex = this.triggerNodes.indexOf(button); + var buttonExpanded = button.getAttribute('aria-expanded') === 'true'; + this.toggleExpand(buttonIndex, !buttonExpanded); +}; + +DisclosureNav.prototype.handleMenuKeyDown = function (event) { + if (this.openIndex === null) { + return; + } + + var menuLinks = Array.prototype.slice.call(this.controlledNodes[this.openIndex].querySelectorAll('a')); + var currentIndex = menuLinks.indexOf(document.activeElement); + + // close on escape + if (event.key === 'Escape') { + this.triggerNodes[this.openIndex].focus(); + this.toggleExpand(this.openIndex, false); + } + + // handle arrow key navigation within menu links, if set + else if (this.useArrowKeys) { + this.controlFocusByKey(event, menuLinks, currentIndex); + } +}; + +// switch on/off arrow key navigation +DisclosureNav.prototype.updateKeyControls = function (useArrowKeys) { + this.useArrowKeys = useArrowKeys; +}; + +/* Initialize Disclosure Menus */ + +window.addEventListener('load', function (event) { + var menus = document.querySelectorAll('.disclosure-nav'); + var disclosureMenus = []; + + for (var i = 0; i < menus.length; i++) { + disclosureMenus[i] = new DisclosureNav(menus[i]); + disclosureMenus[i].init(); + } + + // listen to arrow key checkbox + var arrowKeySwitch = document.getElementById('arrow-behavior-switch'); + arrowKeySwitch.addEventListener('change', function (event) { + var checked = arrowKeySwitch.checked; + for (var i = 0; i < disclosureMenus.length; i++) { + disclosureMenus[i].updateKeyControls(checked); + } + }); + + // fake link behavior + var links = document.querySelectorAll('[href="#mythical-page-content"]'); + var examplePageHeading = document.getElementById('mythical-page-heading'); + for (var k = 0; k < links.length; k++) { + links[k].addEventListener('click', function (event) { + var pageTitle = event.target.innerText; + examplePageHeading.innerText = pageTitle; + + // handle aria-current + for (var n = 0; n < links.length; n++) { + links[n].removeAttribute('aria-current'); + } + this.setAttribute('aria-current', 'page'); + }); + } +}, false); diff --git a/examples/grid/js/dataGrid.js b/examples/grid/js/dataGrid.js index 4251d506c9..f6369c7552 100644 --- a/examples/grid/js/dataGrid.js +++ b/examples/grid/js/dataGrid.js @@ -525,8 +525,8 @@ aria.Grid.prototype.handleSort = function (headerNode) { var comparator = function (row1, row2) { var row1Text = row1.children[columnIndex].innerText; var row2Text = row2.children[columnIndex].innerText; - var row1Value = parseInt(row1Text.replace(/[^0-9\.]+/g, '')); - var row2Value = parseInt(row2Text.replace(/[^0-9\.]+/g, '')); + var row1Value = parseInt(row1Text.replace(/[^0-9.]+/g, '')); + var row2Value = parseInt(row2Text.replace(/[^0-9.]+/g, '')); if (sortType === aria.SortType.ASCENDING) { return row1Value - row2Value; diff --git a/examples/grid/js/layoutGrids.js b/examples/grid/js/layoutGrids.js index c4e2f896bc..b854354f4a 100644 --- a/examples/grid/js/layoutGrids.js +++ b/examples/grid/js/layoutGrids.js @@ -87,7 +87,7 @@ function PillList (grid, input, submitButton, formUpdateText) { this.submitButton.addEventListener('click', this.submitItemForm.bind(this)); this.grid.gridNode.addEventListener('click', this.checkRemovePill.bind(this)); this.grid.gridNode.addEventListener('keydown', this.checkRemovePill.bind(this)); -}; +} PillList.prototype.checkSubmitItem = function (event) { var key = event.which || event.keyCode; diff --git a/examples/js/utils.js b/examples/js/utils.js index 6da3c35f5c..1fdbc4703e 100644 --- a/examples/js/utils.js +++ b/examples/js/utils.js @@ -39,7 +39,9 @@ aria.Utils.matches = function (element, selector) { function (s) { var matches = element.parentNode.querySelectorAll(s); var i = matches.length; - while (--i >= 0 && matches.item(i) !== this) {} + while (--i >= 0 && matches.item(i) !== this) { + // empty + } return i > -1; }; } diff --git a/examples/menu-button/js/PopupMenuAction.js b/examples/menu-button/js/PopupMenuAction.js index 04198e7634..57fa1b1b9f 100644 --- a/examples/menu-button/js/PopupMenuAction.js +++ b/examples/menu-button/js/PopupMenuAction.js @@ -35,7 +35,7 @@ var PopupMenuAction = function (domNode, controllerObj) { msgPrefix = 'PopupMenu constructor argument domNode '; // Check whether domNode is a DOM element - if (!domNode instanceof Element) { + if (!(domNode instanceof Element)) { throw new TypeError(msgPrefix + 'is not a DOM Element.'); } @@ -180,7 +180,9 @@ PopupMenuAction.prototype.setFocusToNextItem = function (currentItem) { }; PopupMenuAction.prototype.setFocusByFirstCharacter = function (currentItem, char) { - var start, index, char = char.toLowerCase(); + var start, index; + + char = char.toLowerCase(); // Get start index for search based on position of currentItem start = this.menuitems.indexOf(currentItem) + 1; diff --git a/examples/menu-button/js/PopupMenuActionActivedescendant.js b/examples/menu-button/js/PopupMenuActionActivedescendant.js index ac0c86bc5c..d238281691 100644 --- a/examples/menu-button/js/PopupMenuActionActivedescendant.js +++ b/examples/menu-button/js/PopupMenuActionActivedescendant.js @@ -35,7 +35,7 @@ var PopupMenuActionActivedescendant = function (domNode, controllerObj) { msgPrefix = 'PopupMenu constructor argument domNode '; // Check whether domNode is a DOM element - if (!domNode instanceof Element) { + if (!(domNode instanceof Element)) { throw new TypeError(msgPrefix + 'is not a DOM Element.'); } @@ -286,7 +286,9 @@ PopupMenuActionActivedescendant.prototype.setFocusToNextItem = function () { }; PopupMenuActionActivedescendant.prototype.setFocusByFirstCharacter = function (char) { - var start, index, char = char.toLowerCase(); + var start, index; + + char = char.toLowerCase(); // Get start index for search based on position of currentItem start = this.menuitems.indexOf(this.currentItem) + 1; diff --git a/examples/menu-button/js/PopupMenuLinks.js b/examples/menu-button/js/PopupMenuLinks.js index 1beca07cd1..e272b3052b 100644 --- a/examples/menu-button/js/PopupMenuLinks.js +++ b/examples/menu-button/js/PopupMenuLinks.js @@ -35,7 +35,7 @@ var PopupMenuLinks = function (domNode, controllerObj) { msgPrefix = 'PopupMenuLinks constructor argument domNode '; // Check whether domNode is a DOM element - if (!domNode instanceof Element) { + if (!(domNode instanceof Element)) { throw new TypeError(msgPrefix + 'is not a DOM Element.'); } @@ -180,7 +180,9 @@ PopupMenuLinks.prototype.setFocusToNextItem = function (currentItem) { }; PopupMenuLinks.prototype.setFocusByFirstCharacter = function (currentItem, char) { - var start, index, char = char.toLowerCase(); + var start, index; + + char = char.toLowerCase(); // Get start index for search based on position of currentItem start = this.menuitems.indexOf(currentItem) + 1; diff --git a/examples/menubar/menubar-1/js/MenubarLinks.js b/examples/menubar/menubar-1/js/MenubarLinks.js index a5e18fafb3..e75d664c90 100644 --- a/examples/menubar/menubar-1/js/MenubarLinks.js +++ b/examples/menubar/menubar-1/js/MenubarLinks.js @@ -8,7 +8,7 @@ var Menubar = function (domNode) { msgPrefix = 'Menubar constructor argument menubarNode '; // Check whether menubarNode is a DOM element - if (!domNode instanceof Element) { + if (!(domNode instanceof Element)) { throw new TypeError(msgPrefix + 'is not a DOM Element.'); } @@ -58,7 +58,7 @@ Menubar.prototype.init = function () { elem = this.domNode.firstElementChild; while (elem) { - var menuElement = elem.firstElementChild; + menuElement = elem.firstElementChild; if (elem && menuElement && menuElement.tagName === 'A') { menubarItem = new MenubarItem(menuElement, this); @@ -146,9 +146,11 @@ Menubar.prototype.setFocusToNextItem = function (currentItem) { }; Menubar.prototype.setFocusByFirstCharacter = function (currentItem, char) { - var start, index, char = char.toLowerCase(); + var start, index; var flag = currentItem.domNode.getAttribute('aria-expanded') === 'true'; + char = char.toLowerCase(); + // Get start index for search based on position of currentItem start = this.menubarItems.indexOf(currentItem) + 1; if (start === this.menubarItems.length) { diff --git a/examples/menubar/menubar-1/js/PopupMenuLinks.js b/examples/menubar/menubar-1/js/PopupMenuLinks.js index 73bc2757e4..f402005c4e 100644 --- a/examples/menubar/menubar-1/js/PopupMenuLinks.js +++ b/examples/menubar/menubar-1/js/PopupMenuLinks.js @@ -7,7 +7,7 @@ var PopupMenu = function (domNode, controllerObj) { msgPrefix = 'PopupMenu constructor argument domNode '; // Check whether domNode is a DOM element - if (!domNode instanceof Element) { + if (!(domNode instanceof Element)) { throw new TypeError(msgPrefix + 'is not a DOM Element.'); } // Check whether domNode has child elements @@ -178,7 +178,9 @@ PopupMenu.prototype.setFocusToNextItem = function (currentItem) { }; PopupMenu.prototype.setFocusByFirstCharacter = function (currentItem, char) { - var start, index, char = char.toLowerCase(); + var start, index; + + char = char.toLowerCase(); // Get start index for search based on position of currentItem start = this.menuitems.indexOf(currentItem) + 1; diff --git a/examples/menubar/menubar-2/js/MenubarAction.js b/examples/menubar/menubar-2/js/MenubarAction.js index bca6f50e4d..1883da3c6a 100644 --- a/examples/menubar/menubar-2/js/MenubarAction.js +++ b/examples/menubar/menubar-2/js/MenubarAction.js @@ -22,7 +22,7 @@ var MenubarAction = function (domNode) { var msgPrefix = 'Menubar constructor argument domNode '; // Check whether domNode is a DOM element - if (!domNode instanceof Element) { + if (!(domNode instanceof Element)) { throw new TypeError(msgPrefix + 'is not a DOM Element.'); } @@ -154,7 +154,9 @@ MenubarAction.prototype.setFocusToNextItem = function (currentItem) { }; MenubarAction.prototype.setFocusByFirstCharacter = function (currentItem, char) { - var start, index, char = char.toLowerCase(); + var start, index; + + char = char.toLowerCase(); // Get start index for search based on position of currentItem start = this.menubarItems.indexOf(currentItem) + 1; diff --git a/examples/menubar/menubar-2/js/MenubarItemAction.js b/examples/menubar/menubar-2/js/MenubarItemAction.js index 22ddda1305..9a6ab78e2f 100644 --- a/examples/menubar/menubar-2/js/MenubarItemAction.js +++ b/examples/menubar/menubar-2/js/MenubarItemAction.js @@ -126,13 +126,6 @@ MenubarItemAction.prototype.handleKeydown = function (event) { flag = true; break; - case this.keyCode.ESC: - if (this.popupMenu) { - this.popupMenu.close(); - } - flag = true; - break; - default: if (isPrintableCharacter(char)) { this.menubar.setFocusByFirstCharacter(this, char); diff --git a/examples/menubar/menubar-2/js/PopupMenuAction.js b/examples/menubar/menubar-2/js/PopupMenuAction.js index 76681e9208..8d1e3ba372 100644 --- a/examples/menubar/menubar-2/js/PopupMenuAction.js +++ b/examples/menubar/menubar-2/js/PopupMenuAction.js @@ -32,7 +32,7 @@ var PopupMenuAction = function (domNode, controllerObj, actionManager) { msgPrefix = 'PopupMenu constructor argument domNode '; // Check whether domNode is a DOM element - if (!domNode instanceof Element) { + if (!(domNode instanceof Element)) { throw new TypeError(msgPrefix + 'is not a DOM Element.'); } @@ -110,7 +110,7 @@ PopupMenuAction.prototype.updateMenuStates = function () { } } - var item = this.domNode.querySelector('[data-option="font-smaller"]'); + item = this.domNode.querySelector('[data-option="font-smaller"]'); if (item) { if (this.actionManager.isMinFontSize()) { item.setAttribute('aria-disabled', 'true'); @@ -192,7 +192,9 @@ PopupMenuAction.prototype.setFocusToNextItem = function (currentItem) { }; PopupMenuAction.prototype.setFocusByFirstCharacter = function (currentItem, char) { - var start, index, char = char.toLowerCase(); + var start, index; + + char = char.toLowerCase(); // Get start index for search based on position of currentItem start = this.menuitems.indexOf(currentItem) + 1; diff --git a/examples/slider/js/multithumb-slider.js b/examples/slider/js/multithumb-slider.js index 40bc53a8dd..35f9bb02cb 100644 --- a/examples/slider/js/multithumb-slider.js +++ b/examples/slider/js/multithumb-slider.js @@ -48,7 +48,7 @@ Slider.prototype.init = function () { } else { this.railMin = parseInt((this.domNode.getAttribute('aria-valuemin'))); - }; + } if (this.domNode.nextElementSibling) { this.maxDomNode = this.domNode.nextElementSibling; @@ -232,7 +232,7 @@ Slider.prototype.handleMouseDown = function (event) { // Initialise Sliders on the page window.addEventListener('load', function () { - var sliders = document.querySelectorAll('[role=slider]');; + var sliders = document.querySelectorAll('[role=slider]'); for (var i = 0; i < sliders.length; i++) { var s = new Slider(sliders[i]); diff --git a/examples/slider/js/slider.js b/examples/slider/js/slider.js index 7d0c495597..83fe97aef7 100644 --- a/examples/slider/js/slider.js +++ b/examples/slider/js/slider.js @@ -170,7 +170,7 @@ Slider.prototype.handleBlur = function (event) { // Initialise Sliders on the page window.addEventListener('load', function () { - var sliders = document.querySelectorAll('[role=slider]');; + var sliders = document.querySelectorAll('[role=slider]'); for (var i = 0; i < sliders.length; i++) { var s = new Slider(sliders[i]); diff --git a/examples/slider/js/text-slider.js b/examples/slider/js/text-slider.js index 9903c0d843..c9fb64f920 100644 --- a/examples/slider/js/text-slider.js +++ b/examples/slider/js/text-slider.js @@ -208,7 +208,7 @@ TSlider.prototype.handleClick = function (event) { // Initialise TSliders on the page window.addEventListener('load', function () { - var sliders = document.querySelectorAll('.aria-widget-text-slider [role=slider]');; + var sliders = document.querySelectorAll('.aria-widget-text-slider [role=slider]'); for (var i = 0; i < sliders.length; i++) { var s = new TSlider(sliders[i]); diff --git a/examples/slider/js/vertical-slider.js b/examples/slider/js/vertical-slider.js index fa7c26e5d7..3a94be54a4 100644 --- a/examples/slider/js/vertical-slider.js +++ b/examples/slider/js/vertical-slider.js @@ -218,7 +218,7 @@ VSlider.prototype.handleClick = function (event) { // Initialise VSliders on the page window.addEventListener('load', function () { - var sliders = document.querySelectorAll('.aria-widget-vertical-slider [role=slider]');; + var sliders = document.querySelectorAll('.aria-widget-vertical-slider [role=slider]'); for (var i = 0; i < sliders.length; i++) { var s = new VSlider(sliders[i]); diff --git a/examples/tabs/tabs-1/js/tabs.js b/examples/tabs/tabs-1/js/tabs.js index 7966b70035..60c91dd208 100644 --- a/examples/tabs/tabs-1/js/tabs.js +++ b/examples/tabs/tabs-1/js/tabs.js @@ -13,7 +13,7 @@ function generateArrays () { tabs = document.querySelectorAll('[role="tab"]'); panels = document.querySelectorAll('[role="tabpanel"]'); - }; + } // For easy reference var keys = { @@ -37,7 +37,7 @@ // Bind listeners for (i = 0; i < tabs.length; ++i) { addListeners(i); - }; + } function addListeners (index) { tabs[index].addEventListener('click', clickEventListener); @@ -46,13 +46,13 @@ // Build an array with all tabs (