MediaWiki:Gadget-edittools.js
Megjegyzés: közzététel után frissítened kell a böngésződ gyorsítótárát, hogy lásd a változásokat.
- Firefox / Safari: tartsd lenyomva a Shift gombot és kattints a Frissítés gombra a címsorban, vagy használd a Ctrl–F5 vagy Ctrl–R (Macen ⌘–R) billentyűkombinációt
- Google Chrome: használd a Ctrl–Shift–R (Macen ⌘–Shift–R) billentyűkombinációt
- Internet Explorer / Edge: tartsd nyomva a Ctrl-t, és kattints a Frissítés gombra, vagy nyomj Ctrl–F5-öt
- Opera: Nyomj Ctrl–F5-öt
function addCharSubsetMenu( forceAll ) {
forceAll = ( forceAll === true ); // $.ready calls with a jQuery object
var $specialchars = $( '#specialchars' );
if ( !$specialchars.length ) return;
var $menu = $( '#charSubsetMenu' );
if ( !$menu.length ) {
$menu = $( '<select>' )
.attr( 'id', 'charSubsetMenu' )
.css( 'display', 'inline' )
.change( chooseCharSubset );
} else if ( forceAll ) { // change customized menu to full
var menuChlidren = [];
$menu.children().each( function () {
menuChildren.push( this );
} );
$menu.children().remove();
} else { // menu already built
return;
}
var specialCharacterTypes = {};
var $l = $specialchars.find( 'p' );
$l.each( function( i ) {
var title = this.title;
var $opt = $( '<option>' )
.text( title )
.attr( 'value', i );
specialCharacterTypes[ title ] = $opt;
} );
if ( typeof allowedCharacterTypes === 'undefined' || forceAll ) {
$l.each( function ( i ) {
$menu.append( specialCharacterTypes[ $l[i].title ] );
} );
} else { // customized menu
for ( var i = 0; i < allowedSpecialCharacterTypes.length; i++ ) {
if ( typeof specialCharacterTypes[ allowedSpecialCharacterTypes[ i ] ] !== 'undefined' ) {
$menu.append( specialCharacterTypes[ allowedSpecialCharacterTypes[ i ] ] );
}
}
$( '<option>' )
.text( 'több…' )
.css( 'font-style', 'italic' )
.attr( 'value', 999 )
.appendTo( $menu );
}
if ( forceAll ) { // reset select to active character set
var value = -1;
$specialchars.find( 'p' ).each( function ( i ) {
if ( $( this ).css( 'display' ) === 'inline' ) {
value = i;
return false;
}
} );
$menu.find( 'option[value="' + value + '"]' ).select();
} else { // activate first character set
chooseCharSubset( null, $menu.find( 'option:first' ).val() );
}
$specialchars.prepend( $menu );
}
function chooseCharSubset( e, val ) {
if ( !val ) {
val = $( this ).val();
}
if ( val === 999 ) { // "more…" option
addCharSubsetMenu( true );
return;
}
$( '#specialchars p' )
.hide()
.eq( val ).css( 'display', 'inline' );
}
$( addCharSubsetMenu );
// WikiEditor toolbar
function addFrequentButtons() {
$( '#wpTextbox1' ).on( 'wikiEditor-toolbar-buildSection-characters', function ( e, section ) {
function paren( left, right ) {
return {
label: left + right,
action: {
type: 'encapsulate',
options: {
pre: left,
post: right
}
}
};
}
var pages = {
basic: {
layout: 'characters',
label: 'Alap',
characters: [
'á', 'é', 'í', 'ó', 'ö', 'ő', 'ú', 'ü', 'ű', 'Á', 'É', 'Í', 'Ó', 'Ö', 'Ő', 'Ú', 'Ü', 'Ű', '~', '|',
'#', paren('„', '”'), paren('»', '«'), paren('’', '’'), '’', '–', '…', paren('<', '>'), '°', '‰', '×',
'→', '∅', 'µ', '²', '³', '½', '⅓', '⅔', '¼', '¾', '€', '§', '†', '‡', '©', '®', '•', '·', ' ', '‑'
]
}
};
for ( var s in section.pages ) {
pages[ s ] = section.pages[ s ];
}
section.pages = pages;
} );
}
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options' ).then( function () {
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( addFrequentButtons );
}
} );
}