function articleAsideOpen(hs, ha){ //################### Apre article e aside separatamente e ad altezze diverse
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);
var fe;
if (jQuery('.entry-title').length!=0) {
fe = parseFloat(jQuery('.entry-title').css('line-height').replace('px',''))+parseFloat(jQuery('.entry-title').css('padding-bottom').replace('px',''))+parseFloat(jQuery('.entry-title').css('padding-top').replace('px','')); //altezza del gap
}
if (jQuery.browser.msie) {
if(jQuery(window).height()>jQuery(document).height()){ //in questo modo anche con menu scrollabile ho l'altezza della section piena
var h = jQuery(window).height();
} else {
var h = jQuery(document).height();
}
} else {
if(window.innerHeight>jQuery(document).height()){ //in questo modo anche con menu scrollabile ho l'altezza della section piena
var h = window.innerHeight;
} else {
var h = jQuery(document).height();
}
}
var off;
off = jQuery('footer').offset();
var offs = jQuery('article').offset();
var offa;
offa = jQuery('aside').offset();
var he = parseFloat(jQuery('section').css('margin-top').replace('px',''));
var foo = jQuery('footer').height();
var hh2 = jQuery('article').not('.always_open').find('.entry-title:first').css({'cursor':'pointer','position':'relative'}).append('^').height()+15+15;
var lhh2 = jQuery('article .entry-title:first').css('line-height'); //mi serve per settare le altezze dei due titoli
var hh3 = jQuery('aside').not('.always_open').find('h2:first').css({'cursor':'pointer','position':'relative'}).append('^').height()+15+15;
jQuery('aside').find('h2:first').addClass('first');
var ph3 = jQuery('aside').find('h2:first').css('padding-top');
jQuery('aside .toggle_arrow').css('padding-top',ph3);
var secMarg = parseFloat(jQuery('section').css('margin-top'));
var h2ln = Math.round(parseFloat(jQuery('article .entry-title:first').height()) / parseFloat(jQuery('article .entry-title:first').css('line-height'))); //numero di righe del titolo della article
var h3ln = Math.round(parseFloat(jQuery('aside h2:first').height()) / parseFloat(jQuery('aside h2:first').css('line-height'))); //numero di righe del titolo della aside
if(h2ln == h3ln && (fe==0 || !jQuery('aside').hasClass('open_toggle') ) ) { //se i numeri di righe sono uguali etc.
jQuery('aside h2:first').css({'line-height':lhh2}); //setto le altezze uguali
hh3 = hh2; //setto le altezze uguali
}
if(jQuery('article').length!=0){
jQuery('article').not('.open_toggle').height(hh2).css({'left':offs.left,'top':off.top-(hh2),'position':'fixed'});
}
if(jQuery('aside').length!=0){
jQuery('aside').not('.open_toggle').height(hh3).css({'left':offa.left,'top':off.top-(hh3),'position':'fixed'});
}
jQuery('.open_toggle').find('.toggle_arrow').text('▼');
Cufon.refresh();
if(hs>h-(he+foo)) {
var hs2 = hs;
} else {
var hs2 = h-(he+foo);
}
if(ha>h-(he+foo+fe)) {
var ha2 = ha;
} else {
var ha2 = h-(he+foo+fe);
}
if(ha+fe>hs) {
jQuery('article.open_toggle').css({'height':ha2+fe,'visibility':'visible'});
jQuery('aside.open_toggle').css({'margin-top':fe,'height':ha2,'visibility':'visible'});
} else {
jQuery('article.open_toggle').css({'height':hs2,'visibility':'visible'});
jQuery('aside.open_toggle').css({'margin-top':fe,'height':hs2-fe,'visibility':'visible'});
}
function layoutAfterResize(){
//var agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);
//if (!agentID) {
var off;
off = jQuery('footer').offset();
var offs = jQuery('article').offset();
var offa = jQuery('aside').offset();
if (jQuery.browser.msie) {
h = jQuery(window).height();
} else {
h = window.innerHeight;
}
var scrolled = jQuery(window).scrollTop();
if(ha+feh-(he+foo)){
jQuery('article.open_toggle').css({'height':hs});
if(jQuery('article').hasClass('open_toggle')){
jQuery('aside.open_toggle').css({'height':hs-fe});
} else {
if(ha+feh-(he+foo)){
if(jQuery('aside').hasClass('open_toggle')){
jQuery('article.open_toggle').css({'height':ha+fe});
} else {
if(hsh-(he+foo)) {
hs2 = hs;
} else {
hs2 = h-(he+foo);
}
if(ha>h-(he+foo)) {
ha2 = ha;
} else {
ha2 = h-(he+foo+fe);
}
//}
}
jQuery(window).resize(function(){
layoutAfterResize();
});
var agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);
if( !jQuery('article').hasClass('always_open')){
jQuery('article .entry-title:first').click(function(){
var t = jQuery(this).parents('article');
if (jQuery.browser.msie) {
var h = jQuery(window).height();
} else {
var h = window.innerHeight;
}
var ha = jQuery('aside').height();
var off;
off = jQuery('footer').offset();
var scrolled = jQuery(window).scrollTop();
if(t.hasClass('open_toggle')){
/*if (agentID) {
return false;
}*/
t.animate({'margin-top':(off.top-scrolled)-(hh2+secMarg),'height':hh2},300,function(){
t.removeClass('open_toggle');
t.find('.toggle_arrow').text('▲');
Cufon.refresh();
t.css({'left':offs.left,'top':(off.top-scrolled)-(hh2),'margin':'0','position':'fixed'});
});
if(!jQuery('aside').hasClass('open_toggle')) {
jQuery('html,body').animate({scrollTop: 0}, 300 );
} else {
jQuery('aside.open_toggle').animate({'height':ha2}, 300 );
jQuery('html,body').animate({scrollTop: 0}, 300 );
}
/*if (agentID) {
jQuery('footer').css({'position':'fixed','margin-top':'0'});
}*/
} else {
t.css({'margin-top':off.top-(hh2+secMarg),'position':'relative','top':'0','left':'0'});
t.find('.toggle_arrow').text('▼');
Cufon.refresh();
if(hsh-(he+foo)) {
jQuery('aside.open_toggle').animate({'height':hs-fe},300);
t.animate({'margin-top':'0','height':hs},300,function(){t.addClass('open_toggle')});
} else {
//jQuery('aside.open_toggle').animate({'height':hs},300);
t.animate({'margin-top':'0','height':h-(he+foo)},300,function(){t.addClass('open_toggle')});
}
/*if (agentID) {
jQuery('footer').css({'position':'relative'});
}*/
}
}),layoutAfterResize();
}
var orPadB = jQuery('aside h2:first').css('padding-bottom');
var orPadT = jQuery('aside h2:first').css('padding-top');
var orPadAr = jQuery('aside h2:first .toggle_arrow').css('padding-top');
var orLh = jQuery('aside h2:first').css('line-height');
jQuery('aside').not('.open_toggle').find('h2:first').each(function(){
var dif = jQuery('.entry-title').height()-jQuery(this).height();
var marg = parseFloat(jQuery(this).css('padding-bottom').replace('px',''));
jQuery(this).css({'padding-bottom':(marg+dif),'padding-top':'20px'});
jQuery('.toggle_arrow',this).css({'padding-top':'20px'});
});
if( !jQuery('aside').hasClass('always_open')){
jQuery('aside h2:first').click(function(){
var t = jQuery(this).parents('aside');
if (jQuery.browser.msie) {
var h = jQuery(window).height();
} else {
var h = window.innerHeight;
}
var hs = jQuery('article').height();
var off;
off = jQuery('footer').offset();
var scrolled = jQuery(window).scrollTop();
if(t.hasClass('open_toggle')){
/*if (agentID) {
return false;
}*/
var dif = jQuery('.entry-title').height()-jQuery(this).height();
var marg = parseFloat(jQuery(this).css('padding-bottom').replace('px',''));
jQuery(this).animate({'padding-bottom':(marg+dif),'padding-top':'20px'});
jQuery('.toggle_arrow',this).animate({'padding-top':'20px'});
if(h2ln == h3ln) { //se i numeri di righe sono uguali etc.
jQuery('aside h2:first').css({'line-height':lhh2}); //setto le altezze uguali
hh3 = hh2; //setto le altezze uguali
}
t.animate({'margin-top':(off.top-scrolled)-(hh3+secMarg),'height':hh3},300,function(){
t.removeClass('open_toggle');
t.find('.toggle_arrow').text('▲');
Cufon.refresh();
t.css({'left':offa.left,'top':(off.top-scrolled)-(hh3),'margin':'0','position':'fixed'});
});
if(!jQuery('article').hasClass('open_toggle')) {
jQuery('html,body').animate({scrollTop: 0}, 300 );
} else {
jQuery('article.open_toggle').animate({'height':hs2}, 300 );
jQuery('html,body').animate({scrollTop: 0}, 300 );
}
} else {
jQuery(this).animate({'padding-bottom':orPadB,'padding-top':orPadT});
jQuery('.toggle_arrow',this).animate({'padding-top':orPadAr});
jQuery('aside h2:first').css({'line-height':orLh});
t.css({'margin-top':off.top-(hh2+secMarg),'position':'relative','top':'0','left':'0'});
t.find('.toggle_arrow').text('▼');
Cufon.refresh();
if(hah-(he+foo)) {
jQuery('article.open_toggle').animate({'height':ha+fe},300);
t.animate({'margin-top':fe,'height':ha},300,function(){t.addClass('open_toggle')});
} else {
//jQuery('article.open_toggle').animate({'height':ha+fe},300);
t.animate({'margin-top':fe,'height':h-(he+foo)},300,function(){t.addClass('open_toggle')});
}
}
}),layoutAfterResize();
}
}
jQuery(window).one('load',function(){
jQuery('article .entry-title:first, aside h2:first').unbind('click');
var hs = 0;
if(jQuery('article').length!=0){
hs = jQuery('article').height();
}
var ha = 0;
if(jQuery('aside').length!=0){
ha = jQuery('aside').height();
}
articleAsideOpen(hs, ha);
Cufon.refresh();
});
jQuery(window).one('load',function(){
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);
/*if (agentID) {
jQuery('aside h2:first').click();
jQuery('article .entry-title:first').click();
jQuery('footer').css({'position':'relative'});
jQuery('#body').css({'height':'auto'});
}*/
});