مدیاویکی:Gadget-CustomizedEditTool.js: تفاوت میان نسخهها
ظاهر
imported>Yamaha5 بدون خلاصۀ ویرایش |
imported>Ebrahim بدون خلاصۀ ویرایش |
||
| (یک نسخهٔ میانی ویرایش شده توسط یک کاربر دیگر نشان داده نشد) | |||
| خط ۱: | خط ۱: | ||
/*jslint indent: 2*/ | /*jslint indent: 2*/ | ||
/*global | /*global mw, $*/ | ||
(function ( | $(function () { | ||
'use strict'; | 'use strict'; | ||
var action = mw.config.get('wgAction'); | var action = mw.config.get('wgAction'); | ||
| خط ۹: | خط ۹: | ||
page: 'کاربر:' + mw.config.get('wgUserName') + '/EditTools', | page: 'کاربر:' + mw.config.get('wgUserName') + '/EditTools', | ||
format: 'json' | format: 'json' | ||
}). | }).then(function (data) { | ||
$('.mw-editTools').html(data.parse.text['*']); | |||
// Copied from https://github.com/wikimedia/mediawiki-extensions-CharInsert/blob/master/modules/ext.charinsert.js#L5-L24 | |||
$( 'a.mw-charinsert-item' ).each( function () { | |||
var $item = $( this ), | |||
start = $item.data( 'mw-charinsert-start' ), | |||
end = $item.data( 'mw-charinsert-end' ); | |||
if ( $item.data( 'mw-charinsert-done' ) ) { | |||
return; | |||
} | |||
$item.on( 'click', function ( e ) { | |||
e.preventDefault(); | |||
$( '#wpTextbox1' ).textSelection( | |||
'encapsulateSelection', { | |||
pre: start, | |||
peri: '', | |||
post: end | |||
} | |||
); | |||
} ) | |||
.data( 'mw-charinsert-done', true ) | |||
.attr( 'href', '#' ); | |||
} ); | |||
}); | }); | ||
} | } | ||
} | }); | ||
نسخهٔ کنونی تا ۲۶ ژانویهٔ ۲۰۱۹، ساعت ۲۰:۰۸
/*jslint indent: 2*/
/*global mw, $*/
$(function () {
'use strict';
var action = mw.config.get('wgAction');
if (action === 'edit' || action === 'submit') {
new mw.Api().get({
action: 'parse',
page: 'کاربر:' + mw.config.get('wgUserName') + '/EditTools',
format: 'json'
}).then(function (data) {
$('.mw-editTools').html(data.parse.text['*']);
// Copied from https://github.com/wikimedia/mediawiki-extensions-CharInsert/blob/master/modules/ext.charinsert.js#L5-L24
$( 'a.mw-charinsert-item' ).each( function () {
var $item = $( this ),
start = $item.data( 'mw-charinsert-start' ),
end = $item.data( 'mw-charinsert-end' );
if ( $item.data( 'mw-charinsert-done' ) ) {
return;
}
$item.on( 'click', function ( e ) {
e.preventDefault();
$( '#wpTextbox1' ).textSelection(
'encapsulateSelection', {
pre: start,
peri: '',
post: end
}
);
} )
.data( 'mw-charinsert-done', true )
.attr( 'href', '#' );
} );
});
}
});