MediaWiki:ToolbarNew.js
Перейти до навігації
Перейти до пошуку
Увага: Після публікування слід очистити кеш браузера, щоб побачити зміни.
- Firefox / Safari: тримайте Shift, коли натискаєте Оновити, або натисніть Ctrl-F5 чи Ctrl-Shift-R (⌘-R на Apple Mac)
- Google Chrome: натисніть Ctrl-Shift-R (⌘-Shift-R на Apple Mac)
- Edge: тримайте Ctrl, коли натискаєте Оновити, або натисніть Ctrl-F5.
//<nowiki>
function wgImg(img) {
return /^http:/i.test(img) ? img : '//upload.wikimedia.org/wikipedia/' + img;
}
function addFuncBtn(id, func, aSection, aGroup, img, title) {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: aSection,
group: aGroup,
tools: {
id: {
type: 'button',
action: {
type: 'callback',
execute: func
},
label: title,
icon: wgImg(img)
}
}
});
}
function addInsertBtn(id, aPre, aPost, aSection, aGroup, img, title) {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: aSection,
group: aGroup,
tools: {
id: {
type: 'button',
action: {
type: 'encapsulate',
options: {
pre: aPre,
post: aPost
}
},
label: title,
icon: wgImg(img)
}
}
});
}
//wikificator from [[:ru:MediaWiki:ToolbarNew.js]]
$(document).ready(function() {
try {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'main',
groups: {
'ukwp': {}
}
});
} catch(e) {
return;
}
mw.loader.using(['mediawiki.util']).done(function () {
mw.util.addCSS('.wikiEditor-ui-toolbar .group-insert {border-right:1px solid #DDD}');
});
addFuncBtn('wikif', function() {
Wikify();
}, 'main', 'ukwp', 'commons/0/06/Wikify-toolbutton.png', 'Вікіфікатор');
addInsertBtn('strike', "<s>", "</s>", 'main', 'format', 'commons/1/1a/Toolbaricon_strike.png', 'Закреслений');
addInsertBtn('stress', "́", "", 'advanced', 'insert', 'commons/thumb/a/a2/A_with_acute.svg/22px-A_with_acute.svg.png', 'Наголос');
addInsertBtn('template', "{{", "}}", 'advanced', 'insert', 'commons/thumb/7/7e/Template_alt_full_black_22.svg/22px-Template_alt_full_black_22.svg.png', 'Шаблон');
addInsertBtn('category', "[[Категорія:", "]]", 'advanced', 'insert', 'commons/thumb/e/e0/Grey_Cyrillic_Ka_with_colon.svg/22px-Grey_Cyrillic_Ka_with_colon.svg.png', 'Категорія');
addInsertBtn('comment', "<!--", "-->", 'advanced', 'format', 'commons/1/11/Toolbaricon_hiddencomment.png', 'Коментар');
$('#toolbar-old').css('float', 'right').prependTo('#wikiEditor-ui-toolbar');
});
//compatibility w/ old scripts: floating old toolbar
$(function() {
$('#toolbar').attr('id', 'toolbar-old');
});
mw.loader.using( 'jquery.client', function () {
var clientProfile = $.client.profile();
$( '#editform' ).on( 'keydown', function ( e ) {
// Ctrl+Alt+W on Windows, Ctrl+Shift+W on Mac
if (
e.ctrlKey &&
!e.metaKey &&
(clientProfile.platform === 'mac' ? e.shiftKey && !e.altKey : !e.shiftKey && e.altKey) &&
e.keyCode === 87
) {
Wikify();
}
});
});
//</nowiki>