مدیاویکی:Gadget-AncreTitres.js: تفاوت میان نسخهها
ظاهر
imported>Dalba به این شکل جمعجورتر و یکدستتر خواهد بود |
imported>Dalba more refactoring |
||
| خط ۲۷: | خط ۲۷: | ||
$(function() { | $(function() { | ||
var _option = { | var _option = { | ||
nom_permalink: ' | nom_permalink: 'پایاپیوند', | ||
nom_ancre: ' | nom_ancre: 'URL', | ||
nom_lien_interne: ' | nom_lien_interne: 'ویکیپیوند', | ||
description_pl: 'نمایش پیوند پایدار به این بخش', | description_pl: 'نمایش پیوند پایدار به این بخش', | ||
description: 'نمایش یوآرال این بخش', | description: 'نمایش یوآرال این بخش', | ||
descinterne: 'نمایش پیوند ویکیپدیایی این بخش', | descinterne: 'نمایش پیوند ویکیپدیایی این بخش', | ||
}; | }; | ||
if (typeof window.AncreTitres !== 'undefined') { | if (typeof window.AncreTitres !== 'undefined') { | ||
$.extend(_option, window.AncreTitres); | $.extend(_option, window.AncreTitres); | ||
} | |||
var startBracket = $('<span class="mw-editsection-bracket"> [</span>'); | |||
var endBracket = $('<span class="mw-editsection-bracket">]</span>'); | |||
function appendTo(headline, item) { | |||
startBracket.clone().appendTo(headline); | |||
item.appendTo(headline); | |||
if ( | endBracket.clone().appendTo(headline); | ||
} | |||
$('.mw-editsection').each(function(_, editSecton) { | |||
if (editSecton.previousElementSibling) { | |||
var anchor = '#' + editSecton.previousElementSibling.id; | |||
} else { | |||
var anchor = ''; | |||
} | |||
if ($('#t-permalink a').length) { | |||
appendTo( | |||
editSecton, | |||
$('<a href="#" title="' + _option.description_pl + '">' + _option.nom_permalink + '</a>') | |||
.click(function() { | |||
window.prompt('پایاپیوند:', $('#t-permalink a')[0].href + anchor); | |||
return false; | |||
}).appendTo(editSecton) | |||
); | |||
} | |||
appendTo( | |||
editSecton, | |||
$('<a href="#" title="' + _option.description + '">' + _option.nom_ancre + '</a>') | |||
.click(function() { | |||
window.prompt('نشانی وب معمولی:', 'https:' + mw.config.get('wgServer') + mw.config.get('wgScript') | |||
+ '?title=' + mw.config.get('wgPageName') + anchor); | |||
return false; | |||
}) | |||
); | |||
appendTo( | |||
editSecton, | |||
$('<a href="#" title="' + _option.descinterne + '">' + _option.nom_lien_interne + '</a>') | |||
.click(function() { | |||
window.prompt('ویکیپیوند:', '[[' + mw.config.get('wgPageName') + anchor + ']]'); | |||
return false; | |||
}).appendTo(editSecton) | |||
); | |||
}); | }); | ||
}); | }); | ||
}(mediaWiki, jQuery)); | }(mediaWiki, jQuery)); | ||
// </nowiki> | // </nowiki> | ||
نسخهٔ ۳ نوامبر ۲۰۱۸، ساعت ۱۰:۲۰
/*jslint browser:true */
/*global $, wgServer, wgScript, wgPageName */
/**
* AncreTitres
*
* Cette fonction fournit un lien vers une section de page en cliquant
* sur le lien [ancre] à droite du titre de section.
*
* Auteurs : Pabix, Phe, Bayo, Dalba -- Correctif apporté par Chphe
* Date de dernière révision : 16 October 2014
* {{Projet:JavaScript/Script|AncreTitres}}
*/
/**
* AncreTitres
*
* Cette fonction fournit un lien vers une section de page en cliquant
* sur le lien [URL] ou [[lien]] à droite du titre de section.
*
* Auteurs : Pabix, Phe, Bayo, Chphe, Arkanosis et Dalba
* {{Projet:JavaScript/Script|AncreTitres}}
*/
/*global alert, jQuery, mediaWiki, window */
/*jslint vars: true, plusplus: true */
// <nowiki>
(function(mw, $) {
'use strict';
$(function() {
var _option = {
nom_permalink: 'پایاپیوند',
nom_ancre: 'URL',
nom_lien_interne: 'ویکیپیوند',
description_pl: 'نمایش پیوند پایدار به این بخش',
description: 'نمایش یوآرال این بخش',
descinterne: 'نمایش پیوند ویکیپدیایی این بخش',
};
if (typeof window.AncreTitres !== 'undefined') {
$.extend(_option, window.AncreTitres);
}
var startBracket = $('<span class="mw-editsection-bracket"> [</span>');
var endBracket = $('<span class="mw-editsection-bracket">]</span>');
function appendTo(headline, item) {
startBracket.clone().appendTo(headline);
item.appendTo(headline);
endBracket.clone().appendTo(headline);
}
$('.mw-editsection').each(function(_, editSecton) {
if (editSecton.previousElementSibling) {
var anchor = '#' + editSecton.previousElementSibling.id;
} else {
var anchor = '';
}
if ($('#t-permalink a').length) {
appendTo(
editSecton,
$('<a href="#" title="' + _option.description_pl + '">' + _option.nom_permalink + '</a>')
.click(function() {
window.prompt('پایاپیوند:', $('#t-permalink a')[0].href + anchor);
return false;
}).appendTo(editSecton)
);
}
appendTo(
editSecton,
$('<a href="#" title="' + _option.description + '">' + _option.nom_ancre + '</a>')
.click(function() {
window.prompt('نشانی وب معمولی:', 'https:' + mw.config.get('wgServer') + mw.config.get('wgScript')
+ '?title=' + mw.config.get('wgPageName') + anchor);
return false;
})
);
appendTo(
editSecton,
$('<a href="#" title="' + _option.descinterne + '">' + _option.nom_lien_interne + '</a>')
.click(function() {
window.prompt('ویکیپیوند:', '[[' + mw.config.get('wgPageName') + anchor + ']]');
return false;
}).appendTo(editSecton)
);
});
});
}(mediaWiki, jQuery));
// </nowiki>