Различие между версиями «MediaWiki:Editpage.js»
Содержимое удалено Содержимое добавлено
DonRumata (обсуждение | вклад) оставил спецсимволы |
DonRumata (обсуждение | вклад) удаляем лишнее в панели редактирования при редактировании статей + новые иконочки |
||
Строка 76: | Строка 76: | ||
$('#wpTextbox1').wikiEditor('removeFromToolbar', |
$('#wpTextbox1').wikiEditor('removeFromToolbar', |
||
{'section': 'help'}); |
{'section': 'help'}); |
||
⚫ | |||
// Adding groups to an existing toolbar section: |
|||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { |
|||
'section': 'main', |
|||
'section': 'main', |
|||
'groups': { |
|||
'extra': { |
|||
'tools': { |
|||
'label': 'Викификатор', |
'wikif': { |
||
'label': 'Викификатор', |
|||
'type': 'button', |
|||
'icon': '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png', |
|||
'action': { |
|||
'type': 'callback', |
|||
'execute': function() {Wikify()} |
|||
} |
|||
} |
} |
||
} |
} |
||
} |
} |
||
'insert': { |
}, |
||
'insert': { |
|||
'tools': { |
|||
'redirect': { |
|||
'labelMsg': 'wikieditor-toolbar-tool-redirect', |
|||
'type': 'button', |
|||
'icon': {'default': 'insert-redirect.png', 'default-rtl': 'insert-redirect-rtl.png'}, |
|||
'action': { |
|||
'type': 'encapsulate', |
|||
'options': { |
'options': { |
||
'pre': "#REDIRECT [[", |
'pre': "#REDIRECT [[", |
||
Строка 108: | Строка 109: | ||
} |
} |
||
} |
} |
||
}, |
|||
'template': { |
|||
'label': 'Шаблон', |
|||
'type': 'button', |
|||
'icon': '//upload.wikimedia.org/wikipedia/commons/4/4a/Norwegian_template_sign.png', |
|||
'action': { |
|||
'type': 'encapsulate', |
|||
'options': { |
|||
'pre': "{{", |
|||
'peri': 'Название шаблона', |
|||
'post': "}}" |
|||
} |
|||
} |
} |
||
} |
} |
||
'category': { |
}, |
||
'category': { |
|||
'label': 'Категория', |
|||
'type': 'button', |
|||
'icon': '//upload.wikimedia.org/wikipedia/commons/c/c4/Toolbar_category.png', |
|||
'action': { |
|||
'type': 'encapsulate', |
|||
'options': { |
|||
'pre': "[[Категория:", |
|||
'peri': 'Название категории', |
|||
'post': "]]" |
|||
} |
|||
} |
} |
||
} |
} |
||
'nonbreakspace': { |
}, |
||
'nonbreakspace': { |
|||
'label': 'Неразрывный пробел', |
|||
'type': 'button', |
|||
'icon': '//upload.wikimedia.org/wikipedia/commons/e/ed/Toolbaricon_nbsp.png', |
|||
'action': { |
|||
'type': 'encapsulate', |
|||
'options': { |
|||
'pre': " " |
|||
} |
|||
} |
} |
||
} |
} |
||
'wikipedialink': { |
}, |
||
'wikipedialink': { |
|||
'label': 'Ссылка на Википедию', |
|||
'type': 'button', |
|||
'icon': '//upload.wikimedia.org/wikipedia/commons/b/b0/Wikipedia-favicon.png', |
|||
'action': { |
|||
'type': 'encapsulate', |
|||
'options': { |
|||
'pre': "{{wikipedia", |
|||
'post': "}}" |
|||
} |
|||
} |
} |
||
} |
} |
||
'acute': { |
}, |
||
'acute': { |
|||
'label': 'Ударение', |
|||
'type': 'button', |
|||
'icon': '//upload.wikimedia.org/wikipedia/commons/8/8b/Vector_toolbar_insert_stress_button.png', |
|||
'action': { |
|||
'type': 'encapsulate', |
|||
'options': { |
|||
'pre': "́" |
|||
} |
|||
} |
} |
||
} |
} |
||
'tagpre': { |
}, |
||
'tagpre': { |
|||
'label': 'Тег <pre>', |
|||
'type': 'button', |
|||
'icon': '//upload.wikimedia.org/wikipedia/commons/b/b9/Toolbar_pre_vector.png', |
|||
'action': { |
|||
'type': 'encapsulate', |
|||
'options': { |
|||
'pre': "<pre>", |
|||
'peri': 'Текст', |
|||
'post': "</pre>" |
|||
} |
|||
} |
} |
||
} |
} |
||
Строка 185: | Строка 185: | ||
} |
} |
||
} |
} |
||
} ); |
} |
||
} ); |
|||
// Prepend wikificator button |
|||
$('#wikiEditor-ui-toolbar .section-main').prepend($('#wikiEditor-ui-toolbar .group-extra')); |
|||
⚫ | |||
} |
} |
||
Версия от 13:18, 21 ноября 2013
//<!--
//Toolbar buttons
mw.loader.using( 'mediawiki.action.edit', function () {
importScript('MediaWiki:Wikificator.js')
//Summary buttons
function SummaryButtons(){
var sum = document.getElementById('wpSummary')
if (!sum || (sum.form.wpSection && sum.form.wpSection.value == 'new')) return
var sp = document.createElement('span'); sp.id = 'userSummaryButtonsA'
sum.parentNode.insertBefore(sp, sum.nextSibling)
sum.parentNode.insertBefore(document.createElement('br'), sum.nextSibling)
addSumButton('викиф.','викификация')
addSumButton('оформл.','оформление')
addSumButton('стандарт.','стандартизация структуры')
addSumButton('стиль','стилевые правки')
addSumButton('орфогр.','орфография')
addSumButton('пункт.','пунктуация')
addSumButton('интервики','интервики','Исправлены межъязыковые ссылки (интервики)')
addSumButton('кат.','категория','Исправлена категоризация')
addSumButton('шаб.','шаблон','Добавлен / изменён шаблон')
addSumButton('к удал.','к удалению','Страница предложена к удалению')
addSumButton('доп.','дополнение')
addSumButton('илл.','иллюстрация')
addSumButton('обнов.','обновление данных')
}
function addSumButton(name, text, title) {
var btn = document.createElement('a')
btn.appendChild(document.createTextNode(name))
btn.title = title || text
btn.onclick = function(){insertSummary(text);return(false)}
document.getElementById('userSummaryButtonsA').appendChild(btn)
}
function insertSummary(text) {
var sum = document.getElementById('wpSummary')
if (sum.value.indexOf(text) != -1) return
if (sum.value.match(/[^,; \/]$/)) sum.value += ','
if (sum.value.match(/[^ ]$/)) sum.value += ' '
sum.value += text
}
$(SummaryButtons);
// Служебная функция, добавляет к тулбару кнопку спереди
function prependFuncButton(img, tip, func){
var toolbar = document.getElementById('toolbar') || document.getElementById('wikiEditor-ui-toolbar');
first = toolbar.firstChild;
if (!toolbar) return
var i=document.createElement('img')
i.src=img; i.alt=tip; i.title=tip; i.onclick=func; i.style.cursor='pointer'
toolbar.insertBefore(i, first);
}
// Служебная функция, добавляет к тулбару кнопку сзади
function addFuncButton(img, tip, func){
var toolbar = document.getElementById('toolbar') || document.getElementById('wikiEditor-ui-toolbar');
if (!toolbar) return
var i=document.createElement('img')
i.src=img; i.alt=tip; i.title=tip; i.onclick=func; i.style.cursor='pointer'
toolbar.appendChild(i)
}
//Update toolbar buttons
function updateNewToolbar() {
if ($('body').hasClass('ns-0')) {
// remove useless sections
$('#wpTextbox1').wikiEditor('removeFromToolbar',
{'section': 'main', 'group': 'insert', 'tool' : 'signature'});
$('#wpTextbox1').wikiEditor('removeFromToolbar',
{'section': 'advanced'});
//$('#wpTextbox1').wikiEditor('removeFromToolbar',
//{'section': 'characters'});
$('#wpTextbox1').wikiEditor('removeFromToolbar',
{'section': 'help'});
}
// Adding groups to an existing toolbar section:
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'groups': {
'extra': {
'tools': {
'wikif': {
'label': 'Викификатор',
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',
'action': {
'type': 'callback',
'execute': function() {Wikify()}
}
}
}
},
'insert': {
'tools': {
'redirect': {
'labelMsg': 'wikieditor-toolbar-tool-redirect',
'type': 'button',
'icon': {'default': 'insert-redirect.png', 'default-rtl': 'insert-redirect-rtl.png'},
'action': {
'type': 'encapsulate',
'options': {
'pre': "#REDIRECT [[",
'periMsg': 'wikieditor-toolbar-tool-redirect-example',
'post': "]]",
'ownline': true
}
}
},
'template': {
'label': 'Шаблон',
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/4/4a/Norwegian_template_sign.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "{{",
'peri': 'Название шаблона',
'post': "}}"
}
}
},
'category': {
'label': 'Категория',
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/c/c4/Toolbar_category.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "[[Категория:",
'peri': 'Название категории',
'post': "]]"
}
}
},
'nonbreakspace': {
'label': 'Неразрывный пробел',
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/e/ed/Toolbaricon_nbsp.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': " "
}
}
},
'wikipedialink': {
'label': 'Ссылка на Википедию',
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/b/b0/Wikipedia-favicon.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "{{wikipedia",
'post': "}}"
}
}
},
'acute': {
'label': 'Ударение',
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/8/8b/Vector_toolbar_insert_stress_button.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "́"
}
}
},
'tagpre': {
'label': 'Тег <pre>',
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/b/b9/Toolbar_pre_vector.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "<pre>",
'peri': 'Текст',
'post': "</pre>"
}
}
}
}
}
}
} );
// Prepend wikificator button
$('#wikiEditor-ui-toolbar .section-main').prepend($('#wikiEditor-ui-toolbar .group-extra'));
}
function updateOldToolbar(){
// Добавление кнопок на устаревшую панель инструментов
addFuncButton("//upload.wikimedia.org/wikipedia/ru/1/1d/Button_redirect_rus.png",
"Перенаправление", function(){insertTags('#Redirect [[',']]','название страницы')});
addFuncButton("//upload.wikimedia.org/wikipedia/commons/3/3b/Button_template_alt.png",
"Шаблон", function(){insertTags('{{','}}','Название шаблона')});
addFuncButton("//upload.wikimedia.org/wikipedia/commons/3/3c/Button_cat_ru.png",
"Категория", function(){insertTags('[[Категория:',']]','Название категории')});
addFuncButton("//upload.wikimedia.org/wikipedia/commons/4/4b/Button_nbsp.png",
"Неразрывный пробел", function(){insertTags(' ','','')});
addFuncButton("//upload.wikimedia.org/wikipedia/commons/b/bf/WP-icon.png",
"Ссылка на Википедию", function(){insertTags('{{wikipedia','}}','')});
addFuncButton("//upload.wikimedia.org/wikipedia/commons/0/0e/Button_acute_accent.png",
"Ударение", function(){insertTags('́','','')});
addFuncButton("//upload.wikimedia.org/wikipedia/commons/3/3c/Button_pre.png",
"Тег <pre>", function(){insertTags('<pre>','</pre>','Текст')});
prependFuncButton("//upload.wikimedia.org/wikipedia/commons/3/38/Button_wikify.png",
'Викификатор', function(){Wikify()});
}
function updateToolbar(){
if( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function () {
updateNewToolbar();
});
} else {
updateOldToolbar();
}
}
// Execute on load
$(updateToolbar);
});
//-->