diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..87ba626651 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +**/*.min.js +examples/landmarks/js/visua11y.js +examples/landmarks/js/SkipTo.min.js +examples/landmarks/js/bootstrap-accessibility.min.js +examples/landmarks/js/bootstrap.min.js +examples/landmarks/js/jquery-2.1.1.min.js +examples/js/highlight.pack.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..b761c0b40a --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,107 @@ +{ + "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" + ] + } +} diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index b780a83fc5..0000000000 --- a/.jscsrc +++ /dev/null @@ -1,128 +0,0 @@ -{ - "excludeFiles": [ - "./**/*.min.js", - "examples/landmarks/js/visua11y.js", - "examples/landmarks/js/SkipTo.min.js", - "examples/landmarks/js/bootstrap-accessibility.min.js", - "examples/landmarks/js/bootstrap.min.js", - "examples/landmarks/js/jquery-2.1.1.min.js", - "examples/js/highlight.pack.js" - ], - "disallowKeywords": ["with"], - "disallowMixedSpacesAndTabs": true, - "disallowMultipleLineBreaks": true, - "disallowMultipleSpaces": false, - "disallowNewlineBeforeBlockStatements": true, - "disallowOperatorBeforeLineBreak": [ - "?", - "+", - "-", - "/", - "*", - "==", - "===", - "!=", - "!==", - ">", - ">=", - "<", - "<=", - "||", - "&&" - ], - "disallowQuotedKeysInObjects": false, - "disallowSpaceAfterObjectKeys": false, - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "~", "!"], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "disallowSpacesInCallExpression": true, - "disallowSpacesInsideArrayBrackets": "all", - "disallowSpacesInsideObjectBrackets": "all", - "disallowSpacesInsideParentheses": true, - "disallowTrailingComma": true, - "disallowTrailingWhitespace": true, - "disallowYodaConditions": true, - "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties", - "requireCapitalizedConstructors": true, - "requireCommaBeforeLineBreak": true, - "requireCurlyBraces": [ - "if", - "else", - "for", - "while", - "do", - "try", - "catch" - ], - "requireDotNotation": true, - "requireKeywordsOnNewLine": ["else"], - "requireLineFeedAtFileEnd": true, - "requireLineBreakAfterVariableAssignment": true, - "requireOperatorBeforeLineBreak": [ - "=" - ], - "requireParenthesesAroundIIFE": true, - "requireSemicolons": true, - "requireSpaceAfterBinaryOperators": [ - "=", - ",", - "+", - "-", - "/", - "*", - "==", - "===", - "!=", - "!==" - ], - "requireSpaceAfterKeywords": [ - "do", - "for", - "if", - "else", - "switch", - "case", - "try", - "catch", - "void", - "while", - "with", - "return", - "typeof" - ], - "requireSpaceAfterLineComment": true, - "requireSpaceBeforeBinaryOperators": [ - "=", - "+", - "-", - "/", - "*", - "==", - "===", - "!=", - "!==" - ], - "requireSpaceBeforeBlockStatements": true, - "requireSpaceBeforeObjectValues": true, - "requireSpacesInConditionalExpression": { - "afterTest": true, - "beforeConsequent": true, - "afterConsequent": true, - "beforeAlternate": true - }, - "requireSpacesInFunctionDeclaration": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "safeContextKeyword": ["self", "that"], - "validateIndentation": 2, - "validateQuoteMarks": "'", - "validateParameterSeparator": ", " -} diff --git a/.travis.yml b/.travis.yml index cb65e819be..4a33b5e640 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,8 @@ language: node_js + +node_js: + - "node" + env: global: - GH_REF: github.com/w3c/aria-practices.git diff --git a/README.md b/README.md index cbae1ba20a..dc1fbd4256 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,15 @@ that supports [EditorConfig](http://editorconfig.org/). - Edit the new html file with an example corresponding to the description in `aria-practices.html` -### Running JSCS, the JavaScript code style checker +### Running ESLint, the pluggable linting utility for JavaScript and JSX -[JSCS](http://jscs.info/) is an automated code style checker. We use it to ensure -common code styling practices in this repository. -Pull requests with JSCS errors will not be merged. +[ESLint](http://eslint.org/) is an automated code style checker. We use it to +ensure common code styling practices in this repository. +Pull requests with ESLint errors will not be merged. -### Setup JSCS so you can run it locally - -1. If you do not already have node.js installed, +### Setup ESLint so you can run it locally + +1. If you do not already have node.js installed, go to the [node installer](https://nodejs.org/en/download/) 1. When you install Node, NPM is included. 1. In a terminal window from the directory that contains the `aria-practices` @@ -50,40 +50,33 @@ A successful install will display a tree of installed packages. ### Test and fix your code -1. Open a terminal window to the directory that contains the `aria-practices` +1. Open a terminal window to the directory that contains the `aria-practices` repository -1. The repository has a script defined that will test all JavaScript in the examples +1. The repository has a script defined that will test all JavaScript in the examples directory. To run it, execute the command `npm test`. -1. Many errors can be fixed automatically with the command `npm run jscs-fix`. +1. Many errors can be fixed automatically with the command `npm run fix`. 1. After running fix, test again to see what you need to fix manually. - -When JSCS encounters errors, it will report them in the console. -The error report will contain the file name and line number, -and it will indicate the character or place in the line -that raised the style violation. -To fix an error, satisfy the change -that the violation indicates. -For example, here is an error for an invalid quotation mark. Quotation marks must -be single quotation marks, not double. +When the linter encounters errors, it will report them in the console. +The error report will contain the file name and line number, and it will +indicate the character or place in the line that raised the style violation. To +fix an error, satisfy the change that the violation indicates. + +For example, here is an error for an invalid variable name style. Variables must +follow a camelCase convention. ``` -validateQuoteMarks: Invalid quote mark found at examples/alert/js/alert.js : - 1 |window.addEventListener('load', function () { - 2 | - 3 | var button = document.getElementById("alert-trigger"); ------------------------------------------------^ - 4 | - 5 | button.addEventListener('click', addAlert); +/Users/user1/Documents/github/aria-practices/examples/slider/js/text-slider.js + 19:8 error Identifier 'value_nodes' is not in camel case camelcase ``` -The error occurred in `examples/alert/js/alert.js`, on line 3 and the offending -character is indicated by the dashed line and a caret pointing up. Change the -double quotation mark to a single quotation mark in your source file to eliminate -this error. +The error occurred in `examples/slider/js/text-slider.js`, on line 19 and the +offending character is indicated by the number `8` after the colon. Change the +variable `value_nodes` to `valueNodes` in your source file to eliminate this +error. -To see the complete list of style rules that are applied by JSCS, -Check out the [.jscsrc](https://github.com/w3c/aria-practices/blob/master/.jscsrc) file in the root of the project. +To see the complete list of style rules that are applied by ESLint, +Check out the [.eslint.json](https://github.com/w3c/aria-practices/blob/master/.eslint.json) file in the root of the project. ### Editorial documentation @@ -95,7 +88,7 @@ for this specification. ## How to update document snapshot Note: These instructions are for editors of the APG who have repository commit access. - + 1. Go to the [editors draft on rawgit](https://cdn.rawgit.com/w3c/aria-practices/master/aria-practices.html) 2. Press the ReSpec button (top right hand corner) 3. Select 'Save snapshot' diff --git a/examples/accordion/js/accordion.js b/examples/accordion/js/accordion.js index 943cc40208..16de495819 100644 --- a/examples/accordion/js/accordion.js +++ b/examples/accordion/js/accordion.js @@ -6,20 +6,20 @@ Gerard K. Cohen, 05/20/2017 Array.from(document.querySelectorAll('.Accordion')).forEach(function (accordion) { // Allow for each toggle to both open and close individually - const allowToggle = accordion.hasAttribute('data-allow-toggle'); + var allowToggle = accordion.hasAttribute('data-allow-toggle'); // Allow for multiple accordion sections to be expanded at the same time - const allowMultiple = accordion.hasAttribute('data-allow-multiple'); + var allowMultiple = accordion.hasAttribute('data-allow-multiple'); // Create the array of toggle elements for the accordion group - const triggers = Array.from(accordion.querySelectorAll('.Accordion-trigger')); - const panels = Array.from(accordion.querySelectorAll('.Accordion-panel')); + var triggers = Array.from(accordion.querySelectorAll('.Accordion-trigger')); + var panels = Array.from(accordion.querySelectorAll('.Accordion-panel')); accordion.addEventListener('click', function (event) { - const target = event.target; + var target = event.target; if (target.classList.contains('Accordion-trigger')) { // Check if the current toggle is expanded. - const isExpanded = target.getAttribute('aria-expanded') == 'true'; + var isExpanded = target.getAttribute('aria-expanded') == 'true'; if (!allowMultiple) { // Close all previously open accordion toggles @@ -52,20 +52,20 @@ Array.from(document.querySelectorAll('.Accordion')).forEach(function (accordion) // Bind keyboard behaviors on the main accordion container accordion.addEventListener('keydown', function (event) { - const target = event.target; - const key = event.which.toString(); + var target = event.target; + var key = event.which.toString(); // 33 = Page Up, 34 = Page Down - const ctrlModifier = (event.ctrlKey && key.match(/33|34/)); + var ctrlModifier = (event.ctrlKey && key.match(/33|34/)); // Is this coming from an accordion header? if (target.classList.contains('Accordion-trigger')) { // Up/ Down arrow and Control + Page Up/ Page Down keyboard operations // 38 = Up, 40 = Down if (key.match(/38|40/) || ctrlModifier) { - const index = triggers.indexOf(target); - const direction = (key.match(/34|40/)) ? 1 : -1; - const length = triggers.length; - const newIndex = (index + length + direction) % length; + var index = triggers.indexOf(target); + var direction = (key.match(/34|40/)) ? 1 : -1; + var length = triggers.length; + var newIndex = (index + length + direction) % length; triggers[newIndex].focus(); diff --git a/examples/checkbox/checkbox-1/js/checkbox.js b/examples/checkbox/checkbox-1/js/checkbox.js index 5445a8a1ff..570e28614e 100644 --- a/examples/checkbox/checkbox-1/js/checkbox.js +++ b/examples/checkbox/checkbox-1/js/checkbox.js @@ -20,8 +20,8 @@ var Checkbox = function (domNode) { this.domNode = domNode; this.keyCode = Object.freeze({ - 'RETURN' : 13, - 'SPACE' : 32 + 'RETURN': 13, + 'SPACE': 32 }); }; diff --git a/examples/checkbox/checkbox-2/js/checkboxMixed.js b/examples/checkbox/checkbox-2/js/checkboxMixed.js index ac00d1c457..0a9d8dfa9d 100644 --- a/examples/checkbox/checkbox-2/js/checkboxMixed.js +++ b/examples/checkbox/checkbox-2/js/checkboxMixed.js @@ -22,8 +22,8 @@ var CheckboxMixed = function (domNode) { this.controlledCheckboxes = []; this.keyCode = Object.freeze({ - 'RETURN' : 13, - 'SPACE' : 32 + 'RETURN': 13, + 'SPACE': 32 }); }; diff --git a/examples/dialog-modal/js/dialog.js b/examples/dialog-modal/js/dialog.js index c485ebd132..a31d73392a 100644 --- a/examples/dialog-modal/js/dialog.js +++ b/examples/dialog-modal/js/dialog.js @@ -20,8 +20,8 @@ aria.Utils = aria.Utils || {}; aria.Utils.focusFirstDescendant = function (element) { for (var i = 0; i < element.childNodes.length; i++) { var child = element.childNodes[i]; - if (aria.Utils.attemptFocus(child) - || aria.Utils.focusFirstDescendant(child)) { + if (aria.Utils.attemptFocus(child) || + aria.Utils.focusFirstDescendant(child)) { return true; } } @@ -38,8 +38,8 @@ aria.Utils = aria.Utils || {}; aria.Utils.focusLastDescendant = function (element) { for (var i = element.childNodes.length - 1; i >= 0; i--) { var child = element.childNodes[i]; - if (aria.Utils.attemptFocus(child) - || aria.Utils.focusLastDescendant(child)) { + if (aria.Utils.attemptFocus(child) || + aria.Utils.focusLastDescendant(child)) { return true; } } @@ -61,7 +61,8 @@ aria.Utils = aria.Utils || {}; aria.Utils.IgnoreUtilFocusChanges = true; try { element.focus(); - } catch (e) { + } + catch (e) { } aria.Utils.IgnoreUtilFocusChanges = false; return (document.activeElement === element); @@ -119,10 +120,10 @@ aria.Utils = aria.Utils || {}; aria.Dialog = function (dialogId, focusAfterClosed, focusFirst) { this.dialogNode = document.getElementById(dialogId); - if (this.dialogNode === null - || this.dialogNode.getAttribute('role') !== 'dialog') { + if (this.dialogNode === null || + this.dialogNode.getAttribute('role') !== 'dialog') { throw new Error( - 'Dialog() requires a DOM element with ARIA role of dialog.'); + 'Dialog() requires a DOM element with ARIA role of dialog.'); } if (typeof focusAfterClosed === 'string') { @@ -133,7 +134,7 @@ aria.Utils = aria.Utils || {}; } else { throw new Error( - 'the focusAfterClosed parameter is required for the aria.Dialog constructor.'); + 'the focusAfterClosed parameter is required for the aria.Dialog constructor.'); } if (typeof focusFirst === 'string') { @@ -151,11 +152,11 @@ aria.Utils = aria.Utils || {}; // leaves the document even if dialogNode is the first or last node. var preDiv = document.createElement('div'); this.preNode = this.dialogNode.parentNode.insertBefore(preDiv, - this.dialogNode); + this.dialogNode); this.preNode.tabIndex = 0; var postDiv = document.createElement('div'); this.postNode = this.dialogNode.parentNode.insertBefore(postDiv, - this.dialogNode.nextSibling); + this.dialogNode.nextSibling); this.postNode.tabIndex = 0; // If this modal is opening on top of one that is already open, @@ -230,7 +231,7 @@ aria.Utils = aria.Utils || {}; * If not specified, the first focusable element will receive focus. */ aria.Dialog.prototype.replace = function (newDialogId, newFocusAfterClosed, - newFocusFirst) { + newFocusFirst) { var closedDialog = aria.getCurrentDialog(); aria.OpenDialogList.pop(); this.removeListeners(); @@ -278,11 +279,11 @@ aria.Utils = aria.Utils || {}; }; // end closeDialog window.replaceDialog = function (newDialogId, newFocusAfterClosed, - newFocusFirst) { + newFocusFirst) { var topDialog = aria.getCurrentDialog(); if (topDialog.dialogNode.contains(document.activeElement)) { topDialog.replace(newDialogId, newFocusAfterClosed, newFocusFirst); } }; // end replaceDialog -})(); +}()); diff --git a/examples/disclosure/js/disclosureButton.js b/examples/disclosure/js/disclosureButton.js index 5f24af27e9..48194415d3 100644 --- a/examples/disclosure/js/disclosureButton.js +++ b/examples/disclosure/js/disclosureButton.js @@ -20,7 +20,7 @@ var ButtonExpand = function (domNode) { this.domNode = domNode; this.keyCode = Object.freeze({ - 'RETURN' : 13 + 'RETURN': 13 }); }; diff --git a/examples/feed/js/feed.js b/examples/feed/js/feed.js index d6be19444c..2e5ae31740 100644 --- a/examples/feed/js/feed.js +++ b/examples/feed/js/feed.js @@ -34,9 +34,9 @@ aria.Feed.prototype.focusItem = function (item) { aria.Feed.prototype.mapKeyShortcut = function (event) { var key = event.which || event.keyCode; var focusedArticle = - aria.Utils.matches(event.target, '[role="article"]') - ? event.target - : aria.Utils.getAncestorBySelector(event.target, '[role="article"]'); + aria.Utils.matches(event.target, '[role="article"]') ? + event.target : + aria.Utils.getAncestorBySelector(event.target, '[role="article"]'); if (!focusedArticle) { return; diff --git a/examples/feed/js/feedDisplay.js b/examples/feed/js/feedDisplay.js index eb7ec6c9b1..9b22da5a07 100644 --- a/examples/feed/js/feedDisplay.js +++ b/examples/feed/js/feedDisplay.js @@ -181,31 +181,31 @@ aria.FeedDisplay.prototype.renderItemData = function (itemData) { feedItem.setAttribute('aria-labelledby', restaurantID); if (itemData.image) { - itemContent += '
' - + itemData.image - + '
'; + itemContent += '
' + + itemData.image + + '
'; } - itemContent += '
' - + itemData.name - + '
'; + itemContent += '
' + + itemData.name + + '
'; if (itemData.rating) { var ratingID = 'restaurant-rating-' + this.feedSize; - itemContent += '
' - + '' - + '
'; + itemContent += '
' + + '' + + '
'; describedbyIDs.push(ratingID); } if (itemData.type) { var typeID = 'restaurant-type-' + this.feedSize; - itemContent += '
' - + itemData.type - + '
'; + itemContent += '
' + + itemData.type + + '
'; describedbyIDs.push(typeID); } @@ -220,21 +220,21 @@ aria.FeedDisplay.prototype.renderItemData = function (itemData) { describedbyIDs.push(locationID); if (itemData.street) { - locationContent += '
' - + itemData.street - + '
'; + locationContent += '
' + + itemData.street + + '
'; } if (itemData.citystate) { - locationContent += '
' - + itemData.citystate - + '
'; + locationContent += '
' + + itemData.citystate + + '
'; } if (itemData.phone) { - locationContent += '
' - + itemData.phone - + '
'; + locationContent += '
' + + itemData.phone + + '
'; } locationBlock.innerHTML = locationContent; @@ -269,10 +269,10 @@ aria.FeedDisplay.prototype.checkLoadMore = function () { } var lastFeedItem = this.feedItems[this.feedItems.length - 1]; - var scrollTop = window.pageYOffset - || document.documentElement.scrollTop - || document.body.scrollTop - || 0; + var scrollTop = window.pageYOffset || + document.documentElement.scrollTop || + document.body.scrollTop || + 0; var scrollBottom = scrollTop + window.innerHeight; if (scrollBottom >= (lastFeedItem.offsetTop - 300)) { diff --git a/examples/grid/js/dataGrid.js b/examples/grid/js/dataGrid.js index 1bd28f5a75..5a92049d63 100644 --- a/examples/grid/js/dataGrid.js +++ b/examples/grid/js/dataGrid.js @@ -173,14 +173,14 @@ aria.Grid.prototype.setFocusPointer = function (row, col) { */ aria.Grid.prototype.isValidCell = function (row, col) { return ( - !isNaN(row) - && !isNaN(col) - && row >= 0 - && col >= 0 - && this.grid - && this.grid.length - && row < this.grid.length - && col < this.grid[row].length + !isNaN(row) && + !isNaN(col) && + row >= 0 && + col >= 0 && + this.grid && + this.grid.length && + row < this.grid.length && + col < this.grid[row].length ); }; @@ -196,7 +196,7 @@ aria.Grid.prototype.isValidCell = function (row, col) { */ aria.Grid.prototype.isHidden = function (row, col) { var cell = this.gridNode.querySelectorAll(aria.GridSelector.ROW)[row] - .querySelectorAll(aria.GridSelector.CELL)[col]; + .querySelectorAll(aria.GridSelector.CELL)[col]; return aria.Utils.hasClass(cell, aria.CSSClass.HIDDEN); }; @@ -268,8 +268,8 @@ aria.Grid.prototype.showKeysIndicator = function () { }; aria.Grid.prototype.hideKeysIndicator = function () { - if (this.keysIndicator - && this.grid[this.focusedRow][this.focusedCol].tabIndex === 0) { + if (this.keysIndicator && + this.grid[this.focusedRow][this.focusedCol].tabIndex === 0) { aria.Utils.addClass(this.keysIndicator, 'hidden'); } }; @@ -355,15 +355,15 @@ aria.Grid.prototype.checkFocusChange = function (event) { aria.Grid.prototype.findFocusedItem = function (focusedTarget) { var focusedCell = this.grid[this.focusedRow][this.focusedCol]; - if (focusedCell === focusedTarget - || focusedCell.contains(focusedTarget)) { + if (focusedCell === focusedTarget || + focusedCell.contains(focusedTarget)) { return; } for (var i = 0; i < this.grid.length; i++) { for (var j = 0; j < this.grid[i].length; j++) { - if (this.grid[i][j] === focusedTarget - || this.grid[i][j].contains(focusedTarget)) { + if (this.grid[i][j] === focusedTarget || + this.grid[i][j].contains(focusedTarget)) { this.setFocusPointer(i, j); return; } @@ -415,12 +415,12 @@ aria.Grid.prototype.delegateButtonHandler = function (event) { } if ( - target.parentNode - && target.parentNode.matches('th[aria-sort]') - && ( - isClickEvent - || key === aria.KeyCode.SPACE - || key === aria.KeyCode.RETURN + target.parentNode && + target.parentNode.matches('th[aria-sort]') && + ( + isClickEvent || + key === aria.KeyCode.SPACE || + key === aria.KeyCode.RETURN ) ) { event.preventDefault(); @@ -428,10 +428,10 @@ aria.Grid.prototype.delegateButtonHandler = function (event) { } if ( - aria.Utils.matches(target, '.editable-text, .edit-text-button') - && ( - isClickEvent - || key === aria.KeyCode.RETURN + aria.Utils.matches(target, '.editable-text, .edit-text-button') && + ( + isClickEvent || + key === aria.KeyCode.RETURN ) ) { event.preventDefault(); @@ -443,10 +443,10 @@ aria.Grid.prototype.delegateButtonHandler = function (event) { } if ( - aria.Utils.matches(target, '.edit-text-input') - && ( - key === aria.KeyCode.RETURN - || key === aria.KeyCode.ESC + aria.Utils.matches(target, '.edit-text-input') && + ( + key === aria.KeyCode.RETURN || + key === aria.KeyCode.ESC ) ) { event.preventDefault(); @@ -645,13 +645,13 @@ aria.Grid.prototype.showFromRow = function (startIndex, scrollDown) { if ( ( - scrollDown - && i >= startIndex - && i < startIndex + this.perPage) - ||( - !scrollDown - && i <= startIndex - && i > startIndex - this.perPage + scrollDown && + i >= startIndex && + i < startIndex + this.perPage) || + ( + !scrollDown && + i <= startIndex && + i > startIndex - this.perPage ) ) { aria.Utils.removeClass(dataRows[i], aria.CSSClass.HIDDEN); diff --git a/examples/grid/js/layoutGrids.js b/examples/grid/js/layoutGrids.js index bf60393101..627139e2aa 100644 --- a/examples/grid/js/layoutGrids.js +++ b/examples/grid/js/layoutGrids.js @@ -40,7 +40,8 @@ window.addEventListener('load', function () { aria.Utils.addClass(gridNUX, 'hidden'); try { firstGridCell.focus(); - } catch (error) { } + } + catch (error) { } }; NUXclose.addEventListener('click', closeNUX); NUXclose.addEventListener('keyup', function (event) { @@ -105,17 +106,17 @@ PillList.prototype.addPillItem = function (recipientName) { newPillItem.className = 'pill-item'; newPillItem.innerHTML = - '' - + '' - + recipientName - + '' - + '' - + '' - + '' - + 'X' - + '' - + ''; + '' + + '' + + recipientName + + '' + + '' + + '' + + '' + + 'X' + + '' + + ''; this.grid.gridNode.append(newPillItem); this.grid.setupFocusGrid(); @@ -136,9 +137,9 @@ PillList.prototype.checkRemovePill = function (event) { var isClickEvent = (event.type === 'click'); var key = event.which || event.keyCode; - if (!isClickEvent - && key !== aria.KeyCode.RETURN - && key !== aria.KeyCode.SPACE) { + if (!isClickEvent && + key !== aria.KeyCode.RETURN && + key !== aria.KeyCode.SPACE) { return; } diff --git a/examples/grid/js/menuButton.js b/examples/grid/js/menuButton.js index 042043cbe6..3222131c0b 100644 --- a/examples/grid/js/menuButton.js +++ b/examples/grid/js/menuButton.js @@ -26,9 +26,9 @@ window.addEventListener('load', function () { [].forEach.call(menuButtons, function (menuButton) { if ( - menuButton - && menuButton.tagName.toLowerCase() === 'button' - || menuButton.getAttribute('role').toLowerCase() === 'button' + menuButton && + menuButton.tagName.toLowerCase() === 'button' || + menuButton.getAttribute('role').toLowerCase() === 'button' ) { var mb = new aria.widget.MenuButton(menuButton); mb.initMenuButton(); @@ -181,8 +181,8 @@ aria.widget.Menu.prototype.nextMenuItem = function (currentMenuItem) { while (mi) { if ( - (mi.nodeType === Node.ELEMENT_NODE) - && (mi.getAttribute('role') === 'menuitem') + (mi.nodeType === Node.ELEMENT_NODE) && + (mi.getAttribute('role') === 'menuitem') ) { mi.focus(); break; @@ -209,8 +209,8 @@ aria.widget.Menu.prototype.previousMenuItem = function (currentMenuItem) { while (mi) { if ( - mi.nodeType === Node.ELEMENT_NODE - && mi.getAttribute('role') === 'menuitem' + mi.nodeType === Node.ELEMENT_NODE && + mi.getAttribute('role') === 'menuitem' ) { mi.focus(); break; @@ -441,12 +441,12 @@ aria.widget.MenuButton.prototype.closeMenu = function (force, focusMenuButton) { } if ( - force - || ( - !this.mouseInMenuButton - && this.menuNode - && !this.menu.mouseInMenu - && !this.menu.menuHasFocus + force || + ( + !this.mouseInMenuButton && + this.menuNode && + !this.menu.mouseInMenu && + !this.menu.menuHasFocus ) ) { this.menuNode.style.display = 'none'; diff --git a/examples/js/app.js b/examples/js/app.js index f274ed25b1..578fe8a250 100644 --- a/examples/js/app.js +++ b/examples/js/app.js @@ -1,4 +1,4 @@ (function () { // Load syntax highlighting hljs.initHighlightingOnLoad(); -})(); +}()); diff --git a/examples/js/utils.js b/examples/js/utils.js index 548b5ef2b9..30803740a7 100644 --- a/examples/js/utils.js +++ b/examples/js/utils.js @@ -31,17 +31,17 @@ aria.Utils = aria.Utils || {}; aria.Utils.matches = function (element, selector) { if (!Element.prototype.matches) { Element.prototype.matches = - Element.prototype.matchesSelector - || Element.prototype.mozMatchesSelector - || Element.prototype.msMatchesSelector - || Element.prototype.oMatchesSelector - || Element.prototype.webkitMatchesSelector - || function (s) { - var matches = element.parentNode.querySelectorAll(s); - var i = matches.length; - while (--i >= 0 && matches.item(i) !== this) {} - return i > -1; - }; + Element.prototype.matchesSelector || + Element.prototype.mozMatchesSelector || + Element.prototype.msMatchesSelector || + Element.prototype.oMatchesSelector || + Element.prototype.webkitMatchesSelector || + function (s) { + var matches = element.parentNode.querySelectorAll(s); + var i = matches.length; + while (--i >= 0 && matches.item(i) !== this) {} + return i > -1; + }; } return element.matches(selector); @@ -51,9 +51,9 @@ aria.Utils.remove = function (item) { if (item.remove && typeof item.remove === 'function') { return item.remove(); } - if (item.parentNode - && item.parentNode.removeChild - && typeof item.parentNode.removeChild === 'function') { + if (item.parentNode && + item.parentNode.removeChild && + typeof item.parentNode.removeChild === 'function') { return item.parentNode.removeChild(item); } return false; diff --git a/examples/link/js/link.js b/examples/link/js/link.js index 8433f37ae8..01c704c028 100644 --- a/examples/link/js/link.js +++ b/examples/link/js/link.js @@ -2,8 +2,8 @@ function goToLink (event, url) { var type = event.type; if ( - (type === 'click') - || (type === 'keydown' && event.keyCode === 13) + (type === 'click') || + (type === 'keydown' && event.keyCode === 13) ) { window.location.href = url; diff --git a/examples/listbox/js/listbox.js b/examples/listbox/js/listbox.js index 662dde1b5f..0df0b5d81a 100644 --- a/examples/listbox/js/listbox.js +++ b/examples/listbox/js/listbox.js @@ -312,7 +312,7 @@ aria.Listbox.prototype.deleteItems = function () { itemsToDelete = this.listboxNode.querySelectorAll('[aria-selected="true"]'); } else if (this.activeDescendant) { - itemsToDelete = [document.getElementById(this.activeDescendant)]; + itemsToDelete = [ document.getElementById(this.activeDescendant) ]; } if (!itemsToDelete || !itemsToDelete.length) { diff --git a/examples/menu-button/js/MenuItemAction.js b/examples/menu-button/js/MenuItemAction.js index 3ad7e3a948..c565a11428 100644 --- a/examples/menu-button/js/MenuItemAction.js +++ b/examples/menu-button/js/MenuItemAction.js @@ -30,18 +30,18 @@ var MenuItem = function (domNode, menuObj) { this.menu = menuObj; 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 + 'TAB': 9, + 'RETURN': 13, + 'ESC': 27, + 'SPACE': 32, + 'PAGEUP': 33, + 'PAGEDOWN': 34, + 'END': 35, + 'HOME': 36, + 'LEFT': 37, + 'UP': 38, + 'RIGHT': 39, + 'DOWN': 40 }); }; @@ -65,9 +65,9 @@ MenuItem.prototype.init = function () { MenuItem.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - flag = false, - char = event.key, - clickEvent; + flag = false, + char = event.key, + clickEvent; function isPrintableCharacter (str) { return str.length === 1 && str.match(/\S/); diff --git a/examples/menu-button/js/MenuItemLinks.js b/examples/menu-button/js/MenuItemLinks.js index ca4991f9e5..067766d36e 100644 --- a/examples/menu-button/js/MenuItemLinks.js +++ b/examples/menu-button/js/MenuItemLinks.js @@ -30,7 +30,7 @@ var MenuItemLinks = function (domNode, menuObj) { this.menu = menuObj; this.keyCode = Object.freeze({ - 'TAB': 9, + 'TAB': 9, 'RETURN': 13, 'ESC': 27, 'SPACE': 32, @@ -65,9 +65,9 @@ MenuItemLinks.prototype.init = function () { MenuItemLinks.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - flag = false, - char = event.key, - clickEvent; + flag = false, + char = event.key, + clickEvent; function isPrintableCharacter (str) { return str.length === 1 && str.match(/\S/); diff --git a/examples/menu-button/js/Menubutton.js b/examples/menu-button/js/Menubutton.js index e951655949..4fcdc278ff 100644 --- a/examples/menu-button/js/Menubutton.js +++ b/examples/menu-button/js/Menubutton.js @@ -40,18 +40,18 @@ var Menubutton = function (domNode) { this.hasHover = false; 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 + 'TAB': 9, + 'RETURN': 13, + 'ESC': 27, + 'SPACE': 32, + 'PAGEUP': 33, + 'PAGEDOWN': 34, + 'END': 35, + 'HOME': 36, + 'LEFT': 37, + 'UP': 38, + 'RIGHT': 39, + 'DOWN': 40 }); }; @@ -85,8 +85,8 @@ Menubutton.prototype.init = function () { Menubutton.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - flag = false, - clickEvent; + flag = false, + clickEvent; switch (event.keyCode) { case this.keyCode.SPACE: diff --git a/examples/menu-button/js/Menubutton2.js b/examples/menu-button/js/Menubutton2.js index 7d07daf4a8..294ac2f852 100644 --- a/examples/menu-button/js/Menubutton2.js +++ b/examples/menu-button/js/Menubutton2.js @@ -39,18 +39,18 @@ var Menubutton = function (domNode) { this.hasHover = false; 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 + 'TAB': 9, + 'RETURN': 13, + 'ESC': 27, + 'SPACE': 32, + 'PAGEUP': 33, + 'PAGEDOWN': 34, + 'END': 35, + 'HOME': 36, + 'LEFT': 37, + 'UP': 38, + 'RIGHT': 39, + 'DOWN': 40 }); }; @@ -78,8 +78,8 @@ Menubutton.prototype.init = function () { Menubutton.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - flag = false, - clickEvent; + flag = false, + clickEvent; switch (event.keyCode) { case this.keyCode.SPACE: diff --git a/examples/menu-button/js/PopupMenuAction.js b/examples/menu-button/js/PopupMenuAction.js index 10b0d5526e..8840056808 100644 --- a/examples/menu-button/js/PopupMenuAction.js +++ b/examples/menu-button/js/PopupMenuAction.js @@ -34,7 +34,7 @@ */ var PopupMenuAction = function (domNode, controllerObj) { var elementChildren, - msgPrefix = 'PopupMenu constructor argument domNode '; + msgPrefix = 'PopupMenu constructor argument domNode '; // Check whether domNode is a DOM element if (!domNode instanceof Element) { diff --git a/examples/menu-button/js/PopupMenuActionActivedescendant.js b/examples/menu-button/js/PopupMenuActionActivedescendant.js index 62bd9d5563..05ee59e6a0 100644 --- a/examples/menu-button/js/PopupMenuActionActivedescendant.js +++ b/examples/menu-button/js/PopupMenuActionActivedescendant.js @@ -34,7 +34,7 @@ */ var PopupMenuActionActivedescendant = function (domNode, controllerObj) { var elementChildren, - msgPrefix = 'PopupMenu constructor argument domNode '; + msgPrefix = 'PopupMenu constructor argument domNode '; // Check whether domNode is a DOM element if (!domNode instanceof Element) { @@ -71,18 +71,18 @@ var PopupMenuActionActivedescendant = function (domNode, controllerObj) { this.hasHover = false; // see PopupMenu handleMouseover, handleMouseout 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 + 'TAB': 9, + 'RETURN': 13, + 'ESC': 27, + 'SPACE': 32, + 'PAGEUP': 33, + 'PAGEDOWN': 34, + 'END': 35, + 'HOME': 36, + 'LEFT': 37, + 'UP': 38, + 'RIGHT': 39, + 'DOWN': 40 }); }; @@ -138,9 +138,9 @@ PopupMenuActionActivedescendant.prototype.init = function () { }; PopupMenuActionActivedescendant.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - flag = false, - char = event.key, - clickEvent; + flag = false, + char = event.key, + clickEvent; function isPrintableCharacter (str) { return str.length === 1 && str.match(/\S/); diff --git a/examples/menu-button/js/PopupMenuLinks.js b/examples/menu-button/js/PopupMenuLinks.js index 730f8bbe08..94f5045537 100644 --- a/examples/menu-button/js/PopupMenuLinks.js +++ b/examples/menu-button/js/PopupMenuLinks.js @@ -34,7 +34,7 @@ */ var PopupMenuLinks = function (domNode, controllerObj) { var elementChildren, - msgPrefix = 'PopupMenuLinks constructor argument domNode '; + msgPrefix = 'PopupMenuLinks constructor argument domNode '; // Check whether domNode is a DOM element if (!domNode instanceof Element) { diff --git a/examples/menubar/menubar-1/js/MenubarItemLinks.js b/examples/menubar/menubar-1/js/MenubarItemLinks.js index 03efb8a680..c72fd19051 100644 --- a/examples/menubar/menubar-1/js/MenubarItemLinks.js +++ b/examples/menubar/menubar-1/js/MenubarItemLinks.js @@ -92,9 +92,9 @@ MenubarItem.prototype.init = function () { MenubarItem.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - char = event.key, - flag = false, - clickEvent; + char = event.key, + flag = false, + clickEvent; function isPrintableCharacter (str) { return str.length === 1 && str.match(/\S/); diff --git a/examples/menubar/menubar-1/js/MenubarLinks.js b/examples/menubar/menubar-1/js/MenubarLinks.js index 86db87ee21..c89ee7f392 100644 --- a/examples/menubar/menubar-1/js/MenubarLinks.js +++ b/examples/menubar/menubar-1/js/MenubarLinks.js @@ -23,7 +23,7 @@ var Menubar = function (domNode) { var elementChildren, - msgPrefix = 'Menubar constructor argument menubarNode '; + msgPrefix = 'Menubar constructor argument menubarNode '; // Check whether menubarNode is a DOM element if (!domNode instanceof Element) { diff --git a/examples/menubar/menubar-1/js/PopupMenuItemLinks.js b/examples/menubar/menubar-1/js/PopupMenuItemLinks.js index 5bdba323fa..541b2491f7 100644 --- a/examples/menubar/menubar-1/js/PopupMenuItemLinks.js +++ b/examples/menubar/menubar-1/js/PopupMenuItemLinks.js @@ -89,9 +89,9 @@ MenuItem.prototype.isExpanded = function () { MenuItem.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - char = event.key, - flag = false, - clickEvent; + char = event.key, + flag = false, + clickEvent; function isPrintableCharacter (str) { return str.length === 1 && str.match(/\S/); diff --git a/examples/menubar/menubar-1/js/PopupMenuLinks.js b/examples/menubar/menubar-1/js/PopupMenuLinks.js index 9968700395..83e2fad6d8 100644 --- a/examples/menubar/menubar-1/js/PopupMenuLinks.js +++ b/examples/menubar/menubar-1/js/PopupMenuLinks.js @@ -34,7 +34,7 @@ */ var PopupMenu = function (domNode, controllerObj, popupMenuItemObj) { var elementChildren, - msgPrefix = 'PopupMenu constructor argument domNode '; + msgPrefix = 'PopupMenu constructor argument domNode '; if (typeof popupMenuItemObj !== 'object') { popupMenuItemObj = false; diff --git a/examples/menubar/menubar-2/js/MenubarAction.js b/examples/menubar/menubar-2/js/MenubarAction.js index 880b7495e0..24ec294c27 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 elementChildren, - msgPrefix = 'Menubar constructor argument menubarNode '; + msgPrefix = 'Menubar constructor argument menubarNode '; // Check whether menubarNode is a DOM element if (!domNode instanceof Element) { @@ -105,7 +105,8 @@ MenubarAction.prototype.setFocusToItem = function (newItem) { for (var i = 0; i < this.menubarItems.length; i++) { var mbi = this.menubarItems[i]; if (mbi.domNode.tabIndex == 0) { - flag = mbi.domNode.getAttribute('aria-expanded') === 'true';} + flag = mbi.domNode.getAttribute('aria-expanded') === 'true'; + } mbi.domNode.tabIndex = -1; if (mbi.popupMenu) { mbi.popupMenu.close(); diff --git a/examples/menubar/menubar-2/js/MenubarItemAction.js b/examples/menubar/menubar-2/js/MenubarItemAction.js index 7eb30d2fcd..6c42b28e3b 100644 --- a/examples/menubar/menubar-2/js/MenubarItemAction.js +++ b/examples/menubar/menubar-2/js/MenubarItemAction.js @@ -86,9 +86,9 @@ MenubarItemAction.prototype.init = function () { MenubarItemAction.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - char = event.key, - flag = false, - clickEvent; + char = event.key, + flag = false, + clickEvent; function isPrintableCharacter (str) { return str.length === 1 && str.match(/\S/); diff --git a/examples/menubar/menubar-2/js/PopupMenuAction.js b/examples/menubar/menubar-2/js/PopupMenuAction.js index 90db77d2ce..d70ccfd9f7 100644 --- a/examples/menubar/menubar-2/js/PopupMenuAction.js +++ b/examples/menubar/menubar-2/js/PopupMenuAction.js @@ -34,7 +34,7 @@ */ var PopupMenuAction = function (domNode, controllerObj, actionManager) { var elementChildren, - msgPrefix = 'PopupMenu constructor argument domNode '; + msgPrefix = 'PopupMenu constructor argument domNode '; // Check whether domNode is a DOM element if (!domNode instanceof Element) { diff --git a/examples/menubar/menubar-2/js/PopupMenuItemAction.js b/examples/menubar/menubar-2/js/PopupMenuItemAction.js index 0ad101b8d8..24dc1c7762 100644 --- a/examples/menubar/menubar-2/js/PopupMenuItemAction.js +++ b/examples/menubar/menubar-2/js/PopupMenuItemAction.js @@ -117,9 +117,9 @@ MenuItem.prototype.activateMenuitem = function (node) { MenuItem.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - char = event.key, - flag = false, - clickEvent; + char = event.key, + flag = false, + clickEvent; function isPrintableCharacter (str) { return str.length === 1 && str.match(/\S/); diff --git a/examples/menubar/menubar-2/js/menubar-2-init.js b/examples/menubar/menubar-2/js/menubar-2-init.js index 0c92d36a9f..2da00df0f6 100644 --- a/examples/menubar/menubar-2/js/menubar-2-init.js +++ b/examples/menubar/menubar-2/js/menubar-2-init.js @@ -10,8 +10,8 @@ */ window.addEventListener('load', function () { - var menubar = new MenubarAction(document.getElementById('menubar1')); - var styleManager = new StyleManager('textarea1'); - menubar.init(styleManager); - }); + var menubar = new MenubarAction(document.getElementById('menubar1')); + var styleManager = new StyleManager('textarea1'); + menubar.init(styleManager); +}); diff --git a/examples/menubar/menubar-2/js/styleManager.js b/examples/menubar/menubar-2/js/styleManager.js index 66e69afac4..9c48b718c7 100644 --- a/examples/menubar/menubar-2/js/styleManager.js +++ b/examples/menubar/menubar-2/js/styleManager.js @@ -57,53 +57,53 @@ StyleManager.prototype.setItalic = function (flag) { StyleManager.prototype.fontSmaller = function () { - switch (this.fontSize) { - case 'small': - this.setFontSize('x-small'); - break; + switch (this.fontSize) { + case 'small': + this.setFontSize('x-small'); + break; - case 'medium': - this.setFontSize('small'); - break; + case 'medium': + this.setFontSize('small'); + break; - case 'large': - this.setFontSize('medium'); - break; + case 'large': + this.setFontSize('medium'); + break; - case 'x-large': - this.setFontSize('large'); - break; + case 'x-large': + this.setFontSize('large'); + break; - default: - break; + default: + break; - } // end switch - }; + } // end switch +}; StyleManager.prototype.fontLarger = function () { - switch (this.fontSize) { - case 'x-small': - this.setFontSize('small'); - break; + switch (this.fontSize) { + case 'x-small': + this.setFontSize('small'); + break; - case 'small': - this.setFontSize('medium'); - break; + case 'small': + this.setFontSize('medium'); + break; - case 'medium': - this.setFontSize('large'); - break; + case 'medium': + this.setFontSize('large'); + break; - case 'large': - this.setFontSize('x-large'); - break; + case 'large': + this.setFontSize('x-large'); + break; - default: - break; + default: + break; - } // end switch - }; + } // end switch +}; StyleManager.prototype.isMinFontSize = function () { return this.fontSize === 'x-small'; diff --git a/examples/radio/radio-1/js/radioButton.js b/examples/radio/radio-1/js/radioButton.js index 84a163e31f..b618c2b916 100644 --- a/examples/radio/radio-1/js/radioButton.js +++ b/examples/radio/radio-1/js/radioButton.js @@ -17,14 +17,14 @@ var RadioButton = function (domNode, groupObj) { this.radioGroup = groupObj; this.keyCode = Object.freeze({ - 'RETURN' : 13, - 'SPACE' : 32, - 'END' : 35, - 'HOME' : 36, - 'LEFT' : 37, - 'UP' : 38, - 'RIGHT' : 39, - 'DOWN' : 40 + 'RETURN': 13, + 'SPACE': 32, + 'END': 35, + 'HOME': 36, + 'LEFT': 37, + 'UP': 38, + 'RIGHT': 39, + 'DOWN': 40 }); }; @@ -43,8 +43,8 @@ RadioButton.prototype.init = function () { RadioButton.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - flag = false, - clickEvent; + flag = false, + clickEvent; // console.log("[RadioButton][handleKeydown]: " + event.keyCode + " " + this.radioGroup) diff --git a/examples/radio/radio-2/js/radioButtonActiveDescendant.js b/examples/radio/radio-2/js/radioButtonActiveDescendant.js index 1a027893a8..90a6c469d0 100644 --- a/examples/radio/radio-2/js/radioButtonActiveDescendant.js +++ b/examples/radio/radio-2/js/radioButtonActiveDescendant.js @@ -17,18 +17,18 @@ var RadioButtonActiveDescendant = function (domNode, groupObj) { 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 + 'TAB': 9, + 'RETURN': 13, + 'ESC': 27, + 'SPACE': 32, + 'PAGEUP': 33, + 'PAGEDOWN': 34, + 'END': 35, + 'HOME': 36, + 'LEFT': 37, + 'UP': 38, + 'RIGHT': 39, + 'DOWN': 40 }); }; diff --git a/examples/radio/radio-2/js/radioGroupActiveDescendant.js b/examples/radio/radio-2/js/radioGroupActiveDescendant.js index 7b26acc4d8..f1301da89f 100644 --- a/examples/radio/radio-2/js/radioGroupActiveDescendant.js +++ b/examples/radio/radio-2/js/radioGroupActiveDescendant.js @@ -26,12 +26,12 @@ var RadioGroup = function (domNode) { this.lastRadioButton = null; this.keyCode = Object.freeze({ - 'TAB' : 9, - 'SPACE' : 32, - 'LEFT' : 37, - 'UP' : 38, - 'RIGHT' : 39, - 'DOWN' : 40 + 'TAB': 9, + 'SPACE': 32, + 'LEFT': 37, + 'UP': 38, + 'RIGHT': 39, + 'DOWN': 40 }); }; @@ -118,8 +118,8 @@ RadioGroup.prototype.getCurrentRadioButton = function () { RadioGroup.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - flag = false, - clickEvent; + flag = false, + clickEvent; var currentItem = this.getCurrentRadioButton(); switch (event.keyCode) { diff --git a/examples/slider/js/slider.js b/examples/slider/js/slider.js index e4ceb05f4b..874d389642 100644 --- a/examples/slider/js/slider.js +++ b/examples/slider/js/slider.js @@ -24,14 +24,14 @@ var Slider = function (domNode) { this.thumbHeight = 28; this.keyCode = Object.freeze({ - 'left' : 37, - 'up' : 38, - 'right' : 39, - 'down' : 40, - 'pageUp' : 33, - 'pageDown' : 34, - 'end' : 35, - 'home' : 36 + 'left': 37, + 'up': 38, + 'right': 39, + 'down': 40, + 'pageUp': 33, + 'pageDown': 34, + 'end': 35, + 'home': 36 }); }; @@ -180,38 +180,38 @@ window.addEventListener('load', function () { Slider.prototype.handleMouseDown = function (event) { - var self = this; + var self = this; - var handleMouseMove = function (event) { + var handleMouseMove = function (event) { - var diffX = event.pageX - self.railDomNode.offsetLeft; - self.valueNow = parseInt(((self.valueMax - self.valueMin) * diffX) / self.railWidth); - self.moveSliderTo(self.valueNow); + var diffX = event.pageX - self.railDomNode.offsetLeft; + self.valueNow = parseInt(((self.valueMax - self.valueMin) * diffX) / self.railWidth); + self.moveSliderTo(self.valueNow); - event.preventDefault(); - event.stopPropagation(); - }; + event.preventDefault(); + event.stopPropagation(); + }; - var handleMouseUp = function (event) { + var handleMouseUp = function (event) { - document.removeEventListener('mousemove', handleMouseMove); - document.removeEventListener('mouseup', handleMouseUp); + document.removeEventListener('mousemove', handleMouseMove); + document.removeEventListener('mouseup', handleMouseUp); - }; + }; // bind a mousemove event handler to move pointer - document.addEventListener('mousemove', handleMouseMove); + document.addEventListener('mousemove', handleMouseMove); - // bind a mouseup event handler to stop tracking mouse movements - document.addEventListener('mouseup', handleMouseUp); + // bind a mouseup event handler to stop tracking mouse movements + document.addEventListener('mouseup', handleMouseUp); - event.preventDefault(); - event.stopPropagation(); + event.preventDefault(); + event.stopPropagation(); - // Set focus to the clicked handle - this.domNode.focus(); + // Set focus to the clicked handle + this.domNode.focus(); - }; +}; // handleMouseMove has the same functionality as we need for handleMouseClick on the rail Slider.prototype.handleClick = function (event) { diff --git a/examples/slider/js/text-slider.js b/examples/slider/js/text-slider.js index 81b0ec51ca..d97921c7cb 100644 --- a/examples/slider/js/text-slider.js +++ b/examples/slider/js/text-slider.js @@ -16,9 +16,9 @@ var TSlider = function (domNode) { this.valueDomNode = false; this.values = []; - this.value_nodes = this.railDomNode.getElementsByClassName('value'); - for (var i = 0; this.value_nodes[i]; i++) { - this.values.push(this.value_nodes[i].innerHTML); + this.valueNodes = this.railDomNode.getElementsByClassName('value'); + for (var i = 0; this.valueNodes[i]; i++) { + this.values.push(this.valueNodes[i].innerHTML); } this.valueMin = 0; this.valueMax = this.values.length - 1; @@ -32,12 +32,12 @@ var TSlider = function (domNode) { this.thumbHeight = 28; this.keyCode = Object.freeze({ - 'left' : 37, - 'up' : 38, - 'right' : 39, - 'down' : 40, - 'end' : 35, - 'home' : 36 + 'left': 37, + 'up': 38, + 'right': 39, + 'down': 40, + 'end': 35, + 'home': 36 }); }; @@ -65,11 +65,11 @@ TSlider.prototype.init = function () { this.domNode.style.top = (this.thumbHeight / -2) + 'px'; var pos = 0; - var diff = this.railWidth / (this.value_nodes.length - 1); - for (var i = 0; this.value_nodes[i]; i++) { + var diff = this.railWidth / (this.valueNodes.length - 1); + for (var i = 0; this.valueNodes[i]; i++) { - this.value_nodes[i].style.left = ( - pos - (this.value_nodes[i].offsetWidth / 2) + this.valueNodes[i].style.left = ( + pos - (this.valueNodes[i].offsetWidth / 2) ) + 'px'; pos = pos + diff; } @@ -159,38 +159,38 @@ TSlider.prototype.handleBlur = function (event) { TSlider.prototype.handleMouseDown = function (event) { - var self = this; + var self = this; - var handleMouseMove = function (event) { + var handleMouseMove = function (event) { - var diffX = event.pageX - self.railDomNode.offsetLeft; - self.valueNow = parseInt(((self.valueMax - self.valueMin) * diffX) / self.railWidth); - self.moveTSliderTo(self.valueNow); + var diffX = event.pageX - self.railDomNode.offsetLeft; + self.valueNow = parseInt(((self.valueMax - self.valueMin) * diffX) / self.railWidth); + self.moveTSliderTo(self.valueNow); - event.preventDefault(); - event.stopPropagation(); - }; + event.preventDefault(); + event.stopPropagation(); + }; - var handleMouseUp = function (event) { + var handleMouseUp = function (event) { - document.removeEventListener('mousemove', handleMouseMove); - document.removeEventListener('mouseup', handleMouseUp); + document.removeEventListener('mousemove', handleMouseMove); + document.removeEventListener('mouseup', handleMouseUp); - }; + }; // bind a mousemove event handler to move pointer - document.addEventListener('mousemove', handleMouseMove); + document.addEventListener('mousemove', handleMouseMove); - // bind a mouseup event handler to stop tracking mouse movements - document.addEventListener('mouseup', handleMouseUp); + // bind a mouseup event handler to stop tracking mouse movements + document.addEventListener('mouseup', handleMouseUp); - event.preventDefault(); - event.stopPropagation(); + event.preventDefault(); + event.stopPropagation(); - // Set focus to the clicked handle - this.domNode.focus(); + // Set focus to the clicked handle + this.domNode.focus(); - }; +}; // handleMouseMove has the same functionality as we need for handleMouseClick on the rail TSlider.prototype.handleClick = function (event) { @@ -215,4 +215,3 @@ window.addEventListener('load', function () { } }); - diff --git a/examples/slider/js/vertical-slider.js b/examples/slider/js/vertical-slider.js index b9c3aabcb2..fb2a55dad3 100644 --- a/examples/slider/js/vertical-slider.js +++ b/examples/slider/js/vertical-slider.js @@ -24,14 +24,14 @@ var VSlider = function (domNode) { this.thumbHeight = 8; this.keyCode = Object.freeze({ - 'left' : 37, - 'up' : 38, - 'right' : 39, - 'down' : 40, - 'pageUp' : 33, - 'pageDown' : 34, - 'end' : 35, - 'home' : 36 + 'left': 37, + 'up': 38, + 'right': 39, + 'down': 40, + 'pageUp': 33, + 'pageDown': 34, + 'end': 35, + 'home': 36 }); }; @@ -169,38 +169,38 @@ VSlider.prototype.handleBlur = function (event) { VSlider.prototype.handleMouseDown = function (event) { - var self = this; + var self = this; - var handleMouseMove = function (event) { + var handleMouseMove = function (event) { - var diffY = event.pageY - self.railDomNode.offsetTop; - self.valueNow = self.valueMax - parseInt(((self.valueMax - self.valueMin) * diffY) / self.railHeight); - self.moveVSliderTo(self.valueNow); + var diffY = event.pageY - self.railDomNode.offsetTop; + self.valueNow = self.valueMax - parseInt(((self.valueMax - self.valueMin) * diffY) / self.railHeight); + self.moveVSliderTo(self.valueNow); - event.preventDefault(); - event.stopPropagation(); - }; + event.preventDefault(); + event.stopPropagation(); + }; - var handleMouseUp = function (event) { + var handleMouseUp = function (event) { - document.removeEventListener('mousemove', handleMouseMove); - document.removeEventListener('mouseup', handleMouseUp); + document.removeEventListener('mousemove', handleMouseMove); + document.removeEventListener('mouseup', handleMouseUp); - }; + }; // bind a mousemove event handler to move pointer - document.addEventListener('mousemove', handleMouseMove); + document.addEventListener('mousemove', handleMouseMove); - // bind a mouseup event handler to stop tracking mouse movements - document.addEventListener('mouseup', handleMouseUp); + // bind a mouseup event handler to stop tracking mouse movements + document.addEventListener('mouseup', handleMouseUp); - event.preventDefault(); - event.stopPropagation(); + event.preventDefault(); + event.stopPropagation(); - // Set focus to the clicked handle - this.domNode.focus(); + // Set focus to the clicked handle + this.domNode.focus(); - }; +}; // handleMouseMove has the same functionality as we need for handleMouseClick on the rail VSlider.prototype.handleClick = function (event) { diff --git a/examples/tabs/tabs-1/js/tabs.js b/examples/tabs/tabs-1/js/tabs.js index 3f1de54342..50c572a06e 100644 --- a/examples/tabs/tabs-1/js/tabs.js +++ b/examples/tabs/tabs-1/js/tabs.js @@ -252,4 +252,4 @@ activateTab(target, false); }; }; -})(); +}()); diff --git a/examples/tabs/tabs-2/js/tabs.js b/examples/tabs/tabs-2/js/tabs.js index 9c8eaefff5..5d5316dcf2 100644 --- a/examples/tabs/tabs-2/js/tabs.js +++ b/examples/tabs/tabs-2/js/tabs.js @@ -236,4 +236,4 @@ return delay; }; -})(); +}()); diff --git a/examples/toolbar/js/menuButton.js b/examples/toolbar/js/menuButton.js index 922b145619..36e2aa862f 100644 --- a/examples/toolbar/js/menuButton.js +++ b/examples/toolbar/js/menuButton.js @@ -26,9 +26,9 @@ window.addEventListener('load', function () { [].forEach.call(menuButtons, function (menuButton) { if ( - menuButton - && menuButton.tagName.toLowerCase() === 'button' - || menuButton.getAttribute('role').toLowerCase() === 'button' + menuButton && + menuButton.tagName.toLowerCase() === 'button' || + menuButton.getAttribute('role').toLowerCase() === 'button' ) { var mb = new aria.widget.MenuButton(menuButton); mb.initMenuButton(); @@ -180,8 +180,8 @@ aria.widget.Menu.prototype.nextMenuItem = function (currentMenuItem) { while (mi) { if ( - (mi.nodeType === Node.ELEMENT_NODE) - && (mi.getAttribute('role') === 'menuitem') + (mi.nodeType === Node.ELEMENT_NODE) && + (mi.getAttribute('role') === 'menuitem') ) { mi.focus(); break; @@ -207,8 +207,8 @@ aria.widget.Menu.prototype.previousMenuItem = function (currentMenuItem) { while (mi) { if ( - mi.nodeType === Node.ELEMENT_NODE - && mi.getAttribute('role') === 'menuitem' + mi.nodeType === Node.ELEMENT_NODE && + mi.getAttribute('role') === 'menuitem' ) { mi.focus(); break; @@ -438,12 +438,12 @@ aria.widget.MenuButton.prototype.closeMenu = function (force, focusMenuButton) { } if ( - force - || ( - !this.mouseInMenuButton - && this.menuNode - && !this.menu.mouseInMenu - && !this.menu.menuHasFocus + force || + ( + !this.mouseInMenuButton && + this.menuNode && + !this.menu.mouseInMenu && + !this.menu.menuHasFocus ) ) { this.menuNode.style.display = 'none'; diff --git a/examples/treeview/treeview-1/js/tree.js b/examples/treeview/treeview-1/js/tree.js index 312d2bfd15..ddbfe63fe2 100644 --- a/examples/treeview/treeview-1/js/tree.js +++ b/examples/treeview/treeview-1/js/tree.js @@ -154,12 +154,12 @@ Tree.prototype.setFocusToParentItem = function (currentItem) { }; Tree.prototype.setFocusToFirstItem = function () { - this.setFocusToItem(this.firstTreeitem); - }; + this.setFocusToItem(this.firstTreeitem); +}; Tree.prototype.setFocusToLastItem = function () { - this.setFocusToItem(this.lastTreeitem); - }; + this.setFocusToItem(this.lastTreeitem); +}; Tree.prototype.expandTreeitem = function (currentItem) { diff --git a/examples/treeview/treeview-1/js/treeitem.js b/examples/treeview/treeview-1/js/treeitem.js index 567e813315..d2448de60a 100644 --- a/examples/treeview/treeview-1/js/treeitem.js +++ b/examples/treeview/treeview-1/js/treeitem.js @@ -106,9 +106,9 @@ Treeitem.prototype.isExpanded = function () { Treeitem.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, - flag = false, - char = event.key, - clickEvent; + flag = false, + char = event.key, + clickEvent; function isPrintableCharacter (str) { return str.length === 1 && str.match(/\S/); diff --git a/examples/treeview/treeview-1/js/treeitemClick.js b/examples/treeview/treeview-1/js/treeitemClick.js index 92fad49519..98760e1e0d 100644 --- a/examples/treeview/treeview-1/js/treeitemClick.js +++ b/examples/treeview/treeview-1/js/treeitemClick.js @@ -19,7 +19,7 @@ window.addEventListener('load', function () { var treeitems = document.querySelectorAll('[role="treeitem"]'); - for (var i = 0; i