summaryrefslogtreecommitdiff
path: root/resources/mediawiki/mediawiki.htmlform.js
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
commitca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch)
treeec04cc15b867bc21eedca904cea9af0254531a11 /resources/mediawiki/mediawiki.htmlform.js
parenta22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff)
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing
Diffstat (limited to 'resources/mediawiki/mediawiki.htmlform.js')
-rw-r--r--resources/mediawiki/mediawiki.htmlform.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/resources/mediawiki/mediawiki.htmlform.js b/resources/mediawiki/mediawiki.htmlform.js
new file mode 100644
index 00000000..1a6acd6f
--- /dev/null
+++ b/resources/mediawiki/mediawiki.htmlform.js
@@ -0,0 +1,64 @@
+/**
+ * Utility functions for jazzing up HTMLForm elements
+ */
+( function( $ ) {
+
+/**
+ * jQuery plugin to fade or snap to visible state.
+ *
+ * @param boolean instantToggle (optional)
+ * @return jQuery
+ */
+$.fn.goIn = function( instantToggle ) {
+ if ( instantToggle !== undefined && instantToggle === true ) {
+ return $(this).show();
+ }
+ return $(this).stop( true, true ).fadeIn();
+};
+
+/**
+ * jQuery plugin to fade or snap to hiding state.
+ *
+ * @param boolean instantToggle (optional)
+ * @return jQuery
+ */
+$.fn.goOut = function( instantToggle ) {
+ if ( instantToggle !== undefined && instantToggle === true ) {
+ return $(this).hide();
+ }
+ return $(this).stop( true, true ).fadeOut();
+};
+
+/**
+ * Bind a function to the jQuery object via live(), and also immediately trigger
+ * the function on the objects with an 'instant' paramter set to true
+ * @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
+ */
+$.fn.liveAndTestAtStart = function( callback ){
+ $(this)
+ .live( 'change', callback )
+ .each( function( index, element ){
+ callback.call( this, true );
+ } );
+};
+
+// 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 ) {
+ var $other = $( '#' + $(this).attr( 'id' ) + '-other' );
+ $other = $other.add( $other.siblings( 'br' ) );
+ if ( $(this).val() === 'other' ) {
+ $other.goIn( instant );
+ } else {
+ $other.goOut( instant );
+ }
+ });
+
+});
+
+
+})( jQuery );