Wasteland Wiki
Advertisement

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* <nowiki> */

/* ######################################################################## */
/* ### JavaScript here is loaded for users using the Vector skin.       ### */
/* ######################################################################## */

/* ######################################################################## */
/* ### SCRIPT LOADER (VECTOR)                                           ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Loads all Vector-specific scripts                   ### */
/* ### Credit:      User:Porter21                                       ### */
/* ######################################################################## */

function vaultScriptLoaderVector () {
   vectorActionButtons();
   usabilityImprovements();
   visualVectorFixes();
}

jQuery(function($) {
   vaultScriptLoaderVector();
});

/* ######################################################################## */
/* ### VECTOR ACTION BUTTONS                                            ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Add action buttons to top navigation                ### */
/* ### Credit:      User:Porter21                                       ### */
/* ######################################################################## */

function vectorActionButtons () {
   var vabDefaultOption = 'n-randompage';
   var vabOptionCookie = $.cookie('vab-button-default');
   var vabPortlets = $('#p-Contribute, #p-On_the_wiki');

   // Create container
   $('#mw-head').append('<div id="p-action-buttons" />');

   // Alter class
   vabPortlets.attr('class', 'vab-button');

   // Get preference for "split" button from cookie & re-save
   if (vabOptionCookie) {
      vabDefaultOption = vabOptionCookie;
   }

   $.cookie('vab-button-default', vabDefaultOption, {'expires': 365, 'path': '/'});

   vabDefaultOption = $('#' + vabDefaultOption + '> a:first')
      .clone()
      .removeAttr('accesskey')
      .addClass('vab-button-default');

   // Set up "split" button
   $('#p-On_the_wiki')
      .addClass('vab-button-split')
      .prepend(vabDefaultOption)
      .find('h5')
         .html('')
         .end()
      .find('.body > ul > li > a')
         .click(function() {
            $.cookie('vab-button-default', $(this).parent().attr('id'), {'expires': 365, 'path': '/'});
            return true;
         });

   // Attach events, add chevron and append
   vabPortlets
      .mouseleave(function() {
         $(this).removeClass('vab-button-active');
      })
      .find('h5')
         .click(function() {
            $(this).parent().toggleClass('vab-button-active');
         })
         .append('<div class="vab-button-chevron"></div>')
         .end()
      .appendTo('#p-action-buttons');
}

/* ######################################################################## */
/* ### USABILITY IMPROVEMENTS                                           ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Changes to improve usability                        ### */
/* ### Credit:      User:Porter21                                       ### */
/* ######################################################################## */

function usabilityImprovements () {
   // Convert tooltips for text inputs to placeholders
   var phSimpleSearch = $('#simpleSearch > #searchInput');
   var phInputs = '';

   if (phSimpleSearch.length) {
      phSimpleSearch.attr('title', '');
   } else {
      phInputs += (phInputs ? ', ' : '') + '#searchInput';
   }

   if (mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') {
      if ($('#wpSummary + #wpTextbox1').length) {
         $('#wpSummary').attr('title', 'Enter the title of your message');
      }

      phInputs += (phInputs ? ', ' : '') + '#wpSummary';
   }

   phInputs = $(phInputs);

   phInputs.each(function () {
      $(this).attr({ placeholder: $(this).attr('title').replace(/ \[.+\]/, ''), title: '' });
   });

   if (!('placeholder' in document.createElement('input'))) {
      phInputs.placeholder();
   } else {
      // FIXME: Check whether still necessary after next Steam browser update
      // Patch broken placeholder support for Steam ingame browser (placeholder text not removed on focus)
      // (Steam browser is significant enough for a gaming wiki, I suppose)
      if (navigator.userAgent.indexOf('Valve Steam GameOverlay') > -1) {
         $('[placeholder]').bind('focus drop keydown paste', function () {
            if ($(this).val() == '') {
               $(this).val('');
            }
         });
      }
   }
}

/* ######################################################################## */
/* ### VISUAL VECTOR FIXES                                              ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Resolves various visual issues with Vector          ### */
/* ### Credit:      User:Porter21                                       ### */
/* ######################################################################## */

function visualVectorFixes () {
   var userBrowser = $.client.profile();

   // Emulate :after/:before on certain elements for IE < 8
   if (userBrowser.name == 'msie' && userBrowser.versionBase < 8) {
      elemAfter = $('#mw-head-base');
      elemBefore = $('#p-logo'); // ', #mw-panel .portal + .portal'

      if (elemAfter.length) {
         elemAfter.append('<span class="after"></span>');
      }

      if (elemBefore.length) {
         elemBefore.prepend('<span class="before"></span>');
      }
   }

   // Move "in other languages" links to bottom of page
   var langLinks = $('#p-lang');

   if (langLinks.length) {
      var catLinks = $('#catlinks');
      var newClass = '';

      if (!(catLinks.length) || catLinks.hasClass('catlinks-allhidden')) {
         newClass = 'p-lang-nocatlinks';
      }

      langLinks.attr('class', newClass).insertBefore($('#bodyContent .visualClear').last());
   }

}

/* </nowiki> */
Advertisement