Skip to content

Commit

Permalink
Update twinklexfd.js
Browse files Browse the repository at this point in the history
  • Loading branch information
nardog authored Nov 11, 2023
1 parent 05b0d1e commit 3f34791
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions modules/twinklexfd.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,8 @@ Twinkle.xfd.callback.change_category = function twinklexfdCallbackChangeCategory
tooltip: 'Use this option when you are unable to perform this uncontroversial move yourself because of a technical reason (e.g. a page already exists at the new title, or the page is protected)',
checked: false,
event: function() {
form.newname.required = this.checked;
$('input[name="newname"]', form).prop('required', this.checked);
$('input[type="button"][value="more"]')[0].sublist.inputs[1].required = this.checked;
},
subgroup: {
type: 'checkbox',
Expand All @@ -703,15 +704,27 @@ Twinkle.xfd.callback.change_category = function twinklexfdCallbackChangeCategory
]
});
work_area.append({
type: 'input',
name: 'newname',
label: 'New title:',
tooltip: 'Required for technical requests. Otherwise, if unsure of the appropriate title, you may leave it blank.'
type: 'dyninput',
inputs: [
{
label: 'From:',
name: 'currentname',
required: true
},
{
label: 'To:',
name: 'newname',
tooltip: 'Required for technical requests. Otherwise, if unsure of the appropriate title, you may leave it blank.'
}
],
min: 1
});

appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);

form.currentname.value = Morebits.pageNameNorm;
break;

default:
Expand Down Expand Up @@ -764,12 +777,19 @@ Twinkle.xfd.callbacks = {
// U+00A0 NO-BREAK SPACE; U+2013 EN RULE
}
if (venue === 'rm') {
// even if invoked from talk page, propose the subject page for move
var pageName = new mw.Title(Morebits.pageNameNorm).getSubjectPage().toText();
var rmtrDiscuss = params['rmtr-discuss'] ? '|discuss=no' : '';
var rmtr = '{{subst:RMassist|1=' + pageName + '|2=' + params.newname + rmtrDiscuss + '|reason=' + params.reason + '}}';
var requestedMove = '{{subst:Requested move|current1=' + pageName + '|new1=' + params.newname + '|reason=' + params.reason + '}}';
return params.rmtr ? rmtr : requestedMove;
if (params.rmtr) {
var rmtrDiscuss = params['rmtr-discuss'] ? '|discuss=no' : '';
return params.currentname
.map((currentname, i) => `{{subst:RMassist|1=${currentname}|2=${params.newname[i] || ''}${rmtrDiscuss}|reason=${params.reason}}}`)
.filter(Boolean)
.join('\n');
} else {
return `{{subst:Requested move${
params.currentname
.map((currentname, i) => `|current${i + 1}=${currentname}|new${i + 1}=${params.newname[i] || ''}`)
.join('')
}|reason=${params.reason}}}`;
}
}

var text = '{{subst:' + venue + '2';
Expand Down

0 comments on commit 3f34791

Please sign in to comment.