summaryrefslogtreecommitdiff
path: root/resources/src/mediawiki.special/mediawiki.special.search.js
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /resources/src/mediawiki.special/mediawiki.special.search.js
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'resources/src/mediawiki.special/mediawiki.special.search.js')
-rw-r--r--resources/src/mediawiki.special/mediawiki.special.search.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/resources/src/mediawiki.special/mediawiki.special.search.js b/resources/src/mediawiki.special/mediawiki.special.search.js
new file mode 100644
index 00000000..b27fe349
--- /dev/null
+++ b/resources/src/mediawiki.special/mediawiki.special.search.js
@@ -0,0 +1,58 @@
+/*!
+ * JavaScript for Special:Search
+ */
+( function ( mw, $ ) {
+ $( function () {
+ var $checkboxes, $headerLinks;
+
+ // 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
+ $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
+ $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( '&' ) !== -1 ) {
+ lastpart = parts[1].slice( parts[1].indexOf( '&' ) );
+ } else {
+ prefix = '&search=';
+ }
+ this.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart;
+ } );
+ } ).trigger( 'change' );
+
+ // When saving settings, use the proper request method (POST instead of GET).
+ $( '#mw-search-powersearch-remember' ).change( function () {
+ this.form.method = this.checked ? 'post' : 'get';
+ } ).trigger( 'change' );
+
+ } );
+
+}( mediaWiki, jQuery ) );