مدیاویکی:Gadget-UserMessages.js

ویکی‌پدیادان، آچیق بیلیک‌لیک‌دن

' 'قئید:' یازدیق‌دان سونرا دییشیک‌لیک‌لری گؤرمک اوچون براوزئرینیزین کئش یادداشیندا تمیزلمه‌نیز لازیم اولا بیلر.

  • 'فایرفاکس / سافاری:Shift دویمه‌سینه باسین "یئنی‌دن یوکله"-ا داخیل اولون یا دا Ctrl-F5 یا Ctrl-R ائدین (ماج اوچون ⌘-R).
  • 'گووگل کروم:'Ctrl+Shift+R باسین. (ماج اوچون ⌘-Shift-R)
  • 'اینترنت ایکسپئلور: کلید Ctrl باسین یئنی‌لئ 'یئ داخیل اولون یا دا Ctrl-F5 ائدین.
  • 'اوپئرا:' آلت‌لری → سئچیملر 'دن اؤنبئللیغی Tools → Preferences تمیزلیین.
/**
 * This gadget is a substantial rewrite of the UserMessages gadget, influenced by
 * [[n:en:MediaWiki:Gadget-UserMessages.js]] and [[n:MediaWiki:Gadget-UserMessages.js]]
 * 
 * Unlike the previous versions, this uses OOUI and can accept one or more
 * parameters for the messages that are being posted on the user's talk page.
 */

