Jump to content

User:Albuseer/vector/improve.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Albuseer (talk | contribs) at 06:43, 22 June 2010. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* jQuery section Begin */ jQuery(document).ready(function($){

$(':header').each(
  function(){
    $(this)
    .append(' ')
    .append(
      $(this).children('span.editsection')
      .css('display','inline')
      .css('float','none')
      .css('font-size','small')
      .css('margin-left','5px')
      .css('line-height','90%').hide()
    )
    .hover(
      function(){$(this).children('span.editsection').show()},
      function(){$(this).children('span.editsection').hide()}
    )
  }
);

/* Improved TOC */

if ($('table#toc.toc').size()>0){
 if ($('table#toc.toc').position().left==0 && $('table#toc.toc li').size()>10){
  $('.toclevel-1>ul').hide()
  $('table#toc.toc #toctitle').append(
    $('<span>').css('font-size','94%').append('[').append(
     $('<a>').attr('id','toggleDetail').attr('href','javascript:void(0)').html('+').click(
      function(){
       $('li.toclevel-1>ul').slideToggle();
       if ($(this).html()=='-'){$(this).html('+')}
       else{$(this).html('-')}
      }
     )
    ).append(']')
  )
  $('table#toc.toc')
  .css('position','absolute')
  .css('float','left')
  .css('margin-right','1em')
  .after(
   $('<div/>')
   .attr('id','tocspace')
   .css('height',$('table#toc.toc').height())
   .css('padding','8px')
  ).hover(
   function(){return},
   function(){ if ($('#toggleDetail').html()=='-'){
    $('li.toclevel-1>ul').slideToggle();$('#toggleDetail').html('+')
   }}
  )
  $('table#toc.toc #togglelink').click(function(){jQuery('#tocspace').css('height',jQuery('table#toc.toc').height())})
 }
}

$('#mw-panel > div.portal:not(:first)')
  .addClass('collapsed')
  .removeClass('expanded')
  .find('div.body').hide()
if ( $.cookie('vector-nav-expand') && $('#mw-panel > div.portal#'+$.cookie('vector-nav-expand')).size() ){
 $('#mw-panel > div.portal#'+$.cookie('vector-nav-expand'))
  .addClass('expanded')
  .removeClass('collapsed')
  .find('div.body').show()
}else{
 $('#mw-panel > div.portal#p-tb')
  .addClass('expanded')
  .removeClass('collapsed')
  .find('div.body').show()
 $.cookie('vector-nav-expand','p-tb',{expires: 7, path: '/'})
}

// Toggle the selected menu's class and expand or collapse the menu
$('#mw-panel > div.portal:not(:first) > h5').click(
  function() {
    $.cookie('vector-nav-expand',$(this).parent().attr('id'),{expires: 7, path: '/'})
    $(this).parent().siblings('div[id!=p-navigation]')
    .addClass('collapsed')
    .removeClass('expanded')
    .find('div.body')
    .hide('fast');
    if ($('#mw-panel').css('position')=='absolute'){hide_lang();}
  }
);
 
/* language section collapse */
 
try{
  var langs = prefered_langs
}
catch(err)
{
  var langs = ['en','de','fr','pl','it','ja','nl','es','simple','zh','zh-classical','zh-yue','wuu','la'];
}
var finish = langs.length;
var pan_top = $('#mw-panel').position().top-$(document).scrollTop();
 
var show_lang = function(){
  $('#mw-panel').css('position','absolute').css('top',$(document).scrollTop()+pan_top)
  .animate({top:$(document).scrollTop()},'slow');
  $('#p-lang > div > ul > li').show();
  $('#p-lang-show').hide();
};
 
var hide_lang = function(){
  var top = $('#mw-panel').position().top-$(document).scrollTop();
  $('#mw-panel').css('position','fixed').css('top',top).animate({top:pan_top},'slow');
  $('#p-lang > div > ul > li').hide();
  langs.map(
    function(lang){return $('.interwiki-'+lang).show();}
  );
  $('#p-lang-show').show();
}
 
if ($('#p-lang > div > ul > li').size() > finish){
  $('#p-lang > div > ul > li').hide();
  langs.map(
    function(lang){return $('.interwiki-'+lang).show();}
  );
 
  $('#p-lang > div > ul').append(
    $('<li id="p-lang-show"><span style="color:gray;font-size:90%;">All '+$('#p-lang > div > ul > li').size()+'</span></li>')
    .click(show_lang)
  );
 
  $('#p-lang > div > ul').append(
    $('<li id="p-lang-hide"><span style="color:gray;font-size:90%;">Hide</span></li>')
    .click(hide_lang).hide()
  );
}
 
$('#mw-panel').css('position','fixed')

$(window).scroll(function(){
  if ( $('#mw-panel').css('position')=='absolute' &&
       ( $('#mw-panel').offset().top>$(document).scrollTop()+pan_top ||
         $('#p-lang-hide').offset().top<$(document).scrollTop()+pan_top ) )
  {hide_lang()}
})

/* jQuery section End */ });