Blame view

frontend/web/js/external/jquery.ui.totop.js 1.88 KB
559be889   Alexander Karnovsky   Init test-9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  /*

  |--------------------------------------------------------------------------

  | UItoTop jQuery Plugin 1.1

  | http://www.mattvarone.com/web-design/uitotop-jquery-plugin/

  |--------------------------------------------------------------------------

  */

  

  (function($){

  	$.fn.UItoTop = function(options) {

  

   		var defaults = {

  			text: 'Top of the page',

  			min: 200,

  			inDelay:600,

  			outDelay:400,

    			containerID: 'toTop',

  			containerHoverID: 'toTopHover',

  			scrollSpeed: 0, /*1200*/

  			easingType: 'linear'

   		};

  

   		var settings = $.extend(defaults, options);

  		var containerIDhash = '#' + settings.containerID;

  		var containerHoverIDHash = '#'+settings.containerHoverID;

  		

  		$('body').append('<a href="#" id="'+settings.containerID+'" title="'+settings.text+'">'+settings.text+'</a>');

  		$(containerIDhash).hide().click(function(){

  			if(settings.scrollSpeed == 0)

  				$('html, body').attr("scrollTop", 0);

  			else 

  				$('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);

  			

  			$('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType);

  			return false;

  		})

  		.prepend('<span id="'+settings.containerHoverID+'"></span>')

  		.hover(function() {

  				$(containerHoverIDHash, this).stop().animate({

  					'opacity': 1

  				}, 600, 'linear');

  			}, function() { 

  				$(containerHoverIDHash, this).stop().animate({

  					'opacity': 0

  				}, 700, 'linear');

  			});

  					

  		$(window).scroll(function() {

  			var sd = $(window).scrollTop();

  			if(typeof document.body.style.maxHeight === "undefined") {

  				$(containerIDhash).css({

  					'position': 'absolute',

  					'top': $(window).scrollTop() + $(window).height() - 50

  				});

  			}

  			if ( sd > settings.min ) 

  				$(containerIDhash).fadeIn(settings.inDelay);

  			else 

  				$(containerIDhash).fadeOut(settings.Outdelay);

  		});

  

  };

  })(jQuery);