Jump to content

MediaWiki:Common.js: Difference between revisions

Jehan (talk | contribs)
No edit summary
Jehan (talk | contribs)
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 41: Line 41:
     var Tables = document.getElementsByTagName( 'table' );
     var Tables = document.getElementsByTagName( 'table' );
var linkTable = document.getElementById( 'linkTable');
var linkTable = document.getElementById( 'linkTable');
var linkRows = linkTable.getElementsByTagName( 'tr' );
if ( linkTable ) var linkRows = linkTable.getElementsByTagName( 'tr' );
     var i, j;
     var i, j;
Line 49: Line 49:
     }
     }
     for ( i = 0; i < linkRows.length; i++ ) {
     if ( linkRows ) {
var linkRow = linkRows[i];
for ( i = 0; i < linkRows.length; i++ ) {
if ( !linkRow ) continue;
var linkRow = linkRows[i];
var linkCells = linkRow.getElementsByTagName( 'th' );
if ( !linkRow ) continue;
if ( !linkCells ) continue;
var linkCells = linkRow.getElementsByTagName( 'th' );
for ( j = 0; j < linkCells.length; j++ ) {
if ( !linkCells ) continue;
var linkCell = linkCells[j];
for ( j = 0; j < linkCells.length; j++ ) {
if ( !linkCell ) continue;
var linkCell = linkCells[j];
if ( $( linkCell ).hasClass( 'hideImage' ) )            /* add id attribute */
if ( !linkCell ) continue;
linkCell.setAttribute( 'id', 'hideImage' + tableIndex++ );
if ( $( linkCell ).hasClass( 'hideImage' ) )            /* add id attribute */
linkCell.setAttribute( 'id', 'hideImage' + tableIndex++ );
}
}
}
}
tableIndex = 0;
tableIndex = 0;
j=0;
j=0;
    for ( i = 0; i < Tables.length; i++ ) {
for ( i = 0; i < Tables.length; i++ ) {
        if ( $( Tables[i] ).hasClass( 'hideable' ) ) {
if ( $( Tables[i] ).hasClass( 'hideable' ) ) {
            /* only add button and increment count if there is a header row to work with */
/* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
            if ( !HeaderRow ) continue;
if ( !HeaderRow ) continue;
            var Header = HeaderRow.getElementsByTagName( 'th' )[0];
var Header = HeaderRow.getElementsByTagName( 'th' )[0];
var linkImage = document.getElementById( 'hideImage' + j++ );;
var linkImage = document.getElementById( 'hideImage' + j++ );;
            if ( !Header ) continue;
if ( !Header ) continue;
            NavigationBoxes[ tableIndex ] = Tables[i];
NavigationBoxes[ tableIndex ] = Tables[i];
            Tables[i].setAttribute( 'id', 'hideableTable' + tableIndex );
Tables[i].setAttribute( 'id', 'hideableTable' + tableIndex );
            var Button    = document.createElement( 'span' );
if ( 0 ) {
            var ButtonLink = document.createElement( 'a' );
                                    $( linkImage ).on( 'click', $.proxy( handlelinkImage, linkImage , tableIndex ) );
            var ButtonText = document.createTextNode( expandCaption );
                                }
if ( 1 ) {
            Button.className = 'hideButton';  /* Styles are declared in Common.css */
                                    var Button    = document.createElement( 'span' );
    var ButtonLink = document.createElement( 'a' );
            ButtonLink.style.color = Header.style.color;
    var ButtonText = document.createTextNode( expandCaption );
            ButtonLink.setAttribute( 'id', 'hideButton' + tableIndex );
            ButtonLink.setAttribute( 'href', '#' );
    Button.className = 'hideButton';  /* Styles are declared in Common.css */
            $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
            ButtonLink.appendChild( ButtonText );
    ButtonLink.style.color = Header.style.color;
    ButtonLink.setAttribute( 'id', 'hideButton' + tableIndex );
            Button.appendChild( document.createTextNode( '[' ) );
    ButtonLink.setAttribute( 'href', '#' );
            Button.appendChild( ButtonLink );
    $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
            Button.appendChild( document.createTextNode( ']' ) );
    ButtonLink.appendChild( ButtonText );
            Header.insertBefore( Button, Header.firstChild );
    Button.appendChild( document.createTextNode( '[' ) );
            if ( linkImage ) linkImage.appendChild( Button );
    Button.appendChild( ButtonLink );
            if ( 0 ) linkImage.insertBefore( Button, linkImage.firstChild );
    Button.appendChild( document.createTextNode( ']' ) );
tableIndex++;
        }
    Header.insertBefore( Button, Header.firstChild );
    }
    if ( linkImage ) linkImage.appendChild( Button );
    if ( 0 ) linkImage.insertBefore( Button, linkImage.firstChild );
                                }
tableIndex++;
}
}


    window.hideTable( 0 );
window.hideTable( 0 );
}
}
}
   
   
Line 175: Line 181:
             ButtonLink.setAttribute( 'href', '#' );
             ButtonLink.setAttribute( 'href', '#' );
             $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
             $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
            ButtonLink.appendChild( ButtonText );
 
    ButtonLink.appendChild( ButtonText );
   
   
             Button.appendChild( document.createTextNode( '[' ) );
             Button.appendChild( document.createTextNode( '[' ) );