From 1fdfc7a37fd825f963497887886ee52a175271f4 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Thu, 10 Mar 2011 17:38:21 +0000 Subject: [PATCH] Fixing minor issues in mw.htmlform * jQuery should be mapped to $ before using it. $ should not be implied as global in-core. ("return $(this).show()" was using $ as global) ** added wrapper and replaced jQuery with $. * Missing semicolon --- resources/mediawiki/mediawiki.htmlform.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/resources/mediawiki/mediawiki.htmlform.js b/resources/mediawiki/mediawiki.htmlform.js index d4265e06a0..4692e9e424 100644 --- a/resources/mediawiki/mediawiki.htmlform.js +++ b/resources/mediawiki/mediawiki.htmlform.js @@ -1,19 +1,20 @@ /** * Utility functions for jazzing up HTMLForm elements */ +( function( $ ) { // Fade or snap depending on argument -jQuery.fn.goIn = function( instantToggle ) { +$.fn.goIn = function( instantToggle ) { if ( typeof instantToggle != 'undefined' && instantToggle === true ) { return $(this).show(); } - return jQuery(this).stop( true, true ).fadeIn(); + return $(this).stop( true, true ).fadeIn(); }; -jQuery.fn.goOut = function( instantToggle ) { +$.fn.goOut = function( instantToggle ) { if ( typeof instantToggle != 'undefined' && instantToggle === true ) { return $(this).hide(); } - return jQuery(this).stop( true, true ).fadeOut(); + return $(this).stop( true, true ).fadeOut(); }; /** @@ -22,19 +23,20 @@ jQuery.fn.goOut = function( instantToggle ) { * @param callback function taking one paramter, which is Bool true when the event * is called immediately, and the EventArgs object when triggered from an event */ -jQuery.fn.liveAndTestAtStart = function( callback ){ +$.fn.liveAndTestAtStart = function( callback ){ $(this) .live( 'change', callback ) .each( function( index, element ){ callback.call( this, true ); } ); -} +}; -jQuery( function( $ ) { +// Document ready: +$( function() { // animate the SelectOrOther fields, to only show the text field when // 'other' is selected - $( '.mw-htmlform-select-or-other' ).liveAndTestAtStart( function( instant ){ + $( '.mw-htmlform-select-or-other' ).liveAndTestAtStart( function( instant ) { var $other = $( '#' + $(this).attr( 'id' ) + '-other' ); if ( $(this).val() == 'other' ) { $other.goIn( instant ); @@ -43,4 +45,7 @@ jQuery( function( $ ) { } }); -}); \ No newline at end of file +}); + + +})( jQuery ); \ No newline at end of file -- 2.20.1