Improve jQuery to automatically remove focus (dotted line) on events with e.preventDefault.

This commit is contained in:
MickeyKay
2015-01-21 12:10:20 -08:00
parent dd5aa2b4c9
commit f9b299eb87
2 changed files with 28 additions and 5 deletions
+28 -4
View File
@@ -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();
});
-1
View File
@@ -1383,7 +1383,6 @@ Site Header
.site-header .toggle-button {
margin-left: 15px;
outline: none;
}
.site-header .toggle-button.open {