(function($, mw) {
  'use strict';
  var windowManager;
  var UM;
  var UMOptions = {
    install: function() {
      if (mw.config.get('wgAction') === 'view' | (mw.config.get('wgAction') === 'edit' & mw.config.get('wgCurRevisionId') === 0)) {
        $(mw.util.addPortletLink( 'p-cactions', '#', 'بیلدیری', 'ca-warn', 'درج یک اعلان مبتنی بر الگو', '*')).click(function(e) {
          mw.loader.using(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.api']).done(UMOptions.createWindow);
          e.preventDefault();
        });
        // Late pre-loading
        mw.loader.load(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.api']);
      }
    },
    createWindow: function() {
      function PreviewPanel(config) {
        PreviewPanel.parent.call(this, config);
        
        this.$content = $('<div>').addClass('oo-ui-PreviewPanel');
      }
      OO.inheritClass(PreviewPanel, OO.ui.PanelLayout);
      PreviewPanel.prototype.setContent = function ($content) {
        this.$element.children().detach();
        this.$element.append($content);
        windowManager.getCurrentWindow().updateSize();
      };
      function UserMessages(config) {
        UserMessages.super.call(this, config);
      }
      OO.inheritClass(UserMessages, OO.ui.ProcessDialog);
      UserMessages.static.name = 'Warn dialog';
      UserMessages.static.title = 'بیلدیری (پیام یوخسا تذکور) یازدیر';
      UserMessages.static.actions = [
        {
          action: 'warn',
          label: 'یازدیر',
          flags: ['primary', 'progressive']
        },
        {
          action: 'diff',
          label: 'فرقلری گؤستر',
          flags: 'safe'
        },
        {
          label: 'وازگئچ',
          flags: 'safe'
        }
      ];
      UserMessages.prototype.initialize = function() {
        var dialog = this;
        UserMessages.super.prototype.initialize.apply(this, arguments);
        
        this.buttons = [];
        this.buttons.Groups = [];
        this.buttons.Noobs = [];
        this.buttons.Warnings = [];
        this.buttons.Tools = [];
        this.buttons.Article = [];
        this.buttons.Copyright = [];
        this.buttons.Advanced = [];
        this.buttons.Spam = [];
        this.buttons.Block = [];
        this.buttons.Rights = [];

        this.buttons.Groups.Noobs = new OO.ui.ButtonOptionWidget({
          label: 'یئنی‌گلنلر',
          data: {
            group: 'Noobs'
          }
        });
        this.buttons.Groups.Warnings = new OO.ui.ButtonOptionWidget({
          label: 'تذکورلر',
          data: {
            group: 'Warnings'
          }
        });
        this.buttons.Groups.Tools = new OO.ui.ButtonOptionWidget({
          label: 'آلتلر',
          data: {
            group: 'Tools'
          }
        });
        this.buttons.Groups.Article = new OO.ui.ButtonOptionWidget({
          label: 'مقاله',
          data: {
            group: 'Article'
          }
        });
        this.buttons.Groups.Copyright = new OO.ui.ButtonOptionWidget({
          label: 'کوپی‌رایت',
          data: {
            group: 'Copyright'
          }
        });
        this.buttons.Groups.Advanced = new OO.ui.ButtonOptionWidget({
          label: 'آرتیق',
          data: {
            group: 'Advanced'
          }
        });
        this.buttons.Groups.Spam = new OO.ui.ButtonOptionWidget({
          label: 'ایسپم',
          data: {
            group: 'Spam'
          }
        });
        this.buttons.Groups.Block = new OO.ui.ButtonOptionWidget({
          label: 'باغلاما',
          data: {
            group: 'Block'
          }
        });
        this.buttons.Groups.Rights = new OO.ui.ButtonOptionWidget({
          label: 'ایشلدن حاقلاری',
          data: {
            group: 'Rights'
          }
        });

        this.buttonSelectGroups = new OO.ui.ButtonSelectWidget({
          items: [
            this.buttons.Groups.Noobs,
            this.buttons.Groups.Warnings,
            this.buttons.Groups.Tools,
            this.buttons.Groups.Article,
            this.buttons.Groups.Copyright,
            this.buttons.Groups.Advanced,
            this.buttons.Groups.Spam
          ]
        });
        if ($(mw.config.get('wgUserGroups')).filter(['eliminator', 'sysop']).length > 0) {
          this.buttonSelectGroups.addItems([
            this.buttons.Groups.Block
          ]);
        }
        if ($(mw.config.get( 'wgUserGroups' )).filter(['sysop']).length > 0) {
          this.buttonSelectGroups.addItems([
            this.buttons.Groups.Rights
          ]);
        }
        this.buttonSelectGroups.selectItem(this.buttons.Groups.Noobs);
        this.buttonSelectGroups.on('choose', function(item) {
          dialog.buttonSelectChoices = new OO.ui.ButtonSelectWidget({
            items: dialog.buttonSelectChoicesItems[item.data.group]
          });
          dialog.buttonSelectChoices.selectItem();
          dialog.panelChoices.$element.children().detach();
          dialog.panelChoices.$element.append(dialog.buttonSelectChoices.$element);
          dialog.setChooseAction();
          dialog.panelParams.toggle(false);
          dialog.previewResult.toggle(false);
          windowManager.getCurrentWindow().updateSize();
        });

        this.buttons.Noobs.WelcomeUser = new OO.ui.ButtonOptionWidget({
          label: 'خوش گلدینیز (ایشلدن)',
          data: {
            template: 'خوش گلدینیز',
            params: [
              {
                id: '1',
                label: 'آرتیقراق پیام (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.WelcomeIP = new OO.ui.ButtonOptionWidget({
          label: 'خوش گلدینیز (آی‌پی)',
          data: {
            template: 'خوش گلدینیز-آی‌پی'
          }
        });
        this.buttons.Noobs.Sign = new OO.ui.ButtonOptionWidget({
          label: 'ایمضالایین',
          data: {
            template: 'ایمضالایین',
            params: [
              {
                id: '1',
                label: 'آرتیقراق پیام (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.DoNotSign = new OO.ui.ButtonOptionWidget({
          label: 'ایمضالامایین',
          data: {
            template: 'ایمضالامایین',
            params: [
              {
                id: '1',
                label: 'مقاله آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.Ping = new OO.ui.ButtonOptionWidget({
          label: 'آذب‌ویکیده فایل یۆکله‌مک (اینصافلی)',
          data: {
            template: 'آذب‌ویکی‌ ده فایل یۆکله‌مک کؤمگی'
          }
        });
        this.buttons.Noobs.UploadGuide = new OO.ui.ButtonOptionWidget({
          label: 'ویکی‌آنباردا فایل یۆکله‌مک (آچیق)',
          data: {
            template: 'ویکی‌آنباردا فایل یۆکله‌مک کؤمگی'
          }
        });
        this.buttons.Noobs.CommonsGuide = new OO.ui.ButtonOptionWidget({
          label: 'تۆرکجه کیبورد',
          data: {
            template: 'تورکجه کیبورددان فایدالانین'
          }
        });
        this.buttons.Noobs.Keyboard = new OO.ui.ButtonOptionWidget({
          label: 'اؤن‌گؤستریش',
          data: {
            template: 'اؤن‌گؤستریشدن فایدالانین'
          }
        });
        this.buttons.Noobs.Preview = new OO.ui.ButtonOptionWidget({
          label: 'دییشدیرمه قیساسی',
          data: {
            template: 'دییشدیرمه قیساسی یازین',
          }
        });
        this.buttons.Noobs.SisterProjects = new OO.ui.ButtonOptionWidget({
          label: 'قارداش ویکیلر',
          data: {
            template: 'قارداش ویکی‌لرده دییشدیرمه',
            params: [
              {
                id: '1',
                label: 'قارداش ویکی‌ آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Noobs.EditSummary = new OO.ui.ButtonOptionWidget({
          label: 'خلاصه ویرایش',
          data: {
            template: 'تذکر خلاصه ویرایش'
          }
        });
        this.buttons.Noobs.Sandbox = new OO.ui.ButtonOptionWidget({
          label: 'قارالاما دفتری',
          data: {
            template: 'قارالاما دفتری'
          }
        });
        this.buttons.Noobs.FakeArticle = new OO.ui.ButtonOptionWidget({
          label: 'مقاله‌یه بنزر ایشلدن صفحه‌سی',
          data: {
            template: 'مقاله‌یه بنزر تذکوری',
            params: [
              {
                id: '1',
                label: 'صفحه آدی (ایختیاری)'
              }
            ]
          }
        });
		this.buttons.Noobs.SeggestedLinks = new OO.ui.ButtonOptionWidget({
          label: 'اؤنریلن باغلانتیلار',
          data: {
            template: 'اؤنریلن باغلانتیلار کؤمگی',
            params: [
              {
                id: '1',
                label: 'صفحه آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.Vandalism = new OO.ui.ButtonOptionWidget({
          label: 'واندالیزم تذکورو',
          data: {
            template: 'واندالیزم تذکورو۱'
          }
        });
        this.buttons.Warnings.VandalismFinal = new OO.ui.ButtonOptionWidget({
          label: 'سون واندالیزم تذکورو',
          data: {
            template: 'واندالیزم تذکورو۲'
          }
        });
        this.buttons.Warnings.Disruption = new OO.ui.ButtonOptionWidget({
          label: 'ایخلالچیلیق تذکورو',
          data: {
            template: 'ایخلالچیلیق دییشدیرمه تذکورو',
            params: [
              {
                id: '1',
                label: 'صفحه آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Warnings.Responsiveness = new OO.ui.ButtonOptionWidget({
          label: 'دانیشیقلارا جواب وئرمک تذکورو',
          data: {
            template: 'دانیشیقلارا جواب وئرین'
          }
        });
        this.buttons.Warnings.SockPupptery = new OO.ui.ButtonOptionWidget({
          label: 'یدک حساب تذکورو',
          data: {
            template: 'یدک حساب تذکورو'
          }
        });
        this.buttons.Tools.VE = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر دیداری',
          data: {
            template: 'کار با ویرایشگر دیداری'
          }
        });
        this.buttons.Tools.ToWikifa = new OO.ui.ButtonOptionWidget({
          label: 'به ویکی‌فا',
          data: {
            template: 'به ویکی‌فا'
          }
        });
        this.buttons.Tools.Translator = new OO.ui.ButtonOptionWidget({
          label: 'کمک‌مترجم',
          data: {
            template: 'ابزار کمک‌مترجم'
          }
        });
        this.buttons.Tools.ExtraEditTools = new OO.ui.ButtonOptionWidget({
          label: 'ابزارهای ویرایشی',
          data: {
            template: 'ابزارهای ویرایشی'
          }
        });
        this.buttons.Tools.Abar = new OO.ui.ButtonOptionWidget({
          label: 'ابرابزار',
          data: {
            template: 'ابرابزار'
          }
        });
        this.buttons.Tools.Applications = new OO.ui.ButtonOptionWidget({
          label: 'ابزارهای کاربردی',
          data: {
            template: 'ابزارهای کاربردی'
          }
        });
        this.buttons.Tools.ProveIt = new OO.ui.ButtonOptionWidget({
          label: 'ابزار اثباتش کن',
          data: {
            template: 'اثباتش کن'
          }
        });
        this.buttons.Tools.AWD = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر خودکار',
          data: {
            template: 'ویرایشگر خودکار'
          }
        });
        this.buttons.Tools.Patrol = new OO.ui.ButtonOptionWidget({
          label: 'ابزار گشت سریع',
          data: {
            template: 'ابزار گشت‌زنی سریع'
          }
        });
        this.buttons.Tools.CheckDictation = new OO.ui.ButtonOptionWidget({
          label: 'اشتباه‌یاب',
          data: {
            template: 'ابزار اشتباه‌یاب'
          }
        });

        this.buttons.Article.Featured = new OO.ui.ButtonOptionWidget({
          label: 'برگزیده/خوبیده',
          data: {
            template: 'تذکر محتوای برگزیده'
          }
        });
        this.buttons.Article.Tutorial = new OO.ui.ButtonOptionWidget({
          label: 'ویکی‌یازما اؤیرتیمی',
          data: {
            template: 'ویکی‌یازما'
          }
        });
        this.buttons.Article.Student = new OO.ui.ButtonOptionWidget({
          label: 'ویرایش دانشجویی',
          data: {
            template: 'ویرایش دانشجویی'
          }
        });
        this.buttons.Article.Incomplete = new OO.ui.ButtonOptionWidget({
          label: 'نوشتار نامناسب',
          data: {
            template: 'نوشتار نامناسب',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.TooShort = new OO.ui.ButtonOptionWidget({
          label: 'زیادی کوتاه',
          data: {
            template: 'بیش از حد کوتاه',
            params: [
              {
                id: '1',
                label: 'مقاله آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.Minima = new OO.ui.ButtonOptionWidget({
          label: 'حداقل‌ها',
          data: {
            template: 'حداقل‌های مقاله'
          }
        });
        this.buttons.Article.Deleted = new OO.ui.ButtonOptionWidget({
          label: 'سیلینمیش',
          data: {
            template: 'سیلینمیش مقاله',
            params: [
              {
                id: '1',
                label: 'آرتیقراق پیام (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.Redirect = new OO.ui.ButtonOptionWidget({
          label: 'یوللاندیرما',
          data: {
            template: 'یوللاندیرمادان فایدالانین'
          }
        });
        this.buttons.Article.Move = new OO.ui.ButtonOptionWidget({
          label: 'داشیما',
          data: {
            template: 'داشیماقدان فایدالانین'
          }
        });
        this.buttons.Article.Titles = new OO.ui.ButtonOptionWidget({
          label: 'ممنوع لقبلر',
          data: {
            template: 'ممنوع لقبلر تذکورو'
          }
        });
        this.buttons.Article.Spoiler = new OO.ui.ButtonOptionWidget({
          label: 'مخدوش‌کردن داستان فیلم',
          data: {
            template: 'خلاصه داستان را مخدوش نکنید'
          }
        });
        this.buttons.Article.MachineTranslation = new OO.ui.ButtonOptionWidget({
          label: 'اوتوماتیک چئویرمه',
          data: {
            template: 'اوتوماتیک چئویرمه ممنوع',
            params: [
              {
                id: '1',
                label: 'صفحه آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Article.NoFlag = new OO.ui.ButtonOptionWidget({
          label: 'بایراقدان فایدالانمایین',
          data: {
            template: 'بایراقدان فایدالانمایین'
          }
        });
        this.buttons.Copyright.DoNotCopy = new OO.ui.ButtonOptionWidget({
          label: 'کوپی ائتمه‌یین',
          data: {
            template: 'کوپی ائتمه‌یین',
            params: [
              {
                id: '1',
                label: 'مقاله آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Copyright.UseCitation = new OO.ui.ButtonOptionWidget({
          label: 'یادکرد دقیق',
          data: {
            template: 'یادکرد دقیق منبع',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Copyright.CiteNotCopy = new OO.ui.ButtonOptionWidget({
          label: 'ارجاع به جای کپی',
          data: {
            template: 'نحوه استفاده از مقالات علمی'
          }
        });
        this.buttons.Copyright.ReliableSources = new OO.ui.ButtonOptionWidget({
          label: 'گئچرلی قایناقلار',
          data: {
            template: 'گئچرلی قایناقلار'
          }
        });
        this.buttons.Copyright.CitationTutorial = new OO.ui.ButtonOptionWidget({
          label: 'ایرجاع اؤیرتیمی',
          data: {
            template: 'دوغرو ایرجاع'
          }
        });
        this.buttons.Copyright.License = new OO.ui.ButtonOptionWidget({
          label: 'فایل موجوزی',
          data: {
            template: 'فایل موجوزی'
          }
        });
        this.buttons.Copyright.Copyvio = new OO.ui.ButtonOptionWidget({
          label: 'فایل تذکورو',
          data: {
            template: 'کوپی‌رایت پوزونتوسو تذکورو'
          }
        });
        this.buttons.Copyright.Ownership = new OO.ui.ButtonOptionWidget({
          label: 'مؤحتوا یییه‌لیگی',
          data: {
            template: 'مؤحتوا یییه‌لیگی پوزونتوسو تذکورو'
          }
        });

        this.buttons.Advanced.Coord = new OO.ui.ButtonOptionWidget({
          label: 'موختصات',
          data: {
            template: 'موختصات شابلونو کؤمگی'
          }
        });
        this.buttons.Advanced.Categories = new OO.ui.ButtonOptionWidget({
          label: 'بؤلمه‌لندیرمه',
          data: {
            template: 'بؤلمه‌لندیرمه'
          }
        });
        this.buttons.Advanced.Interwiki = new OO.ui.ButtonOptionWidget({
          label: 'ویکی‌آراسی',
          data: {
            template: 'ویکی‌آراسی آرتیرین'
          }
        });

        this.buttons.Spam.Advertisement = new OO.ui.ButtonOptionWidget({
          label: 'تبلیغ',
          data: {
            template: 'تبلیغ ائتمه‌یین',
            params: [
              {
                id: '1',
                label: 'مقاله آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Notability = new OO.ui.ButtonOptionWidget({
          label: 'آدلیملیق',
          data: {
            template: 'آدلیملیق پیامی',
            params: [
              {
                id: '1',
                label: 'مقاله آدی (ایختیاری)'
              },
              {
                id: '2',
                label: 'آرتیقراق پیام (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Sereh = new OO.ui.ButtonOptionWidget({
          label: 'سره‌نویسی',
          data: {
            template: 'سره ننویسید',
            params: [
              {
                id: '1',
                label: 'عنوان مقاله (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.WP_3RR = new OO.ui.ButtonOptionWidget({
          label: '۳ قایتاریش',
          data: {
            template: '۳ قایتاریش پوزونتوسو تذکورو',
            params: [
              {
                id: '1',
                label: 'مقاله آدی (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Autobiography = new OO.ui.ButtonOptionWidget({
          label: 'اؤزیازما',
          data: {
            template: 'اؤزیازما'
          }
        });
        this.buttons.Spam.WP_NOT = new OO.ui.ButtonOptionWidget({
          label: 'ایشتباه توتموشسونوز',
          data: {
            template: 'ایشتباه توتموشسونوز',
            params: [
              {
                id: '1',
                label: 'نه ایله ایشتیباه توتوبلار؟ (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Username = new OO.ui.ButtonOptionWidget({
          label: 'ایشلدن آدی',
          data: {
            template: 'غئیرموناسیب ایشلدن آدی',
            params: [
              {
                id: '1',
                label: 'ندن (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Spam.Canvassing = new OO.ui.ButtonOptionWidget({
          label: 'های سالما',
          data: {
            template: 'های سالمایین'
          }
        });

        this.buttons.Block.Username = new OO.ui.ButtonOptionWidget({
          label: 'غئیرموناسیب ایشلدن آدی',
          data: {
            template: 'غئیرموناسیب ایشلدن آدی'
          }
        });
        this.buttons.Block.OneDay = new OO.ui.ButtonOptionWidget({
          label: 'بیر گۆنلوک',
          data: {
            template: 'مووقت باغلانما',
            params: [
              {
                id: 'ندن',
                label: 'ندن (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.Indefinite = new OO.ui.ButtonOptionWidget({
          label: 'سون‌سوز',
          data: {
            template: 'سون‌سوز باغلانما',
            params: [
              {
                id: 'ندن',
                label: 'ندن (ایختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.Detailed = new OO.ui.ButtonOptionWidget({
          label: 'با ذکر مدت و دلیل',
          data: {
            template: 'قطع دسترسی',
            params: [
              {
                id: 'مدت',
                label: 'مدت (اختیاری)'
              },
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.Partial = new OO.ui.ButtonOptionWidget({
          label: 'موردی',
          data: {
            template: 'قطع دسترسی موردی',
            params: [
              {
                id: 'صفحات',
                label: 'صفحه‌ها (مثل [[فلان]] و [[بهمان]])'
              },
              {
                id: 'فضای نام',
                label: 'فضای نام (بین موارد «و» بگذارید)'
              },
              {
                id: 'مدت',
                label: 'مدت (اختیاری)'
              },
              {
                id: 'دلیل',
                label: 'دلیل (اختیاری)'
              }
            ]
          }
        });
        this.buttons.Block.AbuseFilter = new OO.ui.ButtonOptionWidget({
          label: 'سوزگچ خطاسی',
          data: {
            template: 'سوزگچی باغیشلایین'
          }
        });

        this.buttons.Rights.Autopatrol = new OO.ui.ButtonOptionWidget({
          label: 'اوتوماتیک دولانان',
          data: {
            template: 'اوتوماتیک دولانان اعطاسی'
          }
        });
        this.buttons.Rights.Revert = new OO.ui.ButtonOptionWidget({
          label: 'قایتاریجی',
          data: {
            template: 'قایتاریجی اعطاسی'
          }
        });
        this.buttons.Rights.Patroller = new OO.ui.ButtonOptionWidget({
          label: 'دولانان',
          data: {
            template: 'دولانان اعطاسی'
          }
        });
        this.buttons.Rights.TemplateEditor = new OO.ui.ButtonOptionWidget({
          label: 'ویرایشگر الگو',
          data: {
            template: 'اعطای ویرایشگر الگو'
          }
        });
        this.buttons.Rights.Eliminator = new OO.ui.ButtonOptionWidget({
          label: 'ویکی‌بان',
          data: {
            template: 'اعطای ویکی‌بان'
          }
        });
        this.buttons.Rights.Sysop = new OO.ui.ButtonOptionWidget({
          label: 'ایداره‌چی',
          data: {
            template: 'ایداره‌چیلیک اعطاسی'
          }
        });
        this.buttons.Rights.ReinstateEliminator = new OO.ui.ButtonOptionWidget({
          label: 'تمدید ویکی‌بانی',
          data: {
            template: 'تمدید ویکی‌بانی'
          }
        });

        this.buttonSelectChoicesItems = [];
        this.buttonSelectChoicesItems.Noobs = [
          this.buttons.Noobs.WelcomeUser,
          this.buttons.Noobs.WelcomeIP,
          this.buttons.Noobs.Sign,
          this.buttons.Noobs.DoNotSign,
          this.buttons.Noobs.Ping,
          this.buttons.Noobs.UploadGuide,
          this.buttons.Noobs.CommonsGuide,
          this.buttons.Noobs.Keyboard,
          this.buttons.Noobs.Preview,
          this.buttons.Noobs.Sandbox,
          this.buttons.Noobs.SisterProjects,
          this.buttons.Noobs.EditSummary,
          this.buttons.Noobs.FakeArticle,
          this.buttons.Noobs.SeggestedLinks
        ];
        this.buttonSelectChoicesItems.Warnings = [
          this.buttons.Warnings.Vandalism,
          this.buttons.Warnings.VandalismFinal,
          this.buttons.Warnings.Disruption,
          this.buttons.Warnings.Responsiveness,
          this.buttons.Warnings.SockPupptery
        ];
        this.buttonSelectChoicesItems.Tools = [
          this.buttons.Tools.VE,
          this.buttons.Tools.ToWikifa,
          this.buttons.Tools.Translator,
          this.buttons.Tools.ExtraEditTools,
          this.buttons.Tools.Abar,
          this.buttons.Tools.Applications,
          this.buttons.Tools.ProveIt,
          this.buttons.Tools.AWD,
          this.buttons.Tools.Patrol,
          this.buttons.Tools.CheckDictation
        ];
        this.buttonSelectChoicesItems.Article = [
          this.buttons.Article.Featured,
          this.buttons.Article.Tutorial,
          this.buttons.Article.Student,
          this.buttons.Article.Incomplete,
          this.buttons.Article.TooShort,
          this.buttons.Article.Minima,
          this.buttons.Article.Deleted,
          this.buttons.Article.Redirect,
          this.buttons.Article.Move,
          this.buttons.Article.Titles,
          this.buttons.Article.Spoiler,
          this.buttons.Article.MachineTranslation,
          this.buttons.Article.NoFlag
        ];
        this.buttonSelectChoicesItems.Copyright = [
          this.buttons.Copyright.DoNotCopy,
          this.buttons.Copyright.UseCitation,
          this.buttons.Copyright.CiteNotCopy,
          this.buttons.Copyright.ReliableSources,
          this.buttons.Copyright.CitationTutorial,
          this.buttons.Copyright.License,
          this.buttons.Copyright.Copyvio,
          this.buttons.Copyright.Ownership
        ];
        this.buttonSelectChoicesItems.Advanced = [
          this.buttons.Advanced.Coord,
          this.buttons.Advanced.Categories,
          this.buttons.Advanced.Interwiki
        ];
        this.buttonSelectChoicesItems.Spam = [
          this.buttons.Spam.Advertisement,
          this.buttons.Spam.Notability,
          this.buttons.Spam.Sereh,
          this.buttons.Spam.WP_3RR,
          this.buttons.Spam.Autobiography,
          this.buttons.Spam.WP_NOT,
          this.buttons.Spam.Username,
          this.buttons.Spam.Canvassing
        ];
        this.buttonSelectChoicesItems.Block = [
          this.buttons.Block.Username,
          this.buttons.Block.OneDay,
          this.buttons.Block.Indefinite,
          this.buttons.Block.Detailed,
          this.buttons.Block.Partial,
          this.buttons.Block.AbuseFilter
        ];
        this.buttonSelectChoicesItems.Rights = [
          this.buttons.Rights.Autopatrol,
          this.buttons.Rights.Revert,
          this.buttons.Rights.Patroller,
          this.buttons.Rights.TemplateEditor,
          this.buttons.Rights.Eliminator,
          this.buttons.Rights.Sysop,
          this.buttons.Rights.ReinstateEliminator
        ];

        // The default choice
        this.buttonSelectChoices = new OO.ui.ButtonSelectWidget({
          items: this.buttonSelectChoicesItems.Noobs
        });

        this.setChooseAction = function() {
          dialog.buttonSelectChoices.on('choose', function(item) {
            dialog.previewResult.toggle(false);
            if (item.data !== undefined & item.data.params !== undefined) {
              dialog.panelParams.toggle(true);
              dialog.buttonPreview.toggle(true);
              dialog.buttonReset.toggle(true);
              for (var i = 0; i < item.data.params.length; i++) {
                dialog.textParamLayouts[i].toggle(true);
                dialog.textParamLayouts[i].setLabel(item.data.params[i].label);
                dialog.textParamLayouts[i].setData(item.data.params[i].id);
              }
              for (i = item.data.params.length; i < 4; i++) {
                dialog.textParamLayouts[i].toggle(false);
              }
            } else {
              for (var k = 0; k < 4; k++) {
                dialog.textParamLayouts[k].toggle(false);
              }
              dialog.panelParams.toggle(true);
              dialog.buttonPreview.toggle(true);
              dialog.buttonReset.toggle(true);
            }
            windowManager.getCurrentWindow().updateSize();
          });          
        };
        this.setChooseAction();

        // The parameters
        this.textParams = [];
        this.textParamLayouts = [];

        this.textParams[0] = new OO.ui.TextInputWidget({
          placeholder: 'بیر یازی یازین'
        });
        this.textParams[1] = new OO.ui.TextInputWidget({
          placeholder: 'بیر یازی یازین'
        });
        this.textParams[2] = new OO.ui.TextInputWidget({
          placeholder: 'بیر یازی یازین'
        });
        this.textParams[3] = new OO.ui.TextInputWidget({
          placeholder: 'بیر یازی یازین'
        });
        this.textParamLayouts[0] = new OO.ui.FieldLayout( this.textParams[0], {
          label: 'پارامتر اول'
        });
        this.textParamLayouts[1] = new OO.ui.FieldLayout( this.textParams[1], {
          label: 'پارامتر دوم'
        });
        this.textParamLayouts[2] = new OO.ui.FieldLayout( this.textParams[2], {
          label: 'پارامتر سوم'
        });
        this.textParamLayouts[3] = new OO.ui.FieldLayout( this.textParams[3], {
          label: 'پارامتر چهارم'
        });
        this.paramFieldset = new OO.ui.FieldsetLayout({
          items: this.textParamLayouts
        });
        this.buttonPreview = new OO.ui.ButtonWidget({
          label: 'اؤن‌گؤستریش',
          icon: 'check',
          title: 'اؤن‌گؤستریش',
          flags: 'progressive'
        });
        this.buttonPreview.on('click', function() {
          dialog.previewResult.toggle(true);
          dialog.previewResult.setContent(''); // Makes any previous preview results go away, so the user notices the change
          windowManager.getCurrentWindow().updateSize();
          var wikitext = UserMessages.prepareWikitext(dialog);
          var api = new mw.Api();
          api.get({
            action: 'parse',
            text: wikitext,
            pst: true
          }).done(function( data ) {
            dialog.previewResult.setContent($(data.parse.text['*']));
          });
        });
        this.buttonReset = new OO.ui.ButtonWidget({
          label: 'سیل',
          icon: 'clear',
          title: 'سیل',
          flags: 'destructive'
        });
        this.buttonReset.on('click', function() {
          for (var i = 0; i < 4; i++) {
              dialog.textParams[i].setValue('');
          }
          dialog.previewResult.toggle(false);
          dialog.buttonPreview.toggle(true);
          dialog.buttonReset.toggle(true);
          windowManager.getCurrentWindow().updateSize();
        });
        this.panelParams = new OO.ui.PanelLayout({
          expanded: true,
          padded: true
        });
        this.previewResult = new PreviewPanel({
          expanded: true,
          padded: true,
          $content: ''
        });
        this.previewResult.toggle(false);
        this.panelParams.$element.append(this.paramFieldset.$element);
        this.panelParams.$element.append(this.buttonPreview.$element);
        this.panelParams.$element.append(this.buttonReset.$element);
        for (var i = 0; i < 4; i++) {
            this.textParamLayouts[i].toggle(false);
        }
        this.buttonPreview.toggle(false);
        this.buttonReset.toggle(false);
        this.panelGroups = new OO.ui.PanelLayout({
          expanded: true,
          padded: true,
          classes: ['panelGroups']
        });
        this.panelGroups.$element.append(this.buttonSelectGroups.$element);
        this.panelChoices = new OO.ui.PanelLayout({
          expanded: true,
          padded: true,
          classes: ['panelChoices']
        });
        this.panelChoices.$element.append(this.buttonSelectChoices.$element);
        this.panelPreview = new OO.ui.PanelLayout({
          expanded: true,
          padded: true
        });
        this.panelPreview.$element.append(this.previewResult.$element);

        this.stackLayout = new OO.ui.StackLayout({
          items: [
            this.panelGroups,
            this.panelChoices,
            this.panelParams,
            this.panelPreview
          ],
          continuous: true,
          scrollable: false
        });
        this.$body.append(this.stackLayout.$element);
      };
      UserMessages.prepareWikitext = function(dialog) {
        var paramNames = [];
        var paramValues = [];
        var btn = dialog.buttonSelectChoices.findSelectedItem().getData();
        var wikitext = '{{subst:' + btn.template;
        for (var i = 0; i < 4; i ++) {
          paramNames[i] = dialog.textParamLayouts[i].getData();
          paramValues[i] = dialog.textParams[i].getValue();
          if (dialog.textParamLayouts[i].isVisible()) {
            wikitext += '|' + paramNames[i] + '=' + paramValues[i];
          }
        }
        wikitext += '}}';
        return wikitext;
      };
      UserMessages.prototype.getSetupProcess = function(data) {
        data = data || {};
        return UserMessages.super.prototype.getSetupProcess.call( this, data )
          .next( function () {
            // Do something
          }, this );
      };
      UserMessages.prototype.getActionProcess = function(action) {
        var dialog = this;
        if (action === 'warn' | action === 'diff') {
          var wikitext = UserMessages.prepareWikitext(dialog);
          wikitext += '\n~~' + '~~';
var summary = '«[[شابلون:' + dialog.buttonSelectChoices.findSelectedItem().getData().template + ']]» آرتیرماق [[ویکی‌پدیا:ایشلدنلر اوچون بیلدیری آلتی|ایشلدنلر اوچون بیلدیری آلتی]] ایله';
          if (action === 'warn') {
            return new OO.ui.Process(function() {
              UMOptions.savePage(mw.config.get('wgPageName'), wikitext, summary, function() {
                location.reload();
              });
              dialog.close({
                action: action
              }).done(function() {
                // Page will be reloaded once saved
              });
            });
          } else { // action === 'diff'
            return new OO.ui.Process(function() {
              UMOptions.showDiff(
                mw.config.get('wgPageName'),
                wikitext,
                summary
              )
            });
          }
        }
        return UserMessages.super.prototype.getActionProcess.call(this, action);
      };
      if (!windowManager) {
        windowManager = new OO.ui.WindowManager();
        $('body').append(windowManager.$element);
      }
      UM = new UserMessages({
        size: 'large'
      });
      windowManager.addWindows([UM]);
      windowManager.openWindow(UM);
    },
    redirectPost: function(url, data) {
      var form = document.createElement('form');
        document.body.appendChild(form);
        form.method = 'post';
        form.action = url;
        for (var name in data) {
          var input = document.createElement('input');
          input.type = 'hidden';
          input.name = name;
          input.value = data[name];
          form.appendChild(input);
        }
      form.submit();
	},
	showDiff: function(title, text, summary) {
      UMOptions.redirectPost(new mw.Uri(mw.config.get('wgScript')).extend({
        title: title,
          action: 'submit'
        }), {
          wpTextbox1: text,
          wpDiff: '',
          wpSummary: '',
          wpSection: 'new',
          wpUltimateParam: 1
        }
      );
    },
    savePage: function(title, text, summary, callback) {
      (new mw.Api()).post({
        action: 'edit',
        title: title,
        summary: summary,
        appendtext: '\n' + text,
        token: mw.user.tokens.get('csrfToken')
      }).done(function(data) {
        if (data.error && data.error.info) {
          if (data.error.info == 'missingtitle') {
            mw.notify('صفحه ' + title + ' موجود دئییل!', {
              type: 'error'
            });
          } else {
            mw.notify(data.error.info, {
              type: 'error'
            });
          }
        } else {
          callback();
        }
      }).fail(function(data) {
        mw.notify(data);
      });
    },
  };
  if (mw.config.get('wgNamespaceNumber') === 3 | mw.config.get('wgPageName') === 'ویکی‌پدیا:قارالاما دفتری') {
    $(UMOptions.install);
  }
})(jQuery, mediaWiki);