Learn how to use jQuery at the Blog

youPlugins « visit

  • Added 7 months ago
  • 89 Lines of Code shown
  • 2 Links of Interest
http://youplugins.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 youPlugins - http://youplugins.com

jQuery(document).ready(function() {

	var timeout;
	var posts = $('.posts');
	var next = $('.slider-next');
	var prev = $('.slider-prev');
	var step = 0;
	var pos = 0;
	var limit = 10;
	var scroll = false;
	
	next.click(function() {
		if (scroll) {return true;}
		step = 0;
		if (pos < 30*(limit-3)) {
			timeout = setTimeout(sliderNext, 20);
		}
	});
	
	prev.click(function() {
		if (scroll) {return true;}
		step = 0;
		if (pos > 0) {
			timeout = setTimeout(sliderPrev, 20);
		}
	});
	
	function sliderNext() {
//console.log(pos);				
		step++;	
		if (step > 30) {
			clearTimeout(timeout);
			if (pos == 30*(limit-3)) {next.addClass('disable');} else {next.removeClass('disable');}
			if (pos == 0) {prev.addClass('disable');} else {prev.removeClass('disable');}
			scroll = false;
		} else {
			pos++;
			scroll = true;
			posts.css('left',  40 - pos*10);
			posts.css('clip', 'rect(0px, '+(900+pos*10)+'px, auto, '+(pos*10)+'px)');			
			timeout = setTimeout(sliderNext, 20);			
		}
	}
	
	function sliderPrev() {
//console.log(pos);		
		step++;
		if (step > 30) {
			clearTimeout(timeout);
			if (pos == 30*(limit-3)) {next.addClass('disable');} else {next.removeClass('disable');}
			if (pos == 0) {prev.addClass('disable');} else {prev.removeClass('disable');}
			scroll = false;
		} else {
			pos--;
			scroll = true;
			posts.css('left',  40 - pos*10);
			posts.css('clip', 'rect(0px, '+(900+pos*10)+'px, auto, '+(pos*10)+'px)');			
			timeout = setTimeout(sliderPrev, 20);			
		}
	}
	
	$('.post-show').live('click', function() {
		$(this).parents('.post').find('.content-hidden').slideToggle('slow');
		$(this).toggleClass('up');
	});
	
	$('.navigation a').live('click', function() {
		var url = $(this).attr('href');
		$.ajax({
			type: 'POST',
			url: url,
			dataType: 'html',
			success: function(res){
				$('.navigation').remove();
				$('.box:first').append(res);
			}
		});
		$('.navigation').html('<span class="loading"><img src="/wp-content/themes/p2/i/loader.gif" align="absmiddle"> Загрузка</span>');
		return false;
	});
	
	$(".fancybox").fancybox({
		frameHeight: 530, 
		frameWidth: 580
	});

});

//$ = jQuery.noConflict();