Dropped the UItoTop jQuery plugin and wrote our own

This commit is contained in:
evrifaessa committed 2022-11-19 20:55:14 +03:00
1 parent e614aa063e
commit 08b435cb43
6 files changed
+43 -60

No files matched your search

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-up" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<line x1="12" y1="5" x2="12" y2="19" />
<line x1="18" y1="11" x2="12" y2="5" />
<line x1="6" y1="11" x2="12" y2="5" />
</svg>

After

Width:  |  Height:  |  Size: 416 B

@@ -271,8 +271,6 @@ $(function () {
if ($("a.api-link").length) { bb.apiLink(); }
//if($("ul#menu").length){bb.menuAutoActive();}
$().UItoTop();
//===== Datepickers =====//
$(".datepicker").datepicker({
defaultDate: +7,
@@ -323,6 +321,25 @@ $(function () {
bb.reload();
return false;
}).val(bb.cookieRead('BBLANG'));
//===== Back to top =====//
let toTopButton = document.getElementById("back-to-top");
toTopButton.addEventListener("click", toTop);
function toTop() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
window.onscroll = function () {
// If the page is scrolled more than 200px, show the button
if (document.body.scrollTop > 200 || document.documentElement.scrollTop > 200) {
toTopButton.classList.replace("hidden", "visible");
} else {
toTopButton.classList.replace("visible", "hidden");
}
};
});
const FOSSBilling = {
@@ -1,55 +0,0 @@
/*
|--------------------------------------------------------------------------
| 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
}, 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);
@@ -1,3 +1,11 @@
.page {
min-height: calc(100vh - 2px);
}
.visible {
transition: opacity 400ms;
}
.hidden {
opacity: 0;
}
@@ -54,7 +54,6 @@ export const buildThemeAdminJs = function buildThemeAdminJs() {
'assets/js/ui/jquery.tipsy.js',
'assets/js/jquery.collapsible.min.js',
'assets/js/forms/forms.js',
'assets/js/jquery.ToTop.js',
'assets/js/jquery.scrollTo-min.js',
'assets/js/jquery-ui.js',
upath.joinSafe(nodeModulesPath, '@tabler/core/dist/js/tabler.js'),
@@ -99,4 +98,4 @@ gulp.task('admin-sprite', buildThemeAdminSprite);
gulp.task('admin-js', buildThemeAdminJs);
gulp.task('admin-css', buildThemeAdminCSS);
export default build;
export default build;
@@ -236,6 +236,12 @@
{% include '../build/symbol/icons-sprite.svg' %}
</div>
<button type="button" aria-label="Back to top" class="btn btn-floating btn-lg btn-icon hidden" id="back-to-top">
<svg class="icon">
<use xlink:href="#arrow-up" />
</svg>
</button>
<script>
// Switch light/dark theme
document.addEventListener('DOMContentLoaded', () => {
@@ -262,4 +268,4 @@
</noscript>
{% endif %}
</body>
</html>
</html>