From: Krinkle Date: Tue, 26 Apr 2011 18:01:52 +0000 (+0000) Subject: Selectors go from right to left. Starting with a generic 'a' is kind of slow. Also... X-Git-Tag: 1.31.0-rc.0~30546 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=04b9861c6ebf781e47ddb7c7e5dddf40667148dd;p=lhc%2Fweb%2Fwiklou.git 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) --- 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' ); }); });