MediaWiki:Gadget-edit-form-keyboard.js
Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.
- Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
- Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
- Internet Explorer / Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5
- Opera: Naciśnij klawisze Ctrl+F5.
var EKeyboard = {
opened: 0,
keyboard: $( '<div>' ).attr( 'id', 'keyboard' ),
keys: $( '<div>' ).attr( 'id', 'keyboard_keys' ),
},
ESpecialChars = require( './edit-form-special-chars.js' ),
EStr = require( './edit-form-strings.js' ),
EUi = require( './edit-form-ui.js' );
EKeyboard.init = function () {
EKeyboard.keys.append( EStr.KEYBOARD_ALWAYS );
$( 'body' ).append(
EKeyboard.keyboard.hide(),
EKeyboard.keys.hide()
);
if ( EUi.usingNew ) {
ESpecialChars.detach();
}
EKeyboard.opened = false;
EKeyboard.keyboard.on( 'click', function () {
EKeyboard.keys.toggle();
EKeyboard.opened = !EKeyboard.opened;
return false;
} );
if ( EKeyboard.opened ) {
EKeyboard.keys.show();
}
$( window ).on( 'resize', function () {
if ( document.activeElement ) {
$( document.activeElement ).trigger( 'focus' );
}
} );
EUi.form.on( 'focus', '.keyboardable', $( this ).keyboard );
};
EKeyboard.hide = function () {
EKeyboard.keyboard.hide();
EKeyboard.keys.hide();
};
EKeyboard.updatePosition = function ( origin ) {
var nPos;
if ( !origin.is( ':visible' ) ) {
EKeyboard.hide();
return;
}
nPos = origin.offset();
nPos.top += origin.height() + 7;
nPos.left += 20;
EKeyboard.keyboard.show().css( nPos );
EKeyboard.keys.css( {
top: nPos.top,
left: nPos.left + 34
} ).data( 'active_area', origin.attr( 'id' ) );
};
EKeyboard.insertTags = function ( tagOpen, tagClose, sampleText ) {
var txtarea;
if ( document.editform && !EUi.usingNew ) {
txtarea = document.editform.wpTextbox1;
} else if ( EUi.usingNew ) {
var aname = EKeyboard.keys.data( 'active_area' );
txtarea = aname
? document.getElementById( aname )
: undefined;
}
if ( !txtarea ) {
txtarea = document.getElementsByTagName( 'textarea' )[ 0 ];
}
$( txtarea )
.textSelection( 'encapsulateSelection', {
pre: tagOpen,
peri: sampleText,
post: tagClose
} )
.autoresize();
EUi.relocateResult();
};
module.exports = EKeyboard;