|
|
خط ۱: |
خط ۱: |
| // <nowiki> // DON'T REMOVE THIS LINE EVER
| | {{#invoke:Distinguish|distinguish}}<noinclude><!-- splitting these lines causes {{Documentation}} template to terminate green shading when Distinguish is used in /doc pages. --> |
| /*global jQuery, mediaWiki, persianWikiTools, persianTools*/
| | {{Documentation}} |
| /**
| | <!-- Add categories to the /doc subpage and interwikis to Wikidata, not here! --> |
| * UI code for Persian tools
| | </noinclude> |
| * Tests: [[مدیاویکی:Gadget-Extra-Editbuttons-tests.js]] [[وپ:تست]]
| |
| * See also:
| |
| * * [[مدیاویکی:Gadget-Extra-Editbuttons-persiantools.js]]
| |
| * * [[مدیاویکی:Gadget-Extra-Editbuttons-persianwikitools.js]]
| |
| * * [[مدیاویکی:Gadget-Extra-Editbuttons-dictionary.js]]
| |
| * * [[مدیاویکی:Gadget-Extra-Editbuttons-autoed.js]]
| |
| * * [[مدیاویکی:Gadget-Extra-Editbuttons-botworks.js]]
| |
| */
| |
| (function ($, mw) {
| |
| 'use strict';
| |
| | |
| // ابزار در حالت نمایش
| |
| /**
| |
| * Fetch a page
| |
| */
| |
| function loadPage(title) {
| |
| return new mw.Api().get({
| |
| action: 'query',
| |
| prop: 'revisions',
| |
| titles: title,
| |
| rvprop: 'content',
| |
| format: 'json'
| |
| }).then(function (data) {
| |
| return data.query.pages[Object.keys(data.query.pages)[0]].revisions[0]['*'];
| |
| });
| |
| }
| |
| | |
| function insertTags ( pre, post, peri ) {
| |
| var current = $( '#wpTextbox1' );
| |
| if ( current && current.length ) {
| |
| current.textSelection(
| |
| 'encapsulateSelection', { pre: pre, peri: peri, post: post }
| |
| );
| |
| }
| |
| }
| |
| | |
| /**
| |
| * Save a page
| |
| */
| |
| function savePage(title, text, summary) {
| |
| return new mw.Api().post({
| |
| action: 'edit',
| |
| title: title,
| |
| text: text,
| |
| summary: summary,
| |
| nocreate: '',
| |
| minor: '',
| |
| token: mw.user.tokens.get('editToken')
| |
| });
| |
| }
| |
| | |
| if (mw.config.get('wgAction') === 'view' &&
| |
| mw.config.get('wgIsArticle') &&
| |
| mw.config.get('wgPageName') !== 'صفحهٔ_اصلی') {
| |
| $('#ca-abar-abzar').remove();
| |
| if ($('#mw-imagepage-nofile, #noarticletext').length !== 0 ||
| |
| mw.config.get('wgNamespaceNumber') === 6 ||
| |
| mw.config.get('wgNamespaceNumber') === 8) {
| |
| return;
| |
| }
| |
| var interwikiFix = false;
| |
| if (!$('#t-wikibase').length && $('.interlanguage-link').length && $('.wbc-editpage').length) {
| |
| interwikiFix = true;
| |
| }
| |
| $(mw.util.addPortletLink('p-views', '#', interwikiFix ? 'ابرابزار+انتقال میانویکی' : 'ابرابزار', 'ca-abar-abzar', interwikiFix ? 'ابزار پیشرفتهٔ ویرایش متن + ابزار انتقال خودکار میانویکی سنتی به ویکیداده' : 'ابزار پیشرفتهٔ ویرایش متن')).click(function (e) {
| |
| e.preventDefault();
| |
| mw.loader.using('oojs-ui').then(function () {
| |
| OO.ui.confirm('اجرای ابرابزار بر این صفحه؟ مسئولیت ویرایش ابرابزار با شما خواهد بود').then(function (confirmed) {
| |
| if (!confirmed) return;
| |
|
| |
| return loadPage(mw.config.get('wgPageName')).then(function (text) {
| |
| return savePage(
| |
| mw.config.get('wgPageName'),
| |
| persianWikiTools.superTool(text),
| |
| 'ویرایش بهوسیلهٔ [[' + (mw.config.get('wgServerName') !== 'fa.wikipedia.org' ? ':w:fa:' : '') + 'وپ:ابرابزار|ابرابزار]]: '
| |
| );
| |
| }).then(function (data) {
| |
| mw.notify('اجرای ابرابزار بر محتویات این صفحه…');
| |
| // افزودن میانویکی سنتی به ویکیداده به صورت خودکار
| |
| if (interwikiFix) {
| |
| $.get('//tools.wmflabs.org/dexbot/interwikidata.php', { page: mw.config.get('wgPageName') })
| |
| .then(function () {}, function () {});
| |
| }
| |
| // اجرای کدهای ربات
| |
| botworks.trigFillcat();
| |
| botworks.trigMissedFileUpload();
| |
| botworks.trigMissedRef();
| |
| if (data.error) {
| |
| mw.notify('ویرایش موفقیتآمیز نبود، دوباره تلاش کنید: ' + data.error.info);
| |
| } else if (data.edit && data.edit.result === 'Success') {
| |
| if (data.edit.nochange !== undefined) {
| |
| mw.notify('تغییری در صفحه ایجاد نشد.');
| |
| } else {
| |
| mw.notify('ویرایش با موفقیت انجام پذیرفت');
| |
| // Loading diff page
| |
| window.location = new mw.Uri(mw.config.get('wgScript')).extend({
| |
| title: mw.config.get('wgPageName'),
| |
| diff: data.edit.newrevid
| |
| });
| |
| }
| |
| } else {
| |
| mw.notify('ویرایش در صفحه موفقیتآمیز نبود.');
| |
| }
| |
| });
| |
| });
| |
| });
| |
| });
| |
| }
| |
| | |
| // ابزار در حالت ویرایش
| |
| /**
| |
| * Adds edit summary
| |
| */
| |
| function addEditSummary(summaryText, replaceSummary) {
| |
| if (mw.util.getParamValue("section")==='new'){
| |
| return;
| |
| }
| |
| if (summaryText === '') {
| |
| return;
| |
| }
| |
| var summary = $('input#wpSummary, #wpSummary > input'),
| |
| 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 img = $('<img>').on('error', function () {
| |
| img.replaceWith($('<span>', {
| |
| class: 'mw-ui-button mw-ui-small mw-ui-constructive',
| |
| text: alt,
| |
| style: 'padding: 0;'
| |
| }));
| |
| }).attr({
| |
| src: image,
| |
| title: title,
| |
| alt: alt
| |
| });
| |
| var button = $('<span>', {
| |
| id: 'persian-wiki-tools-' + idSuffix
| |
| }).click(clickCallback).append(img);
| |
| 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') || $('.ns-446').length) {
| |
| txtarea = document.getElementById('wpTextbox1');
| |
| } else if ($('[name=wpNewTitleMain]')[0]) {
| |
| txtarea = $('[name=wpNewTitleMain]')[0];
| |
| } 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(persianTools.toStandardPersianCharacters);
| |
| },
| |
| 'اصلاح نویسه\u200cهای عربی',
| |
| false,
| |
| '//upload.wikimedia.org/wikipedia/commons/8/88/Button_YehKeh.png',
| |
| 'اصلاح ی و ک',
| |
| 'ی و ک',
| |
| 'YehKeh'
| |
| );
| |
| | |
| /* فاصلهٔ مجازی */
| |
| tools.zwnj = buttonGenerator(
| |
| function () {
| |
| applyOnSelection(persianWikiTools.wikiApplyZwnj);
| |
| },
| |
| 'اصلاح فاصلهٔ مجازی',
| |
| false,
| |
| '//upload.wikimedia.org/wikipedia/fa/d/d0/Button_ZWNJ.png',
| |
| 'فاصلهٔ مجازی',
| |
| 'فاصلهٔ مجازی',
| |
| 'ZWNJ'
| |
| );
| |
| | |
| /* اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد */
| |
| tools.applyOrthography = buttonGenerator(
| |
| function () {
| |
| applyOnSelection(persianWikiTools.wikiApplyOrthography);
| |
| },
| |
| 'اصلاح نویسه',
| |
| false,
| |
| '//upload.wikimedia.org/wikipedia/fa/9/94/Button_non_standard.png',
| |
| 'اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد',
| |
| 'اصلاح نویسه\u200cها و حالت\u200cهای غیراستاندارد',
| |
| 'apply-orthography'
| |
| );
| |
| | |
| /* اصلاح ارقام */
| |
| 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.wikiConvertToPersianCharacters);
| |
| },
| |
| 'اصلاح ارقام',
| |
| false,
| |
| '//upload.wikimedia.org/wikipedia/fa/4/4a/Button_numbers.png',
| |
| 'اصلاح ارقام',
| |
| 'ارقام',
| |
| 'numbers'
| |
| );
| |
|
| |
| //عدم تغییر در متن بحثها، سیاستها در فضاهای نام دیگر
| |
| if (mw.config.get('wgNamespaceNumber') === 0) {
| |
| /* برداشتن پیوند تاریخها */
| |
| tools.fixBadLinks = buttonGenerator(
| |
| function () {
| |
| applyOnSelection(persianWikiTools.fixBadLinks);
| |
| },
| |
| '[[وپ:پیوند سال|حذف پیوند تاریخها]]',
| |
| false,
| |
| '//upload.wikimedia.org/wikipedia/commons/1/11/Btn_toolbar_link_remove.png',
| |
| 'حذف پیوند تاریخها',
| |
| 'پیوند تاریخها',
| |
| 'datelinks'
| |
| );
| |
| }
| |
| | |
| /* یونیکد نشانی وب */
| |
| 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(persianWikiTools.superTool);
| |
| },
| |
| 'ابرابزار',
| |
| 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(persianWikiTools.superToolMove);
| |
| },
| |
| 'ابرابزار',
| |
| 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/commons/1/13/Button_delete.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, [name=wpNewTitleMain], .ace_editor').css({
| |
| 'text-align': 'start',
| |
| 'direction': $('#wpTextbox1, [name=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/commons/e/ea/Button_align_left.png',
| |
| 'چپ\u200cچین\u200cکردن متن',
| |
| 'چپ\u200cچین',
| |
| 'align-left'
| |
| );
| |
| | |
| /* اندیس بالا */
| |
| tools.upperText = buttonGenerator(
| |
| function () {
| |
| insertTags('<sup>', '</sup>', 'اندیس');
| |
| },
| |
| '',
| |
| true,
| |
| '//upload.wikimedia.org/wikipedia/commons/6/6a/Button_sup_letter.png',
| |
| 'اندیس بالا',
| |
| 'اندیس بالا',
| |
| 'upper-letter'
| |
| );
| |
| | |
| /* اندیس پایین */
| |
| tools.lowerText = buttonGenerator(
| |
| function () {
| |
| insertTags('<sub>', '</sub>', 'اندیس');
| |
| },
| |
| '',
| |
| true,
| |
| '//upload.wikimedia.org/wikipedia/commons/a/aa/Button_sub_letter.png',
| |
| 'اندیس پایین',
| |
| 'اندیس پایین',
| |
| 'lower-letter'
| |
| );
| |
| | |
| /* تغییرمسیر */
| |
| tools.redirectButton = buttonGenerator(
| |
| function () {
| |
| $('#wpTextbox1').val('');
| |
| insertTags(
| |
| '#تغییرمسیر [[',
| |
| ']]',
| |
| 'پیوند'
| |
| );
| |
| },
| |
| '',
| |
| true,
| |
| '//upload.wikimedia.org/wikipedia/commons/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(persianTools.persianSortText);
| |
| },
| |
| '',
| |
| true,
| |
| '//upload.wikimedia.org/wikipedia/fa/3/33/Button_sort.png',
| |
| 'مرتب\u200cسازی بر اساس الفبا',
| |
| 'مرتب\u200cسازی',
| |
| 'sort'
| |
| );
| |
| | |
| /* شد! */
| |
| tools.shod = buttonGenerator(
| |
| function () {
| |
| $('#wpTextbox1').val($('#wpTextbox1').val().trimRight() + '\n:{' + '{شد}} ~~' + '~~');
| |
| },
| |
| 'شد',
| |
| true,
| |
| '//upload.wikimedia.org/wikipedia/commons/5/5b/Button_check.png',
| |
| 'شد',
| |
| 'شد',
| |
| 'check'
| |
| );
| |
| /* عدد انگلیسی */
| |
| tools.toEnNumRobust = buttonGenerator(
| |
| function () {
| |
| applyOnSelection(persianWikiTools.robustToEnglishDigits);
| |
| },
| |
| 'عدد انگلیسی',
| |
| false,
| |
| '//upload.wikimedia.org/wikipedia/commons/f/f5/Button_enNum.png',
| |
| 'عدد انگلیسی',
| |
| 'عدد انگلیسی',
| |
| 'ToEnNumberRobust'
| |
| );
| |
| /* حذف ویکیسازی */
| |
| tools.removeWiki = buttonGenerator(
| |
| function () {
| |
| applyOnSelection(persianWikiTools.removeWikiSigne);
| |
| },
| |
| 'حذف ویکیسازی',
| |
| false,
| |
| '//upload.wikimedia.org/wikipedia/fa/8/88/Button_NoWiki.png',
| |
| 'حذف ویکیسازی',
| |
| 'حذف ویکیسازی',
| |
| 'removeWiki'
| |
| );
| |
| $(function () {
| |
| // کد مناسب ویرایشگر جدید متنی
| |
| /*mw.hook('ve.activationComplete').add(function () {
| |
| var surface = ve.init.target.getSurface();
| |
| if (surface.getMode() === 'source') {
| |
| $('#firstHeading').append($('<img>', { src: '//upload.wikimedia.org/wikipedia/fa/f/fc/Button_super_tool.png' }).click(function () {
| |
| $('.ve-ce-contentBranchNode').get().forEach(function (x) {
| |
| x.innerText = persianWikiTools.superTool(x.innerText);
| |
| });
| |
| }));
| |
| }
| |
| });*/
| |
| | |
| var extraEditButtons = [],
| |
| extraMoveButtons = [],
| |
| space = ' ';
| |
| | |
| extraEditButtons = extraEditButtons.concat(tools.toggleDirection, space, tools.ykArabic, tools.zwnj, tools.applyOrthography,
| |
| tools.dig, tools.punc, tools.dictation, tools.superTool, space, tools.urlFix, tools.fixBadLinks, 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, space, tools.picCopy, tools.picSource, space, tools.toEnNumRobust);
| |
| // شرط برای کاربری که گشت خودکار دارد
| |
| // ابزار حذف الگوهای ناموجود
| |
| if ((mw.config.get('wgUserGroups').indexOf('autopatrolled') > -1 ||mw.config.get('wgUserGroups').indexOf('eliminator') > -1 ||mw.config.get('wgUserGroups').indexOf('sysop') > -1)) {
| |
| extraEditButtons = extraEditButtons.concat(tools.removeWiki);
| |
| };
| |
| extraEditButtons = extraEditButtons.concat(space).concat(window.userCustomEditButtons || []);
| |
| | |
| extraMoveButtons = extraMoveButtons.concat(tools.superToolMove, space, tools.toggleDirection, space,
| |
| tools.ykArabic, tools.zwnj, tools.applyOrthography, tools.digMove, tools.punc, space, tools.dictation);
| |
| | |
| $('#persian-wiki-tools').remove();
| |
| if ($('#wpTextbox1').length !== 0) {
| |
| $('<div>', {
| |
| id: 'persian-wiki-tools',
| |
| dir: 'rtl',
| |
| style: 'float:right;'
| |
| }).append(extraEditButtons).insertBefore('#wpTextbox1');
| |
| }
| |
| if ($('#movepage').length !== 0) {
| |
| $('<span>', {
| |
| id: 'persian-wiki-tools'
| |
| }).append(extraMoveButtons).insertAfter('#wpNewTitle');
| |
| }
| |
| });
| |
| }(jQuery, mediaWiki));
| |