You must log in to edit PetroWiki. Help with editing

Content of PetroWiki is intended for personal use only and to supplement, not replace, engineering judgment. SPE disclaims any and all liability for your use of such content. More information


MediaWiki:Common.js: Difference between revisions

PetroWiki
Jump to navigation Jump to search
mNo edit summary
 
No edit summary
Line 53: Line 53:
$(document).ready(sizing);
$(document).ready(sizing);
$(window).resize(sizing);
$(window).resize(sizing);
var addthis_config = addthis_config||{};
addthis_config.data_track_addressbar = false;
addthis_config.data_track_clickback = false;

Revision as of 13:24, 1 April 2014

/* Any JavaScript here will be loaded for all users on every page load. */
/**
 * MainPage-tab
 * On the main page (and its associated namespaces and actions (Talk, edit, history etc.)
 * this script will put  "Main Page" instead of "Article" or "Page" in the first tab.
 *
 * @source: www.mediawiki.org/wiki/Snippets/Main_Page_tab
 * @rev: 3
 */
$( document ).ready( function() {
        var title = mw.config.get( 'wgTitle' );
        var hasMainPageTab = (title === 'Main Page'); // Title of the main page. If applicable, without the namespace prefix (eg. "MyWiki:")
        if ( hasMainPageTab ) {
                $( '#ca-nstab-main a' ).text( title );
        }
      } );

function stristr (haystack, needle, bool) {
  
  // *     example 1: stristr('Kevin van Zonneveld', 'Van');
  // *     returns 1: 'van Zonneveld'
  // *     example 2: stristr('Kevin van Zonneveld', 'VAN', true);
  // *     returns 2: 'Kevin '
  var pos = 0;

  haystack += '';
  pos = haystack.toLowerCase().indexOf((needle + '').toLowerCase());
  if (pos == -1) {
    return false;
  } else {
    if (bool) {
      return haystack.substr(0, pos);
    } else {
      return haystack.slice(pos);
    }
  }
}

function sizing() {
  var request_uri = location.pathname + location.search;
  left_space= $('#side').outerWidth( true );
  right_space= $('#sponsor').outerWidth( true );

  //alert("Left: "+left_space+"    Right: "+right_space+"    Window: "+$('#container').innerWidth());
    //$('#mainContent').width($(window).width() - left_space - right_space -10);
    //$('#mainContent').width($('#container').innerWidth() - left_space - right_space-10);
    if(stristr(request_uri,'/special:') || stristr(request_uri,'/special%3a') || request_uri.indexOf("Special:") !== -1 || request_uri.indexOf("Special%3A") !== -1)
         $('#mainContent').width($('#container').innerWidth() - left_space - right_space-40);
      else
         $('#mainContent').width($('#container').innerWidth() - left_space - right_space-10);
}

$(document).ready(sizing);
$(window).resize(sizing);

var addthis_config = addthis_config||{};
addthis_config.data_track_addressbar = false;
addthis_config.data_track_clickback = false;