User:JPhil2.0/global.js

/* =========================================================================    JS for monobook and oasis applied to all wikia wikis. @author JPhil2.0 ========================================================================== */ importArticles({   type: 'script',    articles: [ 'u:dev:AjaxRC/code.js', 'u:dev:PortableCSSPad/code.js', 'u:dev:CapsFirst/code.js', 'u:dev:WHAM/code.2.js', 'u:dev:HeaderLinks/code.js', 'u:dev:View_Source/code.js', 'u:dev:RevealAnonIP/usercode.js', 'u:dev:CategoryRenameAuto-update/code.js', 'u:dev:FileUsageAuto-update/code.js', 'u:dev:MassCategorization/code.js', 'u:dev:NoImageLightbox/code.js', 'u:dev:LastEdited/code.js', 'u:dev:DisplayTimer/code.js', 'u:dev:InactiveUsers/code.js', 'u:dev:AjaxBatchDelete/code.2.js', 'u:dev:AjaxUndo/code.js', 'u:dev:AjaxRedirect/code.js'    ] });

/* Custom "NewFilesModule" by 452 (with fixes by JoshuaJSlone) This script displays Special:NewFiles in the right rail There are three ways to use this, by setting the NewFilesModuleCompact variable 0 - Normal, width is 212 1 - Compact, width is 106 2 - Random, if you're not sure which version you like best. In both modes, hovering over each displays the uploader info. NewFilesModuleCount can be used to specify the number of displayed images. var NewFilesModuleCompact= 1; //must be 0, 1, or 2. var NewFilesModuleCount = 13; //any integer if ($('#WikiaRail').length) { //only on pages where the rail is present $('#WikiaRail').bind('DOMNodeInserted', function(event) { //fires after lazy-loading takes place.    if (!$("#NewFilesModule").length) { // Only add it once      if (typeof $temp == "undefined") { // Only load it once        $temp = $(' '); // this line, and the next, originate from http://dev.wikia.com/wiki/AjaxRC/code.js <3        $temp.load("/Special:NewFiles/" +NewFilesModuleCount + " #gallery-", function  { $('#WikiaRail section:last-of-type').after(" New FilesUpload "); if (typeof NewFilesModuleCompact == "undefined") NewFilesModuleCompact = 0; if (NewFilesModuleCompact == 2) NewFilesModuleCompact = Math.floor(Math.random*2); if (NewFilesModuleCompact) { $('#gallery-', $temp).html(             $('#gallery-', $temp).html              .replace(/\/revision\/latest\?/g, "/revision/latest/scale-to-width-down/106?")              .replace(/\/scale-to-width-down\/\d*\?/g, "/scale-to-width-down/106?") //-down is redundant on this line, but kept for consistency            ); $("#NewFilesModule").addClass("compact"); }         $("#NewFilesModule").append($('#gallery-', $temp)); $("#NewFilesModule .wikia-photogallery-add").remove; $("#NewFilesModule .wikia-gallery-item").each(function { $(".lightbox-caption", this).prepend($("").attr("href",$(".gallery-image-wrapper>a", this).attr("href")).html($(".gallery-image-wrapper>a", this).attr("title")).append($(" ")));}); delete $temp; //delete it, in case the rail is wiped after this point. });     }    }  });  //end of DOMNodeInserted block $('#WikiaRail').trigger('DOMNodeInserted'); //Prevent race condition by firing the event.

$('head').append('\n#gallery- { position:relative;overflow-y:auto; clear: both; text-align:center; height:452px; }\n#gallery-:hover {padding-bottom: 13em; }\n#NewFilesModule .gallery-image-wrapper { top: 0 !important; height: auto !important; border:none; background: none; }\n#NewFilesModule.compact .gallery-image-wrapper { width: auto !important; }\n#NewFilesModule .thumb { height:auto !important; }\n#NewFilesModule .wikia-gallery-item { margin: 1px !important; padding: 0 !important; height: auto !important; border: none !important; }\n#NewFilesModule.compact .wikia-gallery-item { width: auto !important; }\n#NewFilesModule .wikia-gallery-item .lightbox-caption { display: none; }\n#NewFilesModule .wikia-gallery-item:hover .lightbox-caption { display:block; padding: 5px; margin-top: 0; position: absolute; border: 1px solid; background-color: #fff; z-index: 2; right: 0; width: 240px !important; }\n#NewFilesModule h2 {margin: 0 2em 0 0;}\n#NewFilesModule h2 a:first-child {color:inherit;}\n#NewFilesModule img { display: block; height: auto !important; width: auto !important; margin-left: auto !important; margin-top: auto !important;}\n.wikia-gallery-item .gallery-image-wrapper a { width: auto !important; height: auto !important; }\n.wikia-gallery-item .gallery-image-wrapper a.image-no-lightbox { line-height: normal; display: block; padding: 1em; }\n '); } // End of custom "NewFilesModule"

/* use Monobook when editing CSS/JS pages. */ $(function {    if (wgCityId == 4470) return;  if ((wgPageName.substr(-3) == ".js") || (wgPageName.substr(-4) == ".css")) {    $("a[href*='.js?action=edit'], a[href*='.css?action=edit']").each(function{ $(this).attr("href", $(this).attr("href").replace('?action=edit', '?action=edit&useskin=monobook&usesitecss=0')); });   if (mw.util.getParamValue('action') == "edit") {           if (!mw.util.getParamValue('useskin') ) {        window.location.href = window.location.href.replace('?action=edit','?action=edit&useskin=monobook&usesitecss=0');      } else {        $("#editform").attr("action", $("#editform").attr("action")+"&useskin="+mw.util.getParamValue('useskin'));      }    }  } });

