From 04b9861c6ebf781e47ddb7c7e5dddf40667148dd Mon Sep 17 00:00:00 2001 From: Krinkle Date: Tue, 26 Apr 2011 18:01:52 +0000 Subject: [PATCH] Selectors go from right to left. Starting with a generic 'a' is kind of slow. Also loses the advantage of an id-selector. * Optimizing by selecting the ID seperately (very fast) and doing a find() within that context (also caching pCactions ). * while at it: - caching selector - aliasing $ to jQuery locally - Shorthand dom-ready (Follow-up r86861) --- CREDITS | 1 + skins/vector/vector.js | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CREDITS b/CREDITS index 7f25ced451..5c240391f2 100644 --- a/CREDITS +++ b/CREDITS @@ -65,6 +65,7 @@ following names for their contribution to the product. * Soxred93 * Thomas Bleher * Tim Starling +* Timo Tijhof * Tom Gries * Trevor Parscal * Victor Vasiliev diff --git a/skins/vector/vector.js b/skins/vector/vector.js index 84cb5b846f..b4c14c76d2 100644 --- a/skins/vector/vector.js +++ b/skins/vector/vector.js @@ -1,18 +1,19 @@ /* * Vector-specific scripts */ -$(document).ready( function() { +jQuery( function( $ ) { + var $pCactions = $( '#p-cactions' ); // For accessibility, show the menu when the hidden link in the menu is clicked - $( '#p-cactions h5 a' ).click( function() { - $( '#p-cactions .menu' ).toggleClass( 'menuForceShow' ); + $pCactions.find( 'h5 a' ).click( function() { + $pCactions.find( '.menu' ).toggleClass( 'menuForceShow' ); }); - + // When the hidden link has focus, also set a class that will change the arrow icon - $( '#p-cactions h5 a' ).focus( function () { - $( '#p-cactions' ).addClass( 'vectorMenuFocus' ); + $pCactions.find( 'h5 a' ).focus( function () { + $pCactions.addClass( 'vectorMenuFocus' ); }); - - $( '#p-cactions h5 a' ).blur( function () { - $( '#p-cactions' ).removeClass( 'vectorMenuFocus' ); + + $pCactions.find( 'h5 a' ).blur( function () { + $pCactions.removeClass( 'vectorMenuFocus' ); }); }); -- 2.20.1