From a8b5e7c454e0042250644ff4de3d634152dcb1f4 Mon Sep 17 00:00:00 2001 From: Ulrich Pogson Date: Sun, 23 Jul 2017 10:47:11 +0200 Subject: [PATCH] Enable coding standards for JS files - Updated file headers to match the WP coding standards See: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/javascript/#file-headers - Save the length in the loop as a variable. See: https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/#iteration --- js/customizer.js | 8 ++++---- js/navigation.js | 9 +++++---- js/skip-link-focus-fix.js | 7 ++++--- phpcs.xml.dist | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/js/customizer.js b/js/customizer.js index 757367a26f..00511c3853 100644 --- a/js/customizer.js +++ b/js/customizer.js @@ -1,9 +1,9 @@ /** - * File customizer.js. + * Theme Customizer enhancements for a better user experience. Contains + * handlers to make Theme Customizer preview reload changes asynchronously. * - * Theme Customizer enhancements for a better user experience. - * - * Contains handlers to make Theme Customizer preview reload changes asynchronously. + * @requires customize-preview.js + * @package _s */ ( function( $ ) { diff --git a/js/navigation.js b/js/navigation.js index 3ffa7cc813..2f3caf116c 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -1,9 +1,10 @@ /** - * File navigation.js. - * * Handles toggling the navigation menu for small screens and enables TAB key * navigation support for dropdown menus. + * + * @package _s */ + ( function() { var container, button, menu, links, i, len; @@ -86,7 +87,7 @@ if ( ! menuItem.classList.contains( 'focus' ) ) { e.preventDefault(); - for ( i = 0; i < menuItem.parentNode.children.length; ++i ) { + for ( var i = 0, len = menuItem.parentNode.children.length; i < len; ++i ) { if ( menuItem === menuItem.parentNode.children[i] ) { continue; } @@ -98,7 +99,7 @@ } }; - for ( i = 0; i < parentLink.length; ++i ) { + for ( var i = 0, len = parentLink.length; i < len; ++i ) { parentLink[i].addEventListener( 'touchstart', touchStartFn, false ); } } diff --git a/js/skip-link-focus-fix.js b/js/skip-link-focus-fix.js index 0037752e09..21bfee3945 100644 --- a/js/skip-link-focus-fix.js +++ b/js/skip-link-focus-fix.js @@ -1,10 +1,11 @@ /** - * File skip-link-focus-fix.js. - * * Helps with accessibility for keyboard only users. * - * Learn more: https://git.io/vWdr2 + * @link https://git.io/vWdr2 + * + * @package _s */ + ( function() { var isIe = /(trident|msie)/i.test( navigator.userAgent ); diff --git a/phpcs.xml.dist b/phpcs.xml.dist index c75e45ecdd..1d0fcb62f6 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -17,7 +17,7 @@ - + .