From f9b299eb87489a969910fa40cbfe204c382b92b9 Mon Sep 17 00:00:00 2001 From: MickeyKay Date: Wed, 21 Jan 2015 12:10:20 -0800 Subject: [PATCH] Improve jQuery to automatically remove focus (dotted line) on events with e.preventDefault. --- includes/js/theme-jquery.js | 32 ++++++++++++++++++++++++++++---- style.css | 1 - 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/includes/js/theme-jquery.js b/includes/js/theme-jquery.js index 784db77..71ff524 100644 --- a/includes/js/theme-jquery.js +++ b/includes/js/theme-jquery.js @@ -57,9 +57,16 @@ jQuery(document).ready(function( $ ) { // Toggle widget areas and primary nav $('.site-header .toggle-button').click( function( event ) { - event.preventDefault(); + + // Prevent default behavior + event.preventDefault(); + // Get toggle button that was clicked var button = $(this); + + // Remove focus + button.blur(); + var target = $( '.toggle-target-' + button.attr('id').match(/\d+/) ); // Toggle buttons @@ -69,6 +76,7 @@ jQuery(document).ready(function( $ ) { // Toggle targets target.toggleClass('open'); $('[class*="toggle-target"]').not(target).removeClass('open'); + }); // Mobile navigation icons @@ -80,8 +88,16 @@ jQuery(document).ready(function( $ ) { // Mobile navigation expand/contract functionality $('.sub-icon').click(function(event) { - event.preventDefault(); - var icon = $(this); + + // Prevent default behavior + event.preventDefault(); + + // Get icon clicked + var icon = $(this); + + // Remove focus + icon.blur(); + icon.next('ul').slideToggle().toggleClass('open'); if ( icon.text().indexOf( closedIcon ) !== -1 ) icon.text(openIcon); @@ -90,8 +106,16 @@ jQuery(document).ready(function( $ ) { }); $('.widget-area-toggle').click(function(event) { - event.preventDefault(); + + // Prevent default behavior + event.preventDefault(); + + // Get button clicked var button = $(this); + + // Remove focus + button.blur(); + button.toggleClass('open'); button.next('.widget-area').slideToggle(); }); diff --git a/style.css b/style.css index 144a514..685abf3 100644 --- a/style.css +++ b/style.css @@ -1383,7 +1383,6 @@ Site Header .site-header .toggle-button { margin-left: 15px; - outline: none; } .site-header .toggle-button.open {