User:Westgrass/common.js

$(function{   if( !$('body.skin-fandomdesktop').length ){        return;    }	if("ontouchstart" in window){ // only when this is not registered in common.js		return; 	}	var l10n = (function{ var $data = { en: { view: 'View', more: 'More' }		};		var $lang = mw.config.get("wgUserLanguage"); return function ($key) { // (null==undefined) is true,(null===undefined) is false return ($data[$lang] && $data[$lang][$key] != null) ? $data[$lang][$key] : $data.en[$key]; };	});	$('.fandom-sticky-header').remove;	//index wiki nav sections:	$(".fandom-community-header__local-navigation .extra-large-navigation > .wds-dropdown").each(function($index, $div){ $div.dataset.index = $index; if($.cookie('hydra-nav-'+$index) == "y"){ $($div).toggleClass('collapsed').find('.wds-dropdown__content').css('display', 'none'); }	});	//move gp logo to top bar	$('.fandom-community-header__top-container').appendTo($('.global-navigation__links'));	//move wiki tools to aside, theme switch to netbar	$('.wiki-tools').first.find('a').removeClass('wds-button').appendTo($('.fandom-community-header__local-navigation .extra-large-navigation>:first-child .wds-list')).wrap('').filter('.wiki-tools__theme-switch').appendTo($('.global-navigation__links'));

//move page tools to aside $("#WikiaRail").on("afterLoad.rail", function{		var $pageTools = $('#p-tb');		if(!$pageTools.length){			return;		}		var $t = $('  '+$pageTools.find('h2').text+'    ');		$t.find("div.wds-dropdown__content").append($pageTools.find('ul').clone.removeClass.addClass('wds-list wds-is-linked'));		if($.cookie('hydra-nav-pagetools') == "y"){			$t.toggleClass('collapsed').find('.wds-dropdown__content').css('display', 'none');		}		var $f = $('.fandom-community-header__local-navigation .extra-large-navigation .page-footer__languages');		if($f.length){			$t.insertBefore($f);		}		else{			$t.appendTo($('.fandom-community-header__local-navigation .extra-large-navigation')); }			});	//move language to aside:	var $l = $('.page-footer__languages').removeClass('wds-collapsible-panel').addClass('wds-dropdown').attr('data-index', 'languages').appendTo($('.fandom-community-header__local-navigation .extra-large-navigation'));	var $h = $l.find('.wds-collapsible-panel__header');	$l.prepend($(' '+$h.text+'  '));	$h.remove;	$l.find('.wds-collapsible-panel__content').removeClass.addClass('wds-dropdown__content wds-is-not-scrollable').find('a').wrap('');	$l.find('.wds-dropdown__content li').wrapAll('');	if($.cookie('hydra-nav-languages') == "y"){		$l.toggleClass('collapsed').find('.wds-dropdown__content').css('display', 'none'); }

//local nav dropdown lists workaround: $(".fandom-community-header__local-navigation").on("click", '.wds-dropdown__toggle.first-level-item', function(event){		event.stopPropagation;		var $item = $(this).closest('.wds-dropdown');		$item.toggleClass('collapsed').find('.wds-dropdown__content').slideToggle('fast');       $.cookie('hydra-nav-' + $item[0].dataset.index, $item.hasClass('collapsed')?"y":"n", { expires: 365, path: '/' });	});	//top bars var $box = $('.page-side-tools__wrapper'); if(!$box.length){ return; }	//left box: var $left = $(' ').appendTo($box); var $right = $(' ').appendTo($box); var $list = $('#p-views .wds-list'); var actions = mw.config.get('wgWikiaBarSkinData').contentActions; actions.dummy = 'dummy'; var last; for(var key in actions){ var item = actions[key]; if(!last){ //first item: View the page? if(/^nstab/.test(key)){ $(' ').attr('id', item.id).addClass(item.class).append($('</a>').attr('href', item.href)				.text(l10n('view'))).appendTo($right); }		}		else{ if(item.primary){ $(' ').attr('id', last.id).addClass(last.class).append($('</a>').attr('href', last.href).text(last.text)).appendTo($left); }			else{ //skip edit/viewSource if(!last.primary){ if(last.id == 'ca-delete' || last.id == 'ca-move' || last.id == 'ca-purge' || last.id == 'ca-protect' || last.id == 'ca-cargo-purge'){ break; }					$(' ').attr('id', last.id).addClass(last.class).append($('</a>').attr('href', last.href).text(last.text)).appendTo($right); }			}		}		last = item; }	//right box (contentActions is lack of gadget actions, so use another way) $('#p-views > a').prependTo($right).wrap(' '); $('#p-views > div').appendTo($right); $right.find('#ca-history').insertBefore($right.find('.wds-dropdown')).wrap(' '); $right.find('.wds-button').removeClass(['wds-button', 'wds-button', 'wds-is-text', 'page-header__action-button']); });