MediaWiki:Common.js: verschil tussen versies
Uit Auditpedia
(12 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 3: | Regel 3: | ||
// take every link-captioned image and change the link to the link in the caption, if present | // take every link-captioned image and change the link to the link in the caption, if present | ||
$( document ).ready(function() { | $( 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 | + | // check for visualeditor textareas -- alter VE4all behaviour |
− | + | var vetextarea = document.querySelector('.ve-area-wrapper'); | |
− | var vetextarea = document. | ||
if ( vetextarea ) { | if ( vetextarea ) { | ||
− | + | ||
− | + | // Disable 'my own work' buttons | |
− | + | mw.loader.using([ | |
− | + | "mediawiki.ForeignStructuredUpload.BookletLayout", | |
− | // | + | "mediawiki.widgets", |
− | var | + | ]).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 | ||
+ | |||
+ | //load veforall | ||
+ | var api = new mw.Api(); | ||
+ | api.loadMessagesIfMissing( ['ve-cite'] ); | ||
+ | mw.loader.using( ['ext.veforall.main','ext.cite.visualEditor',''] ).then(function(data){ | ||
+ | console.log("VE modules loaded!"); | ||
}); | }); | ||
− | + | } |
Huidige versie van 16 mei 2022 om 14:02
/* 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 -- alter VE4all behaviour
var vetextarea = document.querySelector('.ve-area-wrapper');
if ( vetextarea ) {
// 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
//load veforall
var api = new mw.Api();
api.loadMessagesIfMissing( ['ve-cite'] );
mw.loader.using( ['ext.veforall.main','ext.cite.visualEditor',''] ).then(function(data){
console.log("VE modules loaded!");
});
}