MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 349: Line 349:


addOnloadHook( doRoundEdges );
addOnloadHook( doRoundEdges );
addOnloadHook( createSpoilerCollapseButtons );
/***********************************************************
*  Name: createJQueryTabs
*  Description: Runs at page load, inserts jQuery tabs into a page wherever a <div> with class "tabs" is found.
*  Maintainers: [[User:FlyingRagnar]]
*  Additional Notes: This function effectively replaces the Tabber extension which was
*  previously used to insert tabs into a page.  The template [[Template:VersionTabs]] is
*  the primary method to use when inserting jQuery tabs into a page.  It is tightly
*  coupled to this function.
*/
mw.loader.load( 'jquery.ui.tabs' );
function createJQueryTabs()
{
    var tabGroup = 0;
    var Tabs = document.getElementsByTagName( "div" );
    for ( var i = 0; i < Tabs.length; i++ ) {
        if ( hasClass( Tabs[i], "tabs" ) ) {
            Tabs[i].setAttribute("id", "tabs" + tabGroup);
            var children = Tabs[i].childNodes;
            var h = 0;
            for( var j = 0; j < children.length; j++ ) {
              if ( children[j].nodeName == "UL" ) {
                  var Tlinks = children[j].getElementsByTagName( "a" );
                  for( var k = h; k < Tlinks.length; k++ ) {
                    Tlinks[k].setAttribute("href", "#tabs" + tabGroup + "-" + (k+1));
                  }
              } else if ( children[j].nodeName == "DIV" ) {
                  children[j].setAttribute("id", "tabs" + tabGroup + "-" + (h+1));
                  h++;
              }
            }
            // apply the jQuery code to take effect
            jQuery( "#tabs" + tabGroup ).tabs({ /*event: "mouseover"*/ });
            tabGroup++;
        }
    }
}
jQuery( createJQueryTabs );
mw.loader.load( 'jquery.ui.accordion' );
function accordionVideos()
{
  jQuery( "#accordion" ).accordion({ collapsible: true, active: false });
}
jQuery( accordionVideos )


/* IE Correction Code **********************************************
/* IE Correction Code **********************************************
Line 405: Line 465:


/* </pre> */
/* </pre> */
/*********************************************************** *  Name: createJQueryTabs *  Description: Runs at page load, inserts jQuery tabs into a page wherever a <div> with class "tabs" is found. *  Maintainers: [[User:FlyingRagnar]] *  Additional Notes: This function effectively replaces the Tabber extension which was  *  previously used to insert tabs into a page.  The template [[Template:VersionTabs]] is *  the primary method to use when inserting jQuery tabs into a page.  It is tightly  *  coupled to this function. */ mw.loader.load( 'jquery.ui.tabs' ); function createJQueryTabs() {    var tabGroup = 0;    var Tabs = document.getElementsByTagName( "div" );    for ( var i = 0; i < Tabs.length; i++ ) {        if ( hasClass( Tabs[i], "tabs" ) ) {            Tabs[i].setAttribute("id", "tabs" + tabGroup);            var children = Tabs[i].childNodes;            var h = 0;            for( var j = 0; j < children.length; j++ ) {              if ( children[j].nodeName == "UL" ) {                  var Tlinks = children[j].getElementsByTagName( "a" );                  for( var k = h; k < Tlinks.length; k++ ) {                    Tlinks[k].setAttribute("href", "#tabs" + tabGroup + "-" + (k+1));                  }              } else if ( children[j].nodeName == "DIV" ) {                  children[j].setAttribute("id", "tabs" + tabGroup + "-" + (h+1));                  h++;                }            }            // apply the jQuery code to take effect            jQuery( "#tabs" + tabGroup ).tabs({ /*event: "mouseover"*/ });            tabGroup++;        }    } } jQuery( createJQueryTabs );
25,204

edits