مدیاویکی:Gadget-Extra-Editbuttons.js: تفاوت میان نسخهها
ظاهر
imported>Ebrahim بدون خلاصۀ ویرایش |
imported>Ebrahim آزمایشی |
||
| خط ۱: | خط ۱: | ||
/*jslint indent: 2*/ | // <nowiki> // DON'T REMOVE THIS LINE EVER | ||
//(function () { | /*jslint indent: 2, browser: true*/ | ||
/*global jQuery, mediaWiki, | |||
applyOnSelection, YKarabic, FM, NonStandard, digits, digits_move, URLfix, | |||
AtSignReplace, SuperTool, SuperTool_move, ZWNJ_Dictation, Punctuation, insertTags, | |||
toggleDir, SortText*/ | |||
(function ($, mw) { | |||
'use strict'; | 'use strict'; | ||
/** | /** | ||
* | * Adds edit summary | ||
*/ | */ | ||
function | function addEditSummary(summaryText, replaceSummary) { | ||
if (document.location.href.indexOf("§ion=new") > -1 || summaryText === "") { | |||
return; | |||
if ( | } | ||
if ($('#wpSummary').length === 0) { | |||
return; | |||
} | } | ||
var summaryPrefix = "", pos; | |||
if ($('#wpSummary').val().indexOf("*/ ") > -1) { | |||
pos = $('#wpSummary').val().indexOf("*/ "); | |||
summaryPrefix = $('#wpSummary').val().substr(0, pos + 3); | |||
if ( | |||
pos = | |||
summaryPrefix = | |||
} | } | ||
if (replaceSummary) { | if (replaceSummary) { | ||
$('#wpSummary').val(summaryPrefix + summaryText); | |||
} else { | } else { | ||
if ( | if ($('#wpSummary').val() === summaryPrefix) { | ||
$('#wpSummary').val($('#wpSummary').val() + summaryText); | |||
} else { | } else { | ||
if ( | if ($('#wpSummary').val().indexOf(summaryText) === -1) { // do not repeat in edit summary | ||
$('#wpSummary').val($('#wpSummary').val() + "، " + summaryText); | |||
} | } | ||
} | } | ||
} | } | ||
} | } | ||
/** | |||
* Make of button from a common pattern | |||
*/ | |||
function buttonGenerator(callback, summaryText, replaceSummary, imageSuffix, title, alt) { | |||
return $('<a "javascript:;" class="tooly-button" />').click(function (e) { | |||
e.preventDefault(); | |||
callback(); | |||
addEditSummary(summaryText, replaceSummary); | |||
}).append($('<img />').attr({ | |||
src: '//upload.wikimedia.org/wikipedia/' + imageSuffix, | |||
title: title, | |||
alt: alt | |||
}))[0]; | |||
} | |||
var tools = {}; | |||
// Buttons that FIX wikitext | // Buttons that FIX wikitext | ||
/* ی ک */ | /* ی ک */ | ||
tools.ykArabic = buttonGenerator( | |||
function () { applyOnSelection(YKarabic); }, | |||
"اصلاح | "اصلاح نویسه\u200cهای عربی", | ||
false, | false, | ||
"commons/8/88/Button_YehKeh.png", | "commons/8/88/Button_YehKeh.png", | ||
| خط ۵۵: | خط ۶۵: | ||
/* فاصلهٔ مجازی */ | /* فاصلهٔ مجازی */ | ||
tools.zwnj = buttonGenerator( | |||
function () { applyOnSelection(FM); }, | |||
"اصلاح فاصلهٔ مجازی", | "اصلاح فاصلهٔ مجازی", | ||
false, | false, | ||
| خط ۶۵: | خط ۷۵: | ||
/* نویسهٔ غیراستاندارد */ | /* نویسهٔ غیراستاندارد */ | ||
tools.nonS = buttonGenerator( | |||
function () { applyOnSelection(NonStandard); }, | |||
"اصلاح نویسه", | "اصلاح نویسه", | ||
false, | false, | ||
"fa/9/94/Button_non_standard.png", | "fa/9/94/Button_non_standard.png", | ||
" | "نویسه\u200cهای غیراستاندارد", | ||
" | "نویسه\u200cهای غیراستاندارد" | ||
); | ); | ||
/* اصلاح ارقام */ | /* اصلاح ارقام */ | ||
tools.dig = buttonGenerator( | |||
function () { applyOnSelection(digits); }, | |||
"اصلاح ارقام", | "اصلاح ارقام", | ||
false, | false, | ||
| خط ۸۵: | خط ۹۵: | ||
/* اصلاح ارقام مخصوص صفحه انتقال */ | /* اصلاح ارقام مخصوص صفحه انتقال */ | ||
tools.digMove = buttonGenerator( | |||
function () { applyOnSelection(digits_move); }, | |||
"اصلاح ارقام", | "اصلاح ارقام", | ||
false, | false, | ||
"fa/4/4a/Button_numbers.png", | "fa/4/4a/Button_numbers.png", | ||
"اصلاح ارقام", | "اصلاح ارقام", | ||
"ارقام"); | "ارقام" | ||
); | |||
/* | /* یونی\u200cکدسازی نشانی\u200cهای وب */ | ||
tools.urlFix = buttonGenerator( | |||
function () { applyOnSelection(URLfix); }, | |||
"اصلاح نشانی وب", | "اصلاح نشانی وب", | ||
false, | false, | ||
"fa/b/ba/Button_decode_URI.png", | "fa/b/ba/Button_decode_URI.png", | ||
" | "یونی\u200cکدسازی نشانی\u200cها", | ||
" | "یونی\u200cکدسازی" | ||
); | |||
/* اصلاح علامت @ */ | /* اصلاح علامت @ */ | ||
tools.atSignFix = buttonGenerator( | |||
function () { applyOnSelection(AtSignReplace); }, | |||
"اصلاح @", | "اصلاح @", | ||
false, | false, | ||
"fa/7/7f/Button_at_sign.png", | "fa/7/7f/Button_at_sign.png", | ||
"اصلاح علامت @", | "اصلاح علامت @", | ||
"@"); | "@" | ||
); | |||
/* ابرابزار */ | /* ابرابزار */ | ||
tools.superTool = buttonGenerator( | |||
function () { applyOnSelection(SuperTool); }, | |||
"ابرابزار", | "ابرابزار", | ||
false, | false, | ||
"fa/f/fc/Button_super_tool.png", | "fa/f/fc/Button_super_tool.png", | ||
"ابرابزار", | "ابرابزار", | ||
"ابرابزار"); | "ابرابزار" | ||
); | |||
/* ابرابزار مخصوص صفحه انتقال */ | /* ابرابزار مخصوص صفحه انتقال */ | ||
tools.superToolMove = buttonGenerator( | |||
function () { applyOnSelection(SuperTool_move); }, | |||
"ابرابزار", | "ابرابزار", | ||
false, | false, | ||
"fa/f/fc/Button_super_tool.png", | "fa/f/fc/Button_super_tool.png", | ||
"ابرابزار", | "ابرابزار", | ||
"ابرابزار"); | "ابرابزار" | ||
); | |||
/* ابزار املا */ | /* ابزار املا */ | ||
tools.dictation = buttonGenerator( | |||
function () { applyOnSelection(ZWNJ_Dictation); }, | |||
"اصلاح املا", | "اصلاح املا", | ||
false, | false, | ||
"commons/a/a3/Button_Dictation-fa.png", | "commons/a/a3/Button_Dictation-fa.png", | ||
"املا", | "املا", | ||
"املا"); | "املا" | ||
); | |||
/* اصلاحات | /* اصلاحات نقطه\u200cگذاری */ | ||
tools.punc = buttonGenerator( | |||
function () { applyOnSelection(Punctuation); }, | |||
"اصلاح سجاوندی", | "اصلاح سجاوندی", | ||
false, | false, | ||
"fa/e/ed/Button_punctuation.png", | "fa/e/ed/Button_punctuation.png", | ||
" | "نقطه\u200cگذاری", | ||
" | "نقطه\u200cگذاری" | ||
); | |||
// Buttons that add tags | // Buttons that add tags | ||
/* برچسب | /* برچسب ویکی\u200cسازی */ | ||
tools.wikify = buttonGenerator( | |||
function () { | |||
"برچسب | $('#wpSummary').val('{{ویکی\u200cسازی}}\n' + $('wpTextbox1').val()); | ||
}, | |||
"برچسب ویکی\u200cسازی", | |||
false, | false, | ||
"fa/3/38/Button_wikify.png", | "fa/3/38/Button_wikify.png", | ||
"برچسب | "برچسب ویکی\u200cسازی", | ||
" | "ویکی\u200cسازی" | ||
); | |||
/* بدون منبع */ | /* بدون منبع */ | ||
tools.noSource = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = '{{بدون منبع}}\n' + document.getElementById('wpTextbox1').value; | |||
}, | |||
"برچسب منبع", | "برچسب منبع", | ||
false, | false, | ||
"fa/8/8a/Button_no_source_fa.png", | "fa/8/8a/Button_no_source_fa.png", | ||
"برچسب بدون منبع", | "برچسب بدون منبع", | ||
"بدون منبع"); | "بدون منبع" | ||
); | |||
/* حذف سریع */ | /* حذف سریع */ | ||
tools.speedyDel = buttonGenerator( | |||
function () { | |||
var temp1 = document.getElementById('wpTextbox1'), | |||
temp2 = temp1.value; | |||
temp1.value = ''; | |||
insertTags('{{حذف سریع|', '}}\n' + temp2, 'معیار'); | |||
}, | |||
"حذف سریع", | "حذف سریع", | ||
true, | true, | ||
"fa/c/c1/Button_delete_vote.png", | "fa/c/c1/Button_delete_vote.png", | ||
"برچسب حذف سریع", | "برچسب حذف سریع", | ||
"حذف سریع"); | "حذف سریع" | ||
); | |||
/* حذف | /* حذف زمان\u200cدار */ | ||
tools.prod = buttonGenerator( | |||
function () { | |||
"حذف | var temp2 = document.getElementById('wpTextbox1'), | ||
temp3 = temp2.value; | |||
temp2.value = ''; | |||
insertTags('{{جا:حذف زمان\u200cدار|', '}}\n' + temp3, 'معیار'); | |||
}, | |||
"حذف زمان\u200cدار", | |||
true, | true, | ||
"commons/3/3f/Button_attendre.png", | "commons/3/3f/Button_attendre.png", | ||
"برچسب حذف | "برچسب حذف زمان\u200cدار", | ||
"حذف | "حذف زمان\u200cدار" | ||
); | |||
/* منبع تصویر نامعلوم */ | /* منبع تصویر نامعلوم */ | ||
tools.picSource = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = '{{منبع تصویر نامعلوم}}\n' + | |||
document.getElementById('wpTextbox1').value; | |||
}, | |||
"برچسب منبع", | "برچسب منبع", | ||
false, | false, | ||
"fa/5/59/Button_image_source.png", | "fa/5/59/Button_image_source.png", | ||
"برچسب منبع تصویر نامعلوم", | "برچسب منبع تصویر نامعلوم", | ||
"منبع تصویر نامعلوم"); | "منبع تصویر نامعلوم" | ||
); | |||
/* حق تکثیر تصویر نامعلوم */ | /* حق تکثیر تصویر نامعلوم */ | ||
tools.picCopy = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = | |||
'{{جا' + | |||
':حق تکثیر تصویر نامعلوم}}\n' + | |||
document.getElementById('wpTextbox1').value; | |||
}, | |||
"برچسب حق تکثیر", | "برچسب حق تکثیر", | ||
false, | false, | ||
"fa/7/7e/Button_image_copyright.png", | "fa/7/7e/Button_image_copyright.png", | ||
"برچسب حق تکثیر تصویر نامعلوم", | "برچسب حق تکثیر تصویر نامعلوم", | ||
"حق تکثیر تصویر نامعلوم"); | "حق تکثیر تصویر نامعلوم" | ||
); | |||
/* تمیزکاری */ | /* تمیزکاری */ | ||
tools.cleanup = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = '{{تمیزکاری}}\\n' + document.getElementById('wpTextbox1').value; | |||
}, | |||
"برچسب تمیزکاری", | "برچسب تمیزکاری", | ||
false, | false, | ||
"commons/2/2e/Button_broom.png", | "commons/2/2e/Button_broom.png", | ||
"برچسب تمیزکاری", | "برچسب تمیزکاری", | ||
"تمیزکاری"); | "تمیزکاری" | ||
); | |||
/* اخطار نگاره */ | /* اخطار نگاره */ | ||
tools.imgWarn = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = ''; | |||
insertTags( | |||
'{{جا:اخطار نگاره|', | |||
'}}', | |||
'نگاره' | |||
); | |||
}, | |||
"برچسب نگاره", | "برچسب نگاره", | ||
false, | false, | ||
"commons/e/ec/Button_aviso.png", | "commons/e/ec/Button_aviso.png", | ||
"اخطار نگاره", | "اخطار نگاره", | ||
"اخطار نگاره"); | "اخطار نگاره" | ||
); | |||
/* حق تکثیر مشکوک */ | /* حق تکثیر مشکوک */ | ||
tools.sus = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = '{{حق تکثیر مشکوک}}\n' + document.getElementById('wpTextbox1').value; | |||
}, | |||
"برچسب حق تکثیر", | "برچسب حق تکثیر", | ||
false, | false, | ||
"fa/c/c7/Button_Sus.png", | "fa/c/c7/Button_Sus.png", | ||
"برچسب حق تکثیر مشکوک", | "برچسب حق تکثیر مشکوک", | ||
"حق تکثیر مشکوک"); | "حق تکثیر مشکوک" | ||
); | |||
/* نقض حق تکثیر */ | /* نقض حق تکثیر */ | ||
tools.copyR = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = ''; | |||
insertTags( | |||
'{{جا' + | |||
':نقض حق تکثیر|url=', | |||
'}}', | |||
'Address' | |||
); | |||
}, | |||
"برچسب حق تکثیر", | "برچسب حق تکثیر", | ||
false, | false, | ||
"fa/6/6f/Button_CopyR.png", | "fa/6/6f/Button_CopyR.png", | ||
"برچسب نقض حق تکثیر", | "برچسب نقض حق تکثیر", | ||
"نقض حق تکثیر"); | "نقض حق تکثیر" | ||
); | |||
/* لحن نامناسب */ | /* لحن نامناسب */ | ||
tools.tone = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = '{{لحن نامناسب}}\n' + | |||
document.getElementById('wpTextbox1').value; | |||
}, | |||
"برچسب لحن", | "برچسب لحن", | ||
false, | false, | ||
"fa/f/fc/Button_Tone.png", | "fa/f/fc/Button_Tone.png", | ||
"برچسب لحن نامناسب", | "برچسب لحن نامناسب", | ||
"لحن"); | "لحن" | ||
); | |||
// Buttons that help with wiki writing | // Buttons that help with wiki writing | ||
/* تغییر جهت */ | /* تغییر جهت */ | ||
tools.toggleDirection = buttonGenerator( | |||
function () { | |||
toggleDir(document.getElementById('wpTextbox1')); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"fa/d/d0/Button_toggle_dir.png", | "fa/d/d0/Button_toggle_dir.png", | ||
"تغییر جهت جعبهٔ ویرایش", | "تغییر جهت جعبهٔ ویرایش", | ||
"تغییرجهت"); | "تغییرجهت" | ||
); | |||
/* پیوند درونی */ | /* پیوند درونی */ | ||
tools.wikiLink = buttonGenerator( | |||
function () { | |||
insertTags('[[', ']]', 'مقاله'); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"fa/d/d0/Button_in_wikify.png", | "fa/d/d0/Button_in_wikify.png", | ||
"پیوند", | "پیوند", | ||
"پیوند"); | "پیوند" | ||
); | |||
/* متن | /* متن خط\u200cخورده */ | ||
tools.strikeTextButton = buttonGenerator( | |||
function () { | |||
insertTags('<s>', '</s>', 'متن خط خورده'); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"commons/c/c9/Button_strike.png", | "commons/c/c9/Button_strike.png", | ||
"متن | "متن خط\u200cخورده", | ||
"متن | "متن خط\u200cخورده" | ||
); | |||
/* توضیح */ | /* توضیح */ | ||
tools.commentButton = buttonGenerator( | |||
function () { | |||
insertTags('<!--', '-->', 'توضیح'); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"commons/3/34/Button_hide_comment.png", | "commons/3/34/Button_hide_comment.png", | ||
"توضیح", | "توضیح", | ||
"توضیح"); | "توضیح" | ||
); | |||
/* ملزومات مقاله */ | /* ملزومات مقاله */ | ||
tools.addEssentialThings = buttonGenerator( | |||
function () { | |||
insertTags('== جستارهای وابسته ==\\n\\n== منابع ==\\n{{پانویس}}', '', ''); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"commons/e/ef/Add_note.jpg", | "commons/e/ef/Add_note.jpg", | ||
"ملزومات مقاله", | "ملزومات مقاله", | ||
"ملزومات مقاله"); | "ملزومات مقاله" | ||
); | |||
/* خوشامدید */ | /* خوشامدید */ | ||
tools.welcome = buttonGenerator( | |||
function () { | |||
insertTags( | |||
'{{جا:خوشامدید|~~~~}}', | |||
'', | |||
'' | |||
); | |||
}, | |||
"خوشامدگویی", | "خوشامدگویی", | ||
true, | true, | ||
"commons/4/4a/Smilies_Alien_cool.png", | "commons/4/4a/Smilies_Alien_cool.png", | ||
"خوشامدگویی", | "خوشامدگویی", | ||
"خوشامد"); | "خوشامد" | ||
); | |||
/* | /* چپ\u200cچین */ | ||
tools.chapChin = buttonGenerator( | |||
function () { | |||
insertTags( | |||
'{{چپ\u200cچین}}\n', | |||
'\n{{پایان چپ\u200cچین}}', | |||
'متن چپ\u200cچین\u200cشده' | |||
); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"en/e/ea/Button_align_left.png", | "en/e/ea/Button_align_left.png", | ||
" | "چپ\u200cچین\u200cکردن متن", | ||
" | "چپ\u200cچین" | ||
); | |||
/* اندیس بالا */ | /* اندیس بالا */ | ||
tools.upperText = buttonGenerator( | |||
function () { | |||
insertTags('<sup>', '</sup>', 'اندیس'); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"en/8/80/Button_upper_letter.png", | "en/8/80/Button_upper_letter.png", | ||
"اندیس بالا", | "اندیس بالا", | ||
"اندیس بالا"); | "اندیس بالا" | ||
); | |||
/* اندیس پایین */ | /* اندیس پایین */ | ||
tools.lowerText = buttonGenerator( | |||
function () { | |||
insertTags('<sub>', '</sub>', 'اندیس'); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"en/7/70/Button_lower_letter.png", | "en/7/70/Button_lower_letter.png", | ||
"اندیس پایین", | "اندیس پایین", | ||
"اندیس پایین"); | "اندیس پایین" | ||
); | |||
/* تغییرمسیر */ | /* تغییرمسیر */ | ||
tools.redirectButton = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = ''; | |||
insertTags( | |||
'#تغییرمسیر [[', | |||
']]', | |||
'پیوند' | |||
); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"en/c/c8/Button_redirect.png", | "en/c/c8/Button_redirect.png", | ||
"تغییرمسیر", | "تغییرمسیر", | ||
"تغییرمسیر"); | "تغییرمسیر" | ||
); | |||
/* سال میلادی */ | /* سال میلادی */ | ||
tools.gregYear = buttonGenerator( | |||
function () { | |||
insertTags( | |||
'[[', | |||
' (میلادی)|' + ']]', | |||
'سال' | |||
); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"fa/a/a7/Button_cal.png", | "fa/a/a7/Button_cal.png", | ||
"سال میلادی", | "سال میلادی", | ||
"میلادی" | "میلادی" | ||
); | |||
/* | /* مرتب\u200cسازی */ | ||
tools.sortText = buttonGenerator( | |||
function () { | |||
applyOnSelection(SortText); | |||
}, | |||
"", | "", | ||
true, | true, | ||
"fa/3/33/Button_sort.png", | "fa/3/33/Button_sort.png", | ||
" | "مرتب\u200cسازی بر اساس الفبا", | ||
" | "مرتب\u200cسازی" | ||
); | |||
/* شد! */ | /* شد! */ | ||
tools.shod = buttonGenerator( | |||
function () { | |||
document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + | |||
'\n:{{شد}} ~~' + '~~'; | |||
}, | |||
"شد", | "شد", | ||
true, | true, | ||
"commons/5/5b/Button_check.png", | "commons/5/5b/Button_check.png", | ||
"شد", | "شد", | ||
"شد"); | "شد" | ||
); | |||
var extraEditButtons = [], extraMoveButtons = [], space = ' '; | |||
var | |||
extraEditButtons = extraEditButtons.concat(tools.toggleDirection, space, tools.ykArabic, tools.zwnj, tools.nonS, | |||
tools.dig, tools.punc, tools.superTool); | |||
if ( | if (mw.config.get('wgUserGroups').indexOf('autoconfirmed') !== -1) { | ||
// only 'autoconfirmed' users will see dictation tool | |||
extraEditButtons = extraEditButtons.concat(space, tools.dictation); | |||
} | } | ||
extraEditButtons = extraEditButtons.concat(space, tools.urlFix, space, tools.welcome, | |||
tools.addEssentialThings, tools.noSource, tools.sus, tools.tone, tools.wikify, | |||
tools.shod, tools.cleanup, tools.speedyDel, tools.prod, space, tools.redirectButton, | |||
tools.gregYear, tools.strikeTextButton, tools.chapChin, tools.commentButton, space, tools.sortText); | |||
extraMoveButtons = extraMoveButtons.concat(tools.superToolMove, space, tools.toggleDirection, space, | |||
tools.ykArabic, tools.zwnj, tools.nonS, tools.digMove, tools.punc, space, tools.dictation); | |||
console.log(extraEditButtons); | |||
// On DOM Ready | |||
$(function () { | $(function () { | ||
if ($("#wpTextbox1").length !== 0) { | if ($("#wpTextbox1").length !== 0) { | ||
$( | $('<div />').append(extraEditButtons).insertBefore("#wpTextbox1"); | ||
} | } | ||
if ($("#movepage")) { | if ($("#movepage")) { | ||
$('<span />').append(extraMoveButtons).insertAfter("#wpNewTitleMain"); | |||
} | } | ||
}); | }); | ||
}(jQuery, mediaWiki)); | |||
نسخهٔ ۱۳ ژوئن ۲۰۱۳، ساعت ۱۰:۳۵
// <nowiki> // DON'T REMOVE THIS LINE EVER
/*jslint indent: 2, browser: true*/
/*global jQuery, mediaWiki,
applyOnSelection, YKarabic, FM, NonStandard, digits, digits_move, URLfix,
AtSignReplace, SuperTool, SuperTool_move, ZWNJ_Dictation, Punctuation, insertTags,
toggleDir, SortText*/
(function ($, mw) {
'use strict';
/**
* Adds edit summary
*/
function addEditSummary(summaryText, replaceSummary) {
if (document.location.href.indexOf("§ion=new") > -1 || summaryText === "") {
return;
}
if ($('#wpSummary').length === 0) {
return;
}
var summaryPrefix = "", pos;
if ($('#wpSummary').val().indexOf("*/ ") > -1) {
pos = $('#wpSummary').val().indexOf("*/ ");
summaryPrefix = $('#wpSummary').val().substr(0, pos + 3);
}
if (replaceSummary) {
$('#wpSummary').val(summaryPrefix + summaryText);
} else {
if ($('#wpSummary').val() === summaryPrefix) {
$('#wpSummary').val($('#wpSummary').val() + summaryText);
} else {
if ($('#wpSummary').val().indexOf(summaryText) === -1) { // do not repeat in edit summary
$('#wpSummary').val($('#wpSummary').val() + "، " + summaryText);
}
}
}
}
/**
* Make of button from a common pattern
*/
function buttonGenerator(callback, summaryText, replaceSummary, imageSuffix, title, alt) {
return $('<a "javascript:;" class="tooly-button" />').click(function (e) {
e.preventDefault();
callback();
addEditSummary(summaryText, replaceSummary);
}).append($('<img />').attr({
src: '//upload.wikimedia.org/wikipedia/' + imageSuffix,
title: title,
alt: alt
}))[0];
}
var tools = {};
// Buttons that FIX wikitext
/* ی ک */
tools.ykArabic = buttonGenerator(
function () { applyOnSelection(YKarabic); },
"اصلاح نویسه\u200cهای عربی",
false,
"commons/8/88/Button_YehKeh.png",
"اصلاح ی و ک",
"ی و ک"
);
/* فاصلهٔ مجازی */
tools.zwnj = buttonGenerator(
function () { applyOnSelection(FM); },
"اصلاح فاصلهٔ مجازی",
false,
"fa/d/d0/Button_ZWNJ.png",
"فاصلهٔ مجازی",
"فاصلهٔ مجازی"
);
/* نویسهٔ غیراستاندارد */
tools.nonS = buttonGenerator(
function () { applyOnSelection(NonStandard); },
"اصلاح نویسه",
false,
"fa/9/94/Button_non_standard.png",
"نویسه\u200cهای غیراستاندارد",
"نویسه\u200cهای غیراستاندارد"
);
/* اصلاح ارقام */
tools.dig = buttonGenerator(
function () { applyOnSelection(digits); },
"اصلاح ارقام",
false,
"fa/4/4a/Button_numbers.png",
"اصلاح ارقام",
"ارقام"
);
/* اصلاح ارقام مخصوص صفحه انتقال */
tools.digMove = buttonGenerator(
function () { applyOnSelection(digits_move); },
"اصلاح ارقام",
false,
"fa/4/4a/Button_numbers.png",
"اصلاح ارقام",
"ارقام"
);
/* یونی\u200cکدسازی نشانی\u200cهای وب */
tools.urlFix = buttonGenerator(
function () { applyOnSelection(URLfix); },
"اصلاح نشانی وب",
false,
"fa/b/ba/Button_decode_URI.png",
"یونی\u200cکدسازی نشانی\u200cها",
"یونی\u200cکدسازی"
);
/* اصلاح علامت @ */
tools.atSignFix = buttonGenerator(
function () { applyOnSelection(AtSignReplace); },
"اصلاح @",
false,
"fa/7/7f/Button_at_sign.png",
"اصلاح علامت @",
"@"
);
/* ابرابزار */
tools.superTool = buttonGenerator(
function () { applyOnSelection(SuperTool); },
"ابرابزار",
false,
"fa/f/fc/Button_super_tool.png",
"ابرابزار",
"ابرابزار"
);
/* ابرابزار مخصوص صفحه انتقال */
tools.superToolMove = buttonGenerator(
function () { applyOnSelection(SuperTool_move); },
"ابرابزار",
false,
"fa/f/fc/Button_super_tool.png",
"ابرابزار",
"ابرابزار"
);
/* ابزار املا */
tools.dictation = buttonGenerator(
function () { applyOnSelection(ZWNJ_Dictation); },
"اصلاح املا",
false,
"commons/a/a3/Button_Dictation-fa.png",
"املا",
"املا"
);
/* اصلاحات نقطه\u200cگذاری */
tools.punc = buttonGenerator(
function () { applyOnSelection(Punctuation); },
"اصلاح سجاوندی",
false,
"fa/e/ed/Button_punctuation.png",
"نقطه\u200cگذاری",
"نقطه\u200cگذاری"
);
// Buttons that add tags
/* برچسب ویکی\u200cسازی */
tools.wikify = buttonGenerator(
function () {
$('#wpSummary').val('{{ویکی\u200cسازی}}\n' + $('wpTextbox1').val());
},
"برچسب ویکی\u200cسازی",
false,
"fa/3/38/Button_wikify.png",
"برچسب ویکی\u200cسازی",
"ویکی\u200cسازی"
);
/* بدون منبع */
tools.noSource = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = '{{بدون منبع}}\n' + document.getElementById('wpTextbox1').value;
},
"برچسب منبع",
false,
"fa/8/8a/Button_no_source_fa.png",
"برچسب بدون منبع",
"بدون منبع"
);
/* حذف سریع */
tools.speedyDel = buttonGenerator(
function () {
var temp1 = document.getElementById('wpTextbox1'),
temp2 = temp1.value;
temp1.value = '';
insertTags('{{حذف سریع|', '}}\n' + temp2, 'معیار');
},
"حذف سریع",
true,
"fa/c/c1/Button_delete_vote.png",
"برچسب حذف سریع",
"حذف سریع"
);
/* حذف زمان\u200cدار */
tools.prod = buttonGenerator(
function () {
var temp2 = document.getElementById('wpTextbox1'),
temp3 = temp2.value;
temp2.value = '';
insertTags('{{جا:حذف زمان\u200cدار|', '}}\n' + temp3, 'معیار');
},
"حذف زمان\u200cدار",
true,
"commons/3/3f/Button_attendre.png",
"برچسب حذف زمان\u200cدار",
"حذف زمان\u200cدار"
);
/* منبع تصویر نامعلوم */
tools.picSource = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = '{{منبع تصویر نامعلوم}}\n' +
document.getElementById('wpTextbox1').value;
},
"برچسب منبع",
false,
"fa/5/59/Button_image_source.png",
"برچسب منبع تصویر نامعلوم",
"منبع تصویر نامعلوم"
);
/* حق تکثیر تصویر نامعلوم */
tools.picCopy = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value =
'{{جا' +
':حق تکثیر تصویر نامعلوم}}\n' +
document.getElementById('wpTextbox1').value;
},
"برچسب حق تکثیر",
false,
"fa/7/7e/Button_image_copyright.png",
"برچسب حق تکثیر تصویر نامعلوم",
"حق تکثیر تصویر نامعلوم"
);
/* تمیزکاری */
tools.cleanup = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = '{{تمیزکاری}}\\n' + document.getElementById('wpTextbox1').value;
},
"برچسب تمیزکاری",
false,
"commons/2/2e/Button_broom.png",
"برچسب تمیزکاری",
"تمیزکاری"
);
/* اخطار نگاره */
tools.imgWarn = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = '';
insertTags(
'{{جا:اخطار نگاره|',
'}}',
'نگاره'
);
},
"برچسب نگاره",
false,
"commons/e/ec/Button_aviso.png",
"اخطار نگاره",
"اخطار نگاره"
);
/* حق تکثیر مشکوک */
tools.sus = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = '{{حق تکثیر مشکوک}}\n' + document.getElementById('wpTextbox1').value;
},
"برچسب حق تکثیر",
false,
"fa/c/c7/Button_Sus.png",
"برچسب حق تکثیر مشکوک",
"حق تکثیر مشکوک"
);
/* نقض حق تکثیر */
tools.copyR = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = '';
insertTags(
'{{جا' +
':نقض حق تکثیر|url=',
'}}',
'Address'
);
},
"برچسب حق تکثیر",
false,
"fa/6/6f/Button_CopyR.png",
"برچسب نقض حق تکثیر",
"نقض حق تکثیر"
);
/* لحن نامناسب */
tools.tone = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = '{{لحن نامناسب}}\n' +
document.getElementById('wpTextbox1').value;
},
"برچسب لحن",
false,
"fa/f/fc/Button_Tone.png",
"برچسب لحن نامناسب",
"لحن"
);
// Buttons that help with wiki writing
/* تغییر جهت */
tools.toggleDirection = buttonGenerator(
function () {
toggleDir(document.getElementById('wpTextbox1'));
},
"",
true,
"fa/d/d0/Button_toggle_dir.png",
"تغییر جهت جعبهٔ ویرایش",
"تغییرجهت"
);
/* پیوند درونی */
tools.wikiLink = buttonGenerator(
function () {
insertTags('[[', ']]', 'مقاله');
},
"",
true,
"fa/d/d0/Button_in_wikify.png",
"پیوند",
"پیوند"
);
/* متن خط\u200cخورده */
tools.strikeTextButton = buttonGenerator(
function () {
insertTags('<s>', '</s>', 'متن خط خورده');
},
"",
true,
"commons/c/c9/Button_strike.png",
"متن خط\u200cخورده",
"متن خط\u200cخورده"
);
/* توضیح */
tools.commentButton = buttonGenerator(
function () {
insertTags('<!--', '-->', 'توضیح');
},
"",
true,
"commons/3/34/Button_hide_comment.png",
"توضیح",
"توضیح"
);
/* ملزومات مقاله */
tools.addEssentialThings = buttonGenerator(
function () {
insertTags('== جستارهای وابسته ==\\n\\n== منابع ==\\n{{پانویس}}', '', '');
},
"",
true,
"commons/e/ef/Add_note.jpg",
"ملزومات مقاله",
"ملزومات مقاله"
);
/* خوشامدید */
tools.welcome = buttonGenerator(
function () {
insertTags(
'{{جا:خوشامدید|~~~~}}',
'',
''
);
},
"خوشامدگویی",
true,
"commons/4/4a/Smilies_Alien_cool.png",
"خوشامدگویی",
"خوشامد"
);
/* چپ\u200cچین */
tools.chapChin = buttonGenerator(
function () {
insertTags(
'{{چپ\u200cچین}}\n',
'\n{{پایان چپ\u200cچین}}',
'متن چپ\u200cچین\u200cشده'
);
},
"",
true,
"en/e/ea/Button_align_left.png",
"چپ\u200cچین\u200cکردن متن",
"چپ\u200cچین"
);
/* اندیس بالا */
tools.upperText = buttonGenerator(
function () {
insertTags('<sup>', '</sup>', 'اندیس');
},
"",
true,
"en/8/80/Button_upper_letter.png",
"اندیس بالا",
"اندیس بالا"
);
/* اندیس پایین */
tools.lowerText = buttonGenerator(
function () {
insertTags('<sub>', '</sub>', 'اندیس');
},
"",
true,
"en/7/70/Button_lower_letter.png",
"اندیس پایین",
"اندیس پایین"
);
/* تغییرمسیر */
tools.redirectButton = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = '';
insertTags(
'#تغییرمسیر [[',
']]',
'پیوند'
);
},
"",
true,
"en/c/c8/Button_redirect.png",
"تغییرمسیر",
"تغییرمسیر"
);
/* سال میلادی */
tools.gregYear = buttonGenerator(
function () {
insertTags(
'[[',
' (میلادی)|' + ']]',
'سال'
);
},
"",
true,
"fa/a/a7/Button_cal.png",
"سال میلادی",
"میلادی"
);
/* مرتب\u200cسازی */
tools.sortText = buttonGenerator(
function () {
applyOnSelection(SortText);
},
"",
true,
"fa/3/33/Button_sort.png",
"مرتب\u200cسازی بر اساس الفبا",
"مرتب\u200cسازی"
);
/* شد! */
tools.shod = buttonGenerator(
function () {
document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value +
'\n:{{شد}} ~~' + '~~';
},
"شد",
true,
"commons/5/5b/Button_check.png",
"شد",
"شد"
);
var extraEditButtons = [], extraMoveButtons = [], space = ' ';
extraEditButtons = extraEditButtons.concat(tools.toggleDirection, space, tools.ykArabic, tools.zwnj, tools.nonS,
tools.dig, tools.punc, tools.superTool);
if (mw.config.get('wgUserGroups').indexOf('autoconfirmed') !== -1) {
// only 'autoconfirmed' users will see dictation tool
extraEditButtons = extraEditButtons.concat(space, tools.dictation);
}
extraEditButtons = extraEditButtons.concat(space, tools.urlFix, space, tools.welcome,
tools.addEssentialThings, tools.noSource, tools.sus, tools.tone, tools.wikify,
tools.shod, tools.cleanup, tools.speedyDel, tools.prod, space, tools.redirectButton,
tools.gregYear, tools.strikeTextButton, tools.chapChin, tools.commentButton, space, tools.sortText);
extraMoveButtons = extraMoveButtons.concat(tools.superToolMove, space, tools.toggleDirection, space,
tools.ykArabic, tools.zwnj, tools.nonS, tools.digMove, tools.punc, space, tools.dictation);
console.log(extraEditButtons);
// On DOM Ready
$(function () {
if ($("#wpTextbox1").length !== 0) {
$('<div />').append(extraEditButtons).insertBefore("#wpTextbox1");
}
if ($("#movepage")) {
$('<span />').append(extraMoveButtons).insertAfter("#wpNewTitleMain");
}
});
}(jQuery, mediaWiki));