Wikisłownikarz:Joystick/monobook.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.
// importScript('User:Derbeth/sk.js');
// **
// ** DODATKOWE PRZYCISKI W WikiED
// **
// define custom buttons (id, class, popup title, image src, width, height, alt text, onClick and parameters)
var wikEdButton = {};
wikEdButton[100] = ['wikEdDiv', 'wikEdButton', 'Wstaw tagi DIV', 'http://upload.wikimedia.org/wikipedia/commons/6/67/WikEd_logo.png', '16', '16', 'DIV', 'javascript:WikEdEditButton(this, this.id, null, DivHandler);' ];
wikEdButton[101] = ['wikEdSpan', 'wikEdButton', 'Wstaw tagi SPAN', 'http://upload.wikimedia.org/wikipedia/commons/0/07/WikEd_disabled.png', '16', '16', 'SPAN', 'javascript:WikEdEditButton(this, this.id, null, SpanHandler);' ];
wikEdButton[102] = ['wikEdTransliteracja', 'wikEdButton', 'Transliteruj', 'http://upload.wikimedia.org/wikipedia/commons/6/67/WikEd_logo.png', '16', '16', 'Transliteracja', 'javascript:WikEdEditButton(this, this.id, null, TransliteracjaHandler);' ];
wikEdButton[103] = ['wikEdSpan1', 'wikEdButton', 'Wstaw tagi SPAN1', 'http://upload.wikimedia.org/wikipedia/commons/0/07/WikEd_disabled.png', '16', '16', 'SPAN1', 'javascript:WikEdEditButton(this, this.id, null, SpanHandler);' ];
// define custom button bars (id outer, class outer, id inner, class inner, height, grip title, button numbers)
var wikEdButtonBar = {};
wikEdButtonBar['custom1'] = ['wikEdButtonBarCustom1', 'wikEdButtonBarCustom1', 'wikEdButtonsCustom1', 'wikEdButtonsCustom1', 44, 'My custom buttons', [100, 101, 'br', 102, 103] ];
//wikEdButtonBar['custom2'] = ['wikEdButtonBarCustom2', 'wikEdButtonBarCustom2', 'wikEdButtonsCustom2', 'wikEdButtonsCustom2', 44, 'My custom buttons', [100, 'br', 101] ];
// define the function which is called upon clicking the custom button
// this example code adds or removes div tags around the selected text
function DivHandler(obj) {
// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
// focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
}
else {
obj.changed = obj.cursor;
}
// make the changes to the plain target text
// remove the previously added formatting
if ( /<div>(.*?)<\/div>/i.test(obj.changed.plain) ) {
obj.changed.plain = obj.changed.plain.replace(/<div>(.*?)<\/div>/gi, '$1');
}
// add the text formatting
else {
obj.changed.plain = '<div>' + obj.changed.plain + '</div>';
obj.changed.plain = obj.changed.plain.replace(/(<div>)( *)(.*?)( *)(<\/div>)/, '$2$1$3$5$4');
}
// keep the changed text selected, needed to remove the formatting with a second custom button click
obj.changed.keepSel = true;
return;
}
function SpanHandler(obj) {
// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
// focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
}
else {
obj.changed = obj.cursor;
}
// make the changes to the plain target text
// remove the previously added formatting
if ( /<span>(.*?)<\/span>/i.test(obj.changed.plain) ) {
obj.changed.plain = obj.changed.plain.replace(/<span>(.*?)<\/span>/gi, '$1');
}
// add the text formatting
else {
obj.changed.plain = '<span>' + obj.changed.plain + '</span>';
obj.changed.plain = obj.changed.plain.replace(/(<span>)( *)(.*?)( *)(<\/span>)/, '$2$1$3$5$4');
}
// keep the changed text selected, needed to remove the formatting with a second custom button click
obj.changed.keepSel = true;
return;
}
function TransliteracjaHandler(obj) {
// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
// focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line
WikEdGetText(obj, 'selection, cursor');
if (obj.selection.plain != '') {
obj.changed = obj.selection;
}
else {
obj.changed = obj.cursor;
}
// make the changes to the plain target text
// remove the previously added formatting
if ( /<div>(.*?)<\/div>/i.test(obj.changed.plain) ) {
obj.changed.plain = obj.changed.plain.replace(/<div>(.*?)<\/div>/gi, '$1');
}
// add the text formatting
else {
obj.changed.plain = obj.changed.plain.replace(א, a);
}
// keep the changed text selected, needed to remove the formatting with a second custom button click
obj.changed.keepSel = true;
return;
}
// **
// ** DODATKOWE PRZYCISKI
// **
function InsertMyButtonsToToolBar()
{
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png",
"speedTip": "Nowa sekcja językowa",
// <nowiki>
"tagOpen": "== {{subst:PAGENAME}} ({{jidysz}}) ==\n"
+ "{{trans}} {{YIVO|pruv}}; polska: pruw\n"
+ "{{wymowa}} {{IPA|pʀʊv}}\n"
+ "{{znaczenia}}\n''rzeczownik, rodzaj żeński, męski''\n: (1.1) [[",
"tagClose": "]]\n{{odmiana}} (1.1) {{lp}} {{subst:PAGENAME}}; {{lm}} \n"
+ "{{przykłady}}\n: (1.1) ''przykład.‏'' → tłumaczenie\n"
+ "{{składnia}}\n"
+ "{{kolokacje}}\n"
+ "{{synonimy}}\n"
+ "{{antonimy}}\n"
+ "{{pokrewne}}\n"
+ "{{frazeologia}}\n"
+ "{{etymologia}}\n"
+ "{{uwagi}}",
"sampleText": "polski odpowiednik"};
// </nowiki>
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/1/1c/Button_advanced_image.png",
"speedTip": "Wstaw grafikę w haśle jidysz",
"tagOpen": "[[Plik:",
// <nowiki>
"tagClose": "|right|thumb|[[די]] [[{{subst:PAGENAME}}]] (1.1)‏]]",
"sampleText": ""}
// </nowiki>
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/ec/Button_base.png",
"speedTip": "Wstaw rodzajnik {{f}}",
"tagOpen": "",
"tagClose": "",
"sampleText": "די"}
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/ec/Button_base.png",
"speedTip": "Wstaw rodzajnik {{m}}",
"tagOpen": "",
"tagClose": "",
"sampleText": "דער"}
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/ec/Button_base.png",
"speedTip": "Wstaw rodzajnik {{n}}",
"tagOpen": "",
"tagClose": "",
"sampleText": "דאָס"}
}
$( InsertMyButtonsToToolBar );
// **
// ** DODATKOWE POZYCJE GÓRNEGO MENU
// **
function InsertMyTopMenu()
{
mw.util.addPortletLink('p-personal', mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=Portal:Jidysz/pl/redaction', 'portal jidysz', 'pt-portal', 'portal jidysz', '', document.getElementById('pt-preferences'));
mw.util.addPortletLink('p-personal', mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=Portal:Jidysz/pl/project', 'jidysz lebt', 'pt-project', 'ייִדיש לעבט', '', document.getElementById('pt-preferences'));
}
$( InsertMyTopMenu );