PageSourceSearch

https://www.hofmannusa.com/_assets/0befa410f123eac9294e80f3fab2010…/jquery/scrolltotop.js?1791186887

js hofmannusa.com collected 2026-10-05 19:20:05 UTC 4,603 bytes, 92 lines download raw bytes

1var scrolltotop = {
2    //startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
3    //scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
4    setting: {startline: 100, scrollto: 0, scrollduration: 1000, fadeduration: [500, 100]},
5    controlHTML: '<i class="hofmann-i-arrow-top"></i>', //<img src="assets/img/up.png" style="width:51px; height:42px" /> //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
6    controlattrs: {offsetx: 10, offsety: 10}, //offset of control relative to right/ bottom of window corner
7    anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links
8
9    state: {isvisible: false, shouldvisible: false},
10
11    scrollup: function () {
12        if (!this.cssfixedsupport) //if control is positioned using JavaScript
13            this.$control.css({opacity: 0}); //hide control immediately after clicking it
14        var dest = isNaN(this.setting.scrollto) ? this.setting.scrollto : parseInt(this.setting.scrollto);
15        if (typeof dest === "string" && jQuery('#' + dest).length === 1) //check element set by string exists
16            dest = jQuery('#' + dest).offset().top;
17        else
18            dest = 0;
19        this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
20    },
21
22    keepfixed: function () {
23        var $window = jQuery(window);
24        var controlx = $window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx;
25        var controly = $window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety;
26        this.$control.css({left: controlx + 'px', top: controly + 'px'})
27    },
28
29    togglecontrol: function () {
30        var scrolltop = jQuery(window).scrollTop();
31        if (!this.cssfixedsupport)
32            this.keepfixed();
33        this.state.shouldvisible = (scrolltop >= this.setting.startline);
34        if (this.state.shouldvisible && !this.state.isvisible) {
35            this.$control.stop().animate({opacity: 1}, this.setting.fadeduration[0]);
36            this.$control.css('pointer-events', 'auto');
37            this.state.isvisible = true
38        }
39        else if (this.state.shouldvisible === false && this.state.isvisible) {
40            this.$control.stop().animate({opacity: 0}, this.setting.fadeduration[1]);
41            this.$control.css('pointer-events', 'none');
42            this.state.isvisible = false
43        }
44    },
45
46    init: function () {
47        jQuery(document).ready(function ($) {
48            var mainobj = scrolltotop;
49            var iebrws = document.all;
50            mainobj.cssfixedsupport = !iebrws || iebrws && document.compatMode === "CSS1Compat" && window.XMLHttpRequest; //not IE or IE7+ browsers in standards mode
51            mainobj.$body = (window.opera) ? (document.compatMode === "CSS1Compat" ? $('html') : $('body')) : $('html,body');
52
53            let appendTopcontrol = ($('#topcontrol').length === 0);
54
55            if (appendTopcontrol) {
56                mainobj.$control = $('<a id="topcontrol" href="#page">' + mainobj.controlHTML + '</a>')
57                  .css({
58                      position: mainobj.cssfixedsupport ? 'fixed' : 'absolute',
59                      bottom: mainobj.controlattrs.offsety,
60                      right: mainobj.controlattrs.offsetx,
61                      opacity: 0,
62                      cursor: 'pointer'
63                  })
64                  .attr({
65                      'aria-label': 'Scroll Back to Top',
66                      'title': 'Scroll Back to Top'
67                  })
68                  .appendTo('body');
69            } else {
70                mainobj.$control = $('#topcontrol');
71            }
72
73            mainobj.$control
74                .click(function () {
75                    mainobj.scrollup();
76                    return false
77                });
78            if (document.all && !window.XMLHttpRequest && mainobj.$control.text() !== '') //loose check for IE6 and below, plus whether control contains any text
79                mainobj.$control.css({width: mainobj.$control.width()}); //IE6- seems to require an explicit width on a DIV containing text
80            mainobj.togglecontrol();
81            $('a[href="' + mainobj.anchorkeyword + '"]').click(function () {
82                mainobj.scrollup();
83                return false
84            });
85            $(window).bind('scroll resize', function (e) {
86                mainobj.togglecontrol()
87            })
88        })
89    }
90};
91
92scrolltotop.init();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.