پرش به محتوا

مدیاویکی:Gadget-defaultsummaries.js: تفاوت میان نسخه‌ها

از دانشنامه علوم انسانی
imported>Taranet
مثل ویکی انگلیسی. اجتمالا مترجم حواسش به حذف و اضافهٔ دانشگاه بوده!
imported>Ladsgroup
بروزرسانی از نسخه جدید
 
(۳ نسخهٔ میانی ویرایش شده توسط ۲ کاربر نشان داده نشد)
خط ۱: خط ۱:
/*  
/*  
  * Imported as of 2011/11/24 from [[en:MediaWiki:Gadget-defaultsummaries.js]]
  * Imported as of 2011/11/24 from [[:en:MediaWiki:Gadget-defaultsummaries.js]]
  * http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-defaultsummaries.js&oldid=454943034
  * http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-defaultsummaries.js&oldid=454943034
  * Implements default edit summary dropdown boxes
  * Implements default edit summary dropdown boxes
خط ۶: خط ۶:
   
   
(function ($) { // Wrap with anonymous function
(function ($) { // Wrap with anonymous function
    // The original value of the edit summary field is stored here
     var $summaryBox  = $('input#wpSummary, #wpSummary > input');
     var editsummOriginalSummary = "";
 
     function editsummAddOptionToDropdown(dropdown, optionText) {
     function editsummAddOptionToDropdown(dropdown, optionText) {
         var option = document.createElement("option");
         var option = document.createElement("option");
خط ۲۷: خط ۲۶:
     function editsummOnCannedSummarySelected() {
     function editsummOnCannedSummarySelected() {
         // Save the original value of the edit summary field
         // Save the original value of the edit summary field
         editsummOriginalSummary = document.getElementById("wpSummary");
         var editsummOriginalSummary = $summaryBox.val();
        if (editsummOriginalSummary) {
            editsummOriginalSummary = editsummOriginalSummary.value;
        } else {
            editsummOriginalSummary = "";
        }
   
   
         var idx = this.selectedIndex;
         var idx = this.selectedIndex;
خط ۳۹: خط ۳۳:
         var newSummary = editsummOriginalSummary;
         var newSummary = editsummOriginalSummary;
   
   
         // Append old edit summary with space, if exists
         // Append old edit summary with space, if exists,
         if (newSummary.length !== 0) {
        // and last character != space
         if (newSummary.length !== 0 && newSummary.charAt(newSummary.length - 1) !== " ") {
             newSummary += " ";
             newSummary += " ";
         }
         }
         newSummary += canned;
         newSummary += canned;
         document.getElementById("wpSummary").value = newSummary;
         $summaryBox.val( newSummary ).trigger( 'change' );
     }
     }
   
   
     $(function () {
     function insertSummaryOptions($insertBeforeThis, dropdownWidth) {  
        var insertBeforeThis = document.getElementById("wpSummary");
        // Loop through siblings, looking for editCheckboxes class
        while (insertBeforeThis) {
            if (insertBeforeThis.className === "editCheckboxes") {
                break;
            }
            insertBeforeThis = insertBeforeThis.nextSibling;
        }
        // If we failed to find the editCheckboxes class, or insertBeforeThis is null
        if (!insertBeforeThis || insertBeforeThis.className !== "editCheckboxes") {
            return;
        }
        editsummOriginalSummary = editsummOriginalSummary.value;
         // For convenience, add a dropdown box with some canned edit
         // For convenience, add a dropdown box with some canned edit
         // summaries to the form.
         // summaries to the form.
         var dropdown = document.createElement("select");
         var dropdown = document.createElement("select");
         dropdown.style.width = "38%";
         dropdown.style.width = dropdownWidth;
         dropdown.style.margin = "0 4px 0 0";
         dropdown.style.margin = "0 4px 0 0";
         dropdown.onchange = editsummOnCannedSummarySelected;
         dropdown.onchange = editsummOnCannedSummarySelected;
   
   
         var minorDropdown = document.createElement("select");
         var minorDropdown = document.createElement("select");
         minorDropdown.style.width = "38%";
         minorDropdown.style.width = dropdownWidth;
         minorDropdown.onchange = editsummOnCannedSummarySelected;
         minorDropdown.onchange = editsummOnCannedSummarySelected;
   
   
خط ۸۱: خط ۵۹:
         editsummAddOptionToDropdown(minorDropdown, "اصلاح املایی/جمله‌بندی");
         editsummAddOptionToDropdown(minorDropdown, "اصلاح املایی/جمله‌بندی");
         editsummAddOptionToDropdown(minorDropdown, "رفع خطاهای ظاهری");
         editsummAddOptionToDropdown(minorDropdown, "رفع خطاهای ظاهری");
         editsummAddOptionToDropdown(minorDropdown, "[[|راهنما:واگردانی|واگردانی]] [[وپ:خرابکاری|خرابکاری]] یا ویرایش آزمایشی");
         editsummAddOptionToDropdown(minorDropdown, "[[راهنما:خنثی‌سازی|خنثی‌سازی]] [[وپ:خرابکاری|خرابکاری]] یا ویرایش آزمایشی");
         editsummAddOptionToDropdown(minorDropdown, "[[راهنما:واگردانی|واگردانی]] حذف محتوای بدون توضیح");
         editsummAddOptionToDropdown(minorDropdown, "[[راهنما:خنثی‌سازی|خنثی‌سازی]] حذف محتوای بدون توضیح");
         editsummAddOptionToDropdown(minorDropdown, "ویرایش و تصحیح (جزئی)");
         editsummAddOptionToDropdown(minorDropdown, "ویرایش و تصحیح (جزئی)");
   
   
خط ۱۰۷: خط ۸۵:
         }
         }
   
   
         var theParent = insertBeforeThis.parentNode;
$insertBeforeThis.before(dropdown);
         theParent.insertBefore(dropdown, insertBeforeThis);
        $insertBeforeThis.before(minorDropdown);
         theParent.insertBefore(minorDropdown, insertBeforeThis);
    }
         theParent.insertBefore(document.createElement("br"), dropdown);
    mw.hook( 've.saveDialog.stateChanged' ).add(function(){
        //.ve-init-mw-viewPageTarget-saveDialog-checkboxes
        if ( $( 'body' ).data( 'wppresent' ) ) { return; }
        $( 'body' ).data( 'wppresent', 'true' );
         var target = ve.init.target,
        $insertBeforeThis = target.saveDialog.$saveOptions;
         $summaryBox = target.saveDialog.editSummaryInput.$input;
        if (!$insertBeforeThis.length) {
            return;
         }
        insertSummaryOptions($insertBeforeThis, "98%");
    });
    $(function() {
        var $insertBeforeThis = $('.editCheckboxes');
        // If we failed to find the editCheckboxes class
         if (!$insertBeforeThis.length) {
            return;
        }
        insertSummaryOptions($insertBeforeThis, "38%");
     });
     });
}(jQuery)) // End wrap with anonymous function
}(jQuery));

نسخهٔ کنونی تا ۱۳ مهٔ ۲۰۱۷، ساعت ۰۰:۰۰

/* 
 * Imported as of 2011/11/24 from [[:en:MediaWiki:Gadget-defaultsummaries.js]]
 * http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-defaultsummaries.js&oldid=454943034
 * Implements default edit summary dropdown boxes
 */
 
