/* |-------------------------------------------------------------------------- | uitotop jquery plugin 1.1 | http://www.mattvarone.com/web-design/uitotop-jquery-plugin/ |-------------------------------------------------------------------------- */ (function($){ $.fn.uitotop = function(options) { var defaults = { text: 'to top', min: 200, indelay:600, outdelay:400, containerid: 'totop', containerhoverid: 'totophover', scrollspeed: 1200, easingtype: 'linear' }; var settings = $.extend(defaults, options); var containeridhash = '#' + settings.containerid; var containerhoveridhash = '#'+settings.containerhoverid; $('body').append(''+settings.text+''); $(containeridhash).hide().click(function(){ $('html, body').animate({scrolltop:0}, settings.scrollspeed, settings.easingtype); $('#'+settings.containerhoverid, this).stop().animate({'opacity': 0 }, settings.indelay, settings.easingtype); return false; }) .prepend('') .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);