MediaWiki:Gadget-FloatingToolbar.js

/* */

/** * Script for adding a floating toolbar to the bottom of the page * Version 2.01 * Script by User:Porter21 (http://www.falloutwiki.com) */

function floatingToolbar { // i18n var ftbLabels = { purge: 'Purge', showMessages: 'Show message names', toggle: 'Show/hide toolbar', toTop: 'Back to top' };  // Caching window.ftbToolbarState = $.cookie('ftb-toolbar-state'); var ftbPageName = mw.util.wikiUrlencode(mw.config.get('wgPageName')); var ftbWrapper = $('#global-wrapper');

// If no cookie, set default state if (window.ftbToolbarState === null) { window.ftbToolbarState = "show"; $.cookie('ftb-toolbar-state', window.ftbToolbarState, {'expires': 365, 'path': '/'}); }

// Copy & modify "views" var ftbButtons = new Array; var ftbButtonsOut = '';

$('#p-views > ul > li').each(function {      thisList = $(this);      thisLink = thisList.find('span:first > a:first');

ftbButtons[ftbButtons.length] = new Array (thisLink.text, thisLink.attr('href'), 'ftb-' + thisList.attr('id')); });

// Copy & modify "actions" $('#p-cactions > .menu > ul > li').each(function {      thisList = $(this);      thisLink = thisList.children('a:first');

ftbButtons[ftbButtons.length] = new Array (thisLink.text, thisLink.attr('href'), 'ftb-' + thisList.attr('id')); });

// Create output for "views" & "actions" $.each(ftbButtons, function(index) {     ftbButtonsOut += '' + ftbButtons[index][0] + '';   });

// Copy & modify "toolbox" var ftbToolbox = new Array; var ftbToolboxOut = '';

$('#p-tb > .body > ul > li').each(function {      thisList = $(this);      thisLink = thisList.children('a:first');

ftbToolbox[ftbToolbox.length] = new Array (thisLink.text, thisLink.attr('href'), 'ftb-' + thisList.attr('id')); });

// Create output for "toolbox" $.each(ftbToolbox, function(index) {     ftbToolboxOut += '' + ftbToolbox[index][0] + '';   });

// Assemble toolbar var ftbInner = ' '     + (ftbButtonsOut ? '' + ftbButtonsOut + '' : '') + (ftbToolboxOut ? ' '        + ' ' + $('#p-tb > h5').text + ' '+ vaultConfig.chevronUp + ' '         + '' + ftbToolboxOut + ''         + ' ' : '') + ' ';

var ftbButtonToTop = '  ';

var ftbButtonToggle = '  ';

var ftbToolbar = ' '     + '' + ftbButtonToTop + ftbInner + ftbButtonToggle + ' ';

// Insert toolbar ftbWrapper.append(ftbToolbar);

// Set up "click" event for "toggle toolbar" $('#ftb-button-toggle').click(function {     $('#ftb-toolbar-inner').animate({ height: "toggle" }, "fast", function  { $('#ftb-toolbar').toggleClass('ftb-toolbar-collapsed'); window.ftbToolbarState = (window.ftbToolbarState == "show" ? "hide" : "show"); $.cookie('ftb-toolbar-state', window.ftbToolbarState, {'expires': 365, 'path': '/'}); });  });

// Set up "click" event for "back to top" $('#ftb-button-totop').click(function {     $('html, body').scrollTop(0);   });

// Set up "hoverIntent" event for toolbox $('#ftb-toolbox').hoverIntent(function {      $(this).addClass('ftb-toolbox-active');   }, function  {      $(this).removeClass('ftb-toolbox-active');   }); }

jQuery(function($) {  if (mw.config.get('skin') == 'vector') {      floatingToolbar;   } });

/* */