MediaWiki:Common.js: verschil tussen versies
Uit Auditpedia
Regel 22: | Regel 22: | ||
} | } | ||
− | /** | + | // Disable 'my own work' buttons |
− | + | mw.loader.using([ | |
− | + | "mediawiki.ForeignStructuredUpload.BookletLayout", | |
− | + | "mediawiki.widgets", | |
− | + | ]).then(function () { | |
+ | /** | ||
+ | * Removes validation for own work checkbox | ||
+ | * | ||
+ | * @method overrides mw.ForeignStructuredUpload.BookletLayout.prototype.onUploadFormChange | ||
+ | */ | ||
− | mw.ForeignStructuredUpload.BookletLayout.prototype.onUploadFormChange = | + | mw.ForeignStructuredUpload.BookletLayout.prototype.onUploadFormChange = |
− | function () { | + | function () { |
− | + | var file = this.selectFileWidget.getValue(); | |
− | + | var valid = !!file; // && ownWork; | |
− | + | this.emit("uploadValid", valid); | |
− | }; | + | }; |
− | /** | + | /** |
− | + | * Removes own work checkbox en notices | |
− | + | * | |
− | + | * @method overrides mw.ForeignStructuredUpload.BookletLayout.prototype.renderUploadForm | |
− | + | */ | |
− | mw.ForeignStructuredUpload.BookletLayout.prototype.renderUploadForm = | + | mw.ForeignStructuredUpload.BookletLayout.prototype.renderUploadForm = |
− | function () { | + | function () { |
− | + | var fieldset, | |
− | + | layout = this; | |
− | + | this.$ownWorkMessage = $("<p>"); | |
− | + | this.$notOwnWorkMessage = $("<p>"); | |
− | + | this.$notOwnWorkLocal = $("<p>"); | |
− | + | this.selectFileWidget = new OO.ui.SelectFileWidget({ | |
− | + | showDropTarget: true, | |
− | + | }); | |
− | + | this.messageLabel = new OO.ui.LabelWidget({ | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
label: "", | label: "", | ||
− | + | }); | |
− | + | this.ownWorkCheckbox = new OO.ui.CheckboxInputWidget().on( | |
− | + | "change", | |
− | + | function (on) { | |
− | + | layout.messageLabel.toggle(!on); | |
− | + | } | |
+ | ); | ||
− | + | fieldset = new OO.ui.FieldsetLayout(); | |
− | + | fieldset.addItems([ | |
− | + | new OO.ui.FieldLayout(this.selectFileWidget, { | |
− | + | align: "top", | |
− | + | }), | |
− | + | new OO.ui.FieldLayout(this.ownWorkCheckbox, { | |
+ | align: "inline", | ||
+ | label: "", | ||
+ | }), | ||
+ | new OO.ui.FieldLayout(this.messageLabel, { | ||
+ | align: "top", | ||
+ | }), | ||
+ | ]); | ||
+ | this.uploadForm = new OO.ui.FormLayout({ items: [fieldset] }); | ||
− | + | // Validation | |
− | + | this.selectFileWidget.on( | |
− | + | "change", | |
− | + | this.onUploadFormChange.bind(this) | |
+ | ); | ||
+ | this.ownWorkCheckbox.on("change", this.onUploadFormChange.bind(this)); | ||
− | + | // hide ownWork | |
− | + | this.ownWorkCheckbox.$element.hide(); | |
− | + | this.selectFileWidget.on("change", function () { | |
− | + | var file = layout.getFile(); | |
− | + | // Set the date to lastModified once we have the file | |
− | + | if (layout.getDateFromLastModified(file) !== undefined) { | |
− | + | layout.dateWidget.setValue(layout.getDateFromLastModified(file)); | |
− | + | } | |
− | + | // Check if we have EXIF data and set to that where available | |
− | + | layout.getDateFromExif(file).done(function (date) { | |
+ | layout.dateWidget.setValue(date); | ||
+ | }); | ||
− | + | layout.updateFilePreview(); | |
− | }; | + | }); |
− | + | return this.uploadForm; | |
− | + | }; | |
− | + | }); | |
− | + | // end of disable 'my own work' buttons | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Versie van 16 mei 2022 13:37
/* Any JavaScript here will be loaded for all users on every page load. <script>*/
// take every link-captioned image and change the link to the link in the caption, if present
$( document ).ready(function() {
$('#mw-content-text div.thumb a.image').each(function() {
var link = $(this).closest('.thumb').find('div.thumbcaption a');
if (link.length ) {
var url = link[link.length-1].href;
this.href = url;
};
});
});
// check for visualeditor textareas
var vetextarea = document.querySelector('.ve-area-wrapper');
if ( vetextarea ) {
//load veforall
new mw.Api().loadMessagesIfMissing( ['ve-cite'] );
mw.loader.using( ['ext.veforall.main','ext.cite.visualEditor',''] ).then(function(data){
console.log("VE modules loaded!");
});
}
// Disable 'my own work' buttons
mw.loader.using([
"mediawiki.ForeignStructuredUpload.BookletLayout",
"mediawiki.widgets",
]).then(function () {
/**
* Removes validation for own work checkbox
*
* @method overrides mw.ForeignStructuredUpload.BookletLayout.prototype.onUploadFormChange
*/
mw.ForeignStructuredUpload.BookletLayout.prototype.onUploadFormChange =
function () {
var file = this.selectFileWidget.getValue();
var valid = !!file; // && ownWork;
this.emit("uploadValid", valid);
};
/**
* Removes own work checkbox en notices
*
* @method overrides mw.ForeignStructuredUpload.BookletLayout.prototype.renderUploadForm
*/
mw.ForeignStructuredUpload.BookletLayout.prototype.renderUploadForm =
function () {
var fieldset,
layout = this;
this.$ownWorkMessage = $("<p>");
this.$notOwnWorkMessage = $("<p>");
this.$notOwnWorkLocal = $("<p>");
this.selectFileWidget = new OO.ui.SelectFileWidget({
showDropTarget: true,
});
this.messageLabel = new OO.ui.LabelWidget({
label: "",
});
this.ownWorkCheckbox = new OO.ui.CheckboxInputWidget().on(
"change",
function (on) {
layout.messageLabel.toggle(!on);
}
);
fieldset = new OO.ui.FieldsetLayout();
fieldset.addItems([
new OO.ui.FieldLayout(this.selectFileWidget, {
align: "top",
}),
new OO.ui.FieldLayout(this.ownWorkCheckbox, {
align: "inline",
label: "",
}),
new OO.ui.FieldLayout(this.messageLabel, {
align: "top",
}),
]);
this.uploadForm = new OO.ui.FormLayout({ items: [fieldset] });
// Validation
this.selectFileWidget.on(
"change",
this.onUploadFormChange.bind(this)
);
this.ownWorkCheckbox.on("change", this.onUploadFormChange.bind(this));
// hide ownWork
this.ownWorkCheckbox.$element.hide();
this.selectFileWidget.on("change", function () {
var file = layout.getFile();
// Set the date to lastModified once we have the file
if (layout.getDateFromLastModified(file) !== undefined) {
layout.dateWidget.setValue(layout.getDateFromLastModified(file));
}
// Check if we have EXIF data and set to that where available
layout.getDateFromExif(file).done(function (date) {
layout.dateWidget.setValue(date);
});
layout.updateFilePreview();
});
return this.uploadForm;
};
});
// end of disable 'my own work' buttons