تفاوت میان نسخههای «مدیاویکی:Gadget-Extra-Editbuttons.js»
پرش به ناوبری
پرش به جستجو
(test) |
Bellavista (گفتگو | مشارکتها) |
||
خط ۱: | خط ۱: | ||
− | mw.loader. | + | // <nowiki> // DON'T REMOVE THIS LINE EVER |
− | mw. | + | /*jslint indent: 2, browser: true*/ |
− | + | /*global jQuery, mediaWiki, persianWikiTools, insertTags*/ | |
+ | (function ($, mw) { | ||
+ | 'use strict'; | ||
+ | |||
+ | |||
+ | // ابزار در حالت نمایش | ||
+ | function loadPage(title, callback) { | ||
+ | new mw.Api().get({ | ||
+ | action: 'query', | ||
+ | prop: 'revisions', | ||
+ | titles: title, | ||
+ | rvprop: 'content', | ||
+ | format: 'json' | ||
+ | }).done(function (data) { | ||
+ | callback($.map(data.query.pages, function (value) { return value; })[0].revisions[0]['*']); | ||
+ | }); | ||
+ | } | ||
+ | function savePage(title, text, summary, callback) { | ||
+ | new mw.Api().post({ | ||
+ | action: 'edit', | ||
+ | title: title, | ||
+ | text: text, | ||
+ | summary: summary, | ||
+ | nocreate: '', | ||
+ | minor: '', | ||
+ | token: mw.user.tokens.get('editToken') | ||
+ | }).done(function (data) { | ||
+ | if (data.error && data.error.info) { | ||
+ | mw.notify(data.error.info); | ||
+ | } else { | ||
+ | callback(); | ||
+ | } | ||
+ | }).fail(function (data) { | ||
+ | mw.notify(data); | ||
+ | }); | ||
+ | } | ||
+ | function loadSavePageRefresh(replaceCallback, summary) { | ||
+ | loadPage(mw.config.get('wgPageName'), function (text) { | ||
+ | savePage(mw.config.get('wgPageName'), replaceCallback(text), summary, function () { | ||
+ | mw.notify('ویرایش با موفقیت انجام پذیرفت'); | ||
+ | // Loading diff page | ||
+ | var uri = new mw.Uri(); | ||
+ | uri.query = { | ||
+ | 'title': mw.config.get('wgPageName'), | ||
+ | 'diff': 'cur', | ||
+ | 'oldid': 'prev' | ||
+ | }; | ||
+ | uri.path = mw.config.get('wgScriptPath') + '/index.php'; | ||
+ | window.location = uri.toString(); | ||
+ | }); | ||
+ | }); | ||
+ | } | ||
+ | if (mw.config.get('wgAction') === 'view' && mw.config.get('wgIsArticle') && mw.config.get('wgPageName') !== 'صفحهٔ_اصلی') { | ||
+ | mw.loader.using('jquery.ui.dialog', function () { | ||
+ | $(function () { | ||
+ | $(mw.util.addPortletLink('p-views', '#', 'ابرابزار', 'ca-abar-abzar')) | ||
+ | .click(function () { | ||
+ | $('<div><h6>مطمئنید می\u200cخواهید ویرایشی خودکار جهت اصلاح متن این صفحه به کمک ابرابزار داشته باشید؟</h6></div>') | ||
+ | .dialog({ | ||
+ | modal: true, | ||
+ | title: 'ابرابزار', | ||
+ | resizable: false, | ||
+ | buttons: { | ||
+ | 'بله': function () { | ||
+ | loadSavePageRefresh( | ||
+ | function (text) { | ||
+ | text = persianWikiTools.wikiConvertToPersianCharacters(text); | ||
+ | text = persianWikiTools.applyZwnj(text); | ||
+ | text = persianWikiTools.nonStandard(text); | ||
+ | if (mw.config.get('wgNamespaceNumber') !== 10) { | ||
+ | text = persianWikiTools.wikiTextDigitsToPersian(text); | ||
+ | } | ||
+ | text = persianWikiTools.wikiDictation(text); | ||
+ | text = persianWikiTools.wikiUrlMinifier(text); | ||
+ | return persianWikiTools.wikiPunctuation(text); | ||
+ | }, | ||
+ | 'ویرایش به وسیلهٔ [[وپ:ابرابزار|ابزار خودکار ابرابزار]]' | ||
+ | ); | ||
+ | $(this).dialog("close"); | ||
+ | }, | ||
+ | 'خیر': function () { | ||
+ | $(this).dialog("close"); | ||
+ | } | ||
+ | }, | ||
+ | close: function () { | ||
+ | $(this).remove(); | ||
+ | } | ||
+ | }); | ||
+ | }); | ||
+ | }); | ||
+ | }); | ||
+ | } | ||
+ | |||
+ | |||
+ | // ابزار در حالت ویرایش | ||
+ | /** | ||
+ | * Adds edit summary | ||
+ | */ | ||
+ | function addEditSummary(summaryText, replaceSummary) { | ||
+ | if (summaryText === '') { | ||
+ | return; | ||
+ | } | ||
+ | var summary = $('.editOptions #wpSummary'), summaryPrefix = '', pos; | ||
+ | if (summary.length === 0) { | ||
+ | return; | ||
+ | } | ||
+ | if (summary.val().indexOf('*/ ') > -1) { | ||
+ | pos = summary.val().indexOf('*/ '); | ||
+ | summaryPrefix = summary.val().substr(0, pos + 3); | ||
+ | } | ||
+ | if (replaceSummary) { | ||
+ | summary.val(summaryPrefix + summaryText); | ||
+ | } else { | ||
+ | if (summary.val() === summaryPrefix) { | ||
+ | summary.val(summary.val() + summaryText); | ||
+ | } else { | ||
+ | if (summary.val().indexOf(summaryText) === -1) { // do not repeat in edit summary | ||
+ | summary.val(summary.val() + '، ' + summaryText); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Makes a simple button from parameters | ||
+ | */ | ||
+ | function buttonGenerator(callback, summaryText, replaceSummary, image, title, alt, idSuffix) { | ||
+ | function clickCallback(e) { | ||
+ | e.preventDefault(); | ||
+ | callback(); | ||
+ | addEditSummary(summaryText, replaceSummary); | ||
+ | } | ||
+ | var button = $('<a />', { id: 'persian-wiki-tools-' + idSuffix }).click(clickCallback).append( | ||
+ | $('<img />').attr({ | ||
+ | src: image, | ||
+ | title: title, | ||
+ | alt: alt | ||
+ | }).error(function () { | ||
+ | button.replaceWith($('<button />').text(alt).click(clickCallback)); | ||
+ | }) | ||
+ | ); | ||
+ | return button[0]; | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Applies the string functions defined below to the | ||
+ | * selected text in the edit box. If no text is selected, applies | ||
+ | * the function to the whole contents of edit box. | ||
+ | */ | ||
+ | function applyOnSelection(callback) { | ||
+ | var txtarea, range, startPos, endPos, selText; | ||
+ | if (document.getElementById('editform')) { | ||
+ | txtarea = document.getElementById('wpTextbox1'); | ||
+ | } else if (document.getElementById('wpNewTitleMain')) { | ||
+ | txtarea = document.getElementById('wpNewTitleMain'); | ||
+ | } else { | ||
+ | return; | ||
+ | } | ||
+ | if (document.selection && document.selection.createRange) { // IE/Opera | ||
+ | // get current selection | ||
+ | txtarea.focus(); | ||
+ | range = document.selection.createRange(); | ||
+ | selText = range.text; | ||
+ | if (selText) { | ||
+ | range.text = callback(selText); | ||
+ | range.select(); | ||
+ | } else { | ||
+ | txtarea.value = callback(txtarea.value); | ||
+ | } | ||
+ | } else if (txtarea.selectionStart || txtarea.selectionStart === 0) { // Mozilla | ||
+ | // get current selection | ||
+ | txtarea.focus(); | ||
+ | startPos = txtarea.selectionStart; | ||
+ | endPos = txtarea.selectionEnd; | ||
+ | selText = txtarea.value.substring(startPos, endPos); | ||
+ | // insert tags | ||
+ | if (selText) { | ||
+ | txtarea.value = txtarea.value.substring(0, startPos) + callback(selText) + txtarea.value.substring(endPos, txtarea.value.length); | ||
+ | txtarea.selectionStart = startPos + selText.length; | ||
+ | txtarea.selectionEnd = txtarea.selectionStart; | ||
+ | } else { | ||
+ | txtarea.value = callback(txtarea.value); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | var tools = {}; | ||
+ | |||
+ | // Buttons that FIX wikitext | ||
+ | /* ی ک */ | ||
+ | tools.ykArabic = buttonGenerator( | ||
+ | function () { applyOnSelection(persianWikiTools.wikiConvertToPersianCharacters); }, | ||
+ | 'اصلاح نویسه\u200cهای عربی', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/8/88/Button_YehKeh.png', | ||
+ | 'اصلاح ی و ک', | ||
+ | 'ی و ک', | ||
+ | 'YehKeh' | ||
+ | ); | ||
+ | |||
+ | /* فاصلهٔ مجازی */ | ||
+ | tools.zwnj = buttonGenerator( | ||
+ | function () { applyOnSelection(persianWikiTools.applyZwnj); }, | ||
+ | 'اصلاح فاصلهٔ مجازی', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/d/d0/Button_ZWNJ.png', | ||
+ | 'فاصلهٔ مجازی', | ||
+ | 'فاصلهٔ مجازی', | ||
+ | 'ZWNJ' | ||
+ | ); | ||
+ | |||
+ | /* نویسهٔ غیراستاندارد */ | ||
+ | tools.nonStandard = buttonGenerator( | ||
+ | function () { applyOnSelection(persianWikiTools.nonStandard); }, | ||
+ | 'اصلاح نویسه', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/9/94/Button_non_standard.png', | ||
+ | 'نویسه\u200cهای غیراستاندارد', | ||
+ | 'نویسه\u200cهای غیراستاندارد', | ||
+ | 'non-standard' | ||
+ | ); | ||
+ | |||
+ | /* اصلاح ارقام */ | ||
+ | tools.dig = buttonGenerator( | ||
+ | function () { applyOnSelection(persianWikiTools.wikiTextDigitsToPersian); }, | ||
+ | 'اصلاح ارقام', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/4/4a/Button_numbers.png', | ||
+ | 'اصلاح ارقام', | ||
+ | 'ارقام', | ||
+ | 'numbers' | ||
+ | ); | ||
+ | |||
+ | /* اصلاح ارقام مخصوص صفحه انتقال */ | ||
+ | tools.digMove = buttonGenerator( | ||
+ | function () { applyOnSelection(persianWikiTools.convertDigitsToPersian); }, | ||
+ | 'اصلاح ارقام', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/4/4a/Button_numbers.png', | ||
+ | 'اصلاح ارقام', | ||
+ | 'ارقام', | ||
+ | 'numbers' | ||
+ | ); | ||
+ | |||
+ | /* یونیکد نشانی وب */ | ||
+ | tools.urlFix = buttonGenerator( | ||
+ | function () { applyOnSelection(persianWikiTools.wikiUrlMinifier); }, | ||
+ | 'اصلاح نشانی وب', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/b/ba/Button_decode_URI.png', | ||
+ | 'یونی\u200cکدسازی نشانی\u200cها', | ||
+ | 'یونی\u200cکدسازی', | ||
+ | 'decode-URI' | ||
+ | ); | ||
+ | |||
+ | /* اصلاح علامت @ */ | ||
+ | tools.atSignFix = buttonGenerator( | ||
+ | function () { | ||
+ | applyOnSelection(function (text) { | ||
+ | return text.replace(/(\S+?)@(\S+?)/g, '$1{{at}}$2'); | ||
+ | }); | ||
+ | }, | ||
+ | 'اصلاح @', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/7/7f/Button_at_sign.png', | ||
+ | 'اصلاح علامت @', | ||
+ | '@', | ||
+ | 'at-sign' | ||
+ | ); | ||
+ | |||
+ | /* ابرابزار */ | ||
+ | tools.superTool = buttonGenerator( | ||
+ | function () { | ||
+ | applyOnSelection(function (text) { | ||
+ | text = persianWikiTools.wikiConvertToPersianCharacters(text); | ||
+ | text = persianWikiTools.applyZwnj(text); | ||
+ | text = persianWikiTools.nonStandard(text); | ||
+ | if (mw.config.get('wgNamespaceNumber') !== 10) { | ||
+ | text = persianWikiTools.wikiTextDigitsToPersian(text); | ||
+ | } | ||
+ | text = persianWikiTools.wikiUrlMinifier(text); | ||
+ | text = persianWikiTools.wikiDictation(text); | ||
+ | return persianWikiTools.wikiPunctuation(text); | ||
+ | }); | ||
+ | }, | ||
+ | 'ابرابزار', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/f/fc/Button_super_tool.png', | ||
+ | 'ابرابزار', | ||
+ | 'ابرابزار', | ||
+ | 'super-tool' | ||
+ | ); | ||
+ | |||
+ | /* ابزار املا */ | ||
+ | tools.dictation = buttonGenerator( | ||
+ | function () { applyOnSelection(persianWikiTools.wikiDictation); }, | ||
+ | 'اصلاح املا', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/a/a3/Button_Dictation-fa.png', | ||
+ | 'املا', | ||
+ | 'املا', | ||
+ | 'dictation' | ||
+ | ); | ||
+ | |||
+ | /* ابرابزار مخصوص صفحه انتقال */ | ||
+ | tools.superToolMove = buttonGenerator( | ||
+ | function () { | ||
+ | applyOnSelection(function (text) { | ||
+ | text = persianWikiTools.wikiConvertToPersianCharacters(text); | ||
+ | text = persianWikiTools.applyZwnj(text); | ||
+ | text = persianWikiTools.nonStandard(text); | ||
+ | text = persianWikiTools.wikiTextDigitsToPersian(text); | ||
+ | text = persianWikiTools.wikiUrlMinifier(text); | ||
+ | text = persianWikiTools.wikiDictation(text); | ||
+ | return persianWikiTools.wikiPunctuation(text); | ||
+ | }); | ||
+ | }, | ||
+ | 'ابرابزار', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/f/fc/Button_super_tool.png', | ||
+ | 'ابرابزار', | ||
+ | 'ابرابزار', | ||
+ | 'super-tool' | ||
+ | ); | ||
+ | |||
+ | /* اصلاحات قراردادن نقطه */ | ||
+ | tools.punc = buttonGenerator( | ||
+ | function () { applyOnSelection(persianWikiTools.wikiPunctuation); }, | ||
+ | 'اصلاح سجاوندی', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/e/ed/Button_punctuation.png', | ||
+ | 'نقطه\u200cگذاری', | ||
+ | 'نقطه\u200cگذاری', | ||
+ | 'punctuation' | ||
+ | ); | ||
+ | |||
+ | // Buttons that add tags | ||
+ | /* برچسب ویکی\u200cسازی */ | ||
+ | tools.wikify = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val('{{ویکی\u200cسازی}}\n' + $('#wpTextbox1').val()); | ||
+ | }, | ||
+ | 'برچسب ویکی\u200cسازی', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/3/38/Button_wikify.png', | ||
+ | 'برچسب ویکی\u200cسازی', | ||
+ | 'ویکی\u200cسازی', | ||
+ | 'wikify' | ||
+ | ); | ||
+ | |||
+ | /* بدون منبع */ | ||
+ | tools.noSource = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val('{{بدون منبع}}\n' + $('#wpTextbox1').val()); | ||
+ | }, | ||
+ | 'برچسب منبع', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/8/8a/Button_no_source_fa.png', | ||
+ | 'برچسب بدون منبع', | ||
+ | 'بدون منبع', | ||
+ | 'no-source' | ||
+ | ); | ||
+ | |||
+ | /* حذف سریع */ | ||
+ | tools.speedyDel = buttonGenerator( | ||
+ | function () { | ||
+ | var temp = $('#wpTextbox1').val(); | ||
+ | $('#wpTextbox1').val(''); | ||
+ | insertTags('{{حذف سریع|', '}}\n' + temp, 'معیار'); | ||
+ | }, | ||
+ | 'حذف سریع', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/c/c1/Button_delete_vote.png', | ||
+ | 'برچسب حذف سریع', | ||
+ | 'حذف سریع', | ||
+ | 'delete-vote' | ||
+ | ); | ||
+ | |||
+ | /* حذف زماندار */ | ||
+ | tools.prod = buttonGenerator( | ||
+ | function () { | ||
+ | var temp = $('#wpTextbox1').val(); | ||
+ | $('#wpTextbox1').val(''); | ||
+ | insertTags('{{جا:حذف زمان\u200cدار|', '}}\n' + temp, 'معیار'); | ||
+ | }, | ||
+ | 'حذف زمان\u200cدار', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/3/3f/Button_attendre.png', | ||
+ | 'برچسب حذف زمان\u200cدار', | ||
+ | 'حذف زمان\u200cدار', | ||
+ | 'attendre' | ||
+ | ); | ||
+ | |||
+ | /* منبع تصویر نامعلوم */ | ||
+ | tools.picSource = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val('{{منبع تصویر نامعلوم}}\n' + $('#wpTextbox1').val()); | ||
+ | }, | ||
+ | 'برچسب منبع', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/5/59/Button_image_source.png', | ||
+ | 'برچسب منبع تصویر نامعلوم', | ||
+ | 'منبع تصویر نامعلوم', | ||
+ | 'image-source' | ||
+ | ); | ||
+ | |||
+ | /* حق تکثیر تصویر نامعلوم */ | ||
+ | tools.picCopy = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val('{{جا:حق تکثیر تصویر نامعلوم}}\n' + $('#wpTextbox1').val()); | ||
+ | }, | ||
+ | 'برچسب حق تکثیر', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/7/7e/Button_image_copyright.png', | ||
+ | 'برچسب حق تکثیر تصویر نامعلوم', | ||
+ | 'حق تکثیر تصویر نامعلوم', | ||
+ | 'image-copyright' | ||
+ | ); | ||
+ | |||
+ | /* تمیزکاری */ | ||
+ | tools.cleanup = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val('{{تمیزکاری}}\n' + $('#wpTextbox1').val()); | ||
+ | }, | ||
+ | 'برچسب تمیزکاری', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_broom.png', | ||
+ | 'برچسب تمیزکاری', | ||
+ | 'تمیزکاری', | ||
+ | 'broom' | ||
+ | ); | ||
+ | |||
+ | /* اخطار نگاره */ | ||
+ | tools.imgWarn = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val(''); | ||
+ | insertTags( | ||
+ | '{{جا:اخطار نگاره|', | ||
+ | '}}', | ||
+ | 'نگاره' | ||
+ | ); | ||
+ | }, | ||
+ | 'برچسب نگاره', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/e/ec/Button_aviso.png', | ||
+ | 'اخطار نگاره', | ||
+ | 'اخطار نگاره', | ||
+ | 'aviso' | ||
+ | ); | ||
+ | |||
+ | /* حق تکثیر مشکوک */ | ||
+ | tools.sus = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val('{{حق تکثیر مشکوک}}\n' + $('#wpTextbox1').val()); | ||
+ | }, | ||
+ | 'برچسب حق تکثیر', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/c/c7/Button_Sus.png', | ||
+ | 'برچسب حق تکثیر مشکوک', | ||
+ | 'حق تکثیر مشکوک', | ||
+ | 'sus' | ||
+ | ); | ||
+ | |||
+ | /* نقض حق تکثیر */ | ||
+ | tools.copyR = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val(''); | ||
+ | insertTags( | ||
+ | '{{جا:نقض حق تکثیر|url=', | ||
+ | '}}', | ||
+ | 'نشانی ایرنتنتی' | ||
+ | ); | ||
+ | }, | ||
+ | 'برچسب حق تکثیر', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/6/6f/Button_CopyR.png', | ||
+ | 'برچسب نقض حق تکثیر', | ||
+ | 'نقض حق تکثیر', | ||
+ | 'copyr' | ||
+ | ); | ||
+ | |||
+ | /* لحن نامناسب */ | ||
+ | tools.tone = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val('{{لحن نامناسب}}\n' + $('#wpTextbox1').val()); | ||
+ | }, | ||
+ | 'برچسب لحن', | ||
+ | false, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/f/fc/Button_Tone.png', | ||
+ | 'برچسب لحن نامناسب', | ||
+ | 'لحن', | ||
+ | 'tone' | ||
+ | ); | ||
+ | |||
+ | // Buttons that help with wiki writing | ||
+ | /* تغییر جهت */ | ||
+ | tools.toggleDirection = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1, #wpNewTitleMain').css({ | ||
+ | 'text-align': 'start', | ||
+ | 'direction': $('#wpTextbox1, #wpNewTitleMain').css('direction') === 'rtl' ? 'ltr' : 'rtl' | ||
+ | }); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/d/d0/Button_toggle_dir.png', | ||
+ | 'تغییر جهت جعبهٔ ویرایش', | ||
+ | 'تغییرجهت', | ||
+ | 'toggle-dir' | ||
+ | ); | ||
+ | |||
+ | /* پیوند درونی */ | ||
+ | tools.wikiLink = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags('[[', ']]', 'مقاله'); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/d/d0/Button_in_wikify.png', | ||
+ | 'پیوند', | ||
+ | 'پیوند', | ||
+ | 'wikify' | ||
+ | ); | ||
+ | |||
+ | /* متن خطخورده */ | ||
+ | tools.strikeTextButton = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags('<s>', '</s>', 'متن خط خورده'); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/c/c9/Button_strike.png', | ||
+ | 'متن خط\u200cخورده', | ||
+ | 'متن خط\u200cخورده', | ||
+ | 'strike' | ||
+ | ); | ||
+ | |||
+ | /* توضیح */ | ||
+ | tools.commentButton = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags('<!--', '-->', 'توضیح'); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/3/34/Button_hide_comment.png', | ||
+ | 'توضیح', | ||
+ | 'توضیح', | ||
+ | 'hide-comment' | ||
+ | ); | ||
+ | |||
+ | /* ملزومات مقاله */ | ||
+ | tools.addEssentialThings = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags('== جستارهای وابسته ==\n\n== منابع ==\n{{پانویس}}', '', ''); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/e/ef/Add_note.jpg', | ||
+ | 'ملزومات مقاله', | ||
+ | 'ملزومات مقاله', | ||
+ | 'add-note' | ||
+ | ); | ||
+ | |||
+ | /* خوشامدید */ | ||
+ | tools.welcome = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags( | ||
+ | '{{جا:خوشامدید|~~~~}}', | ||
+ | '', | ||
+ | '' | ||
+ | ); | ||
+ | }, | ||
+ | 'خوشامدگویی', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/4/4a/Smilies_Alien_cool.png', | ||
+ | 'خوشامدگویی', | ||
+ | 'خوشامد', | ||
+ | 'alien-cool' | ||
+ | ); | ||
+ | |||
+ | /* چپچین */ | ||
+ | tools.chapChin = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags( | ||
+ | '{{چپ\u200cچین}}\n', | ||
+ | '\n{{پایان چپ\u200cچین}}', | ||
+ | 'متن چپ\u200cچین\u200cشده' | ||
+ | ); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/en/e/ea/Button_align_left.png', | ||
+ | 'چپ\u200cچین\u200cکردن متن', | ||
+ | 'چپ\u200cچین', | ||
+ | 'align-left' | ||
+ | ); | ||
+ | |||
+ | /* اندیس بالا */ | ||
+ | tools.upperText = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags('<sup>', '</sup>', 'اندیس'); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png', | ||
+ | 'اندیس بالا', | ||
+ | 'اندیس بالا', | ||
+ | 'upper-letter' | ||
+ | ); | ||
+ | |||
+ | /* اندیس پایین */ | ||
+ | tools.lowerText = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags('<sub>', '</sub>', 'اندیس'); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png', | ||
+ | 'اندیس پایین', | ||
+ | 'اندیس پایین', | ||
+ | 'lower-letter' | ||
+ | ); | ||
+ | |||
+ | /* تغییرمسیر */ | ||
+ | tools.redirectButton = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val(''); | ||
+ | insertTags( | ||
+ | '#تغییرمسیر [[', | ||
+ | ']]', | ||
+ | 'پیوند' | ||
+ | ); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png', | ||
+ | 'تغییرمسیر', | ||
+ | 'تغییرمسیر', | ||
+ | 'redirect' | ||
+ | ); | ||
+ | |||
+ | /* سال میلادی */ | ||
+ | tools.gregYear = buttonGenerator( | ||
+ | function () { | ||
+ | insertTags( | ||
+ | '[[', | ||
+ | ' (میلادی)|]]', | ||
+ | 'سال' | ||
+ | ); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/a/a7/Button_cal.png', | ||
+ | 'سال میلادی', | ||
+ | 'میلادی', | ||
+ | 'cal' | ||
+ | ); | ||
+ | |||
+ | /* مرتبسازی */ | ||
+ | tools.sortText = buttonGenerator( | ||
+ | function () { | ||
+ | applyOnSelection(persianWikiTools.persianSortText); | ||
+ | }, | ||
+ | '', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/fa/3/33/Button_sort.png', | ||
+ | 'مرتب\u200cسازی بر اساس الفبا', | ||
+ | 'مرتب\u200cسازی', | ||
+ | 'sort' | ||
+ | ); | ||
+ | |||
+ | /* شد! */ | ||
+ | tools.shod = buttonGenerator( | ||
+ | function () { | ||
+ | $('#wpTextbox1').val($('#wpTextbox1').val() + '\n:{{شد}} ~~~~'); | ||
+ | }, | ||
+ | 'شد', | ||
+ | true, | ||
+ | '//upload.wikimedia.org/wikipedia/commons/5/5b/Button_check.png', | ||
+ | 'شد', | ||
+ | 'شد', | ||
+ | 'check' | ||
+ | ); | ||
+ | |||
+ | $(function () { | ||
+ | var extraEditButtons = [], extraMoveButtons = [], space = ' '; | ||
+ | |||
+ | extraEditButtons = extraEditButtons.concat(tools.toggleDirection, space, tools.ykArabic, tools.zwnj, tools.nonStandard, | ||
+ | tools.dig, tools.punc, tools.dictation, tools.superTool, 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); | ||
+ | |||
+ | extraEditButtons = extraEditButtons.concat(space).concat(window.userCustomEditButtons || []); | ||
+ | |||
+ | extraMoveButtons = extraMoveButtons.concat(tools.superToolMove, space, tools.toggleDirection, space, | ||
+ | tools.ykArabic, tools.zwnj, tools.nonStandard, tools.digMove, tools.punc, space, tools.dictation); | ||
+ | |||
+ | if ($('#wpTextbox1').length !== 0) { | ||
+ | $('<div id="persian-wiki-tools" />').append(extraEditButtons).insertBefore('#wpTextbox1'); | ||
+ | } | ||
+ | if ($('#movepage').length !== 0) { | ||
+ | $('<span id="persian-wiki-tools" />').append(extraMoveButtons).insertAfter('#wpNewTitleMain'); | ||
+ | } | ||
+ | }); | ||
+ | }(jQuery, mediaWiki)); |
نسخهٔ ۲۱ ژوئن ۲۰۱۴، ساعت ۱۴:۵۷
// <nowiki> // DON'T REMOVE THIS LINE EVER /*jslint indent: 2, browser: true*/ /*global jQuery, mediaWiki, persianWikiTools, insertTags*/ (function ($, mw) { 'use strict'; // ابزار در حالت نمایش function loadPage(title, callback) { new mw.Api().get({ action: 'query', prop: 'revisions', titles: title, rvprop: 'content', format: 'json' }).done(function (data) { callback($.map(data.query.pages, function (value) { return value; })[0].revisions[0]['*']); }); } function savePage(title, text, summary, callback) { new mw.Api().post({ action: 'edit', title: title, text: text, summary: summary, nocreate: '', minor: '', token: mw.user.tokens.get('editToken') }).done(function (data) { if (data.error && data.error.info) { mw.notify(data.error.info); } else { callback(); } }).fail(function (data) { mw.notify(data); }); } function loadSavePageRefresh(replaceCallback, summary) { loadPage(mw.config.get('wgPageName'), function (text) { savePage(mw.config.get('wgPageName'), replaceCallback(text), summary, function () { mw.notify('ویرایش با موفقیت انجام پذیرفت'); // Loading diff page var uri = new mw.Uri(); uri.query = { 'title': mw.config.get('wgPageName'), 'diff': 'cur', 'oldid': 'prev' }; uri.path = mw.config.get('wgScriptPath') + '/index.php'; window.location = uri.toString(); }); }); } if (mw.config.get('wgAction') === 'view' && mw.config.get('wgIsArticle') && mw.config.get('wgPageName') !== 'صفحهٔ_اصلی') { mw.loader.using('jquery.ui.dialog', function () { $(function () { $(mw.util.addPortletLink('p-views', '#', 'ابرابزار', 'ca-abar-abzar')) .click(function () { $('<div><h6>مطمئنید می\u200cخواهید ویرایشی خودکار جهت اصلاح متن این صفحه به کمک ابرابزار داشته باشید؟</h6></div>') .dialog({ modal: true, title: 'ابرابزار', resizable: false, buttons: { 'بله': function () { loadSavePageRefresh( function (text) { text = persianWikiTools.wikiConvertToPersianCharacters(text); text = persianWikiTools.applyZwnj(text); text = persianWikiTools.nonStandard(text); if (mw.config.get('wgNamespaceNumber') !== 10) { text = persianWikiTools.wikiTextDigitsToPersian(text); } text = persianWikiTools.wikiDictation(text); text = persianWikiTools.wikiUrlMinifier(text); return persianWikiTools.wikiPunctuation(text); }, 'ویرایش به وسیلهٔ [[وپ:ابرابزار|ابزار خودکار ابرابزار]]' ); $(this).dialog("close"); }, 'خیر': function () { $(this).dialog("close"); } }, close: function () { $(this).remove(); } }); }); }); }); } // ابزار در حالت ویرایش /** * Adds edit summary */ function addEditSummary(summaryText, replaceSummary) { if (summaryText === '') { return; } var summary = $('.editOptions #wpSummary'), summaryPrefix = '', pos; if (summary.length === 0) { return; } if (summary.val().indexOf('*/ ') > -1) { pos = summary.val().indexOf('*/ '); summaryPrefix = summary.val().substr(0, pos + 3); } if (replaceSummary) { summary.val(summaryPrefix + summaryText); } else { if (summary.val() === summaryPrefix) { summary.val(summary.val() + summaryText); } else { if (summary.val().indexOf(summaryText) === -1) { // do not repeat in edit summary summary.val(summary.val() + '، ' + summaryText); } } } } /** * Makes a simple button from parameters */ function buttonGenerator(callback, summaryText, replaceSummary, image, title, alt, idSuffix) { function clickCallback(e) { e.preventDefault(); callback(); addEditSummary(summaryText, replaceSummary); } var button = $('<a />', { id: 'persian-wiki-tools-' + idSuffix }).click(clickCallback).append( $('<img />').attr({ src: image, title: title, alt: alt }).error(function () { button.replaceWith($('<button />').text(alt).click(clickCallback)); }) ); return button[0]; } /** * Applies the string functions defined below to the * selected text in the edit box. If no text is selected, applies * the function to the whole contents of edit box. */ function applyOnSelection(callback) { var txtarea, range, startPos, endPos, selText; if (document.getElementById('editform')) { txtarea = document.getElementById('wpTextbox1'); } else if (document.getElementById('wpNewTitleMain')) { txtarea = document.getElementById('wpNewTitleMain'); } else { return; } if (document.selection && document.selection.createRange) { // IE/Opera // get current selection txtarea.focus(); range = document.selection.createRange(); selText = range.text; if (selText) { range.text = callback(selText); range.select(); } else { txtarea.value = callback(txtarea.value); } } else if (txtarea.selectionStart || txtarea.selectionStart === 0) { // Mozilla // get current selection txtarea.focus(); startPos = txtarea.selectionStart; endPos = txtarea.selectionEnd; selText = txtarea.value.substring(startPos, endPos); // insert tags if (selText) { txtarea.value = txtarea.value.substring(0, startPos) + callback(selText) + txtarea.value.substring(endPos, txtarea.value.length); txtarea.selectionStart = startPos + selText.length; txtarea.selectionEnd = txtarea.selectionStart; } else { txtarea.value = callback(txtarea.value); } } } var tools = {}; // Buttons that FIX wikitext /* ی ک */ tools.ykArabic = buttonGenerator( function () { applyOnSelection(persianWikiTools.wikiConvertToPersianCharacters); }, 'اصلاح نویسه\u200cهای عربی', false, '//upload.wikimedia.org/wikipedia/commons/8/88/Button_YehKeh.png', 'اصلاح ی و ک', 'ی و ک', 'YehKeh' ); /* فاصلهٔ مجازی */ tools.zwnj = buttonGenerator( function () { applyOnSelection(persianWikiTools.applyZwnj); }, 'اصلاح فاصلهٔ مجازی', false, '//upload.wikimedia.org/wikipedia/fa/d/d0/Button_ZWNJ.png', 'فاصلهٔ مجازی', 'فاصلهٔ مجازی', 'ZWNJ' ); /* نویسهٔ غیراستاندارد */ tools.nonStandard = buttonGenerator( function () { applyOnSelection(persianWikiTools.nonStandard); }, 'اصلاح نویسه', false, '//upload.wikimedia.org/wikipedia/fa/9/94/Button_non_standard.png', 'نویسه\u200cهای غیراستاندارد', 'نویسه\u200cهای غیراستاندارد', 'non-standard' ); /* اصلاح ارقام */ tools.dig = buttonGenerator( function () { applyOnSelection(persianWikiTools.wikiTextDigitsToPersian); }, 'اصلاح ارقام', false, '//upload.wikimedia.org/wikipedia/fa/4/4a/Button_numbers.png', 'اصلاح ارقام', 'ارقام', 'numbers' ); /* اصلاح ارقام مخصوص صفحه انتقال */ tools.digMove = buttonGenerator( function () { applyOnSelection(persianWikiTools.convertDigitsToPersian); }, 'اصلاح ارقام', false, '//upload.wikimedia.org/wikipedia/fa/4/4a/Button_numbers.png', 'اصلاح ارقام', 'ارقام', 'numbers' ); /* یونیکد نشانی وب */ tools.urlFix = buttonGenerator( function () { applyOnSelection(persianWikiTools.wikiUrlMinifier); }, 'اصلاح نشانی وب', false, '//upload.wikimedia.org/wikipedia/fa/b/ba/Button_decode_URI.png', 'یونی\u200cکدسازی نشانی\u200cها', 'یونی\u200cکدسازی', 'decode-URI' ); /* اصلاح علامت @ */ tools.atSignFix = buttonGenerator( function () { applyOnSelection(function (text) { return text.replace(/(\S+?)@(\S+?)/g, '$1{{at}}$2'); }); }, 'اصلاح @', false, '//upload.wikimedia.org/wikipedia/fa/7/7f/Button_at_sign.png', 'اصلاح علامت @', '@', 'at-sign' ); /* ابرابزار */ tools.superTool = buttonGenerator( function () { applyOnSelection(function (text) { text = persianWikiTools.wikiConvertToPersianCharacters(text); text = persianWikiTools.applyZwnj(text); text = persianWikiTools.nonStandard(text); if (mw.config.get('wgNamespaceNumber') !== 10) { text = persianWikiTools.wikiTextDigitsToPersian(text); } text = persianWikiTools.wikiUrlMinifier(text); text = persianWikiTools.wikiDictation(text); return persianWikiTools.wikiPunctuation(text); }); }, 'ابرابزار', false, '//upload.wikimedia.org/wikipedia/fa/f/fc/Button_super_tool.png', 'ابرابزار', 'ابرابزار', 'super-tool' ); /* ابزار املا */ tools.dictation = buttonGenerator( function () { applyOnSelection(persianWikiTools.wikiDictation); }, 'اصلاح املا', false, '//upload.wikimedia.org/wikipedia/commons/a/a3/Button_Dictation-fa.png', 'املا', 'املا', 'dictation' ); /* ابرابزار مخصوص صفحه انتقال */ tools.superToolMove = buttonGenerator( function () { applyOnSelection(function (text) { text = persianWikiTools.wikiConvertToPersianCharacters(text); text = persianWikiTools.applyZwnj(text); text = persianWikiTools.nonStandard(text); text = persianWikiTools.wikiTextDigitsToPersian(text); text = persianWikiTools.wikiUrlMinifier(text); text = persianWikiTools.wikiDictation(text); return persianWikiTools.wikiPunctuation(text); }); }, 'ابرابزار', false, '//upload.wikimedia.org/wikipedia/fa/f/fc/Button_super_tool.png', 'ابرابزار', 'ابرابزار', 'super-tool' ); /* اصلاحات قراردادن نقطه */ tools.punc = buttonGenerator( function () { applyOnSelection(persianWikiTools.wikiPunctuation); }, 'اصلاح سجاوندی', false, '//upload.wikimedia.org/wikipedia/fa/e/ed/Button_punctuation.png', 'نقطه\u200cگذاری', 'نقطه\u200cگذاری', 'punctuation' ); // Buttons that add tags /* برچسب ویکی\u200cسازی */ tools.wikify = buttonGenerator( function () { $('#wpTextbox1').val('{{ویکی\u200cسازی}}\n' + $('#wpTextbox1').val()); }, 'برچسب ویکی\u200cسازی', false, '//upload.wikimedia.org/wikipedia/fa/3/38/Button_wikify.png', 'برچسب ویکی\u200cسازی', 'ویکی\u200cسازی', 'wikify' ); /* بدون منبع */ tools.noSource = buttonGenerator( function () { $('#wpTextbox1').val('{{بدون منبع}}\n' + $('#wpTextbox1').val()); }, 'برچسب منبع', false, '//upload.wikimedia.org/wikipedia/fa/8/8a/Button_no_source_fa.png', 'برچسب بدون منبع', 'بدون منبع', 'no-source' ); /* حذف سریع */ tools.speedyDel = buttonGenerator( function () { var temp = $('#wpTextbox1').val(); $('#wpTextbox1').val(''); insertTags('{{حذف سریع|', '}}\n' + temp, 'معیار'); }, 'حذف سریع', true, '//upload.wikimedia.org/wikipedia/fa/c/c1/Button_delete_vote.png', 'برچسب حذف سریع', 'حذف سریع', 'delete-vote' ); /* حذف زماندار */ tools.prod = buttonGenerator( function () { var temp = $('#wpTextbox1').val(); $('#wpTextbox1').val(''); insertTags('{{جا:حذف زمان\u200cدار|', '}}\n' + temp, 'معیار'); }, 'حذف زمان\u200cدار', true, '//upload.wikimedia.org/wikipedia/commons/3/3f/Button_attendre.png', 'برچسب حذف زمان\u200cدار', 'حذف زمان\u200cدار', 'attendre' ); /* منبع تصویر نامعلوم */ tools.picSource = buttonGenerator( function () { $('#wpTextbox1').val('{{منبع تصویر نامعلوم}}\n' + $('#wpTextbox1').val()); }, 'برچسب منبع', false, '//upload.wikimedia.org/wikipedia/fa/5/59/Button_image_source.png', 'برچسب منبع تصویر نامعلوم', 'منبع تصویر نامعلوم', 'image-source' ); /* حق تکثیر تصویر نامعلوم */ tools.picCopy = buttonGenerator( function () { $('#wpTextbox1').val('{{جا:حق تکثیر تصویر نامعلوم}}\n' + $('#wpTextbox1').val()); }, 'برچسب حق تکثیر', false, '//upload.wikimedia.org/wikipedia/fa/7/7e/Button_image_copyright.png', 'برچسب حق تکثیر تصویر نامعلوم', 'حق تکثیر تصویر نامعلوم', 'image-copyright' ); /* تمیزکاری */ tools.cleanup = buttonGenerator( function () { $('#wpTextbox1').val('{{تمیزکاری}}\n' + $('#wpTextbox1').val()); }, 'برچسب تمیزکاری', false, '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_broom.png', 'برچسب تمیزکاری', 'تمیزکاری', 'broom' ); /* اخطار نگاره */ tools.imgWarn = buttonGenerator( function () { $('#wpTextbox1').val(''); insertTags( '{{جا:اخطار نگاره|', '}}', 'نگاره' ); }, 'برچسب نگاره', false, '//upload.wikimedia.org/wikipedia/commons/e/ec/Button_aviso.png', 'اخطار نگاره', 'اخطار نگاره', 'aviso' ); /* حق تکثیر مشکوک */ tools.sus = buttonGenerator( function () { $('#wpTextbox1').val('{{حق تکثیر مشکوک}}\n' + $('#wpTextbox1').val()); }, 'برچسب حق تکثیر', false, '//upload.wikimedia.org/wikipedia/fa/c/c7/Button_Sus.png', 'برچسب حق تکثیر مشکوک', 'حق تکثیر مشکوک', 'sus' ); /* نقض حق تکثیر */ tools.copyR = buttonGenerator( function () { $('#wpTextbox1').val(''); insertTags( '{{جا:نقض حق تکثیر|url=', '}}', 'نشانی ایرنتنتی' ); }, 'برچسب حق تکثیر', false, '//upload.wikimedia.org/wikipedia/fa/6/6f/Button_CopyR.png', 'برچسب نقض حق تکثیر', 'نقض حق تکثیر', 'copyr' ); /* لحن نامناسب */ tools.tone = buttonGenerator( function () { $('#wpTextbox1').val('{{لحن نامناسب}}\n' + $('#wpTextbox1').val()); }, 'برچسب لحن', false, '//upload.wikimedia.org/wikipedia/fa/f/fc/Button_Tone.png', 'برچسب لحن نامناسب', 'لحن', 'tone' ); // Buttons that help with wiki writing /* تغییر جهت */ tools.toggleDirection = buttonGenerator( function () { $('#wpTextbox1, #wpNewTitleMain').css({ 'text-align': 'start', 'direction': $('#wpTextbox1, #wpNewTitleMain').css('direction') === 'rtl' ? 'ltr' : 'rtl' }); }, '', true, '//upload.wikimedia.org/wikipedia/fa/d/d0/Button_toggle_dir.png', 'تغییر جهت جعبهٔ ویرایش', 'تغییرجهت', 'toggle-dir' ); /* پیوند درونی */ tools.wikiLink = buttonGenerator( function () { insertTags('[[', ']]', 'مقاله'); }, '', true, '//upload.wikimedia.org/wikipedia/fa/d/d0/Button_in_wikify.png', 'پیوند', 'پیوند', 'wikify' ); /* متن خطخورده */ tools.strikeTextButton = buttonGenerator( function () { insertTags('<s>', '</s>', 'متن خط خورده'); }, '', true, '//upload.wikimedia.org/wikipedia/commons/c/c9/Button_strike.png', 'متن خط\u200cخورده', 'متن خط\u200cخورده', 'strike' ); /* توضیح */ tools.commentButton = buttonGenerator( function () { insertTags('<!--', '-->', 'توضیح'); }, '', true, '//upload.wikimedia.org/wikipedia/commons/3/34/Button_hide_comment.png', 'توضیح', 'توضیح', 'hide-comment' ); /* ملزومات مقاله */ tools.addEssentialThings = buttonGenerator( function () { insertTags('== جستارهای وابسته ==\n\n== منابع ==\n{{پانویس}}', '', ''); }, '', true, '//upload.wikimedia.org/wikipedia/commons/e/ef/Add_note.jpg', 'ملزومات مقاله', 'ملزومات مقاله', 'add-note' ); /* خوشامدید */ tools.welcome = buttonGenerator( function () { insertTags( '{{جا:خوشامدید|~~~~}}', '', '' ); }, 'خوشامدگویی', true, '//upload.wikimedia.org/wikipedia/commons/4/4a/Smilies_Alien_cool.png', 'خوشامدگویی', 'خوشامد', 'alien-cool' ); /* چپچین */ tools.chapChin = buttonGenerator( function () { insertTags( '{{چپ\u200cچین}}\n', '\n{{پایان چپ\u200cچین}}', 'متن چپ\u200cچین\u200cشده' ); }, '', true, '//upload.wikimedia.org/wikipedia/en/e/ea/Button_align_left.png', 'چپ\u200cچین\u200cکردن متن', 'چپ\u200cچین', 'align-left' ); /* اندیس بالا */ tools.upperText = buttonGenerator( function () { insertTags('<sup>', '</sup>', 'اندیس'); }, '', true, '//upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png', 'اندیس بالا', 'اندیس بالا', 'upper-letter' ); /* اندیس پایین */ tools.lowerText = buttonGenerator( function () { insertTags('<sub>', '</sub>', 'اندیس'); }, '', true, '//upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png', 'اندیس پایین', 'اندیس پایین', 'lower-letter' ); /* تغییرمسیر */ tools.redirectButton = buttonGenerator( function () { $('#wpTextbox1').val(''); insertTags( '#تغییرمسیر [[', ']]', 'پیوند' ); }, '', true, '//upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png', 'تغییرمسیر', 'تغییرمسیر', 'redirect' ); /* سال میلادی */ tools.gregYear = buttonGenerator( function () { insertTags( '[[', ' (میلادی)|]]', 'سال' ); }, '', true, '//upload.wikimedia.org/wikipedia/fa/a/a7/Button_cal.png', 'سال میلادی', 'میلادی', 'cal' ); /* مرتبسازی */ tools.sortText = buttonGenerator( function () { applyOnSelection(persianWikiTools.persianSortText); }, '', true, '//upload.wikimedia.org/wikipedia/fa/3/33/Button_sort.png', 'مرتب\u200cسازی بر اساس الفبا', 'مرتب\u200cسازی', 'sort' ); /* شد! */ tools.shod = buttonGenerator( function () { $('#wpTextbox1').val($('#wpTextbox1').val() + '\n:{{شد}} ~~~~'); }, 'شد', true, '//upload.wikimedia.org/wikipedia/commons/5/5b/Button_check.png', 'شد', 'شد', 'check' ); $(function () { var extraEditButtons = [], extraMoveButtons = [], space = ' '; extraEditButtons = extraEditButtons.concat(tools.toggleDirection, space, tools.ykArabic, tools.zwnj, tools.nonStandard, tools.dig, tools.punc, tools.dictation, tools.superTool, 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); extraEditButtons = extraEditButtons.concat(space).concat(window.userCustomEditButtons || []); extraMoveButtons = extraMoveButtons.concat(tools.superToolMove, space, tools.toggleDirection, space, tools.ykArabic, tools.zwnj, tools.nonStandard, tools.digMove, tools.punc, space, tools.dictation); if ($('#wpTextbox1').length !== 0) { $('<div id="persian-wiki-tools" />').append(extraEditButtons).insertBefore('#wpTextbox1'); } if ($('#movepage').length !== 0) { $('<span id="persian-wiki-tools" />').append(extraMoveButtons).insertAfter('#wpNewTitleMain'); } }); }(jQuery, mediaWiki));