MediaWiki:Gadget-twinkleblock.js: Difference between revisions

Content deleted Content added
Repo at f1135f6: Link pages in partial block template
Repo at fd5b702: customize "Could not load search results" text for page selector; remove stray comment; match from beginning of words only in namespace selector; create links to pages selected for partial block; use ajax lookup in partial block pages menu
Line 431:
$form.find('[name=pagerestrictions]').select2({
width: '100%',
placeholder: 'EnterSelect pages to block user from',
tags: true,
placeholder: 'Enter pages to block user from',
maximumSelectionLength: 10, // Software limitation [[phab:T202776]]
language: {
noResultserrorLoading: function() {
return 'NoIncomplete pagesor enteredinvalid yetsearch term';
}
},
maximumSelectionLength: 10, // Software limitation [[phab:T202776]]
minimumInputLength: 1, // prevent ajax call when empty
ajax: {
url: mw.util.wikiScript('api'),
dataType: 'json',
delay: 100,
data: function(params) {
var title = mw.Title.newFromText(params.term);
if (!title) {
return;
}
return {
'action': 'query',
'format': 'json',
'list': 'allpages',
'apfrom': title.title,
'apnamespace': title.namespace,
'aplimit': '10'
};
},
processResults: function(data) {
return {
results: data.query.allpages.map(function(page) {
var title = mw.Title.newFromText(page.title, page.ns).toText();
return {
id: title,
text: title
};
})
};
}
},
templateSelection: function(choice) {
return $('<a>').text(choice.text).attr({
href: mw.util.getUrl(choice.text),
target: '_blank'
});
}
});
Line 444 ⟶ 480:
$form.find('[name=namespacerestrictions]').select2({
width: '100%',
matcher: Morebits.select2.matchers.wordBeginning,
language: {
searching: Morebits.select2.queryInterceptor
Line 451 ⟶ 488:
});
 
// Reduce padding
mw.util.addCSS(
// prevent dropdown from appearing behind the dialog, just in case