User:Ilmari Karonen/standard.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// Replace mw.util.addPortletLink() from wikibits with approximate workalike for the Classic skin (EXPERIMENTAL)
// FIXME: portlet, accesskey and nextnode parameters are ignored

function addPortletLink( portlet, href, text, id, tooltip, accesskey, nextnode ) {
    var quickbar = document.getElementById('quickbar');
    if (!quickbar) return null;

    var link = document.createElement( 'a' );
    link.appendChild( document.createTextNode( text ) );
    link.href = href;
    if ( tooltip ) link.setAttribute( 'title', tooltip );

    var item = document.createElement( 'div' );
    item.appendChild( link );
    if ( id ) item.id = id;

    quickbar.appendChild( item );
    return item;
}