پرش به محتوا

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

از دانشنامه علوم انسانی
imported>Darafsh
صفحه‌ای جدید حاوی «// دکمهٔ اضافه‌کردن بحث جدید را کنار دکمهٔ ویرایش آخرین بخش یک صفحهٔ بحث اضاف...» ایجاد کرد
 
imported>Ebrahim
خط ۱: خط ۱:
// دکمهٔ اضافه‌کردن بحث جدید را کنار دکمهٔ ویرایش آخرین بخش یک صفحهٔ بحث اضافه می‌کند
/*global $*/
/*global $*/
/*Maintainer: User:Ebraminio*/
/**
$(function () {
* دکمهٔ اضافه‌کردن بحث جدید را کنار دکمهٔ ویرایش آخرین بخش یک صفحهٔ بحث اضافه می‌کند ('+ ') (از de.wikipedia)
    'use strict';
*/
    if ($("#ca-addsection").length === 0) {
$( function() {
        return; // never mind
var newSectionLink = $( '#ca-addsection a' );
    }
if( newSectionLink.length ) {
    var lastButton = $("#mw-content-text h2:last .mw-editsection"),
  var link = newSectionLink.clone(); //create a copy
        addButton = lastButton.clone(),
  //avoid duplicate accesskey
        addLinkElement = $("#ca-addsection a").clone(),
  link.removeAttr( 'accesskey' ).attr( 'title', function ( index, oldTitle ) {
        addTitle = addLinkElement.attr('title').replace(/\s\[[a-zA-Z+\-\s]*\]/, '');
  return oldTitle.replace( /\s*\[.*\]\s*$/, '' );
    $("a", addButton).replaceWith(addLinkElement.attr('title', addTitle).html(addTitle));
  } );
    lastButton.after(addButton);
  //add it within the brackets
  var lastEditsectionLink = $( 'span.mw-editsection:last a:last' );
  lastEditsectionLink.after( link );
  lastEditsectionLink.after( ' | ' ); //see [[MediaWiki:Pipe-separator]]
}
});
});

نسخهٔ ۱۸ ژوئیهٔ ۲۰۱۴، ساعت ۱۹:۲۴

/*global $*/
/**
 * دکمهٔ اضافه‌کردن بحث جدید را کنار دکمهٔ ویرایش آخرین بخش یک صفحهٔ بحث اضافه می‌کند ('+ ') (از de.wikipedia)
 */
$( function() {
 var newSectionLink = $( '#ca-addsection a' );
 if( newSectionLink.length ) {
  var link = newSectionLink.clone(); //create a copy
  //avoid duplicate accesskey
  link.removeAttr( 'accesskey' ).attr( 'title', function ( index, oldTitle ) {
   return oldTitle.replace( /\s*\[.*\]\s*$/, '' );
  } );
  //add it within the brackets
  var lastEditsectionLink = $( 'span.mw-editsection:last a:last' );
  lastEditsectionLink.after( link );
  lastEditsectionLink.after( ' | ' ); //see [[MediaWiki:Pipe-separator]]
 }
});