MediaWiki:Common.js

Uit Auditpedia
Versie door Admin (overleg | bijdragen) op 16 mei 2022 om 12:37
Ga naar:navigatie, zoeken

Opmerking: nadat u de wijzigingen hebt opgeslagen is het wellicht nodig uw browsercache te legen.

  • Firefox / Safari: houd Shift ingedrukt terwijl u op Vernieuwen klikt of druk op Ctrl-F5 of Ctrl-R (⌘-Shift-R op een Mac)
  • Google Chrome: druk op Ctrl-Shift-R (⌘-Shift-R op een Mac)
  • Internet Explorer: houd Ctrl ingedrukt terwijl u op Vernieuwen klikt of druk op Ctrl-F5
  • Opera: ga naar Menu → Instellingen (Opera → Voorkeuren op een Mac) en daarna naar Privacy & beveiliging → Browsegegevens wissen... → Tijdelijk opgeslagen afbeeldingen en bestanden.
/* 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