(function ($) { // Wrap with anonymous function
    var $summaryBox  = $('input#wpSummary, #wpSummary > input');

    function editsummAddOptionToDropdown(dropdown, optionText) {
        var option = document.createElement("option");
        var optionTextNode = document.createTextNode(optionText);
        option.appendChild(optionTextNode);
        dropdown.appendChild(option);
    }
 
    function editsummAddCatToDropdown(dropdown, catText) {
        var option = document.createElement("option");
        option.disabled = true;
        option.selected = true;
        var optionTextNode = document.createTextNode(catText);
        option.appendChild(optionTextNode);
        dropdown.appendChild(option);
    }
 
    function editsummOnCannedSummarySelected() {
        // Save the original value of the edit summary field
        var editsummOriginalSummary = $summaryBox.val();
 
        var idx = this.selectedIndex;
        var canned = this.options[idx].text;
 
        var newSummary = editsummOriginalSummary;
 
        // Append old edit summary with space, if exists,
        // and last character != space
        if (newSummary.length !== 0 && newSummary.charAt(newSummary.length - 1) !== " ") {
            newSummary += " ";
        }
        newSummary += canned;
        $summaryBox.val( newSummary ).trigger( 'change' );
    }
 
    function insertSummaryOptions($insertBeforeThis, dropdownWidth) { 
        // For convenience, add a dropdown box with some canned edit
        // summaries to the form.
        var dropdown = document.createElement("select");
        dropdown.style.width = dropdownWidth;
        dropdown.style.margin = "0 4px 0 0";
        dropdown.onchange = editsummOnCannedSummarySelected;
 
        var minorDropdown = document.createElement("select");
        minorDropdown.style.width = dropdownWidth;
        minorDropdown.onchange = editsummOnCannedSummarySelected;
 
        editsummAddCatToDropdown(minorDropdown, "خلاصه ویرایش‌های جزئی رایج - برای استفاده کلیک کنید");
        editsummAddCatToDropdown(dropdown, "خلاصه ویرایش‌های رایج - برای استفاده کلیک کنید");
 
        editsummAddOptionToDropdown(minorDropdown, "اصلاح املایی/جمله‌بندی");
        editsummAddOptionToDropdown(minorDropdown, "رفع خطاهای ظاهری");
        editsummAddOptionToDropdown(minorDropdown, "[[راهنما:خنثی‌سازی|خنثی‌سازی]] [[وپ:خرابکاری|خرابکاری]] یا ویرایش آزمایشی");
        editsummAddOptionToDropdown(minorDropdown, "[[راهنما:خنثی‌سازی|خنثی‌سازی]] حذف محتوای بدون توضیح");
        editsummAddOptionToDropdown(minorDropdown, "ویرایش و تصحیح (جزئی)");
 
        if (mw.config.get('wgNamespaceNumber') === 0) {
            editsummAddOptionToDropdown(dropdown, "گسترش مقاله");
            editsummAddOptionToDropdown(dropdown, "فارسی‌سازی");
            editsummAddOptionToDropdown(dropdown, "ویکی‌سازی");
            editsummAddOptionToDropdown(dropdown, "بهبود/اضافه کردن منبع‌");
            editsummAddOptionToDropdown(dropdown, "حذف/اضافه کردن رده");
            editsummAddOptionToDropdown(dropdown, "حذف/اضافه کردن پیوند به بیرون");
            editsummAddOptionToDropdown(dropdown, "حذف محتوای بدون منبع");
            editsummAddOptionToDropdown(dropdown, "درخواست مدرک");
            editsummAddOptionToDropdown(dropdown, "حذف [[وپ:هرزنامه|هرزنامه]]");
            editsummAddOptionToDropdown(dropdown, "تمیزکاری");
            editsummAddOptionToDropdown(dropdown, "ویرایش و تصحیح");
        } else {
            editsummAddOptionToDropdown(dropdown, "پاسخ");
            editsummAddOptionToDropdown(dropdown, "توضیح");
            editsummAddOptionToDropdown(dropdown, "پیشنهاد");
            if ((mw.config.get('wgNamespaceNumber') % 2 !== 0) & (mw.config.get('wgNamespaceNumber') !== 3)) {
                editsummAddOptionToDropdown(dropdown, "برچسب [[وپ:ویکی‌پروژه]]");
                editsummAddOptionToDropdown(dropdown, "تعیین برچسب [[وپ:ویکی‌پروژه]]");
            }
        }
 
	$insertBeforeThis.before(dropdown);
        $insertBeforeThis.before(minorDropdown);
    }
    mw.hook( 've.saveDialog.stateChanged' ).add(function(){
        //.ve-init-mw-viewPageTarget-saveDialog-checkboxes
         if ( $( 'body' ).data( 'wppresent' ) ) { return; }
         $( 'body' ).data( 'wppresent', 'true' );
        var target = ve.init.target,
        	$insertBeforeThis = target.saveDialog.$saveOptions;
        $summaryBox = target.saveDialog.editSummaryInput.$input;
        if (!$insertBeforeThis.length) {
            return;
        }
        insertSummaryOptions($insertBeforeThis, "98%");
    });
    $(function() {
        var $insertBeforeThis = $('.editCheckboxes');
 
        // If we failed to find the editCheckboxes class
        if (!$insertBeforeThis.length) {
            return;
        }
        insertSummaryOptions($insertBeforeThis, "38%");
    });
}(jQuery));