var c = mw.config.get( [   'wgArticlePath',    'wgPageName',    'wgCanonicalSpecialPageName',    'wgTitle',    'wgAction',    'wgCanonicalNamespace',    'wgNamespaceNumber',    'wgUserGroups',    'wgSiteName',    'skin' ] ), tempArray, escapedPage = encodeURIComponent(c.wgPageName);
 * (function($, mw) {

/* View Source Customization */ mw.util.addCSS(   '#source-code, #source-toc {' +        'font-family: monaco, monospace !important;' +    '}' +    '#source-code > a {' +        'color: ' + $('a').css('color') + ' !important;' +        'font-weight: bold;' +    '}' );

/* Add powerusers checkbox to Special:Listuers */ if (wgCanonicalSpecialPageName == "Listusers") $("fieldset.lu_fieldset tr:last-child").prepend('  Power Users ');

/* LastEdited Customization */ window.lastEdited = { avatar: false, size: false, comment: false };

// Opens links on new pages $('.rc-conntent, .activityfeed') .find('a') .each(function {       if ($(this).attr('href') !== '#') {            $(this).attr('target', '_blank');        }    }); if ($.getUrlVar('action') == 'edit' &&  $('#wpSummary').length   ) { var val = ''; if ($('#wpSummary').val) { val = $('#wpSummary').val; }   $('#wpSummary').replaceWith($(' ').attr({ id: 'wpSummary', name: 'wpSummary', style: 'resize: none; height: 40px', placeholder: 'Add a summary of your edit' }).val(val)); }

/* AjaxRC Customization */ if (mw.config.get('wgCanonicalSpecialPageName') == 'WikiActivity') { mw.util.addCSS(       '#ajaxRefresh {' +            'position: absolute;' +            'right: 0;' +            'bottom: 10px;' +        '}' +        '#ajaxLoadProgress {' +            'margin-left:5px;' +        '}'    ); } window.ajaxCallAgain = window.ajaxCallAgain || []; window.ajaxCallAgain.push(function {   $('.rc-conntent, .activityfeed')        .find('a')        .each(function { $(this).attr('target', '_blank'); }); }); window.ajaxPages = ['Special:RecentChanges', 'Special:WikiActivity'], window.ajaxRefresh = 30000;

/* Custom Account Navigation */ $(function { $('Contributions').insertBefore('.AccountNavigation .subnav li:first'); }); $(function { $('Global.css</a></li>').insertBefore('.AccountNavigation .subnav li:first'); }); $(function { $('<a href="http://community.wikia.com/wiki/User:JPhil2.0/global.js">Global.js</a></li>').insertBefore('.AccountNavigation .subnav li:first'); });

/* Masthead modifications */ if ($("#UserProfileMasthead").size) $("#UserProfileMasthead .tally em").wrap($("").attr("href", "/wiki/Special:EditCount/"+$("#UserProfileMasthead h1[itemprop=name]").html));

/* Wiki Activity to Recent Changes */ $('[data-canonical="wikiactivity"]') .attr('href', '/wiki/Special:RecentChanges') .html('Recent Changes'); $('.rc-conntent, .activityfeed') .find('a') .each(function {       $(this).attr('target', '_blank');    }); /* IP lookup on contribs */ if (c.wgCanonicalSpecialPageName == "Contributions" && $('#anontalktext').length && c.wgTitle.split('.').length == 4) $('.masthead-info h2').html('<a style="color:white" href="http://myip.ms/info/whois/'+c.wgPageName.split('/')[1]+'">(lookup)</a>'); /* InactiveUsers Customization */ InactiveUsers = { months: 1 };

/* Always go to IP contributions, not userpage */ if (c.wgNamespaceNumber == 2 && $('h2:contains("A Wikia Contributor")').length) location.replace(articlePath + 'Special:Contributions/' + c.wgTitle.split('/')[1]);

/* Thread modifications @author 452 */ if ((wgNamespaceNumber == 1201) && !$(".msg-title a").text) { $("ul.replies").prepend("<h1 class='center'><a href="+$(".msg-title a").attr("href")+">Link to parent thread</a> </li>"); } if ($(".replies .SpeechBubble.message").length) $(".replies .SpeechBubble.message").each(function{ $(".timestamp", this).append("(<a href='./Thread:"+$(this).attr("data-id")+"'>link</a>)"); });

/* Untick minor edit box after 10 seconds when editing */ if (c.wgAction === 'edit' || c.wgAction === 'submit') { setTimeout(function {   if ($('#wpMinoredit').attr('Checked'))       $('#wpMinoredit').removeAttr('checked');  }, 10000); }

/* Toolbar modifications */ function addToolbarTool(param,text) { if ($('.toolbar > .tools').length) { $('.toolbar > .tools > li:last').after(     $('').append('<a href="/index.php?title=' + escapedPage + param + '">' + text + '</a>')    ); } } addToolbarTool("&allowuserjs=0","No User JS"); addToolbarTool("&allowusercss=0","No User CSS"); addToolbarTool("&usesitejs=0","No Site JS"); addToolbarTool("&usesitecss=0","No Site CSS");

/* Skin Switch Buttons */ $('.start-wikia-container').html(   '<a href="/wiki/' + mw.config.get('wgPageName') + (document.URL.indexOf('?') > -1 ? '&' : '?') + 'useskin=monobook" class="start-wikia">M</a>' +    '<a href="/wiki/' + mw.config.get('wgPageName') + (document.URL.indexOf('?') > -1 ? '&' : '?') + 'useskin=wikiamobile" class="start-wikia" style="margin-left:10px">W</a>' +    '<a href="/wiki/' + mw.config.get('wgPageName') + (document.URL.indexOf('?') > -1 ? '&' : '?') + 'uselang=qqx" class="start-wikia" style="margin-left:10px">Q</a>' ); }) (this.jQuery, this.mediaWiki);