אונטערשייד צווישן ווערסיעס פון "מעדיעוויקי:Ref2template.js"
קפיצה לניווט
קפיצה לחיפוש
אין תקציר עריכה |
(log) |
||
שורה 60: | שורה 60: | ||
$(function () { | $(function () { | ||
mw.hook('wikiEditor.toolbarReady').add(function ($textarea) { | mw.hook('wikiEditor.toolbarReady').add(function ($textarea) { | ||
console.log("Toolbar ready"); | |||
var action = $('[rel=reference]').data('action'), | var action = $('[rel=reference]').data('action'), | ||
options = (action || {}).options; | options = (action || {}).options; |
רעוויזיע פון 15:43, 18 סעפטעמבער 2023
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) + 1) {
console.log("Current action:", mw.config.get('wgAction'));
$('#wpTextbox1').on('wikiEditor-dialogs-loaded-insert-reference', function () {
console.log("WikiEditor dialog loaded");
$('#wikieditor-toolbar-reference-dialog').on('dialogopen', function () {
console.log("Reference dialog opened");
var
dialog = $(this).parent(),
addButton,
clone,
refnameId = 'wikieditor-toolbar-reference-name',
onAdd = function () {
var $this = $('#wikieditor-toolbar-reference-dialog'),
refContent = $('#wikieditor-toolbar-reference-text').val(),
refName = $('#' + refnameId).val(),
whitespace = $this.data('whitespace'),
attributes = $this.data('attributes'),
refPrefix = whitespace[0]
+ '{{' + 'הערה|'
+ ($.trim(refName) ? 'שם=' + refName + '|' : '')
+ (/=/.test(refContent) ? '1=' : '');
console.log("Reference content:", refContent);
console.log("Reference name:", refName);
console.log("Whitespace:", whitespace);
console.log("Attributes:", attributes);
console.log("Reference prefix:", refPrefix);
// Close the dialog
$this.dialog('close');
console.log("Dialog closed");
$.wikiEditor.modules.toolbar.fn.doAction(
$this.data('context'),
{
type: 'replace',
options: {
pre: refPrefix,
peri: refContent,
post: '}}' + whitespace[1]
}
},
$this
);
console.log("Action performed");
// Restore form state
$('#wikieditor-toolbar-reference-text').val('');
console.log("Form state restored");
$('#' + refnameId).val('');
};
if (!window.refDialogbeenThere) {
$('label[for=wikieditor-toolbar-reference-text]').before($('<input>', { id: refnameId })).before($('<p>'));
$('#' + refnameId).before($('<label>', { 'for': refnameId, rel: refnameId, text: 'שם ההערה (אופציונלי) :' }));
$(this).dialog('option', { height: 'auto' });
window.refDialogbeenThere = true;
addButton = dialog.find('button:contains(הוספה)'),
clone = addButton.clone().click(onAdd).insertAfter(addButton);
addButton.toggle(false);
}
});
});
$(function () {
mw.hook('wikiEditor.toolbarReady').add(function ($textarea) {
console.log("Toolbar ready");
var action = $('[rel=reference]').data('action'),
options = (action || {}).options;
console.log("Reference action:", action);
console.log("Reference options:", options);
if (options) {
options.pre = '{{הערה|1=';
options.post = '}}';
}
action = $('[rel=newline]').data('action');
console.log("Newline action:", action);
options = (action || {}).options;
console.log("Newline options:", options);
if (options)
options.pre = '{{ש}}\n';
else
$('#wpTextbox1').on('wikiEditor-toolbar-buildSection-advanced', function (e, d) {
d.groups.format.tools.newline.action.options.pre = '{{ש}}\n';
});
});
})
}