Jump to content

User:Albuseer/vector/improve.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Albuseer (talk | contribs)
No edit summary
Maintenance: mw:RL/MGU - Replace jQuery#size (deprecated)
 
(14 intermediate revisions by one other user not shown)
Line 1: Line 1:
/* jQuery section Begin */ jQuery(document).ready(function($){
/* jQuery section Begin */ jQuery(document).ready(function($){

$(window).load(function(){


$(':header').each(
$(':header').each(
Line 16: Line 18:
function(){$(this).children('span.editsection').show()},
function(){$(this).children('span.editsection').show()},
function(){$(this).children('span.editsection').hide()}
function(){$(this).children('span.editsection').hide()}
)
);
}
}
);
);
Line 22: Line 24:
/* Improved TOC */
/* Improved TOC */


if ($('table#toc.toc').size()>0){
if ($('table#toc.toc').length>0){
if ($('table#toc.toc').position().left==0 && $('table#toc.toc li').size()>10){
if ($('table#toc.toc').position().left==0 && $('table#toc.toc li').length>10 && $('.toclevel-1>ul').length>0){
$('.toclevel-1>ul').hide()
$('.toclevel-1>ul').hide()
$('table#toc.toc #toctitle').append(
$('table#toc.toc #toctitle').append(
Line 40: Line 42:
.css('float','left')
.css('float','left')
.css('margin-right','1em')
.css('margin-right','1em')
.css('z-index','1')
.after(
.after(
$('<div/>')
$('<div/>')
Line 55: Line 58:
}
}


/*
$('#mw-panel > div.portal:not(:first)')
$('#mw-panel > div.portal:not(.persistent)')
.addClass('collapsed')
.addClass('collapsed')
.removeClass('expanded')
.removeClass('expanded')
.find('div.body').hide()
.find('div.body').hide()
if ( $.cookie('vector-nav-expand') && $('#mw-panel > div.portal#'+$.cookie('vector-nav-expand')).size() ){
if ( $.cookie('vector-nav-expand') && $('#mw-panel > div.portal#'+$.cookie('vector-nav-expand')).length ){
$('#mw-panel > div.portal#'+$.cookie('vector-nav-expand'))
$('#mw-panel > div.portal#'+$.cookie('vector-nav-expand'))
.addClass('expanded')
.addClass('expanded')
.removeClass('collapsed')
.removeClass('collapsed')
.find('div.body').show()
.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: '/'})
}
}
$('#mw-panel h3 > a').unbind('click').click(function(e){e.preventDefault()})

$('#mw-panel > div.portal:not(.persistent) > h3').click(
// Toggle the selected menu's class and expand or collapse the menu
$('#mw-panel > div.portal:not(:first) > h5').click(
function() {
function() {
if ($(this).parent().hasClass('expanded')){
$.cookie('vector-nav-expand',$(this).parent().attr('id'),{expires: 7, path: '/'})
$.cookie('vector-nav-expand',$(this).parent().attr('id'),{expires: 7, path: '/'})
}else{
$(this).parent().siblings('div[id!=p-navigation]')
$.cookie('vector-nav-expand','',{expires: 7, path: '/'})
}
$(this).parent().siblings('div.portal:not(.persistent)')
.addClass('collapsed')
.addClass('collapsed')
.removeClass('expanded')
.removeClass('expanded')
.find('div.body')
.find('div.body')
.hide('fast');
.hide('fast');
if ($('#mw-panel').css('position')=='absolute'){hide_lang();}
if ($('#mw-panel').css('position')=='absolute'){hide_lang();}
}
}
);
);*/
/* language section collapse */
/* language section collapse */
var langs;
try{
try{
var langs = prefered_langs
langs = prefered_langs;
}
}
catch(err)
catch(err)
{
{
var langs = ['en','de','fr','pl','it','ja','nl','es','simple','zh','zh-classical','zh-yue','wuu','la'];
langs = ['en','de','fr','pl','it','ja','nl','es','simple','zh','zh-classical','zh-yue','wuu','la'];
}
}
var finish = langs.length;
var finish = langs.length;
var pan_top = $('#mw-panel').position().top-$(document).scrollTop();
var pan_top = $('#mw-panel').position().top-$(document).scrollTop();

var show_lang = function(){
var show_lang = function(){
$('#mw-panel').css('position','absolute').css('top',$(document).scrollTop()+pan_top)
$('#mw-panel').css('position','absolute').css('top',$(document).scrollTop()+pan_top)
Line 112: Line 113:
);
);
$('#p-lang-show').show();
$('#p-lang-show').show();
}
};
if ($('#p-lang > div > ul > li').size() > finish){
if ($('#p-lang > div > ul > li').length > finish){
$('#p-lang > div > ul > li').hide();
$('#p-lang > div > ul > li').hide();
langs.map(
langs.map(
Line 121: Line 122:
$('#p-lang > div > ul').append(
$('#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>')
$('<li id="p-lang-show"><span style="color:gray;font-size:90%;">All '+$('#p-lang > div > ul > li').length+'</span></li>')
.click(show_lang)
.click(show_lang)
);
);
Line 131: Line 132:
}
}
$('#mw-panel').css('position','fixed')
$('#mw-panel').css('position','fixed');


$(window).scroll(function(){
$(window).scroll(function(){
Line 138: Line 139:
$('#p-lang-hide').offset().top<$(document).scrollTop()+pan_top ) )
$('#p-lang-hide').offset().top<$(document).scrollTop()+pan_top ) )
{hide_lang()}
{hide_lang()}
})
});

});


/* jQuery section End */ });
/* jQuery section End */ });

Latest revision as of 21:04, 26 August 2021

/* jQuery section Begin */ jQuery(document).ready(function($){

$(window).load(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').length>0){
 if ($('table#toc.toc').position().left==0 && $('table#toc.toc li').length>10 && $('.toclevel-1>ul').length>0){
  $('.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')
  .css('z-index','1')
  .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(.persistent)')
  .addClass('collapsed')
  .removeClass('expanded')
  .find('div.body').hide()
if ( $.cookie('vector-nav-expand') && $('#mw-panel > div.portal#'+$.cookie('vector-nav-expand')).length ){
 $('#mw-panel > div.portal#'+$.cookie('vector-nav-expand'))
  .addClass('expanded')
  .removeClass('collapsed')
  .find('div.body').show()
}
$('#mw-panel h3 > a').unbind('click').click(function(e){e.preventDefault()})
$('#mw-panel > div.portal:not(.persistent) > h3').click(
  function() {
   if ($(this).parent().hasClass('expanded')){
    $.cookie('vector-nav-expand',$(this).parent().attr('id'),{expires: 7, path: '/'})
   }else{
    $.cookie('vector-nav-expand','',{expires: 7, path: '/'})
   }
   $(this).parent().siblings('div.portal:not(.persistent)')
    .addClass('collapsed')
    .removeClass('expanded')
    .find('div.body')
    .hide('fast');
   if ($('#mw-panel').css('position')=='absolute'){hide_lang();}
  }
);*/
 
/* language section collapse */
var langs;
try{
  langs = prefered_langs;
}
catch(err)
{
  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').length > 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').length+'</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 */ });