User:Albuseer/vector/improve.js: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 18: | 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 58: | Line 58: | ||
} |
} |
||
/* |
|||
$('#mw-panel > div.portal:not(.persistent)') |
$('#mw-panel > div.portal:not(.persistent)') |
||
.addClass('collapsed') |
.addClass('collapsed') |
||
Line 68: | Line 69: | ||
.find('div.body').show() |
.find('div.body').show() |
||
} |
} |
||
$('#mw-panel h3 > a').unbind('click').click(function(e){e.preventDefault()}) |
$('#mw-panel h3 > a').unbind('click').click(function(e){e.preventDefault()}) |
||
$('#mw-panel > div.portal:not(.persistent) > h3').click( |
$('#mw-panel > div.portal:not(.persistent) > h3').click( |
||
Line 84: | Line 84: | ||
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{ |
||
langs = prefered_langs; |
|||
} |
} |
||
catch(err) |
catch(err) |
||
{ |
{ |
||
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 113: | Line 113: | ||
); |
); |
||
$('#p-lang-show').show(); |
$('#p-lang-show').show(); |
||
} |
}; |
||
if ($('#p-lang > div > ul > li').size() > finish){ |
if ($('#p-lang > div > ul > li').size() > finish){ |
||
Line 132: | Line 132: | ||
} |
} |
||
$('#mw-panel').css('position','fixed') |
$('#mw-panel').css('position','fixed'); |
||
$(window).scroll(function(){ |
$(window).scroll(function(){ |
||
Line 139: | 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 */ }); |
Revision as of 03:01, 13 November 2014
/* 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').size()>0){
if ($('table#toc.toc').position().left==0 && $('table#toc.toc li').size()>10 && $('.toclevel-1>ul').size()>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')).size() ){
$('#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').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 */ });