/*
|--------------------------------------------------------------------------
| uitotop jquery plugin 1.2 by matt varone
| http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
|--------------------------------------------------------------------------
*/
(function($){
$.fn.uitotop = function(options) {
var defaults = {
text: 'to top',
min: 800,
indelay:600,
outdelay:400,
containerid: 'totop',
containerhoverid: 'totophover',
scrollspeed: 1200,
easingtype: 'linear'
},
settings = $.extend(defaults, options),
containeridhash = '#' + settings.containerid,
containerhoveridhash = '#'+settings.containerhoverid;
$('body').append(''+settings.text+'');
$(containeridhash).hide().on('click.uitotop',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': sd + $(window).height() - 50
});
}
if ( sd > settings.min )
$(containeridhash).fadein(settings.indelay);
else
$(containeridhash).fadeout(settings.outdelay);
});
};
})(jquery);