summaryrefslogtreecommitdiff
path: root/resources/mediawiki.special
diff options
context:
space:
mode:
Diffstat (limited to 'resources/mediawiki.special')
-rw-r--r--resources/mediawiki.special/mediawiki.special.block.js78
-rw-r--r--resources/mediawiki.special/mediawiki.special.changeemail.js62
-rw-r--r--resources/mediawiki.special/mediawiki.special.changeslist.css11
-rw-r--r--resources/mediawiki.special/mediawiki.special.javaScriptTest.js2
-rw-r--r--resources/mediawiki.special/mediawiki.special.js6
-rw-r--r--resources/mediawiki.special/mediawiki.special.movePage.js9
-rw-r--r--resources/mediawiki.special/mediawiki.special.preferences.js336
-rw-r--r--resources/mediawiki.special/mediawiki.special.recentchanges.js31
-rw-r--r--resources/mediawiki.special/mediawiki.special.search.js90
-rw-r--r--resources/mediawiki.special/mediawiki.special.undelete.js13
-rw-r--r--resources/mediawiki.special/mediawiki.special.upload.js91
-rw-r--r--resources/mediawiki.special/mediawiki.special.userLogin.signup.js10
12 files changed, 400 insertions, 339 deletions
diff --git a/resources/mediawiki.special/mediawiki.special.block.js b/resources/mediawiki.special/mediawiki.special.block.js
index 6f79929b..2a158dfb 100644
--- a/resources/mediawiki.special/mediawiki.special.block.js
+++ b/resources/mediawiki.special/mediawiki.special.block.js
@@ -1,46 +1,46 @@
-/* JavaScript for Special:Block */
+/**
+ * JavaScript for Special:Block
+ */
+( function ( mw, $ ) {
+ $( document ).ready( function () {
+ var $blockTarget = $( '#mw-bi-target' ),
+ $anonOnlyRow = $( '#mw-input-wpHardBlock' ).closest( 'tr' ),
+ $enableAutoblockRow = $( '#mw-input-wpAutoBlock' ).closest( 'tr' ),
+ $hideUser = $( '#mw-input-wpHideUser' ).closest( 'tr' ),
+ $watchUser = $( '#mw-input-wpWatch' ).closest( 'tr' );
-jQuery( function( $ ) {
+ function updateBlockOptions( instant ) {
+ var blocktarget = $.trim( $blockTarget.val() ),
+ isEmpty = blocktarget === '',
+ isIp = mw.util.isIPv4Address( blocktarget, true ) || mw.util.isIPv6Address( blocktarget, true ),
+ isIpRange = isIp && blocktarget.match( /\/\d+$/ );
- var DO_INSTANT = true,
- $blockTarget = $( '#mw-bi-target' ),
- $anonOnlyRow = $( '#mw-input-wpHardBlock' ).closest( 'tr' ),
- $enableAutoblockRow = $( '#mw-input-wpAutoBlock' ).closest( 'tr' ),
- $hideUser = $( '#mw-input-wpHideUser' ).closest( 'tr' ),
- $watchUser = $( '#mw-input-wpWatch' ).closest( 'tr' );
-
- var updateBlockOptions = function( instant ) {
- if ( !$blockTarget.length ) {
- return;
+ if ( isIp && !isEmpty ) {
+ $enableAutoblockRow.goOut( instant );
+ $hideUser.goOut( instant );
+ } else {
+ $enableAutoblockRow.goIn( instant );
+ $hideUser.goIn( instant );
+ }
+ if ( !isIp && !isEmpty ) {
+ $anonOnlyRow.goOut( instant );
+ } else {
+ $anonOnlyRow.goIn( instant );
+ }
+ if ( isIpRange && !isEmpty ) {
+ $watchUser.goOut( instant );
+ } else {
+ $watchUser.goIn( instant );
+ }
}
- var blocktarget = $.trim( $blockTarget.val() );
- var isEmpty = ( blocktarget === '' );
- var isIp = mw.util.isIPv4Address( blocktarget, true ) || mw.util.isIPv6Address( blocktarget, true );
- var isIpRange = isIp && blocktarget.match( /\/\d+$/ );
+ if ( $blockTarget.length ) {
+ // Bind functions so they're checked whenever stuff changes
+ $blockTarget.keyup( updateBlockOptions );
- if ( isIp && !isEmpty ) {
- $enableAutoblockRow.goOut( instant );
- $hideUser.goOut( instant );
- } else {
- $enableAutoblockRow.goIn( instant );
- $hideUser.goIn( instant );
- }
- if ( !isIp && !isEmpty ) {
- $anonOnlyRow.goOut( instant );
- } else {
- $anonOnlyRow.goIn( instant );
+ // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
+ updateBlockOptions( /* instant= */ true );
}
- if ( isIpRange && !isEmpty ) {
- $watchUser.goOut( instant );
- } else {
- $watchUser.goIn( instant );
- }
- };
-
- // Bind functions so they're checked whenever stuff changes
- $blockTarget.keyup( updateBlockOptions );
+ } );
+}( mediaWiki, jQuery ) );
- // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
- updateBlockOptions( DO_INSTANT );
-});
diff --git a/resources/mediawiki.special/mediawiki.special.changeemail.js b/resources/mediawiki.special/mediawiki.special.changeemail.js
index cab0bbd3..14c2f036 100644
--- a/resources/mediawiki.special/mediawiki.special.changeemail.js
+++ b/resources/mediawiki.special/mediawiki.special.changeemail.js
@@ -1,42 +1,42 @@
-/*
+/**
* JavaScript for Special:ChangeEmail
*/
( function ( mw, $ ) {
+ /**
+ * Given an email validity status (true, false, null) update the label CSS class
+ */
+ function updateMailValidityLabel( mail ) {
+ var isValid = mw.util.validateEmail( mail ),
+ $label = $( '#mw-emailaddress-validity' );
-/**
- * Given an email validity status (true, false, null) update the label CSS class
- */
-function updateMailValidityLabel( mail ) {
- var isValid = mw.util.validateEmail( mail ),
- $label = $( '#mw-emailaddress-validity' );
-
- // We allow empty address
- if( isValid === null ) {
- $label.text( '' ).removeClass( 'valid invalid' );
+ // We allow empty address
+ if ( isValid === null ) {
+ $label.text( '' ).removeClass( 'valid invalid' );
- // Valid
- } else if ( isValid ) {
- $label.text( mw.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' );
+ // Valid
+ } else if ( isValid ) {
+ $label.text( mw.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' );
- // Not valid
- } else {
- $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' );
+ // Not valid
+ } else {
+ $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' );
+ }
}
-}
-$( document ).ready( function () {
- // Lame tip to let user know if its email is valid. See bug 22449
- // Only bind once for 'blur' so that the user can fill it in without errors
- // After that look at every keypress for direct feedback if it was invalid onblur
- $( '#wpNewEmail' ).one( 'blur', function () {
- if ( $( '#mw-emailaddress-validity' ).length === 0 ) {
- $(this).after( '<label for="wpNewEmail" id="mw-emailaddress-validity"></label>' );
- }
- updateMailValidityLabel( $(this).val() );
- $(this).keyup( function () {
- updateMailValidityLabel( $(this).val() );
+ $( document ).ready( function () {
+ // Lame tip to let user know if its email is valid. See bug 22449.
+ // Only bind once for 'blur' so that the user can fill it in without errors;
+ // after that, look at every keypress for immediate feedback.
+ $( '#wpNewEmail' ).one( 'blur', function () {
+ var $this = $( this );
+ if ( $( '#mw-emailaddress-validity' ).length === 0 ) {
+ $this.after( '<label for="wpNewEmail" id="mw-emailaddress-validity"></label>' );
+ }
+
+ updateMailValidityLabel( $this.val() );
+ $this.keyup( function () {
+ updateMailValidityLabel( $this.val() );
+ } );
} );
} );
-} );
-
}( mediaWiki, jQuery ) );
diff --git a/resources/mediawiki.special/mediawiki.special.changeslist.css b/resources/mediawiki.special/mediawiki.special.changeslist.css
index 8a5421e8..fcdeba1b 100644
--- a/resources/mediawiki.special/mediawiki.special.changeslist.css
+++ b/resources/mediawiki.special/mediawiki.special.changeslist.css
@@ -31,12 +31,12 @@ table.mw-enhanced-rc td.mw-enhanced-rc-nested {
float: none;
}
-/* If JS is disabled, the arrow shouldn't be shown */
-.client-nojs .mw-enhancedchanges-arrow.mw-collapsible-toggle {
+/* If JS is disabled, the arrows or the placeholder space shouldn't be shown */
+.client-nojs .mw-enhancedchanges-arrow-space {
display: none;
}
-.mw-enhancedchanges-arrow {
+.mw-enhancedchanges-arrow-space {
display: inline-block;
*display: inline; /* IE7 and below */
zoom: 1;
@@ -44,8 +44,9 @@ table.mw-enhanced-rc td.mw-enhanced-rc-nested {
height: 15px;
}
-.mw-enhancedchanges-arrow.mw-enhancedchanges-arrow-space {
- background: none;
+/* let it look like it is clickable */
+.mw-enhancedchanges-arrow.mw-collapsible-toggle {
+ cursor: pointer;
}
.mw-enhancedchanges-arrow.mw-collapsible-toggle-collapsed {
diff --git a/resources/mediawiki.special/mediawiki.special.javaScriptTest.js b/resources/mediawiki.special/mediawiki.special.javaScriptTest.js
index 808d5fe8..a560ca95 100644
--- a/resources/mediawiki.special/mediawiki.special.javaScriptTest.js
+++ b/resources/mediawiki.special/mediawiki.special.javaScriptTest.js
@@ -8,7 +8,7 @@
// (only if a framework was found, not on error pages).
$( '#mw-javascripttest-summary.mw-javascripttest-frameworkfound' ).append( function () {
- var $html = $( '<p><label for="useskin">'
+ var $html = $( '<p><label for="useskin">'
+ mw.message( 'javascripttest-pagetext-skins' ).escaped()
+ ' '
+ '</label></p>' ),
diff --git a/resources/mediawiki.special/mediawiki.special.js b/resources/mediawiki.special/mediawiki.special.js
index 3526cef4..8edb1cbe 100644
--- a/resources/mediawiki.special/mediawiki.special.js
+++ b/resources/mediawiki.special/mediawiki.special.js
@@ -1 +1,5 @@
-mw.special = {};
+/*
+ * Namespace for mediawiki.special.* modules
+ */
+
+mediaWiki.special = {};
diff --git a/resources/mediawiki.special/mediawiki.special.movePage.js b/resources/mediawiki.special/mediawiki.special.movePage.js
index 68c2ed07..f719d07c 100644
--- a/resources/mediawiki.special/mediawiki.special.movePage.js
+++ b/resources/mediawiki.special/mediawiki.special.movePage.js
@@ -1,5 +1,6 @@
-/* JavaScript for Special:MovePage */
-
-jQuery( function( $ ) {
+/**
+ * JavaScript for Special:MovePage
+ */
+jQuery( document ).ready( function ( $ ) {
$( '#wpReason, #wpNewTitleMain' ).byteLimit();
-});
+} );
diff --git a/resources/mediawiki.special/mediawiki.special.preferences.js b/resources/mediawiki.special/mediawiki.special.preferences.js
index 47872907..6eaec6a1 100644
--- a/resources/mediawiki.special/mediawiki.special.preferences.js
+++ b/resources/mediawiki.special/mediawiki.special.preferences.js
@@ -1,175 +1,199 @@
-/*
+/**
* JavaScript for Special:Preferences
*/
jQuery( document ).ready( function ( $ ) {
-$( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
-var $preftoc = $('<ul id="preftoc"></ul>');
-var $preferences = $( '#preferences' )
- .addClass( 'jsprefs' )
- .before( $preftoc );
-
-var $fieldsets = $preferences.children( 'fieldset' )
- .hide()
- .addClass( 'prefsection' );
+ var $preftoc, $preferences, $fieldsets, $legends,
+ hash,
+ $tzSelect, $tzTextbox, $localtimeHolder, servertime;
+
+ $( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
+
+ $preftoc = $('<ul id="preftoc"></ul>');
+ $preferences = $( '#preferences' )
+ .addClass( 'jsprefs' )
+ .before( $preftoc );
+ $fieldsets = $preferences.children( 'fieldset' )
+ .hide()
+ .addClass( 'prefsection' );
+ $legends = $fieldsets
+ .children( 'legend' )
+ .addClass( 'mainLegend' );
+
+ /**
+ * It uses document.getElementById for security reasons (HTML injections in $()).
+ *
+ * @param String name: the name of a tab without the prefix ("mw-prefsection-")
+ * @param String mode: [optional] A hash will be set according to the current
+ * open section. Set mode 'noHash' to surpress this.
+ */
+ function switchPrefTab( name, mode ) {
+ var $tab, scrollTop;
+ // Handle hash manually to prevent jumping,
+ // therefore save and restore scrollTop to prevent jumping.
+ scrollTop = $( window ).scrollTop();
+ if ( mode !== 'noHash' ) {
+ window.location.hash = '#mw-prefsection-' + name;
+ }
+ $( window ).scrollTop( scrollTop );
+
+ $preftoc.find( 'li' ).removeClass( 'selected' );
+ $tab = $( document.getElementById( 'preftab-' + name ) );
+ if ( $tab.length ) {
+ $tab.parent().addClass( 'selected' );
+ $preferences.children( 'fieldset' ).hide();
+ $( document.getElementById( 'mw-prefsection-' + name ) ).show();
+ }
+ }
-var $legends = $fieldsets.children( 'legend' )
- .addClass( 'mainLegend' );
+ // Populate the prefToc
+ $legends.each( function ( i, legend ) {
+ var $legend = $(legend),
+ ident, $li, $a;
+ if ( i === 0 ) {
+ $legend.parent().show();
+ }
+ ident = $legend.parent().attr( 'id' );
+
+ $li = $( '<li>' )
+ .addClass( i === 0 ? 'selected' : '' );
+ $a = $( '<a>' )
+ .attr( {
+ id: ident.replace( 'mw-prefsection', 'preftab' ),
+ href: '#' + ident
+ } )
+ .text( $legend.text() );
+ $li.append( $a );
+ $preftoc.append( $li );
+ } );
+
+ // If we've reloaded the page or followed an open-in-new-window,
+ // make the selected tab visible.
+ hash = window.location.hash;
+ if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) {
+ switchPrefTab( hash.replace( '#mw-prefsection-' , '' ) );
+ }
-/**
- * It uses document.getElementById for security reasons (html injections in
- * jQuery()).
- *
- * @param String name: the name of a tab without the prefix ("mw-prefsection-")
- * @param String mode: [optional] A hash will be set according to the current
- * open section. Set mode 'noHash' to surpress this.
- */
-function switchPrefTab( name, mode ) {
- var $tab, scrollTop;
- // Handle hash manually to prevent jumping,
- // therefore save and restore scrollTop to prevent jumping.
- scrollTop = $( window ).scrollTop();
- if ( mode !== 'noHash' ) {
- window.location.hash = '#mw-prefsection-' + name;
+ // In browsers that support the onhashchange event we will not bind click
+ // handlers and instead let the browser do the default behavior (clicking the
+ // <a href="#.."> will naturally set the hash, handled by onhashchange.
+ // But other things that change the hash will also be catched (e.g. using
+ // the Back and Forward browser navigation).
+ // Note the special check for IE "compatibility" mode.
+ if ( 'onhashchange' in window &&
+ ( document.documentMode === undefined || document.documentMode >= 8 )
+ ) {
+ $(window).on( 'hashchange' , function () {
+ var hash = window.location.hash;
+ if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) {
+ switchPrefTab( hash.replace( '#mw-prefsection-', '' ) );
+ } else if ( hash === '' ) {
+ switchPrefTab( 'personal', 'noHash' );
+ }
+ });
+ // In older browsers we'll bind a click handler as fallback.
+ // We must not have onhashchange *and* the click handlers, other wise
+ // the click handler calls switchPrefTab() which sets the hash value,
+ // which triggers onhashcange and calls switchPrefTab() again.
+ } else {
+ $preftoc.on( 'click', 'li a', function ( e ) {
+ switchPrefTab( $( this ).attr( 'href' ).replace( '#mw-prefsection-', '' ) );
+ e.preventDefault();
+ });
}
- $( window ).scrollTop( scrollTop );
-
- $preftoc.find( 'li' ).removeClass( 'selected' );
- $tab = $( document.getElementById( 'preftab-' + name ) );
- if ( $tab.length ) {
- $tab.parent().addClass( 'selected' );
- $preferences.children( 'fieldset' ).hide();
- $( document.getElementById( 'mw-prefsection-' + name ) ).show();
+
+ /**
+ * Timezone functions.
+ * Guesses Timezone from browser and updates fields onchange
+ */
+
+ $tzSelect = $( '#mw-input-wptimecorrection' );
+ $tzTextbox = $( '#mw-input-wptimecorrection-other' );
+ $localtimeHolder = $( '#wpLocalTime' );
+ servertime = parseInt( $( 'input[name="wpServerTime"]' ).val(), 10 );
+
+ function minutesToHours( min ) {
+ var tzHour = Math.floor( Math.abs( min ) / 60 ),
+ tzMin = Math.abs( min ) % 60,
+ tzString = ( ( min >= 0 ) ? '' : '-' ) + ( ( tzHour < 10 ) ? '0' : '' ) + tzHour +
+ ':' + ( ( tzMin < 10 ) ? '0' : '' ) + tzMin;
+ return tzString;
}
-}
-// Populate the prefToc
-$legends.each( function ( i, legend ) {
- var $legend = $(legend);
- if ( i === 0 ) {
- $legend.parent().show();
+ function hoursToMinutes( hour ) {
+ var minutes,
+ arr = hour.split( ':' );
+
+ arr[0] = parseInt( arr[0], 10 );
+
+ if ( arr.length === 1 ) {
+ // Specification is of the form [-]XX
+ minutes = arr[0] * 60;
+ } else {
+ // Specification is of the form [-]XX:XX
+ minutes = Math.abs( arr[0] ) * 60 + parseInt( arr[1], 10 );
+ if ( arr[0] < 0 ) {
+ minutes *= -1;
+ }
+ }
+ // Gracefully handle non-numbers.
+ if ( isNaN( minutes ) ) {
+ return 0;
+ } else {
+ return minutes;
+ }
}
- var ident = $legend.parent().attr( 'id' );
-
- var $li = $( '<li/>', {
- 'class' : ( i === 0 ) ? 'selected' : null
- });
- var $a = $( '<a/>', {
- text : $legend.text(),
- id : ident.replace( 'mw-prefsection', 'preftab' ),
- href : '#' + ident
- });
- $li.append( $a );
- $preftoc.append( $li );
-} );
-// If we've reloaded the page or followed an open-in-new-window,
-// make the selected tab visible.
-var hash = window.location.hash;
-if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) {
- switchPrefTab( hash.replace( '#mw-prefsection-' , '' ) );
-}
-
-// In browsers that support the onhashchange event we will not bind click
-// handlers and instead let the browser do the default behavior (clicking the
-// <a href="#.."> will naturally set the hash, handled by onhashchange.
-// But other things that change the hash will also be catched (e.g. using
-// the Back and Forward browser navigation).
-if ( 'onhashchange' in window ) {
- $(window).on( 'hashchange' , function () {
- var hash = window.location.hash;
- if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) {
- switchPrefTab( hash.replace( '#mw-prefsection-', '' ) );
- } else if ( hash === '' ) {
- switchPrefTab( 'personal', 'noHash' );
+ function updateTimezoneSelection () {
+ var minuteDiff, localTime,
+ type = $tzSelect.val();
+
+ if ( type === 'guess' ) {
+ // Get browser timezone & fill it in
+ minuteDiff = -( new Date().getTimezoneOffset() );
+ $tzTextbox.val( minutesToHours( minuteDiff ) );
+ $tzSelect.val( 'other' );
+ $tzTextbox.prop( 'disabled', false );
+ } else if ( type === 'other' ) {
+ // Grab data from the textbox, parse it.
+ minuteDiff = hoursToMinutes( $tzTextbox.val() );
+ } else {
+ // Grab data from the $tzSelect value
+ minuteDiff = parseInt( type.split( '|' )[1], 10 ) || 0;
+ $tzTextbox.val( minutesToHours( minuteDiff ) );
}
- });
-// In older browsers we'll bind a click handler as fallback.
-// We must not have onhashchange *and* the click handlers, other wise
-// the click handler calls switchPrefTab() which sets the hash value,
-// which triggers onhashcange and calls switchPrefTab() again.
-} else {
- $preftoc.on( 'click', 'li a', function ( e ) {
- switchPrefTab( $( this ).attr( 'href' ).replace( '#mw-prefsection-', '' ) );
- e.preventDefault();
- });
-}
-/**
-* Timezone functions.
-* Guesses Timezone from browser and updates fields onchange
-*/
-
-var $tzSelect = $( '#mw-input-wptimecorrection' );
-var $tzTextbox = $( '#mw-input-wptimecorrection-other' );
-
-var $localtimeHolder = $( '#wpLocalTime' );
-var servertime = parseInt( $( 'input[name=wpServerTime]' ).val(), 10 );
-var minuteDiff = 0;
-
-var minutesToHours = function ( min ) {
- var tzHour = Math.floor( Math.abs( min ) / 60 );
- var tzMin = Math.abs( min ) % 60;
- var tzString = ( ( min >= 0 ) ? '' : '-' ) + ( ( tzHour < 10 ) ? '0' : '' ) + tzHour +
- ':' + ( ( tzMin < 10 ) ? '0' : '' ) + tzMin;
- return tzString;
-};
-
-var hoursToMinutes = function ( hour ) {
- var arr = hour.split( ':' );
- arr[0] = parseInt( arr[0], 10 );
-
- var minutes;
- if ( arr.length == 1 ) {
- // Specification is of the form [-]XX
- minutes = arr[0] * 60;
- } else {
- // Specification is of the form [-]XX:XX
- minutes = Math.abs( arr[0] ) * 60 + parseInt( arr[1], 10 );
- if ( arr[0] < 0 ) {
- minutes *= -1;
+ // Determine local time from server time and minutes difference, for display.
+ localTime = servertime + minuteDiff;
+
+ // Bring time within the [0,1440) range.
+ while ( localTime < 0 ) {
+ localTime += 1440;
}
+ while ( localTime >= 1440 ) {
+ localTime -= 1440;
+ }
+ $localtimeHolder.text( minutesToHours( localTime ) );
}
- // Gracefully handle non-numbers.
- if ( isNaN( minutes ) ) {
- return 0;
- } else {
- return minutes;
- }
-};
-
-var updateTimezoneSelection = function () {
- var type = $tzSelect.val();
- if ( type == 'guess' ) {
- // Get browser timezone & fill it in
- minuteDiff = -new Date().getTimezoneOffset();
- $tzTextbox.val( minutesToHours( minuteDiff ) );
- $tzSelect.val( 'other' );
- $tzTextbox.get( 0 ).disabled = false;
- } else if ( type == 'other' ) {
- // Grab data from the textbox, parse it.
- minuteDiff = hoursToMinutes( $tzTextbox.val() );
- } else {
- // Grab data from the $tzSelect value
- minuteDiff = parseInt( type.split( '|' )[1], 10 ) || 0;
- $tzTextbox.val( minutesToHours( minuteDiff ) );
+
+ if ( $tzSelect.length && $tzTextbox.length ) {
+ $tzSelect.change( updateTimezoneSelection );
+ $tzTextbox.blur( updateTimezoneSelection );
+ updateTimezoneSelection();
}
- // Determine local time from server time and minutes difference, for display.
- var localTime = servertime + minuteDiff;
+ // Preserve the tab after saving the preferences
+ // Not using cookies, because their deletion results are inconsistent.
+ // Not using jStorage due to its enormous size (for this feature)
+ if ( window.sessionStorage ) {
+ if ( sessionStorage.getItem( 'mediawikiPreferencesTab' ) !== null ) {
+ switchPrefTab( sessionStorage.getItem( 'mediawikiPreferencesTab' ), 'noHash' );
+ }
+ // Deleting the key, the tab states should be reset until we press Save
+ sessionStorage.removeItem( 'mediawikiPreferencesTab' );
- // Bring time within the [0,1440) range.
- while ( localTime < 0 ) {
- localTime += 1440;
- }
- while ( localTime >= 1440 ) {
- localTime -= 1440;
+ $( '#mw-prefs-form' ).submit( function () {
+ var storageData = $( $preftoc ).find( 'li.selected a' ).attr( 'id' ).replace( 'preftab-', '' );
+ sessionStorage.setItem( 'mediawikiPreferencesTab', storageData );
+ } );
}
- $localtimeHolder.text( minutesToHours( localTime ) );
-};
-
-if ( $tzSelect.length && $tzTextbox.length ) {
- $tzSelect.change( function () { updateTimezoneSelection(); } );
- $tzTextbox.blur( function () { updateTimezoneSelection(); } );
- updateTimezoneSelection();
-}
} );
diff --git a/resources/mediawiki.special/mediawiki.special.recentchanges.js b/resources/mediawiki.special/mediawiki.special.recentchanges.js
index 7996d935..d1c1354f 100644
--- a/resources/mediawiki.special/mediawiki.special.recentchanges.js
+++ b/resources/mediawiki.special/mediawiki.special.recentchanges.js
@@ -1,39 +1,34 @@
-/* JavaScript for Special:RecentChanges */
+/**
+ * JavaScript for Special:RecentChanges
+ */
( function ( mw, $ ) {
+ var rc, $checkboxes, $select;
- var checkboxes = [ 'nsassociated', 'nsinvert' ];
-
- /**
- * @var select {jQuery}
- */
- var $select = null;
-
- var rc = mw.special.recentchanges = {
-
+ rc = {
/**
* Handler to disable/enable the namespace selector checkboxes when the
* special 'all' namespace is selected/unselected respectively.
*/
updateCheckboxes: function () {
// The option element for the 'all' namespace has an empty value
- var isAllNS = $select.find('option:selected').val() === '';
+ var isAllNS = $select.val() === '';
// Iterates over checkboxes and propagate the selected option
- $.each( checkboxes, function ( i, id ) {
- $( '#' + id ).prop( 'disabled', isAllNS );
- });
+ $checkboxes.prop( 'disabled', isAllNS );
},
init: function () {
- // Populate
$select = $( '#namespace' );
+ $checkboxes = $( '#nsassociated, #nsinvert' );
// Bind to change event, and trigger once to set the initial state of the checkboxes.
- $select.change( rc.updateCheckboxes ).change();
+ rc.updateCheckboxes();
+ $select.change( rc.updateCheckboxes );
}
};
- // Run when document is ready
- $( rc.init );
+ $( document ).ready( rc.init );
+
+ mw.special.recentchanges = rc;
}( mediaWiki, jQuery ) );
diff --git a/resources/mediawiki.special/mediawiki.special.search.js b/resources/mediawiki.special/mediawiki.special.search.js
index 04954e8d..2dab3026 100644
--- a/resources/mediawiki.special/mediawiki.special.search.js
+++ b/resources/mediawiki.special/mediawiki.special.search.js
@@ -1,49 +1,53 @@
-/*
+/**
* JavaScript for Special:Search
*/
-( function( $, mw ) { $( function() {
+( function ( mw, $ ) {
+ $( document ).ready( function () {
+ var $checkboxes, $headerLinks;
-// Emulate HTML5 autofocus behavior in non HTML5 compliant browsers
-if ( !( 'autofocus' in document.createElement( 'input' ) ) ) {
- $( 'input[autofocus]:first' ).focus();
-}
+ // Emulate HTML5 autofocus behavior in non HTML5 compliant browsers
+ if ( !( 'autofocus' in document.createElement( 'input' ) ) ) {
+ $( 'input[autofocus]' ).eq( 0 ).focus();
+ }
-// Create check all/none button
-var $checkboxes = $('#powersearch input[id^=mw-search-ns]');
-$('#mw-search-togglebox').append(
- $('<label />')
- .text(mw.msg('powersearch-togglelabel'))
-).append(
- $('<input type="button" />')
- .attr('id', 'mw-search-toggleall')
- .attr('value', mw.msg('powersearch-toggleall'))
- .click( function() {
- $checkboxes.prop('checked', true);
- } )
-).append(
- $('<input type="button" />')
- .attr('id', 'mw-search-togglenone')
- .attr('value', mw.msg('powersearch-togglenone'))
- .click( function() {
- $checkboxes.prop('checked', false);
- } )
-);
+ // Create check all/none button
+ $checkboxes = $('#powersearch input[id^=mw-search-ns]');
+ $('#mw-search-togglebox').append(
+ $('<label>')
+ .text(mw.msg('powersearch-togglelabel'))
+ ).append(
+ $('<input type="button" />')
+ .attr( 'id', 'mw-search-toggleall' )
+ .prop( 'value', mw.msg('powersearch-toggleall' ) )
+ .click( function () {
+ $checkboxes.prop('checked', true);
+ } )
+ ).append(
+ $('<input type="button" />')
+ .attr( 'id', 'mw-search-togglenone' )
+ .prop( 'value', mw.msg('powersearch-togglenone' ) )
+ .click( function() {
+ $checkboxes.prop( 'checked', false );
+ } )
+ );
-// Change the header search links to what user entered
-var headerLinks = $('.search-types a');
-$('#searchText, #powerSearchText').change(function() {
- var searchterm = $(this).val();
- headerLinks.each( function() {
- var parts = $(this).attr('href').split( 'search=' );
- var lastpart = '';
- var prefix = 'search=';
- if( parts.length > 1 && parts[1].indexOf('&') >= 0 ) {
- lastpart = parts[1].substring( parts[1].indexOf('&') );
- } else {
- prefix = '&search=';
- }
- this.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart;
- });
-}).trigger('change');
+ // Change the header search links to what user entered
+ $headerLinks = $( '.search-types a' );
+ $( '#searchText, #powerSearchText' ).change( function () {
+ var searchterm = $(this).val();
+ $headerLinks.each( function () {
+ var parts = $(this).attr('href').split( 'search=' ),
+ lastpart = '',
+ prefix = 'search=';
+ if ( parts.length > 1 && parts[1].indexOf('&') >= 0 ) {
+ lastpart = parts[1].substring( parts[1].indexOf('&') );
+ } else {
+ prefix = '&search=';
+ }
+ this.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart;
+ });
+ }).trigger( 'change' );
+
+ } );
-} ); } )( jQuery, mediaWiki );
+}( mediaWiki, jQuery ) );
diff --git a/resources/mediawiki.special/mediawiki.special.undelete.js b/resources/mediawiki.special/mediawiki.special.undelete.js
index 33b80275..d20aab51 100644
--- a/resources/mediawiki.special/mediawiki.special.undelete.js
+++ b/resources/mediawiki.special/mediawiki.special.undelete.js
@@ -1,10 +1,11 @@
-/*
- * JavaScript for Specical:Undelete
+/**
+ * JavaScript for Special:Undelete
*/
-jQuery( document ).ready( function( $ ) {
- $( '#mw-undelete-invert' ).click( function( e ) {
+jQuery( document ).ready( function ( $ ) {
+ $( '#mw-undelete-invert' ).click( function ( e ) {
+ $( '#undelete input[type="checkbox"]' ).prop( 'checked', function ( i, val ) {
+ return !val;
+ } );
e.preventDefault();
- $( '#undelete' ).find( 'input:checkbox' )
- .prop( 'checked', function( i, val ) { return !val; } );
} );
} );
diff --git a/resources/mediawiki.special/mediawiki.special.upload.js b/resources/mediawiki.special/mediawiki.special.upload.js
index 63e89713..75532f18 100644
--- a/resources/mediawiki.special/mediawiki.special.upload.js
+++ b/resources/mediawiki.special/mediawiki.special.upload.js
@@ -6,12 +6,12 @@
/**
* Add a preview to the upload form
*/
- $( function ( $ ) {
+ $( document ).ready( function () {
/**
* Is the FileAPI available with sufficient functionality?
*/
function hasFileAPI() {
- return typeof window.FileReader !== 'undefined';
+ return window.FileReader !== undefined;
}
/**
@@ -25,7 +25,7 @@
* @return boolean
*/
function fileIsPreviewable( file ) {
- var known = ['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml'],
+ var known = ['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml'],
tooHuge = 10 * 1024 * 1024;
return ( $.inArray( file.type, known ) !== -1 ) && file.size > 0 && file.size < tooHuge;
}
@@ -43,23 +43,26 @@
* @param {File} file
*/
function showPreview( file ) {
- var previewSize = 180,
+ var $canvas,
+ ctx,
+ meta,
+ previewSize = 180,
thumb = $( '<div id="mw-upload-thumbnail" class="thumb tright">' +
'<div class="thumbinner">' +
'<div class="mw-small-spinner" style="width: 180px; height: 180px"></div>' +
'<div class="thumbcaption"><div class="filename"></div><div class="fileinfo"></div></div>' +
'</div>' +
'</div>' );
+
thumb.find( '.filename' ).text( file.name ).end()
.find( '.fileinfo' ).text( prettySize( file.size ) ).end();
- var $canvas = $('<canvas width="' + previewSize + '" height="' + previewSize + '" ></canvas>'),
- ctx = $canvas[0].getContext( '2d' );
+ $canvas = $('<canvas width="' + previewSize + '" height="' + previewSize + '" ></canvas>');
+ ctx = $canvas[0].getContext( '2d' );
$( '#mw-htmlform-source' ).parent().prepend( thumb );
- var meta;
- fetchPreview( file, function( dataURL ) {
- var img = new Image(),
+ fetchPreview( file, function ( dataURL ) {
+ var img = new Image(),
rotation = 0;
if ( meta && meta.tiff && meta.tiff.Orientation ) {
@@ -79,7 +82,8 @@
}
img.onload = function () {
- var width, height, x, y, dx, dy, logicalWidth, logicalHeight;
+ var info, width, height, x, y, dx, dy, logicalWidth, logicalHeight;
+
// Fit the image within the previewSizexpreviewSize box
if ( img.width > img.height ) {
width = previewSize;
@@ -129,12 +133,14 @@
thumb.find('.mw-small-spinner').replaceWith($canvas);
// Image size
- var info = mw.msg( 'widthheight', logicalWidth, logicalHeight ) +
+ info = mw.msg( 'widthheight', logicalWidth, logicalHeight ) +
', ' + prettySize( file.size );
+
$( '#mw-upload-thumbnail .fileinfo' ).text( info );
};
img.src = dataURL;
}, mw.config.get( 'wgFileCanRotate' ) ? function ( data ) {
+ /*jshint camelcase: false, nomen: false */
try {
meta = mw.libs.jpegmeta( data, file.fileName );
meta._binary_data = null;
@@ -171,9 +177,10 @@
// However, our JPEG metadata library wants a string.
// So, this is going to be an ugly conversion.
reader.onload = function() {
- var buffer = new Uint8Array( reader.result ),
+ var i,
+ buffer = new Uint8Array( reader.result ),
string = '';
- for ( var i = 0; i < buffer.byteLength; i++ ) {
+ for ( i = 0; i < buffer.byteLength; i++ ) {
string += String.fromCharCode( buffer[i] );
}
callbackBinary( string );
@@ -196,7 +203,7 @@
} else {
// This ends up decoding the file to base-64 and back again, which
// feels horribly inefficient.
- reader.onload = function() {
+ reader.onload = function () {
callback( reader.result );
};
reader.readAsDataURL( file );
@@ -230,22 +237,29 @@
* Check if the file does not exceed the maximum size
*/
function checkMaxUploadSize( file ) {
+ var maxSize, $error;
+
function getMaxUploadSize( type ) {
var sizes = mw.config.get( 'wgMaxUploadSize' );
+
if ( sizes[type] !== undefined ) {
return sizes[type];
}
return sizes['*'];
}
+
$( '.mw-upload-source-error' ).remove();
- var maxSize = getMaxUploadSize( 'file' );
+ maxSize = getMaxUploadSize( 'file' );
if ( file.size > maxSize ) {
- var error = $( '<p class="error mw-upload-source-error" id="wpSourceTypeFile-error">' +
- mw.message( 'largefileserver', file.size, maxSize ).escaped() + '</p>' );
- $( '#wpUploadFile' ).after( error );
+ $error = $( '<p class="error mw-upload-source-error" id="wpSourceTypeFile-error">' +
+ mw.message( 'largefileserver', file.size, maxSize ).escaped() + '</p>' );
+
+ $( '#wpUploadFile' ).after( $error );
+
return false;
}
+
return true;
}
@@ -276,23 +290,30 @@
/**
* Disable all upload source fields except the selected one
*/
- $( function ( $ ) {
- var i, row,
- rows = $( '.mw-htmlform-field-UploadSourceField' );
- for ( i = rows.length; i; i-- ) {
- row = rows[i - 1];
- $( 'input[name="wpSourceType"]', row ).change( ( function () {
- var currentRow = row; // Store current row in our own scope
- return function () {
- $( '.mw-upload-source-error' ).remove();
- if ( this.checked ) {
- // Disable all inputs
- $( 'input[name!="wpSourceType"]', rows ).prop( 'disabled', true );
- // Re-enable the current one
- $( 'input', currentRow ).prop( 'disabled', false );
- }
- };
- }() ) );
+ $( document ).ready( function () {
+ var i, $row,
+ $rows = $( '.mw-htmlform-field-UploadSourceField' );
+
+ function createHandler( $currentRow ) {
+ /**
+ * @param {jQuery.Event}
+ */
+ return function () {
+ $( '.mw-upload-source-error' ).remove();
+ if ( this.checked ) {
+ // Disable all inputs
+ $rows.find( 'input[name!="wpSourceType"]' ).prop( 'disabled', true );
+ // Re-enable the current one
+ $currentRow.find( 'input' ).prop( 'disabled', false );
+ }
+ };
+ }
+
+ for ( i = $rows.length; i; i-- ) {
+ $row = $rows.eq(i - 1);
+ $row
+ .find( 'input[name="wpSourceType"]' )
+ .change( createHandler( $row ) );
}
} );
diff --git a/resources/mediawiki.special/mediawiki.special.userLogin.signup.js b/resources/mediawiki.special/mediawiki.special.userLogin.signup.js
new file mode 100644
index 00000000..bba42605
--- /dev/null
+++ b/resources/mediawiki.special/mediawiki.special.userLogin.signup.js
@@ -0,0 +1,10 @@
+/**
+ * JavaScript for Special:UserLogin/signup
+ */
+jQuery( document ).ready( function ( $ ) {
+ $( '#wpCreateaccountMail' )
+ .on( 'change', function() {
+ $( '.mw-row-password' ).toggle( !$( this ).attr( 'checked' ) );
+ } )
+ .trigger( 'change' );
+} );