MediaWiki:Common.js: Porōwnanie wersyji

Ze SileSłownik
Idź do: nawigacyjŏ, szukej
Linijŏ 26: Linijŏ 26:
 
searchForm.search.id = searchBoxId;
 
searchForm.search.id = searchBoxId;
 
} else {
 
} else {
searchBoxId = 'ooui-php-1';
+
searchBoxId = '#ooui-php-1';
 
}
 
}
 
}
 
}

Wersyjŏ ze dnia 08:53, 1 kwi 2019

// <pre>
// Skrypt dla strony specjalnej [[Special:Search]]
/*
== Small search keyboard ==
; Author: Maciej Jaros [[:pl:User:Nux]]
; Licence: CC-BY or [http://opensource.org/licenses/gpl-license.php GNU General Public License v2]
*/
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == "Search" ) {
	jQuery( document ).ready( function() {
		if ( document.forms['search'] ) {
			addSearchKeyboard( document.forms['search'] );
		}

		if ( document.forms['powersearch'] ) {
			addSearchKeyboard( document.forms['powersearch'] );
		}

	} );
}

function addSearchKeyboard( searchForm ) {
	var searchBoxId = 'lsearchbox';
	if ( !searchForm.lsearchbox ) {
		if ( searchForm.search.id == '' ) {
			searchBoxId = searchForm.name + 'box';
			searchForm.search.id = searchBoxId;
		} else {
			searchBoxId = '#ooui-php-1';
		}
	}

	var $input = jQuery( '#' + searchBoxId );
	var $panel = jQuery( '<div class="search_keyboard" style="width:50%; font-size:small; font-weight: bold" />' );
	$panel.append( "Polskie znaki: " );

	var letters = ['ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż', '–', '„', '”'];
	for ( var i = 0; i < letters.length; i++ ) {
		var $link = jQuery( '<a href="#"/>' );
		$link.append( letters[i] );
		$link.click( function( event ) {
			$input.textSelection( 'encapsulateSelection', {
				pre: jQuery( this ).text()
			} );
			event.preventDefault();
		} );
		$panel.append( $link );
	}

	$input.parent().parent().append( $panel );
}