Skip to content

Commit

Permalink
protect: sanitized-css: don't tick <noinclude> check box (#1637)
Browse files Browse the repository at this point in the history
* sanitized-css: don't tick <noinclude> check box

* refactor based on code review suggestion

Co-authored-by: Siddharth VP <siddharthvp@gmail.com>

* fix

* Morebits.pageNameNorm.startsWith

* Morebits.pageNameNorm.startsWith

* includes()

---------

Co-authored-by: Siddharth VP <siddharthvp@gmail.com>
  • Loading branch information
NovemLinguae and siddharthvp committed Jul 20, 2023
1 parent d9520e8 commit f090f1e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/twinkleprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ Twinkle.protect.callback.changeAction = function twinkleprotectCallbackChangeAct
list: Twinkle.protect.protectionTags,
event: Twinkle.protect.formevents.tagtype
});

var isTemplateNamespace = mw.config.get('wgNamespaceNumber') === 10;
var isAFD = Morebits.pageNameNorm.startsWith('Wikipedia:Articles for deletion/');
var isCode = ['javascript', 'css', 'sanitized-css'].includes(mw.config.get('wgPageContentModel'));
field1.append({
type: 'checkbox',
list: [
Expand All @@ -530,7 +534,7 @@ Twinkle.protect.callback.changeAction = function twinkleprotectCallbackChangeAct
name: 'noinclude',
label: 'Wrap protection template with &lt;noinclude&gt;',
tooltip: 'Will wrap the protection template in &lt;noinclude&gt; tags, so that it won\'t transclude',
checked: mw.config.get('wgNamespaceNumber') === 10 || (mw.config.get('wgNamespaceNumber') === mw.config.get('wgNamespaceIds').project && mw.config.get('wgTitle').indexOf('Articles for deletion/') === 0)
checked: (isTemplateNamespace || isAFD) && !isCode
}
]
});
Expand Down Expand Up @@ -1079,11 +1083,12 @@ Twinkle.protect.callback.changePreset = function twinkleprotectCallbackChangePre

// Default settings for adding <noinclude> tags to protection templates
var isTemplateEditorProtection = form.category.value === 'pp-template';
var isAFD = mw.config.get('wgNamespaceNumber') === mw.config.get('wgNamespaceIds').project && mw.config.get('wgTitle').indexOf('Articles for deletion/') === 0;
var isAFD = Morebits.pageNameNorm.startsWith('Wikipedia:Articles for deletion/');
var isNotTemplateNamespace = mw.config.get('wgNamespaceNumber') !== 10;
if (isTemplateEditorProtection || isAFD) {
var isCode = ['javascript', 'css', 'sanitized-css'].includes(mw.config.get('wgPageContentModel'));
if ((isTemplateEditorProtection || isAFD) && !isCode) {
form.noinclude.checked = true;
} else if (isNotTemplateNamespace) {
} else if (isCode || isNotTemplateNamespace) {
form.noinclude.checked = false;
}
}
Expand Down

0 comments on commit f090f1e

Please sign in to comment.