Learn how to use jQuery at the Blog

Nacional Financiera « visit

  • Added 6 months ago
  • 115 Lines of Code shown
  • 5 Links of Interest
http://nafin.com
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to Nacional Financiera - http://nafin.com

/*
 * @projectDescription Nacional Financiera by Ingenia Group
 * @author Mario Palomera
*/

function crearCarrouselMiniMundos(centrarActual){
	var $panels = $('.unMiniMundo');
	var $scroll = $('#divPanelMiniMundos');
	var $prev = $('#flechaIZQminM'),
		$next = $('#flechaDERminM');
	var numeroDEminimundos = $panels.length;
	$('#verMas').hide();
	
	var inicializoHover = false;
	var $minimActual;
	var miniMundoURL = window.location.pathname;
	var numeroDeMiniMundoActual;
	
	function seleccionarActual(){
		var encontroActual = false;
		$panels.each(function(index) {
			if($(this).children('.ligaSinUmm').attr('href') == miniMundoURL){
				$minimActual = $(this);
				$minimActual.addClass('miniMundoActual');
				numeroDeMiniMundoActual = index;
				encontroActual = true;
			}
		});
		if(encontroActual){
			$minimActual.children(".unMiniMundoROLL").css('opacity', 1).fadeIn();
		}else{
			$(".unMiniMundoROLL").css('opacity', 1);
		}
	}
		
	if(centrarActual) {
		$(".unMiniMundoROLL").css('opacity', .76);
		seleccionarActual();
	}
	
	if(numeroDEminimundos > 3){
		$('#verMas').show();
		$prev.show().css({'opacity': .4});
		$next.show();
	
		var $container = $('#divMiniMundosContainer');

        $panels.css({
            'float' : 'left',
            'position' : 'relative' // IE fix to ensure overflow is hidden
        });
        $container.css('width', $panels.width() * $panels.length);

	    $scroll.css('overflow', 'hidden');
	
		$next.bind('click', function(event) {
			$scroll.trigger('next');
		});
	
	    var scrollOptions = {
	        target: $scroll, // the element that has the overflow
	        items: $panels,
	        prev: $prev, 
	        //next: '.soyNEXT',
	        axis: 'xy',
	        duration: 250,
			cycle: false,
			onBefore:function( e, elem, $scroll, $panels, pos ){
				if( pos == 0 ) $prev.animate({'opacity': .4}, 200); else $prev.animate({'opacity': 1}, 200);
				if( pos == $panels.length-3 ){
					$next.animate({'opacity': .4}, 200).unbind('click');
				} else if( pos < $panels.length-3 ) $next.animate({'opacity': 1}, 200).bind('click', function(event) {
						$scroll.trigger('next');
					});
			}
	    };

	    $('#divMiniMundos').serialScroll(scrollOptions);
		
		if(centrarActual){
			seleccionarActual();
			centrarElMiniMundoActual();
		}
			
	} else {
		$prev.hide();
		$next.hide();
	}

	function centrarElMiniMundoActual(){
		if(numeroDeMiniMundoActual > 1){
			numeroDeMiniMundoActual--;
			var chekMiniMlimit = numeroDEminimundos-3;
			if(numeroDeMiniMundoActual > chekMiniMlimit) numeroDeMiniMundoActual--;
			$scroll.trigger( 'goto', [numeroDeMiniMundoActual] ).trigger( 'notify', [ numeroDeMiniMundoActual ] );
		}
		$(".unMiniMundo").hover(function() {
			if($(this).attr('class') != 'unMiniMundo miniMundoActual')
				$(this).find(".unMiniMundoROLL").fadeIn('slow');
		}, function() {
			if($(this).attr('class') != 'unMiniMundo miniMundoActual')
				$(this).find(".unMiniMundoROLL").fadeOut('fast');
		});
	}
	
	if(!centrarActual){
		$(".unMiniMundo").hover(function() {
			$(this).find(".unMiniMundoROLL").fadeIn('slow');
		}, function() {
			$(this).find(".unMiniMundoROLL").fadeOut('fast');
		});
	}


}