MediaWiki:Gadget-common-action-edit.js — различия между версиями
Материал из CelestePedia
SoulTrain (обсуждение | вклад) |
SoulTrain (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
− | + | /* <pre><nowiki> */ | |
− | + | ||
− | function | + | //Script 'Wikificator' from Wikipedia |
− | return | + | |
+ | importScriptURI('http://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript') | ||
+ | |||
+ | |||
+ | //Toolbar buttons | ||
+ | |||
+ | function StandardButtons(){ | ||
+ | if (mwEditButtons.length < 6) return | ||
+ | mwEditButtons[5].tagClose = '|thumb]]' | ||
} | } | ||
− | + | ||
− | + | function addFuncButton(img, tip, func){ | |
− | ( | + | var toolbar = document.getElementById('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) | |
− | |||
− | |||
} | } | ||
− | |||
− | + | ||
− | //Summary buttons | + | //Toolbar buttons |
+ | |||
+ | function StandardButtons(){ | ||
+ | if (mwEditButtons.length < 6) return | ||
+ | mwEditButtons[5].tagClose = '|thumb]]' | ||
+ | } | ||
+ | |||
+ | |||
+ | function CustomButtons(){ | ||
+ | addCustomButton('http://upload.wikimedia.org/wikipedia/ru/1/1d/Button_redirect_rus.png', 'Перенаправление','#REDIRECT [[',']]','название страницы') | ||
+ | addCustomButton('http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png','Категория','[[Категория:',']]\n','') | ||
+ | addCustomButton('http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png', 'Комментарий', '<!-- ', ' -->', 'Комментарий') | ||
+ | addCustomButton('http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png', 'Развёрнутая цитата', '<blockquote>\n', '\n</blockquote>', 'Развёрнутая цитата одним абзацем') | ||
+ | addCustomButton('http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png', | ||
+ | 'Вставить таблицу', '{| class="wikitable"\n|-\n', '\n|}', '! заголовок 1\n! заголовок 2\n! заголовок 3\n|-\n| строка 1, ячейка 1\n| строка 1, ячейка 2\n| строка 1, ячейка 3\n|-\n| строка 2, ячейка 1\n| строка 2, ячейка 2\n| строка 2, ячейка 3') | ||
+ | } | ||
+ | |||
+ | function addCustomButton(img, tip, open, close, sample){ | ||
+ | mwCustomEditButtons[mwCustomEditButtons.length] = | ||
+ | {'imageFile':img, 'speedTip':tip, 'tagOpen':open, 'tagClose':close, 'sampleText':sample} | ||
+ | } | ||
+ | |||
+ | |||
+ | function WikifButton(){ | ||
+ | var t = document.getElementById('wpTextbox1') | ||
+ | if (!t || (!document.selection && t.selectionStart == null)) return | ||
+ | addFuncButton('http://upload.wikimedia.org/wikisource/ru/d/d1/Button-wikifikator.png', 'Викификатор', Wikify) | ||
+ | } | ||
+ | |||
+ | function addFuncButton(img, tip, func){ | ||
+ | var toolbar = document.getElementById('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) | ||
+ | } | ||
+ | |||
+ | |||
+ | //Edit Summary buttons | ||
+ | |||
function SummaryButtons(){ | function SummaryButtons(){ | ||
− | var | + | var wpSummary = document.getElementById('wpSummary') |
− | if (! | + | if (!wpSummary || (wpSummary.form.wpSection && wpSummary.form.wpSection.value == 'new')) return |
− | + | wpSummaryBtn = document.createElement('span') //global var | |
− | + | wpSummaryBtn.id = 'userSummaryButtonsA' | |
− | + | wpSummary.parentNode.insertBefore(wpSummaryBtn, wpSummary.nextSibling) | |
− | addSumButton('викиф.','викификация') | + | wpSummary.parentNode.insertBefore(document.createElement('br'), wpSummary.nextSibling) |
− | addSumButton('оформл.','оформление') | + | addSumButton('викиф.', 'викификация', 'Проведена викификация') |
− | addSumButton('стиль',' | + | addSumButton('оформл.', 'оформление', 'Изменено оформление') |
− | addSumButton('орфогр.','орфография') | + | addSumButton('стиль', 'стиль', 'Поправлен стиль изложения') |
− | addSumButton('пункт.','пунктуация | + | addSumButton('орфогр.', 'орфография', 'Поправлена орфография') |
− | + | addSumButton('пункт.', 'пунктуация', 'Изменена пунктуация') | |
− | addSumButton('кат.',' | + | addSumButton('кат.', 'категоризация', 'Поправлена категоризация') |
− | addSumButton('шаб.','шаблон','Добавлен / изменён шаблон') | + | addSumButton('шаб.', 'шаблон', 'Добавлен / изменён шаблон') |
− | addSumButton('к удал.','к удалению','Страница | + | addSumButton('к удал.', 'к удалению', 'Страница выставлена к удалению') |
− | addSumButton('доп.',' | + | addSumButton('доп.', 'дополнения', 'Добавлены новые сведения') |
− | addSumButton('иллюстрация','иллюстрация') | + | addSumButton('илл.', 'иллюстрация', 'Размещена иллюстрация') |
− | addSumButton('обнов.','обновление | + | addSumButton('инт.', 'интервики', 'Исправлены интервики') |
+ | addSumButton('обнов.', 'обновление', 'Обновлены данные') | ||
} | } | ||
+ | |||
function addSumButton(name, text, title) { | function addSumButton(name, text, title) { | ||
var btn = document.createElement('a') | var btn = document.createElement('a') | ||
btn.appendChild(document.createTextNode(name)) | btn.appendChild(document.createTextNode(name)) | ||
− | btn.title = title | + | btn.title = title |
btn.onclick = function(){insertSummary(text)} | btn.onclick = function(){insertSummary(text)} | ||
− | + | wpSummaryBtn.appendChild(btn) | |
} | } | ||
+ | |||
function insertSummary(text) { | function insertSummary(text) { | ||
− | var | + | var wpSummary = document.getElementById('wpSummary') |
− | if ( | + | if (wpSummary.value.indexOf(text) != -1) return |
− | if ( | + | if (wpSummary.value.match(/[^,; \/]$/)) wpSummary.value += ',' |
− | if ( | + | if (wpSummary.value.match(/[^ ]$/)) wpSummary.value += ' ' |
− | + | wpSummary.value += text | |
} | } | ||
+ | |||
+ | |||
+ | //call functions | ||
+ | addOnloadHook(StandardButtons) | ||
+ | addOnloadHook(CustomButtons) | ||
+ | addOnloadHook(WikifButton) | ||
addOnloadHook(SummaryButtons) | addOnloadHook(SummaryButtons) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | /* </nowiki></pre> */ | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Версия 19:00, 30 ноября 2010
/* <pre><nowiki> */
//Script 'Wikificator' from Wikipedia
importScriptURI('http://ru.wikipedia.org/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript')
//Toolbar buttons
function StandardButtons(){
if (mwEditButtons.length < 6) return
mwEditButtons[5].tagClose = '|thumb]]'
}
function addFuncButton(img, tip, func){
var toolbar = document.getElementById('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)
}
//Toolbar buttons
function StandardButtons(){
if (mwEditButtons.length < 6) return
mwEditButtons[5].tagClose = '|thumb]]'
}
function CustomButtons(){
addCustomButton('http://upload.wikimedia.org/wikipedia/ru/1/1d/Button_redirect_rus.png', 'Перенаправление','#REDIRECT [[',']]','название страницы')
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png','Категория','[[Категория:',']]\n','')
addCustomButton('http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png', 'Комментарий', '<!-- ', ' -->', 'Комментарий')
addCustomButton('http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png', 'Развёрнутая цитата', '<blockquote>\n', '\n</blockquote>', 'Развёрнутая цитата одним абзацем')
addCustomButton('http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png',
'Вставить таблицу', '{| class="wikitable"\n|-\n', '\n|}', '! заголовок 1\n! заголовок 2\n! заголовок 3\n|-\n| строка 1, ячейка 1\n| строка 1, ячейка 2\n| строка 1, ячейка 3\n|-\n| строка 2, ячейка 1\n| строка 2, ячейка 2\n| строка 2, ячейка 3')
}
function addCustomButton(img, tip, open, close, sample){
mwCustomEditButtons[mwCustomEditButtons.length] =
{'imageFile':img, 'speedTip':tip, 'tagOpen':open, 'tagClose':close, 'sampleText':sample}
}
function WikifButton(){
var t = document.getElementById('wpTextbox1')
if (!t || (!document.selection && t.selectionStart == null)) return
addFuncButton('http://upload.wikimedia.org/wikisource/ru/d/d1/Button-wikifikator.png', 'Викификатор', Wikify)
}
function addFuncButton(img, tip, func){
var toolbar = document.getElementById('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)
}
//Edit Summary buttons
function SummaryButtons(){
var wpSummary = document.getElementById('wpSummary')
if (!wpSummary || (wpSummary.form.wpSection && wpSummary.form.wpSection.value == 'new')) return
wpSummaryBtn = document.createElement('span') //global var
wpSummaryBtn.id = 'userSummaryButtonsA'
wpSummary.parentNode.insertBefore(wpSummaryBtn, wpSummary.nextSibling)
wpSummary.parentNode.insertBefore(document.createElement('br'), wpSummary.nextSibling)
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
btn.onclick = function(){insertSummary(text)}
wpSummaryBtn.appendChild(btn)
}
function insertSummary(text) {
var wpSummary = document.getElementById('wpSummary')
if (wpSummary.value.indexOf(text) != -1) return
if (wpSummary.value.match(/[^,; \/]$/)) wpSummary.value += ','
if (wpSummary.value.match(/[^ ]$/)) wpSummary.value += ' '
wpSummary.value += text
}
//call functions
addOnloadHook(StandardButtons)
addOnloadHook(CustomButtons)
addOnloadHook(WikifButton)
addOnloadHook(SummaryButtons)
/* </nowiki></pre> */