Selectors go from right to left. Starting with a generic 'a' is kind of slow. Also...
authorKrinkle <krinkle@users.mediawiki.org>
Tue, 26 Apr 2011 18:01:52 +0000 (18:01 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Tue, 26 Apr 2011 18:01:52 +0000 (18:01 +0000)
* 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
skins/vector/vector.js

diff --git a/CREDITS b/CREDITS
index 7f25ced..5c24039 100644 (file)
--- 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
index 84cb5b8..b4c14c7 100644 (file)
@@ -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' );
        });
 });