Jump to content

MediaWiki:Common.js: Difference between revisions

From TwainFrame
No edit summary
No edit summary
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
/* Das folgende JavaScript wird für alle Benutzer geladen. */
// DataTables CSS laden
// Lade Fotorama CSS und JS von CDN und initialisiere Galerie
mw.loader.load('https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css', 'text/css');
mw.loader.using(['mediawiki.util', 'jquery'], function () {
  // Fotorama CSS
  var css = document.createElement('link');
  css.rel = 'stylesheet';
  css.href = 'https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.css';
  document.head.appendChild(css);


  // Fotorama JS laden und nach dem Laden initieren
// DataTables JS laden und initialisieren
  var script = document.createElement('script');
mw.loader.getScript('https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js')
  script.src = 'https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.js';
   .then(function () {
   script.onload = function () {
     $(function () {
     jQuery('.fotorama').fotorama();
      var table = $('#example');
  };
 
  document.head.appendChild(script);
      if (table.length) {
});
        // Füge zusätzliche Kopfzeile mit Input-Feldern hinzu
        $('#example thead').append('<tr></tr>');
        $('#example thead tr:eq(0) th').each(function () {
          var title = $(this).text();
          $('#example thead tr:eq(1)').append('<th><input type="text" placeholder="Suche ' + title + '" /></th>');
        });
 
        // DataTable initialisieren
        var dataTable = table.DataTable();
 
        // Spaltensuche aktivieren
        dataTable.columns().every(function () {
          var that = this;
          $('input', this.header()).on('keyup change clear', function () {
            if (that.search() !== this.value) {
              that.search(this.value).draw();
            }
          });
        });
      }
    });
  });
 
/* Move Edittools directly below the edit field. */
mw.loader.load("https://twainframe.org/index.php?title=MediaWiki:MoveEdittools.js&action=raw&ctype=text/javascript");

Latest revision as of 16:09, 25 June 2025

// DataTables CSS laden
mw.loader.load('https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css', 'text/css');

// DataTables JS laden und initialisieren
mw.loader.getScript('https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js')
  .then(function () {
    $(function () {
      var table = $('#example');

      if (table.length) {
        // Füge zusätzliche Kopfzeile mit Input-Feldern hinzu
        $('#example thead').append('<tr></tr>');
        $('#example thead tr:eq(0) th').each(function () {
          var title = $(this).text();
          $('#example thead tr:eq(1)').append('<th><input type="text" placeholder="Suche ' + title + '" /></th>');
        });

        // DataTable initialisieren
        var dataTable = table.DataTable();

        // Spaltensuche aktivieren
        dataTable.columns().every(function () {
          var that = this;
          $('input', this.header()).on('keyup change clear', function () {
            if (that.search() !== this.value) {
              that.search(this.value).draw();
            }
          });
        });
      }
    });
  });

/* Move Edittools directly below the edit field. */
mw.loader.load("https://twainframe.org/index.php?title=MediaWiki:MoveEdittools.js&action=raw&ctype=text/javascript");