Refactor code structure for improved readability and maintainability
This commit is contained in:
55
modules/lib/UItoTop/jquery.ui.totop.js
vendored
Normal file
55
modules/lib/UItoTop/jquery.ui.totop.js
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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: 200,
|
||||
inDelay:600,
|
||||
outDelay:400,
|
||||
containerID: 'toTop',
|
||||
containerHoverID: 'toTopHover',
|
||||
scrollSpeed: 1200,
|
||||
easingType: 'linear'
|
||||
},
|
||||
settings = $.extend(defaults, options),
|
||||
containerIDhash = '#' + settings.containerID,
|
||||
containerHoverIDHash = '#'+settings.containerHoverID;
|
||||
|
||||
$('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');
|
||||
$(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('<span id="'+settings.containerHoverID+'"></span>')
|
||||
.hover(function() {
|
||||
$(containerHoverIDHash, this).stop().animate({
|
||||
'opacity': 1
|
||||
}, 200, 'linear');
|
||||
}, function() {
|
||||
$(containerHoverIDHash, this).stop().animate({
|
||||
'opacity': 0
|
||||
}, 300, '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);
|
||||
5
modules/lib/UItoTop/jquery.ui.totop.min.js
vendored
Normal file
5
modules/lib/UItoTop/jquery.ui.totop.min.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/* UItoTop jQuery Plugin 1.2 | Matt Varone | 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'},settings=$.extend(defaults,options),containerIDhash='#'+settings.containerID,containerHoverIDHash='#'+settings.containerHoverID;$('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');$(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('<span id="'+settings.containerHoverID+'"></span>').hover(function(){$(containerHoverIDHash,this).stop().animate({'opacity':1},200,'linear');},function(){$(containerHoverIDHash,this).stop().animate({'opacity':0},300,'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);
|
||||
Reference in New Issue
Block a user