« MediaWiki:DataTables.js » : différence entre les versions

De Mouvement Arbre-Évolution
Aller à :navigation, rechercher
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 11 : Ligne 11 :
         $content.find('.datatable:not(.datatable-loaded)').each(function() {
         $content.find('.datatable:not(.datatable-loaded)').each(function() {
         language: {
         language: {
     info: 'Showing page _PAGE_ of _PAGES_',
     info: 'Showing page _PAGE_ of _PAGES_'}
        infoEmpty: 'No records available',
       
    infoFiltered: '(filtered from _MAX_ total records)',
    lengthMenu: 'Display _MENU_ records per page',
    zeroRecords: 'Nothing found - sorry'
};
             var $table = $(this).addClass('datatable-loaded'),
             var $table = $(this).addClass('datatable-loaded'),
                 $tableHeader = $('<thead>');
                 $tableHeader = $('<thead>');

Version du 10 juin 2024 à 22:22

/**
 * Name:        DataTables.js
 * Author:      KockaAdmiralac <wikia@kocka.tech>
 * Description: Loads CSS and JavaScript from https://datatables.net and
 *              initializes all tables with the `datatable` class as data tables
 */
(function($, mw) {
    'use strict';
    var initialized = false, queue = [];
    function process($content) {
        $content.find('.datatable:not(.datatable-loaded)').each(function() {
        	language: {
    		 info: 'Showing page _PAGE_ of _PAGES_'}
        
            var $table = $(this).addClass('datatable-loaded'),
                $tableHeader = $('<thead>');
            $table.prepend($tableHeader);
            $table.find('> tbody > tr').first().appendTo($tableHeader);
            $table.DataTable();
        });
    }
    function initialize($content) {
        if (initialized) {
            process($content);
        } else {
            queue.push($content);
        }
    }
    mw.loader.load('https://cdn.datatables.net/v/dt/dt-1.12.0/b-2.2.3/b-colvis-2.2.3/date-1.1.2/fc-4.1.0/r-2.3.0/rg-1.2.0/sc-2.0.6/sp-2.0.1/sl-1.4.0/datatables.css', 'text/css');
    mw.loader.getScript('https://cdn.datatables.net/v/dt/dt-1.12.0/b-2.2.3/b-colvis-2.2.3/date-1.1.2/fc-4.1.0/r-2.3.0/rg-1.2.0/sc-2.0.6/sp-2.0.1/sl-1.4.0/datatables.js').then(function() {
        initialized = true;
        queue.forEach(process);
    });
    mw.hook('wikipage.content').add(initialize);
    mw.hook('datatables.loaded').fire();
})(jQuery, mediaWiki);