TickerAnimation = { strelapsed2 : function( selector, timestamp ){ //console.log('strelapsed2: ' + selector + ' ' + timestamp + ' ' + strelapsed(timestamp) + ' ' + strelapsed(timestamp).indexOf('NaN')); if(strelapsed(timestamp).indexOf('NaN')!=0){ $('span#'+selector).html(strelapsed(timestamp)); } }, endingRows : function ( theContext, theMethod ){ $('ul.list_topNews > li:gt(2)',theContext)[theMethod](); $('ul.user > li:eq(2)',theContext)[theMethod](); $('ul.dallaRete > li:eq(2)',theContext)[theMethod](); }, beginningRows: function ( theContext, theMethod ){ $('ul.list_topNews > li:eq(0)',theContext)[theMethod](); $('ul.user > li:eq(0)',theContext)[theMethod](); $('ul.dallaRete > li:eq(0)',theContext)[theMethod](); $('div.box_list',theContext)[theMethod](); }, sandwitchedRows: function ( theContext, theMethod ){ $('ul.list_topNews > li:eq(1)',theContext)[theMethod](); $('ul.list_topNews > li:eq(2)',theContext)[theMethod](); $('ul.user > li:eq(1)',theContext)[theMethod](); $('ul.dallaRete > li:eq(1)',theContext)[theMethod](); }, serializeBoxesStatus: function (){ var theCookieValue = ''; $.each( $('div.box_news'), function(i,n){ if ( $(n).attr('boxStatus') ){ theCookieValue += $(n).attr('id') + ':'+ $(n).attr('boxStatus') + '&'; } } ); $.cookie('hpHeightsSerialized', theCookieValue.replace(/&$/,''), {expires: 365}); } } BoxDxTabber = { switchTab: function( elem, target ){ $(elem).parent().parent().children().removeClass('sel'); $(elem).parent().addClass('sel'); $('div.tab_evidenza').hide(); $(target).show(); } } //$(document).ready( window.onload = function () { if($.cookie('hpSortSerialized')) { var sorted = $.cookie('hpSortSerialized').replace(/contenuti\[\]=/g,'').split('&'); var eachFunc = function(){ var lastBox = 'div#primo_piano'; return function(i,n){ $(lastBox).after($('div#'+n)); lastBox = 'div#'+n; } }(); $.each( sorted, eachFunc); } if($.cookie('hpHeightsSerialized')) { var heights = $.cookie('hpHeightsSerialized').split('&'); $.each( heights, function(i,n){ var pair = n.split(':'); if (pair[1]!='opened') { TickerAnimation.endingRows( $('div#'+pair[0]), 'hide' ); } if (pair[1]=='half-closed') { TickerAnimation.sandwitchedRows( $('div#'+pair[0]), 'hide' ); } if (pair[1]=='closed') { TickerAnimation.sandwitchedRows( $('div#'+pair[0]), 'hide' ); TickerAnimation.beginningRows( $('div#'+pair[0]), 'hide' ); } $('div#'+pair[0]).attr('boxStatus',pair[1]); } ); }else{ $.each( $('div.box_news'), function(i,n){ if( $('div.boxstatus', n).size() == 0 ){ // default: chiudiamo di uno TickerAnimation.endingRows( $(n), 'hide' ); $(n).children().attr('boxStatus','half-opened'); } } ); } if(!$.browser.safari){ $('div#contenuti').Sortable( { accept : 'box_news', opacity : 0.5, handle: 'img.img_move', onStop : function(){$.cookie('hpSortSerialized', $.SortSerialize().hash, {expires: 365});} } ) }else{ $('img.img_move').hide() } $('img.img_news_meno').mousedown( function() { if( $(this).parent().parent().parent().attr('boxStatus') && $(this).parent().parent().parent().attr('boxStatus')=='half-closed' ){ TickerAnimation.beginningRows( $(this).parent().parent().parent(), 'hide' ); $(this).parent().parent().parent().attr('boxStatus','closed'); }else if( $(this).parent().parent().parent().attr('boxStatus') && $(this).parent().parent().parent().attr('boxStatus')=='closed' ){ /* void */ }else if( $(this).parent().parent().parent().attr('boxStatus') && $(this).parent().parent().parent().attr('boxStatus')=='half-opened' ){ TickerAnimation.sandwitchedRows( $(this).parent().parent().parent(), 'hide' ); $(this).parent().parent().parent().attr('boxStatus','half-closed'); }else{ TickerAnimation.endingRows( $(this).parent().parent().parent(), 'hide' ); $(this).parent().parent().parent().attr('boxStatus','half-opened'); } TickerAnimation.serializeBoxesStatus(); } ); $('img.img_news_piu').mousedown( function() { if( $(this).parent().parent().parent().attr('boxStatus') && $(this).parent().parent().parent().attr('boxStatus')=='half-closed' ){ TickerAnimation.sandwitchedRows( $(this).parent().parent().parent(), 'show' ); $(this).parent().parent().parent().attr('boxStatus','half-opened'); }else if( $(this).parent().parent().parent().attr('boxStatus') && $(this).parent().parent().parent().attr('boxStatus')=='half-opened' ){ TickerAnimation.endingRows( $(this).parent().parent().parent(), 'show' ); $(this).parent().parent().parent().attr('boxStatus','opened'); }else if( $(this).parent().parent().parent().attr('boxStatus') && $(this).parent().parent().parent().attr('boxStatus')=='closed' ){ TickerAnimation.beginningRows( $(this).parent().parent().parent(), 'show' ); $(this).parent().parent().parent().attr('boxStatus','half-closed'); }else{ /* void */ } TickerAnimation.serializeBoxesStatus(); } ); $('#link_tab_evidenza_1').mousedown( function() { BoxDxTabber.switchTab( this, '#tab_evidenza_1' ); } ) $('#link_tab_evidenza_2').mousedown( function() { BoxDxTabber.switchTab( this, '#tab_evidenza_2' ); } ) $('#link_tab_evidenza_3').mousedown( function() { BoxDxTabber.switchTab( this, '#tab_evidenza_3' ); } ) /* RULLO REAL TIME */ if( $('div.realtime_content').size()>0 ){ $('div.realtime_content').eq(0).show(); setInterval( function(){ var curr = $('div.realtime_content:visible'); curr.hide(); if ( curr.next().size()>0 ){ curr.next().show(); }else{ $('div.realtime_content').eq(0).show(); } }, 3000 ); } /* FILTRO NUMERO NOTIZIE IN SUBCATS */ if( $('div#news_canale > ul > li').size()>0 ){ //alert($('div#news_canale > ul > li').gt(0)) /*$('div#news_canale > ul > li').gt($('label.right > select').val()-1).hide();*/ var numNewsDisplay = $('label.right > select').val()-1; $('div#news_canale > ul > li:gt(' + numNewsDisplay + ')').hide(); $('label.right > select').get(0).onchange = function(){ var numNewsDisplay = this.value; $('div#news_canale > ul > li:gt(' + (numNewsDisplay - 1) + ')').hide(); $('div#news_canale > ul > li:lt(' + numNewsDisplay + ')').show(); } } } //);