「MediaWiki:Common.js/edit.js」の版間の差分
(ページの作成:「→Any JavaScript here will be loaded for all users on edit page load.: $(function() { $(".mw-summary-preset-item a").closest('.oo-ui-fieldLayout-header').width($('...」) |
|||
1行目: | 1行目: | ||
/* Any JavaScript here will be loaded for all users on edit page load. */ | /* Any JavaScript here will be loaded for all users on edit page load. */ | ||
$(function() { | $(function() { | ||
− | $(".mw-summary-preset-item a").closest('.oo-ui-fieldLayout-header').width($('#wpSummary').width()); | + | var tcBtn = document.getElementById("TencentCaptcha"); |
+ | if (tcBtn) { | ||
+ | var wpCaptchaWord = document.getElementById("wpCaptchaWord"); | ||
+ | var wpCaptchaId = document.getElementById("wpCaptchaId"); | ||
+ | var c; | ||
+ | c = setInterval(function() { | ||
+ | if (typeof window.TencentCaptcha === "function") { | ||
+ | clearInterval(c); | ||
+ | new TencentCaptcha(document.getElementById("TencentCaptcha")); | ||
+ | } | ||
+ | }, 100); | ||
+ | document.getElementById("wpSave").addEventListener("click", function(e) { | ||
+ | if (!wpCaptchaWord.value || !wpCaptchaId.value) { | ||
+ | alert("ボタンをクリックして検証を完成させてから提出してください"); | ||
+ | e.preventDefault(); | ||
+ | e.stopImmediatePropagation(); | ||
+ | e.stopPropagation(); | ||
+ | } | ||
+ | }, { | ||
+ | capture: true | ||
+ | }); | ||
+ | } | ||
+ | |||
+ | var wpSummary = $('[name="wpSummary"]'); | ||
+ | // $(".mw-summary-preset-item a").closest('.oo-ui-fieldLayout-header').width($('#wpSummary').width()); | ||
$(".mw-summary-preset-item a").on("click", function() { | $(".mw-summary-preset-item a").on("click", function() { | ||
− | + | wpSummary.val(wpSummary.val() + " " + $(this).text()); | |
+ | wpSummary.focus(); | ||
+ | return false; | ||
}); | }); | ||
− | // .wikiEditor-ui-controls | + | // .wikiEditor-ui-controls 颜色修正 |
$('.wikiEditor-ui-controls').css('background-color', $('#content').css('background-color')); | $('.wikiEditor-ui-controls').css('background-color', $('#content').css('background-color')); | ||
− | |||
− | |||
− | |||
// Customized File Insertion dialog | // Customized File Insertion dialog | ||
// Copyright 2017 The Little Moe New LLC. All rights reserved. | // Copyright 2017 The Little Moe New LLC. All rights reserved. | ||
− | mw.loader.using([ "oojs", "oojs-ui" ]).then(function() { | + | mw.loader.using(["oojs", "oojs-ui"]).then(function() { |
$("#wpTextbox1").on("wikiEditor-toolbar-doneInitialSections", function() { | $("#wpTextbox1").on("wikiEditor-toolbar-doneInitialSections", function() { | ||
function FileInsertionDialog(config) { | function FileInsertionDialog(config) { | ||
23行目: | 46行目: | ||
FileInsertionDialog.static.name = "fileInsertionDialog"; | FileInsertionDialog.static.name = "fileInsertionDialog"; | ||
FileInsertionDialog.static.title = mw.msg("wikieditor-toolbar-tool-file-title"); | FileInsertionDialog.static.title = mw.msg("wikieditor-toolbar-tool-file-title"); | ||
− | FileInsertionDialog.static.actions = [ { | + | FileInsertionDialog.static.actions = [{ |
− | flags:"primary", | + | flags: "primary", |
− | label:mw.msg("wikieditor-toolbar-tool-file-insert"), | + | label: mw.msg("wikieditor-toolbar-tool-file-insert"), |
− | action:"insert" | + | action: "insert" |
}, { | }, { | ||
− | flags:"safe", | + | flags: "safe", |
− | label:mw.msg("wikieditor-toolbar-tool-file-cancel") | + | label: mw.msg("wikieditor-toolbar-tool-file-cancel") |
− | } ]; | + | }]; |
// Initialization | // Initialization | ||
FileInsertionDialog.prototype.initialize = function() { | FileInsertionDialog.prototype.initialize = function() { | ||
FileInsertionDialog.super.prototype.initialize.call(this); | FileInsertionDialog.super.prototype.initialize.call(this); | ||
this.panel = new OO.ui.PanelLayout({ | this.panel = new OO.ui.PanelLayout({ | ||
− | padded:true, | + | padded: true, |
− | expanded:false | + | expanded: false |
}); | }); | ||
this.fileMetaContent = new OO.ui.FieldsetLayout(); | this.fileMetaContent = new OO.ui.FieldsetLayout(); | ||
42行目: | 65行目: | ||
this.formatContent = new OO.ui.FieldsetLayout(); | this.formatContent = new OO.ui.FieldsetLayout(); | ||
this.fileNameInput = new OO.ui.TextInputWidget({ | this.fileNameInput = new OO.ui.TextInputWidget({ | ||
− | indicator:"required" | + | indicator: "required" |
}); | }); | ||
this.fileNameField = new OO.ui.FieldLayout(this.fileNameInput, { | this.fileNameField = new OO.ui.FieldLayout(this.fileNameInput, { | ||
− | label:mw.msg("wikieditor-toolbar-file-target"), | + | label: mw.msg("wikieditor-toolbar-file-target"), |
− | align:"top" | + | align: "top" |
}); | }); | ||
this.fileTitleInput = new OO.ui.TextInputWidget(); | this.fileTitleInput = new OO.ui.TextInputWidget(); | ||
this.fileTitleField = new OO.ui.FieldLayout(this.fileTitleInput, { | this.fileTitleField = new OO.ui.FieldLayout(this.fileTitleInput, { | ||
− | label:mw.msg("wikieditor-toolbar-file-caption"), | + | label: mw.msg("wikieditor-toolbar-file-caption"), |
− | align:"top" | + | align: "top" |
}); | }); | ||
this.sizeInput = new OO.ui.TextInputWidget(); | this.sizeInput = new OO.ui.TextInputWidget(); | ||
this.sizeField = new OO.ui.FieldLayout(this.sizeInput, { | this.sizeField = new OO.ui.FieldLayout(this.sizeInput, { | ||
− | label:mw.msg("wikieditor-toolbar-file-size"), | + | label: mw.msg("wikieditor-toolbar-file-size"), |
− | align:"top" | + | align: "top" |
}); | }); | ||
− | this.fileMetaContent.addItems([ this.fileNameField, this.fileTitleField, this.sizeField ]); | + | this.fileMetaContent.addItems([this.fileNameField, this.fileTitleField, this.sizeField]); |
var alignOptionDefault = new OO.ui.ButtonOptionWidget({ | var alignOptionDefault = new OO.ui.ButtonOptionWidget({ | ||
− | data:"default", | + | data: "default", |
− | label:mw.msg("wikieditor-toolbar-file-default"), | + | label: mw.msg("wikieditor-toolbar-file-default"), |
− | title:mw.msg("wikieditor-toolbar-file-default") | + | title: mw.msg("wikieditor-toolbar-file-default") |
}); | }); | ||
var alignOptionNone = new OO.ui.ButtonOptionWidget({ | var alignOptionNone = new OO.ui.ButtonOptionWidget({ | ||
− | data:"none", | + | data: "none", |
− | label:mw.msg("wikieditor-toolbar-file-format-none"), | + | label: mw.msg("wikieditor-toolbar-file-format-none"), |
− | title:mw.msg("wikieditor-toolbar-file-format-none") | + | title: mw.msg("wikieditor-toolbar-file-format-none") |
}); | }); | ||
var magicWords = mw.config.get("wgWikiEditorMagicWords"); | var magicWords = mw.config.get("wgWikiEditorMagicWords"); | ||
var alignOptionMid = new OO.ui.ButtonOptionWidget({ | var alignOptionMid = new OO.ui.ButtonOptionWidget({ | ||
− | data:"center", | + | data: "center", |
− | label:magicWords.img_center, | + | label: magicWords.img_center, |
− | title:magicWords.img_center | + | title: magicWords.img_center |
}); | }); | ||
var alignOptionLeft = new OO.ui.ButtonOptionWidget({ | var alignOptionLeft = new OO.ui.ButtonOptionWidget({ | ||
− | data:"left", | + | data: "left", |
− | label:magicWords.img_left, | + | label: magicWords.img_left, |
− | title:magicWords.img_left | + | title: magicWords.img_left |
}); | }); | ||
var alignOptionRight = new OO.ui.ButtonOptionWidget({ | var alignOptionRight = new OO.ui.ButtonOptionWidget({ | ||
− | data:"right", | + | data: "right", |
− | label:magicWords.img_right, | + | label: magicWords.img_right, |
− | title:magicWords.img_right | + | title: magicWords.img_right |
}); | }); | ||
this.alignmentSelect = new OO.ui.ButtonSelectWidget({ | this.alignmentSelect = new OO.ui.ButtonSelectWidget({ | ||
− | items:[ alignOptionNone, alignOptionDefault, alignOptionMid, alignOptionLeft, alignOptionRight ] | + | items: [alignOptionNone, alignOptionDefault, alignOptionMid, alignOptionLeft, alignOptionRight] |
}); | }); | ||
this.alignmentField = new OO.ui.FieldLayout(this.alignmentSelect, { | this.alignmentField = new OO.ui.FieldLayout(this.alignmentSelect, { | ||
− | label:mw.msg("wikieditor-toolbar-file-float"), | + | label: mw.msg("wikieditor-toolbar-file-float"), |
− | align:"top" | + | align: "top" |
}); | }); | ||
− | this.alignmentContent.addItems([ this.alignmentField ]); | + | this.alignmentContent.addItems([this.alignmentField]); |
var formatOptionThumbnail = new OO.ui.ButtonOptionWidget({ | var formatOptionThumbnail = new OO.ui.ButtonOptionWidget({ | ||
− | data:"thumbnail", | + | data: "thumbnail", |
− | label:magicWords.img_thumbnail, | + | label: magicWords.img_thumbnail, |
− | title:magicWords.img_thumbnail | + | title: magicWords.img_thumbnail |
}); | }); | ||
var formatOptionFramed = new OO.ui.ButtonOptionWidget({ | var formatOptionFramed = new OO.ui.ButtonOptionWidget({ | ||
− | data:"framed", | + | data: "framed", |
− | label:magicWords.img_framed, | + | label: magicWords.img_framed, |
− | title:magicWords.img_framed | + | title: magicWords.img_framed |
}); | }); | ||
var formatOptionFrameless = new OO.ui.ButtonOptionWidget({ | var formatOptionFrameless = new OO.ui.ButtonOptionWidget({ | ||
− | data:"frameless", | + | data: "frameless", |
− | label:magicWords.img_frameless, | + | label: magicWords.img_frameless, |
− | title:magicWords.img_frameless | + | title: magicWords.img_frameless |
}); | }); | ||
var formatOptionNone = new OO.ui.ButtonOptionWidget({ | var formatOptionNone = new OO.ui.ButtonOptionWidget({ | ||
− | data:"default", | + | data: "default", |
− | label:magicWords.img_none, | + | label: magicWords.img_none, |
− | title:magicWords.img_none | + | title: magicWords.img_none |
}); | }); | ||
this.formatSelect = new OO.ui.ButtonSelectWidget({ | this.formatSelect = new OO.ui.ButtonSelectWidget({ | ||
− | items:[ formatOptionThumbnail, formatOptionFramed, formatOptionFrameless, formatOptionNone ] | + | items: [formatOptionThumbnail, formatOptionFramed, formatOptionFrameless, formatOptionNone] |
}); | }); | ||
this.formatField = new OO.ui.FieldLayout(this.formatSelect, { | this.formatField = new OO.ui.FieldLayout(this.formatSelect, { | ||
− | label:mw.msg("wikieditor-toolbar-file-format"), | + | label: mw.msg("wikieditor-toolbar-file-format"), |
− | align:"top" | + | align: "top" |
}); | }); | ||
− | this.formatContent.addItems([ this.formatField ]); | + | this.formatContent.addItems([this.formatField]); |
this.panel.$element.append(this.fileMetaContent.$element); | this.panel.$element.append(this.fileMetaContent.$element); | ||
this.panel.$element.append(this.alignmentContent.$element); | this.panel.$element.append(this.alignmentContent.$element); | ||
126行目: | 149行目: | ||
this.$body.append(this.panel.$element); | this.$body.append(this.panel.$element); | ||
this.fileNameInput.connect(this, { | this.fileNameInput.connect(this, { | ||
− | change:"onFileNameChange" | + | change: "onFileNameChange" |
}); | }); | ||
}; | }; | ||
136行目: | 159行目: | ||
FileInsertionDialog.prototype.onFileNameChange = function(value) { | FileInsertionDialog.prototype.onFileNameChange = function(value) { | ||
this.actions.setAbilities({ | this.actions.setAbilities({ | ||
− | insert:!!value.length | + | insert: !!value.length |
}); | }); | ||
}; | }; | ||
144行目: | 167行目: | ||
return FileInsertionDialog.super.prototype.getSetupProcess.call(this, data).next(function() { | return FileInsertionDialog.super.prototype.getSetupProcess.call(this, data).next(function() { | ||
this.actions.setAbilities({ | this.actions.setAbilities({ | ||
− | insert:false | + | insert: false |
}); | }); | ||
this.fileNameInput.setValue(""); | this.fileNameInput.setValue(""); | ||
170行目: | 193行目: | ||
FileInsertionDialog.prototype.insertImage = function() { | FileInsertionDialog.prototype.insertImage = function() { | ||
if (!this.editorContext) return; | if (!this.editorContext) return; | ||
− | var fileName, caption, fileFloat, fileFormat, fileSize, fileTitle, options, fileUse, hasPxRgx = /.+px$/, magicWordsI18N = mw.config.get("wgWikiEditorMagicWords"); | + | var fileName, caption, fileFloat, fileFormat, fileSize, fileTitle, options, fileUse, hasPxRgx = /.+px$/, |
+ | magicWordsI18N = mw.config.get("wgWikiEditorMagicWords"); | ||
fileName = this.fileNameInput.getValue(); | fileName = this.fileNameInput.getValue(); | ||
caption = this.fileTitleInput.getValue(); | caption = this.fileTitleInput.getValue(); | ||
188行目: | 212行目: | ||
fileName = fileTitle.toText(); | fileName = fileTitle.toText(); | ||
} | } | ||
− | options = [ fileSize, fileFormat, fileFloat ]; | + | options = [fileSize, fileFormat, fileFloat]; |
// Filter empty values | // Filter empty values | ||
options = $.grep(options, function(val) { | options = $.grep(options, function(val) { | ||
196行目: | 220行目: | ||
options.push(caption); | options.push(caption); | ||
} | } | ||
− | fileUse = options.length === 0 ? fileName :fileName + "|" + options.join("|"); | + | fileUse = options.length === 0 ? fileName : fileName + "|" + options.join("|"); |
$.wikiEditor.modules.toolbar.fn.doAction(this.editorContext, { | $.wikiEditor.modules.toolbar.fn.doAction(this.editorContext, { | ||
− | type:"replace", | + | type: "replace", |
− | options:{ | + | options: { |
− | pre:"[[", | + | pre: "[[", |
− | peri:fileUse, | + | peri: fileUse, |
− | post:"]]", | + | post: "]]", |
− | ownline:true | + | ownline: true |
} | } | ||
}); | }); | ||
210行目: | 234行目: | ||
// Remove legacy file insertion | // Remove legacy file insertion | ||
$("#wpTextbox1").wikiEditor("removeFromToolbar", { | $("#wpTextbox1").wikiEditor("removeFromToolbar", { | ||
− | section:"main", | + | section: "main", |
− | group:"insert", | + | group: "insert", |
− | tool:"file" | + | tool: "file" |
}); | }); | ||
$("#wpTextbox1").wikiEditor("addToToolbar", { | $("#wpTextbox1").wikiEditor("addToToolbar", { | ||
− | section:"main", | + | section: "main", |
− | group:"insert", | + | group: "insert", |
− | tools:{ | + | tools: { |
− | "file-alt":{ | + | "file-alt": { |
− | label:mw.msg("wikieditor-toolbar-tool-file-title"), | + | label: mw.msg("wikieditor-toolbar-tool-file-title"), |
− | type:"button", | + | type: "button", |
− | icon:" | + | icon: "https://img.moegirl.org.cn/common/3/3e/Insert-file.svg", |
− | offset:[ 2, -1438 ], | + | offset: [2, -1438], |
− | action:{ | + | action: { |
− | type:"callback", | + | type: "callback", |
− | execute:function(context) { | + | execute: function(context) { |
var windowManager = new OO.ui.WindowManager(); | var windowManager = new OO.ui.WindowManager(); | ||
$("body").append(windowManager.$element); | $("body").append(windowManager.$element); | ||
var fileInsertionDialog = new FileInsertionDialog(); | var fileInsertionDialog = new FileInsertionDialog(); | ||
fileInsertionDialog.setContext(context); | fileInsertionDialog.setContext(context); | ||
− | windowManager.addWindows([ fileInsertionDialog ]); | + | windowManager.addWindows([fileInsertionDialog]); |
windowManager.openWindow(fileInsertionDialog); | windowManager.openWindow(fileInsertionDialog); | ||
} | } |
2020年9月20日 (日) 18:02時点における最新版
/* Any JavaScript here will be loaded for all users on edit page load. */ $(function() { var tcBtn = document.getElementById("TencentCaptcha"); if (tcBtn) { var wpCaptchaWord = document.getElementById("wpCaptchaWord"); var wpCaptchaId = document.getElementById("wpCaptchaId"); var c; c = setInterval(function() { if (typeof window.TencentCaptcha === "function") { clearInterval(c); new TencentCaptcha(document.getElementById("TencentCaptcha")); } }, 100); document.getElementById("wpSave").addEventListener("click", function(e) { if (!wpCaptchaWord.value || !wpCaptchaId.value) { alert("ボタンをクリックして検証を完成させてから提出してください"); e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); } }, { capture: true }); } var wpSummary = $('[name="wpSummary"]'); // $(".mw-summary-preset-item a").closest('.oo-ui-fieldLayout-header').width($('#wpSummary').width()); $(".mw-summary-preset-item a").on("click", function() { wpSummary.val(wpSummary.val() + " " + $(this).text()); wpSummary.focus(); return false; }); // .wikiEditor-ui-controls 颜色修正 $('.wikiEditor-ui-controls').css('background-color', $('#content').css('background-color')); // Customized File Insertion dialog // Copyright 2017 The Little Moe New LLC. All rights reserved. mw.loader.using(["oojs", "oojs-ui"]).then(function() { $("#wpTextbox1").on("wikiEditor-toolbar-doneInitialSections", function() { function FileInsertionDialog(config) { FileInsertionDialog.super.call(this, config); } OO.inheritClass(FileInsertionDialog, OO.ui.ProcessDialog); // Name FileInsertionDialog.static.name = "fileInsertionDialog"; FileInsertionDialog.static.title = mw.msg("wikieditor-toolbar-tool-file-title"); FileInsertionDialog.static.actions = [{ flags: "primary", label: mw.msg("wikieditor-toolbar-tool-file-insert"), action: "insert" }, { flags: "safe", label: mw.msg("wikieditor-toolbar-tool-file-cancel") }]; // Initialization FileInsertionDialog.prototype.initialize = function() { FileInsertionDialog.super.prototype.initialize.call(this); this.panel = new OO.ui.PanelLayout({ padded: true, expanded: false }); this.fileMetaContent = new OO.ui.FieldsetLayout(); this.alignmentContent = new OO.ui.FieldsetLayout(); this.formatContent = new OO.ui.FieldsetLayout(); this.fileNameInput = new OO.ui.TextInputWidget({ indicator: "required" }); this.fileNameField = new OO.ui.FieldLayout(this.fileNameInput, { label: mw.msg("wikieditor-toolbar-file-target"), align: "top" }); this.fileTitleInput = new OO.ui.TextInputWidget(); this.fileTitleField = new OO.ui.FieldLayout(this.fileTitleInput, { label: mw.msg("wikieditor-toolbar-file-caption"), align: "top" }); this.sizeInput = new OO.ui.TextInputWidget(); this.sizeField = new OO.ui.FieldLayout(this.sizeInput, { label: mw.msg("wikieditor-toolbar-file-size"), align: "top" }); this.fileMetaContent.addItems([this.fileNameField, this.fileTitleField, this.sizeField]); var alignOptionDefault = new OO.ui.ButtonOptionWidget({ data: "default", label: mw.msg("wikieditor-toolbar-file-default"), title: mw.msg("wikieditor-toolbar-file-default") }); var alignOptionNone = new OO.ui.ButtonOptionWidget({ data: "none", label: mw.msg("wikieditor-toolbar-file-format-none"), title: mw.msg("wikieditor-toolbar-file-format-none") }); var magicWords = mw.config.get("wgWikiEditorMagicWords"); var alignOptionMid = new OO.ui.ButtonOptionWidget({ data: "center", label: magicWords.img_center, title: magicWords.img_center }); var alignOptionLeft = new OO.ui.ButtonOptionWidget({ data: "left", label: magicWords.img_left, title: magicWords.img_left }); var alignOptionRight = new OO.ui.ButtonOptionWidget({ data: "right", label: magicWords.img_right, title: magicWords.img_right }); this.alignmentSelect = new OO.ui.ButtonSelectWidget({ items: [alignOptionNone, alignOptionDefault, alignOptionMid, alignOptionLeft, alignOptionRight] }); this.alignmentField = new OO.ui.FieldLayout(this.alignmentSelect, { label: mw.msg("wikieditor-toolbar-file-float"), align: "top" }); this.alignmentContent.addItems([this.alignmentField]); var formatOptionThumbnail = new OO.ui.ButtonOptionWidget({ data: "thumbnail", label: magicWords.img_thumbnail, title: magicWords.img_thumbnail }); var formatOptionFramed = new OO.ui.ButtonOptionWidget({ data: "framed", label: magicWords.img_framed, title: magicWords.img_framed }); var formatOptionFrameless = new OO.ui.ButtonOptionWidget({ data: "frameless", label: magicWords.img_frameless, title: magicWords.img_frameless }); var formatOptionNone = new OO.ui.ButtonOptionWidget({ data: "default", label: magicWords.img_none, title: magicWords.img_none }); this.formatSelect = new OO.ui.ButtonSelectWidget({ items: [formatOptionThumbnail, formatOptionFramed, formatOptionFrameless, formatOptionNone] }); this.formatField = new OO.ui.FieldLayout(this.formatSelect, { label: mw.msg("wikieditor-toolbar-file-format"), align: "top" }); this.formatContent.addItems([this.formatField]); this.panel.$element.append(this.fileMetaContent.$element); this.panel.$element.append(this.alignmentContent.$element); this.panel.$element.append(this.formatContent.$element); this.$body.append(this.panel.$element); this.fileNameInput.connect(this, { change: "onFileNameChange" }); }; // Specify the dialog height (or don"t to use the automatically generated height). FileInsertionDialog.prototype.getBodyHeight = function() { return this.panel.$element.outerHeight(true); }; // Name validation FileInsertionDialog.prototype.onFileNameChange = function(value) { this.actions.setAbilities({ insert: !!value.length }); }; // Default state initialization FileInsertionDialog.prototype.getSetupProcess = function(data) { data = data || {}; return FileInsertionDialog.super.prototype.getSetupProcess.call(this, data).next(function() { this.actions.setAbilities({ insert: false }); this.fileNameInput.setValue(""); this.fileTitleInput.setValue(""); this.sizeInput.setValue(""); this.alignmentSelect.selectItemByData("default"); this.formatSelect.selectItemByData("thumbnail"); }, this); }; // Context setup FileInsertionDialog.prototype.setContext = function(context) { this.editorContext = context; }; // Specify processes to handle the actions. FileInsertionDialog.prototype.getActionProcess = function(action) { if (action === "insert") { return new OO.ui.Process(function() { this.insertImage(); }, this); } // Fallback to parent handler return FileInsertionDialog.super.prototype.getActionProcess.call(this, action); }; // Handles image insertion. FileInsertionDialog.prototype.insertImage = function() { if (!this.editorContext) return; var fileName, caption, fileFloat, fileFormat, fileSize, fileTitle, options, fileUse, hasPxRgx = /.+px$/, magicWordsI18N = mw.config.get("wgWikiEditorMagicWords"); fileName = this.fileNameInput.getValue(); caption = this.fileTitleInput.getValue(); fileSize = this.sizeInput.getValue(); fileFloat = this.alignmentSelect.getSelectedItem().data; fileFormat = this.formatSelect.getSelectedItem().data; // Append px to end to size if not already contains it if (fileSize !== "" && !hasPxRgx.test(fileSize)) { fileSize += "px"; } if (fileName !== "") { fileTitle = new mw.Title(fileName); // Append file namespace prefix to filename if not already contains it if (fileTitle.getNamespaceId() !== 6) { fileTitle = new mw.Title(fileName, 6); } fileName = fileTitle.toText(); } options = [fileSize, fileFormat, fileFloat]; // Filter empty values options = $.grep(options, function(val) { return val.length && val !== "default"; }); if (caption.length) { options.push(caption); } fileUse = options.length === 0 ? fileName : fileName + "|" + options.join("|"); $.wikiEditor.modules.toolbar.fn.doAction(this.editorContext, { type: "replace", options: { pre: "[[", peri: fileUse, post: "]]", ownline: true } }); this.close(); }; // Remove legacy file insertion $("#wpTextbox1").wikiEditor("removeFromToolbar", { section: "main", group: "insert", tool: "file" }); $("#wpTextbox1").wikiEditor("addToToolbar", { section: "main", group: "insert", tools: { "file-alt": { label: mw.msg("wikieditor-toolbar-tool-file-title"), type: "button", icon: "https://img.moegirl.org.cn/common/3/3e/Insert-file.svg", offset: [2, -1438], action: { type: "callback", execute: function(context) { var windowManager = new OO.ui.WindowManager(); $("body").append(windowManager.$element); var fileInsertionDialog = new FileInsertionDialog(); fileInsertionDialog.setContext(context); windowManager.addWindows([fileInsertionDialog]); windowManager.openWindow(fileInsertionDialog); } } } } }); }); }); });