MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus MitsuWiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „Das folgende JavaScript wird für alle Benutzer geladen.: /////////////////////// // Table Filter/Sort // /////////////////////// // specific to http://…“)
Zeile 80: Zeile 80:
     initCollapsebox(); //collapsible parts  
     initCollapsebox(); //collapsible parts  
// </source>
// </source>
/* booktable as in (scientific) books/journals */
table.booktable, table.booktabledotted {
    margin: 1em 1em 1em 0;
    background: #ffffff;
    border-top:    2px #656463 solid;
    border-bottom: 2px #656463 solid;
    border-collapse: collapse;
.booktabledotted td {
  border-bottom: 1px dotted gray;
.booktable td {
  border: 0px none !important;
.booktable tr.line-t td, .booktable tr td.line-t{
  border-top:    1px #656463 solid !important;
.booktable tr.line-b td, .booktable tr td.line-b{
  border-bottom:    1px #656463 solid !important;
.booktable tr.line-tb td, .booktable tr td.line-tb{
  border-bottom:    1px #656463 solid !important;
  border-top:    1px #656463 solid !important;
.booktabledotted th, .booktable th {
    border-bottom:1px solid #656463;
    border-top:  1px solid #656463;
    padding: 0.2em;
.booktabledotted th, .booktable th {
  background: #ffffff;
  text-align: center;
.booktable caption, .booktabledotted caption {
    font-weight: normal;

Version vom 9. Januar 2013, 13:49 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */

// Table Filter/Sort //
// specific to
// TODO ?replace by jQuery plugin datatable?
function initTableFilterSort(){ // see MediaWiki:SortTableFilter.js
/* Note: problem is auto-inserted <tbody></tbody> by the browser: must be removed and
   replaced by thead + tbody. jQuery.unwrap() was not successful */
   // add possibly more classes from
  // Note: only applies to non-nested tables
  var jAutotables = $('table.table-autosort, table.table-autofilter, table-autostripe,table-sorted-asc,table-sorted-desc, table-filtered');
  if (jAutotables.length) {
    // Note: in MediaWiki:SortTableFilter.js 'InputFilterTitle' was not recognized
    $.extend(true, $.jI18n, {
    en: {
      AutoSortTitle : 'Click to sort',
      FilterAllLabel: 'Filter: All',
      InputFilterTitle: 'Filter text (case sensitive, uses reg. expressions)'
    de: {
      AutoSortTitle : 'Zum Sortieren klicken',
      FilterAllLabel: 'Zeige: alle',
      InputFilterTitle: 'Text filtern (GROß/klein!, nutzt reg. Ausdrücke)'
    // get sortable/filterable here already otherwise multiple th-filters
    $.getScript(mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' ) + "?title=MediaWiki:SortTableFilter.js&action=raw&ctype=text/javascript",
      function(){return true;});
    // modify tables to introduce thead structure
    jAutotables.each(function(index){ //TODO simplify code? if()…
      // There may or may not be a tbody around tr. NOTE: $.unwrap() does not work here!
      // Memo: find('tr th') finds th, .parent() retrieves tr! .wrapAll will wrap inside DOM, not in return value! .detach() returns detached
      // OK in FF 3.6 and IE 7-8, not in IE6 (like the old code)
      // FURTHER WORK: Ideally, all normal tr td should remain in a tbody.
      var jThis = $(this),
        jThead = jThis.find('tr th').parent().detach(),
        jTfoot = jThis.find('tr[class=tfoot] td').parent().detach(),// remove it from the DOM
        jTbody = jThis.find('tbody:first');
      if (jTbody.length===0) {
        jTbody = jThis.find('tbody:first');
      if (jTfoot.length) {
      // th with class="input" gives an input field instead of selections
      $(this).find('th[class=input]').append('<input name="filter" title="'+$.resource('InputFilterTitle')+'" size="8" onkeyup="Table.filter(this,this)">');
    });// end each()
  } // END if any autotable

   mediaWiki.loader.state({"site":"ready"}); is appended and takes care of
   the document ready event. If $(document).ready() is used, for forms
   $ is then unknown. Scope or closure problem? (AP 2011-02-20)
// When document is completely loaded
$(document).ready(function() {
  initTargetHighlighting(); // page-internal jumps
  initmoveTOC(); // TOC CSS position fixed or static
  // specific to
    initTableFilterSort(); // tests internally whether table with corresponding classes exist 
}); // end $(document).ready()
  // ***** CAN initCollapseButtons BE DELETED?
  // initCollapseButtons(); // strongly changes page layout: execute first
  // page specific
  if(mw.config.get( 'wgAction' )==="formedit" || mw.config.get( 'wgCanonicalSpecialPageName' )==="FormEdit"){
   // initConfirmDeleteSubform();
  // specific to
    initCollapsebox(); //collapsible parts 
// </source>