“User:Bhsd/edit.js”的版本间差异

添加13字节 、​ 2020年12月13日 (日) 05:05
无编辑摘要
contentmodel = mw.config.get( 'wgPageContentModel' ),
skin = mw.config.get('skin');
 
// 修改WikiEditor的替换文本框
if (['edit', 'submit'].includes( action ) && skin == 'vector') {
$('body').on('click', 'input#wikieditor-toolbar-replace-replace', function() {
$(this).replaceWith( $('<textarea>', {id: "wikieditor-toolbar-replace-replace", tabindex:10})
.on('keydown keypress', e => { if (e.keyCode == '13') { e.stopPropagation(); } }) );
});
}
 
// 引自[[moegirl:User:東東君/js/Wikiplus-replace.js]]
const states = ['readyloading', 'loaded', 'executing', 'ready'];
if (action == 'view' && mw.config.get( 'wgIsArticle' ) && mw.config.get( 'wgIsProbablyEditable' ) &&
(states.includes( mw.loader.getState( 'ext.gadget.Wikiplus' ) ) ||
'<label>查找:<input type="text" id="quickEdit-replace-pattern"></label>' +
'<label>替换:<textarea id="quickEdit-replace-val"></textarea></label>' +
'<label><input id="quickEdit-replace-regex"><input type="checkbox">正则</label>' +
'<button id="quickEdit-replace_replaceBtn">替换</button>' +
'<button id="quickEdit-replace_undoBtn" disabled="true">撤销</button>' +
const ptn = $( '#quickEdit-replace-pattern' ).val(),
value = $( '#quickEdit-replace-val' ).val(),
isRegex = $( '#quickEdit-replace-regex input' ).prop( 'checked' );
backup = textarea.val();
$( '#quickEdit-replace_undoBtn' ).prop('disabled', false);
/* JavaScript编辑界面按tab键空4格 */
if (contentmodel == 'javascript' && skin == 'vector' && ['view', 'edit', 'submit'].includes(action)) {
mw.loader.using( 'jquery.textSelection' ).then(() => {
$('body').on('keydown', '#wpTextbox1, #Wikiplus-Quickedit', function(e) {
}
 
if (['edit', 'submit'].includes( action )) {
// 修改WikiEditor的替换文本框
if (['edit', 'submit'].includes( action ) &&if (skin == 'vector') {
$('body').on('click', 'input#wikieditor-toolbar-replace-replace', function() {
$(this).replaceWith( $('<textarea>', {id: "wikieditor-toolbar-replace-replace", tabindex:10})
.on('keydown keypress', e => { if (e.keyCode == '13') { e.stopPropagation(); } }) );
});
});
 
// 修改templateSandbox的默认页面
$('body').on('click', '#wpTemplateSandboxPreview', () => {
$( 'input[name=wpTemplateSandboxPage]' ).val(function() {
const namespaces = mw.config.get( 'wgFormattedNamespaces' ),
ns = mw.config.get( 'wgNamespaceNumber' ),;
return $(this).val() || (namespaces[ns] title+ (ns === 0 ? '' : ':') + mw.config.get('wgTitle'));
return $(this).val() || (namespaces[ns] + (ns === 0 ? '' : ':') + title);
});
});
 
// JS统一使用4个空格缩进
if (contentmodel == 'javascript') {
// JS统一使用4个空格缩进
const btns = '#wpSaveWidget, #wpPreviewWidget, #wpDiffWidget, #wpTemplateSandboxPreview';
$('body').on('click', btns, () => {
16,874

个编辑