diff --git a/examples/menubar/menubar-1/js/.jscsrc b/examples/menubar/menubar-1/js/.jscsrc deleted file mode 100644 index 8729368a27..0000000000 --- a/examples/menubar/menubar-1/js/.jscsrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "preset": "jquery" -} \ No newline at end of file diff --git a/examples/menubar/menubar-1/js/MenuItemLinks.js b/examples/menubar/menubar-1/js/MenuItemLinks.js index 385078b743..18957e115e 100644 --- a/examples/menubar/menubar-1/js/MenuItemLinks.js +++ b/examples/menubar/menubar-1/js/MenuItemLinks.js @@ -24,101 +24,101 @@ * The object that is a wrapper for the PopupMenu DOM element that * contains the menu item DOM element. See PopupMenu.js */ -var MenuItem = function( domNode, menuObj ) { +var MenuItem = function (domNode, menuObj) { this.domNode = domNode; 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 - } ); + 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 + }); }; -MenuItem.prototype.init = function() { +MenuItem.prototype.init = function () { this.domNode.tabIndex = -1; - if ( !this.domNode.getAttribute( "role" ) ) { - this.domNode.setAttribute( "role", "menuitem" ); + if (!this.domNode.getAttribute('role')) { + this.domNode.setAttribute('role', 'menuitem'); } - this.domNode.addEventListener( "keydown", this.handleKeydown.bind( this ) ); - this.domNode.addEventListener( "keypress", this.handleKeypress.bind( this ) ); - this.domNode.addEventListener( "click", this.handleClick.bind( this ) ); - this.domNode.addEventListener( "focus", this.handleFocus.bind( this ) ); - this.domNode.addEventListener( "blur", this.handleBlur.bind( this ) ); - this.domNode.addEventListener( "mouseover", this.handleMouseover.bind( this ) ); - this.domNode.addEventListener( "mouseout", this.handleMouseout.bind( this ) ); + this.domNode.addEventListener('keydown', this.handleKeydown.bind(this)); + this.domNode.addEventListener('keypress', this.handleKeypress.bind(this)); + this.domNode.addEventListener('click', this.handleClick.bind(this)); + this.domNode.addEventListener('focus', this.handleFocus.bind(this)); + this.domNode.addEventListener('blur', this.handleBlur.bind(this)); + this.domNode.addEventListener('mouseover', this.handleMouseover.bind(this)); + this.domNode.addEventListener('mouseout', this.handleMouseout.bind(this)); }; /* EVENT HANDLERS */ -MenuItem.prototype.handleKeydown = function( event ) { +MenuItem.prototype.handleKeydown = function (event) { var tgt = event.currentTarget, flag = false, clickEvent; // Console.log("[MenuItem][handleKeydown]: " + event.keyCode + " " + this.menu) - switch ( event.keyCode ) { + switch (event.keyCode) { case this.keyCode.SPACE: case this.keyCode.RETURN: // Create simulated mouse event to mimic the behavior of ATs // and let the event handler handleClick do the housekeeping. try { - clickEvent = new MouseEvent( "click", { - "view": window, - "bubbles": true, - "cancelable": true - } ); + clickEvent = new MouseEvent('click', { + 'view': window, + 'bubbles': true, + 'cancelable': true + }); } - catch ( err ) { - if ( document.createEvent ) { + catch (err) { + if (document.createEvent) { // DOM Level 3 for IE 9+ - clickEvent = document.createEvent( "MouseEvents" ); - clickEvent.initEvent( "click", true, true ); + clickEvent = document.createEvent('MouseEvents'); + clickEvent.initEvent('click', true, true); } } - tgt.dispatchEvent( clickEvent ); + tgt.dispatchEvent(clickEvent); flag = true; break; case this.keyCode.ESC: this.menu.setFocusToController(); - this.menu.close( true ); + this.menu.close(true); flag = true; break; case this.keyCode.UP: - this.menu.setFocusToPreviousItem( this ); + this.menu.setFocusToPreviousItem(this); flag = true; break; case this.keyCode.DOWN: - this.menu.setFocusToNextItem( this ); + this.menu.setFocusToNextItem(this); flag = true; break; case this.keyCode.LEFT: - this.menu.setFocusToController( "previous" ); - this.menu.close( true ); + this.menu.setFocusToController('previous'); + this.menu.close(true); flag = true; break; case this.keyCode.RIGHT: - this.menu.setFocusToController( "next" ); - this.menu.close( true ); + this.menu.setFocusToController('next'); + this.menu.close(true); flag = true; break; @@ -136,52 +136,52 @@ MenuItem.prototype.handleKeydown = function( event ) { case this.keyCode.TAB: this.menu.setFocusToController(); - this.menu.close( true ); + this.menu.close(true); break; default: break; } - if ( flag ) { + if (flag) { event.stopPropagation(); event.preventDefault(); } }; -MenuItem.prototype.handleKeypress = function( event ) { - var char = String.fromCharCode( event.charCode ); +MenuItem.prototype.handleKeypress = function (event) { + var char = String.fromCharCode(event.charCode); - function isPrintableCharacter ( str ) { - return str.length === 1 && str.match( /\S/ ); + function isPrintableCharacter (str) { + return str.length === 1 && str.match(/\S/); } - if ( isPrintableCharacter( char ) ) { - this.menu.setFocusByFirstCharacter( this, char ); + if (isPrintableCharacter(char)) { + this.menu.setFocusByFirstCharacter(this, char); } }; -MenuItem.prototype.handleClick = function( event ) { +MenuItem.prototype.handleClick = function (event) { this.menu.setFocusToController(); - this.menu.close( true ); + this.menu.close(true); }; -MenuItem.prototype.handleFocus = function( event ) { +MenuItem.prototype.handleFocus = function (event) { this.menu.hasFocus = true; }; -MenuItem.prototype.handleBlur = function( event ) { +MenuItem.prototype.handleBlur = function (event) { this.menu.hasFocus = false; - setTimeout( this.menu.close.bind( this.menu, false ), 300 ); + setTimeout(this.menu.close.bind(this.menu, false), 300); }; -MenuItem.prototype.handleMouseover = function( event ) { +MenuItem.prototype.handleMouseover = function (event) { this.menu.hasHover = true; this.menu.open(); }; -MenuItem.prototype.handleMouseout = function( event ) { +MenuItem.prototype.handleMouseout = function (event) { this.menu.hasHover = false; - setTimeout( this.menu.close.bind( this.menu, false ), 300 ); + setTimeout(this.menu.close.bind(this.menu, false), 300); }; diff --git a/examples/menubar/menubar-1/js/MenubarItemLinks.js b/examples/menubar/menubar-1/js/MenubarItemLinks.js index 4336c40ad1..68ea1c6e64 100644 --- a/examples/menubar/menubar-1/js/MenubarItemLinks.js +++ b/examples/menubar/menubar-1/js/MenubarItemLinks.js @@ -1,17 +1,6 @@ /* -* Copyright 2016 University of Illinois -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. +* This content is licensed according to the W3C Software License at +* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document * * File: MenubarItemLinks.js * @@ -85,7 +74,7 @@ MenubarItem.prototype.init = function () { this.domNode.addEventListener('mouseover', this.handleMouseover.bind(this)); this.domNode.addEventListener('mouseout', this.handleMouseout.bind(this)); - // initialize pop up menus + // Initialize pop up menus var nextElement = this.domNode.nextElementSibling; diff --git a/examples/menubar/menubar-1/js/MenubarLinks.js b/examples/menubar/menubar-1/js/MenubarLinks.js index 4e7fb6c7e5..5a89a8e502 100644 --- a/examples/menubar/menubar-1/js/MenubarLinks.js +++ b/examples/menubar/menubar-1/js/MenubarLinks.js @@ -21,26 +21,26 @@ * be an A element */ -var Menubar = function( domNode ) { +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 ) { - throw new TypeError( msgPrefix + "is not a DOM Element." ); + if (!domNode instanceof Element) { + throw new TypeError(msgPrefix + 'is not a DOM Element.'); } // Check whether menubarNode has descendant elements - if ( domNode.childElementCount === 0 ) { - throw new Error( msgPrefix + "has no element children." ); + if (domNode.childElementCount === 0) { + throw new Error(msgPrefix + 'has no element children.'); } // Check whether menubarNode has A elements e = domNode.firstElementChild; - while ( e ) { + while (e) { var menubarItem = e.firstElementChild; - if ( e && menubarItem && menubarItem.tagName !== "A" ) { - throw new Error( msgPrefix + "has child elements are note A elements." ); + if (e && menubarItem && menubarItem.tagName !== 'A') { + throw new Error(msgPrefix + 'has child elements are note A elements.'); } e = e.nextElementSibling; } @@ -65,24 +65,24 @@ var Menubar = function( domNode ) { * Traverse menubar children for A elements to configure each A element as a ARIA menuitem * and populate menuitems array. Initialize firstItem and lastItem properties. */ -Menubar.prototype.init = function() { +Menubar.prototype.init = function () { var menubarItem, childElement, menuElement, textContent, numItems; - this.domNode.setAttribute( "role", "menubar" ); + this.domNode.setAttribute('role', 'menubar'); // Traverse the element children of menubarNode: configure each with // menuitem role behavior and store reference in menuitems array. e = this.domNode.firstElementChild; - while ( e ) { + while (e) { var menuElement = e.firstElementChild; - if ( e && menuElement && menuElement.tagName === "A" ) { - menubarItem = new MenubarItem( menuElement, this ); + if (e && menuElement && menuElement.tagName === 'A') { + menubarItem = new MenubarItem(menuElement, this); menubarItem.init(); - this.menubarItems.push( menubarItem ); + this.menubarItems.push(menubarItem); textContent = menuElement.textContent.trim(); - this.firstChars.push( textContent.substring( 0, 1 ).toLowerCase() ); + this.firstChars.push(textContent.substring(0, 1).toLowerCase()); } e = e.nextElementSibling; @@ -90,7 +90,7 @@ Menubar.prototype.init = function() { // Use populated menuitems array to initialize firstItem and lastItem. numItems = this.menubarItems.length; - if ( numItems > 0 ) { + if (numItems > 0) { this.firstItem = this.menubarItems[ 0 ]; this.lastItem = this.menubarItems[ numItems - 1 ]; } @@ -99,70 +99,72 @@ Menubar.prototype.init = function() { /* FOCUS MANAGEMENT METHODS */ -Menubar.prototype.setFocusToFirstItem = function() { +Menubar.prototype.setFocusToFirstItem = function () { this.firstItem.domNode.focus(); }; -Menubar.prototype.setFocusToLastItem = function() { +Menubar.prototype.setFocusToLastItem = function () { this.lastItem.domNode.focus(); }; -Menubar.prototype.setFocusToPreviousItem = function( currentItem ) { +Menubar.prototype.setFocusToPreviousItem = function (currentItem) { var index; currentItem.domNode.tabIndex = -1; - if ( currentItem === this.firstItem ) { + if (currentItem === this.firstItem) { this.lastItem.domNode.focus(); this.lastItem.domNode.tabIndex = 0; - } else { - index = this.menubarItems.indexOf( currentItem ); + } + else { + index = this.menubarItems.indexOf(currentItem); this.menubarItems[ index - 1 ].domNode.focus(); this.menubarItems[ index - 1 ].domNode.tabIndex = 0; } }; -Menubar.prototype.setFocusToNextItem = function( currentItem ) { +Menubar.prototype.setFocusToNextItem = function (currentItem) { var index; currentItem.domNode.tabIndex = -1; - if ( currentItem === this.lastItem ) { + if (currentItem === this.lastItem) { this.firstItem.domNode.focus(); this.firstItem.domNode.tabIndex = 0; - } else { - index = this.menubarItems.indexOf( currentItem ); + } + else { + index = this.menubarItems.indexOf(currentItem); this.menubarItems[ index + 1 ].domNode.focus(); this.menubarItems[ index + 1 ].domNode.tabIndex = 0; } }; -Menubar.prototype.setFocusByFirstCharacter = function( currentItem, char ) { +Menubar.prototype.setFocusByFirstCharacter = function (currentItem, char) { var start, index, char = char.toLowerCase(); // Get start index for search based on position of currentItem - start = this.menubarItems.indexOf( currentItem ) + 1; - if ( start === this.menubarItems.length ) { + start = this.menubarItems.indexOf(currentItem) + 1; + if (start === this.menubarItems.length) { start = 0; } // Check remaining slots in the menu - index = this.getIndexFirstChars( start, char ); + index = this.getIndexFirstChars(start, char); // If not found in remaining slots, check from beginning - if ( index === -1 ) { - index = this.getIndexFirstChars( 0, char ); + if (index === -1) { + index = this.getIndexFirstChars(0, char); } // If match was found... - if ( index > -1 ) { + if (index > -1) { this.menubarItems[ index ].domNode.focus(); this.menubarItems[ index ].domNode.tabIndex = 0; currentItem.tabIndex = -1; } }; -Menubar.prototype.getIndexFirstChars = function( startIndex, char ) { - for ( var i = startIndex; i < this.firstChars.length; i++ ) { - if ( char === this.firstChars[ i ] ) { +Menubar.prototype.getIndexFirstChars = function (startIndex, char) { + for (var i = startIndex; i < this.firstChars.length; i++) { + if (char === this.firstChars[ i ]) { return i; } } @@ -171,21 +173,21 @@ Menubar.prototype.getIndexFirstChars = function( startIndex, char ) { /* MENU DISPLAY METHODS */ -Menubar.prototype.getPosition = function( element ) { +Menubar.prototype.getPosition = function (element) { var x = 0, y = 0; - while ( element ) { - x += ( element.offsetLeft - element.scrollLeft + element.clientLeft ); - y += ( element.offsetTop - element.scrollTop + element.clientTop ); + while (element) { + x += (element.offsetLeft - element.scrollLeft + element.clientLeft); + y += (element.offsetTop - element.scrollTop + element.clientTop); element = element.offsetParent; } - return { x: x, y: y }; + return {x: x, y: y}; }; -Menubar.prototype.open = function() { +Menubar.prototype.open = function () { }; -Menubar.prototype.close = function( force ) { +Menubar.prototype.close = function (force) { }; diff --git a/examples/menubar/menubar-1/js/PopupMenuLinks.js b/examples/menubar/menubar-1/js/PopupMenuLinks.js index 27fe81c70a..8d9ed4fe58 100644 --- a/examples/menubar/menubar-1/js/PopupMenuLinks.js +++ b/examples/menubar/menubar-1/js/PopupMenuLinks.js @@ -32,25 +32,24 @@ * domNode has responded to a mouseover event with no subsequent * mouseout event having occurred. */ -var PopupMenu = function( domNode, controllerObj ) { +var PopupMenu = 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 ) { - throw new TypeError( msgPrefix + "is not a DOM Element." ); + if (!domNode instanceof Element) { + throw new TypeError(msgPrefix + 'is not a DOM Element.'); } // Check whether domNode has child elements - if ( domNode.childElementCount === 0 ) { - throw new Error( msgPrefix + "has no element children." ); + if (domNode.childElementCount === 0) { + throw new Error(msgPrefix + 'has no element children.'); } // Check whether domNode descendant elements have A elements var childElement = domNode.firstElementChild; - while ( childElement ) { + while (childElement) { var menuitem = childElement.firstElementChild; - if ( menuitem && menuitem === "A" ) { - throw new Error( msgPrefix + - "has descendant elements that are not A elements." ); + if (menuitem && menuitem === 'A') { + throw new Error(msgPrefix + 'has descendant elements that are not A elements.'); } childElement = childElement.nextElementSibling; } @@ -76,44 +75,42 @@ var PopupMenu = function( domNode, controllerObj ) { * domNode children to configure each menuitem and populate menuitems * array. Initialize firstItem and lastItem properties. */ -PopupMenu.prototype.init = function() { +PopupMenu.prototype.init = function () { var childElement, menuElement, menuItem, textContent, numItems, label; // Configure the domNode itself this.domNode.tabIndex = -1; - this.domNode.setAttribute( "role", "menu" ); + this.domNode.setAttribute('role', 'menu'); - if ( !this.domNode.getAttribute( "aria-labelledby" ) && - !this.domNode.getAttribute( "aria-label" ) && - !this.domNode.getAttribute( "title" ) ) { + if (!this.domNode.getAttribute('aria-labelledby') && !this.domNode.getAttribute('aria-label') && !this.domNode.getAttribute('title')) { label = this.controller.domNode.innerHTML; - this.domNode.setAttribute( "aria-label", label ); + this.domNode.setAttribute('aria-label', label); } - this.domNode.addEventListener( "mouseover", this.handleMouseover.bind( this ) ); - this.domNode.addEventListener( "mouseout", this.handleMouseout.bind( this ) ); + this.domNode.addEventListener('mouseover', this.handleMouseover.bind(this)); + this.domNode.addEventListener('mouseout', this.handleMouseout.bind(this)); // Traverse the element children of domNode: configure each with // menuitem role behavior and store reference in menuitems array. childElement = this.domNode.firstElementChild; - while ( childElement ) { + while (childElement) { menuElement = childElement.firstElementChild; - if ( menuElement && menuElement.tagName === "A" ) { - menuItem = new MenuItem( menuElement, this ); + if (menuElement && menuElement.tagName === 'A') { + menuItem = new MenuItem(menuElement, this); menuItem.init(); - this.menuitems.push( menuItem ); + this.menuitems.push(menuItem); textContent = menuElement.textContent.trim(); - this.firstChars.push( textContent.substring( 0, 1 ).toLowerCase() ); + this.firstChars.push(textContent.substring(0, 1).toLowerCase()); } childElement = childElement.nextElementSibling; } // Use populated menuitems array to initialize firstItem and lastItem. numItems = this.menuitems.length; - if ( numItems > 0 ) { + if (numItems > 0) { this.firstItem = this.menuitems[ 0 ]; this.lastItem = this.menuitems[ numItems - 1 ]; } @@ -121,86 +118,90 @@ PopupMenu.prototype.init = function() { /* EVENT HANDLERS */ -PopupMenu.prototype.handleMouseover = function( event ) { +PopupMenu.prototype.handleMouseover = function (event) { this.hasHover = true; }; -PopupMenu.prototype.handleMouseout = function( event ) { +PopupMenu.prototype.handleMouseout = function (event) { this.hasHover = false; - setTimeout( this.close.bind( this, false ), 300 ); + setTimeout(this.close.bind(this, false), 300); }; /* FOCUS MANAGEMENT METHODS */ -PopupMenu.prototype.setFocusToController = function( command ) { - if ( typeof command !== "string" ) { - command = ""; +PopupMenu.prototype.setFocusToController = function (command) { + if (typeof command !== 'string') { + command = ''; } - if ( command === "previous" ) { - this.controller.menubar.setFocusToPreviousItem( this.controller ); - } else if ( command === "next" ) { - this.controller.menubar.setFocusToNextItem( this.controller ); - } else { + if (command === 'previous') { + this.controller.menubar.setFocusToPreviousItem(this.controller); + } + else if (command === 'next') { + this.controller.menubar.setFocusToNextItem(this.controller); + } + else { this.controller.domNode.focus(); } }; -PopupMenu.prototype.setFocusToFirstItem = function() { +PopupMenu.prototype.setFocusToFirstItem = function () { this.firstItem.domNode.focus(); }; -PopupMenu.prototype.setFocusToLastItem = function() { +PopupMenu.prototype.setFocusToLastItem = function () { this.lastItem.domNode.focus(); }; -PopupMenu.prototype.setFocusToPreviousItem = function( currentItem ) { +PopupMenu.prototype.setFocusToPreviousItem = function (currentItem) { var index; - if ( currentItem === this.firstItem ) { + if (currentItem === this.firstItem) { this.lastItem.domNode.focus(); - } else { - index = this.menuitems.indexOf( currentItem ); + } + else { + index = this.menuitems.indexOf(currentItem); this.menuitems[ index - 1 ].domNode.focus(); } }; -PopupMenu.prototype.setFocusToNextItem = function( currentItem ) { +PopupMenu.prototype.setFocusToNextItem = function (currentItem) { var index; - if ( currentItem === this.lastItem ) { + if (currentItem === this.lastItem) { this.firstItem.domNode.focus(); - } else { - index = this.menuitems.indexOf( currentItem ); + } + else { + index = this.menuitems.indexOf(currentItem); this.menuitems[ index + 1 ].domNode.focus(); } }; -PopupMenu.prototype.setFocusByFirstCharacter = function( currentItem, char ) { +PopupMenu.prototype.setFocusByFirstCharacter = function (currentItem, char) { var start, index, char = char.toLowerCase(); // Get start index for search based on position of currentItem - start = this.menuitems.indexOf( currentItem ) + 1; - if ( start === this.menuitems.length ) { + start = this.menuitems.indexOf(currentItem) + 1; + if (start === this.menuitems.length) { start = 0; } // Check remaining slots in the menu - index = this.getIndexFirstChars( start, char ); + index = this.getIndexFirstChars(start, char); // If not found in remaining slots, check from beginning - if ( index === -1 ) { - index = this.getIndexFirstChars( 0, char ); + if (index === -1) { + index = this.getIndexFirstChars(0, char); } // If match was found... - if ( index > -1 ) { + if (index > -1) { this.menuitems[ index ].domNode.focus(); } }; -PopupMenu.prototype.getIndexFirstChars = function( startIndex, char ) { - for ( var i = startIndex; i < this.firstChars.length; i++ ) { - if ( char === this.firstChars[ i ] ) { +PopupMenu.prototype.getIndexFirstChars = function (startIndex, char) { + for (var i = startIndex; i < this.firstChars.length; i++) { + if (char === this.firstChars[ i ]) { return i; } } @@ -209,38 +210,38 @@ PopupMenu.prototype.getIndexFirstChars = function( startIndex, char ) { /* MENU DISPLAY METHODS */ -PopupMenu.prototype.getPosition = function( element ) { +PopupMenu.prototype.getPosition = function (element) { var x = 0, y = 0; - while ( element ) { - x += ( element.offsetLeft - element.scrollLeft + element.clientLeft ); - y += ( element.offsetTop - element.scrollTop + element.clientTop ); + while (element) { + x += (element.offsetLeft - element.scrollLeft + element.clientLeft); + y += (element.offsetTop - element.scrollTop + element.clientTop); element = element.offsetParent; } - return { x: x, y: y }; + return {x: x, y: y}; }; -PopupMenu.prototype.open = function() { +PopupMenu.prototype.open = function () { // Get position and bounding rectangle of controller object's DOM node - var pos = this.getPosition( this.controller.domNode ); + var pos = this.getPosition(this.controller.domNode); var rect = this.controller.domNode.getBoundingClientRect(); // Set CSS properties - this.domNode.style.display = "block"; - this.domNode.style.position = "absolute"; - this.domNode.style.top = ( pos.y + rect.height ) + "px"; - this.domNode.style.left = pos.x + "px"; + this.domNode.style.display = 'block'; + this.domNode.style.position = 'absolute'; + this.domNode.style.top = (pos.y + rect.height) + 'px'; + this.domNode.style.left = pos.x + 'px'; // Set aria-expanded attribute - this.controller.domNode.setAttribute( "aria-expanded", "true" ); + this.controller.domNode.setAttribute('aria-expanded', 'true'); }; -PopupMenu.prototype.close = function( force ) { +PopupMenu.prototype.close = function (force) { - if ( force || ( !this.hasFocus && !this.hasHover && !this.controller.hasHover ) ) { - this.domNode.style.display = "none"; - this.controller.domNode.setAttribute( "aria-expanded", "false" ); + if (force || (!this.hasFocus && !this.hasHover && !this.controller.hasHover)) { + this.domNode.style.display = 'none'; + this.controller.domNode.setAttribute('aria-expanded', 'false'); } }; diff --git a/examples/menubar/menubar-1/js/npm-debug.log b/examples/menubar/menubar-1/js/npm-debug.log new file mode 100644 index 0000000000..df59cda30b --- /dev/null +++ b/examples/menubar/menubar-1/js/npm-debug.log @@ -0,0 +1,28 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/local/bin/node', +1 verbose cli '/usr/local/bin/npm', +1 verbose cli 'run', +1 verbose cli 'jscs', +1 verbose cli '-fix' ] +2 info using npm@3.10.3 +3 info using node@v6.7.0 +4 verbose stack Error: missing script: jscs +4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:151:19) +4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:61:5 +4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:356:5 +4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:320:45) +4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:354:3) +4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5) +4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:311:12 +4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16 +4 verbose stack at tryToString (fs.js:455:3) +4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12) +5 verbose cwd /Users/jku/jemma-aria-practice/examples/menubar/menubar-1/js +6 error Darwin 15.6.0 +7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "jscs" "-fix" +8 error node v6.7.0 +9 error npm v3.10.3 +10 error missing script: jscs +11 error If you need help, you may report this error at: +11 error +12 verbose exit [ 1, true ] diff --git a/examples/menubar/menubar-2/js/MenubarAction.js b/examples/menubar/menubar-2/js/MenubarAction.js index a900280348..8f5d25bbeb 100644 --- a/examples/menubar/menubar-2/js/MenubarAction.js +++ b/examples/menubar/menubar-2/js/MenubarAction.js @@ -1,17 +1,6 @@ /* -* Copyright 2016 University of Illinois -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. +* This content is licensed according to the W3C Software License at +* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document * * File: MenubarAction.js * diff --git a/examples/menubar/menubar-2/js/PopupMenuAction.js b/examples/menubar/menubar-2/js/PopupMenuAction.js index d8356f039c..17bc40f0bf 100644 --- a/examples/menubar/menubar-2/js/PopupMenuAction.js +++ b/examples/menubar/menubar-2/js/PopupMenuAction.js @@ -51,8 +51,7 @@ var PopupMenuAction = function (domNode, controllerObj) { while (childElement) { var menuitem = childElement.firstElementChild; if (menuitem && menuitem === 'A') { - throw new Error(msgPrefix + - 'has descendant elements that are not A elements.'); + throw new Error(msgPrefix + 'has descendant elements that are not A elements.'); } childElement = childElement.nextElementSibling; } @@ -86,9 +85,7 @@ PopupMenuAction.prototype.init = function () { this.domNode.setAttribute('role', 'menu'); - if (!this.domNode.getAttribute('aria-labelledby') && - !this.domNode.getAttribute('aria-label') && - !this.domNode.getAttribute('title')) { + if (!this.domNode.getAttribute('aria-labelledby') && !this.domNode.getAttribute('aria-label') && !this.domNode.getAttribute('title')) { label = this.controller.domNode.innerHTML; this.domNode.setAttribute('aria-label', label); } diff --git a/examples/menubar/menubar-2/js/TextStyling.js b/examples/menubar/menubar-2/js/TextStyling.js index 5a3312aca7..aab53b703e 100644 --- a/examples/menubar/menubar-2/js/TextStyling.js +++ b/examples/menubar/menubar-2/js/TextStyling.js @@ -11,18 +11,14 @@ /* * @eventHandler setFontFamily -* * @desc * Sets the CSS font-family property of the text content * identified by the id and updates the menuitemradio * group in the menu to indicate which font is selected -* * @param event * Event object of menuitemradio in the radio group -* * @param id * id property of the element to apply the styling -* * @param value * value for the CSS font-family property * @@ -32,18 +28,23 @@ function setFontFamily (event, id) { var value = event.target.innerHTML; - if (value) document.getElementById(id).style.fontFamily = value; + if (value) { + document.getElementById(id).style.fontFamily = value; + } var childElement = currentTarget.firstElementChild; while (childElement) { - if (childElement.innerHTML === value) childElement.setAttribute('aria-checked', 'true'); - else childElement.setAttribute('aria-checked', 'false'); + if (childElement.innerHTML === value) { + childElement.setAttribute('aria-checked', 'true'); + } + else { + childElement.setAttribute('aria-checked', 'false'); + } childElement = childElement.nextElementSibling; } }; - /* * @eventHandler setTextDecoration * @@ -65,13 +66,19 @@ function setTextDecoration (event, id) { var value = event.target.innerHTML; - if (value) document.getElementById(id).style.textDecoration = value; + if (value) { + document.getElementById(id).style.textDecoration = value; + } var childElement = currentTarget.firstElementChild; while (childElement) { - if (childElement.innerHTML === value) childElement.setAttribute('aria-checked', 'true'); - else childElement.setAttribute('aria-checked', 'false'); + if (childElement.innerHTML === value) { + childElement.setAttribute('aria-checked', 'true'); + } + else { + childElement.setAttribute('aria-checked', 'false'); + } childElement = childElement.nextElementSibling; } }; @@ -96,13 +103,19 @@ function setTextAlign (event, id) { var value = event.target.innerHTML; - if (value) document.getElementById(id).style.textAlign = value; + if (value) { + document.getElementById(id).style.textAlign = value; + } var childElement = currentTarget.firstElementChild; while (childElement) { - if (childElement.innerHTML === value) childElement.setAttribute('aria-checked', 'true'); - else childElement.setAttribute('aria-checked', 'false'); + if (childElement.innerHTML === value) { + childElement.setAttribute('aria-checked', 'true'); + } + else { + childElement.setAttribute('aria-checked', 'false'); + } childElement = childElement.nextElementSibling; } }; @@ -134,8 +147,8 @@ function setFontSize (event, id) { var childElement; var flag; var i; - var disable_smaller; - var disable_larger; + var disableSmaller; + var disableLarger; value = target.innerHTML; @@ -146,11 +159,17 @@ function setFontSize (event, id) { while (childElement) { flag = childElement.getAttribute('aria-checked'); childElement = childElement.nextElementSibling; - if (flag === 'true') break; + if (flag === 'true') { + break; + } } - if (childElement) value = childElement.innerHTML; - else value = false; + if (childElement) { + value = childElement.innerHTML; + } + else { + value = false; + } } else { @@ -161,11 +180,17 @@ function setFontSize (event, id) { while (childElement) { var flag = childElement.getAttribute('aria-checked'); childElement = childElement.previousElementSibling; - if (flag === 'true') break; + if (flag === 'true') { + break; + } } - if (childElement) value = childElement.innerHTML; - else value = false; + if (childElement) { + value = childElement.innerHTML; + } + else { + value = false; + } } } @@ -177,24 +202,40 @@ function setFontSize (event, id) { childElement = radioGroup.firstElementChild; while (childElement) { - if (childElement.innerHTML === value) childElement.setAttribute('aria-checked', 'true'); - else childElement.setAttribute('aria-checked', 'false'); + if (childElement.innerHTML === value) { + childElement.setAttribute('aria-checked', 'true'); + } + else { + childElement.setAttribute('aria-checked', 'false'); + } childElement = childElement.nextElementSibling; + } - if (value === 'X-Small') disable_smaller = 'true'; - else disable_smaller = 'false'; + if (value === 'X-Small') { + disableSmaller = 'true'; + } + else { + disableSmaller = 'false'; + } - if (value === 'X-Large') disable_larger = 'true'; - else disable_larger = 'false'; + if (value === 'X-Large') { + disableLarger = 'true'; + } + else { + disableLarger = 'false'; + } childElement = currentTarget.firstElementChild; while (childElement) { - if (childElement.innerHTML === 'Smaller') childElement.setAttribute('aria-disabled', disable_smaller); - - if (childElement.innerHTML === 'Larger') childElement.setAttribute('aria-disabled', disable_larger); + if (childElement.innerHTML === 'Smaller') { + childElement.setAttribute('aria-disabled', disableSmaller); + } + if (childElement.innerHTML === 'Larger') { + childElement.setAttribute('aria-disabled', disableLarger); + } childElement = childElement.nextElementSibling; } @@ -226,20 +267,23 @@ function setColor (event, id, value) { var value = event.target.innerHTML; - if (value) document.getElementById(id).style.color = value; + if (value) { + document.getElementById(id).style.color = value; + } var childElement = currentTarget.firstElementChild; while (childElement) { - if (childElement.innerHTML === value) childElement.setAttribute('aria-checked', 'true'); - else childElement.setAttribute('aria-checked', 'false'); + if (childElement.innerHTML === value) { + childElement.setAttribute('aria-checked', 'true'); + } + else { + childElement.setAttribute('aria-checked', 'false'); + } childElement = childElement.nextElementSibling; } - }; - - /* * @eventHandler toggleBold *