PageSourceSearch

https://www.huskermax.com/wp-content/themes/sportsfish/js/bottom/04-rail-lock.js?ver=1.0.0

js huskermax.com collected 2026-10-02 07:07:17 UTC 7,262 bytes, 221 lines download raw bytes

1var checkAdInterval;
2
3// DOM elements on page
4var article_container_dom = '.article-container';
5var article_dom = '.article-container article';
6var page_content_dom = '.page-content';
7var search_container_dom = '#search-container';
8
9var footer_dom = ".page-footer";
10var nav_dom = ".navbar-fixed";
11var locked_elements_padding_top = 10;
12
13// Locking rails
14var social_rail_dom = '.article-container .social-rail';
15var social_rail_width_hide = 900;
16
17var right_rail_dom = '#right-rail';
18var right_rail_dom_lock = '#right-rail-lock';
19var right_rail_width_hide = 1000;
20
21
22// Dom element: CSS selector of locked element on page
23// Position: Left or right. Decide if you want to lock it on the left or right of the screen
24var lockedElement = function(dom_element, position, min_width) {
25  var locked_element = {
26    // Initial values
27    dom_element: dom_element,
28    position: position,
29    top_padding: jQuery(nav_dom).outerHeight() + locked_elements_padding_top,
30    min_width: min_width,
31    element_height: 0,
32    // Used when scrolling
33    current_scroll: 0,
34    position_top: 0,
35    rail_locked: false,
36    rail_shown: true,
37    scroll_when_locked: 0,
38    // Sets position left or right of the page when locked
39    total_position_space: 0,
40    // Prevent overlap with footer
41    footer_dom_element: footer_dom,
42    footer_height:0,
43    footer_top: 0,
44    rail_bottom: 0,
45    
46    // Sets how far to the left or right we want our locked rail
47    setPositionSpace: function() {
48      if (position === 'left') {
49        this.total_position_space = jQuery(dom_element).offset().left;
50      } else {
51        this.total_position_space = jQuery(window).width() - (jQuery(dom_element).offset().left + jQuery(dom_element).outerWidth());
52      }
53    },
54
55    // This prevents the locked element from overlapping with the footer
56    preventFooterOverlap: function() {
57      // Run if we have a footer on the page
58      if ( jQuery(this.footer_dom_element).is(":visible") ) {
59        // Where footer is on the page
60        this.footer_top = jQuery(this.footer_dom_element).offset().top - 50;
61
62        // The bottom pixel amount of the locked element
63        // Will increase as the reader scrolls down the page
64        this.rail_bottom = jQuery(this.dom_element).offset().top + this.element_height;
65
66        // Make sure locked element doesn't overlap with footer
67        if (this.rail_bottom >= this.footer_top) {
68
69          // Set bottom attribute to height between bottom of page
70          // And top of footer
71          // jQuery(this.dom_element).css({
72          //   'height': + jQuery(this.footer_dom_element).offset().top - jQuery(window).scrollTop() - jQuery(nav_dom).outerHeight() - 25
73          // });
74        } else {
75          jQuery(this.dom_element).css({
76            'height': 'auto'
77          });
78        }
79      // Close if footer
80      }
81    // Close prevent footer overlap
82    },
83
84    // Called when reader is scrolling
85    whenScrolling: function() {
86      this.current_scroll = jQuery(window).scrollTop();
87
88      if(this.current_scroll >= this.position_top && !this.rail_locked){
89        // Add class
90        jQuery(this.dom_element).addClass("locked");
91
92        // Set position
93        jQuery(this.dom_element).css(this.position, this.total_position_space);
94
95        // Push article to the right
96        if (dom_element === social_rail_dom) {
97
98          jQuery(article_dom).css({
99            'margin-left': jQuery(dom_element).outerWidth()
100          })
101        }
102
103        jQuery(dom_element).css({
104          top: jQuery(nav_dom).outerHeight() + locked_elements_padding_top
105        })
106
107        this.rail_locked = true;
108        this.scroll_when_locked = this.current_scroll;
109      }
110      else if(this.current_scroll < this.scroll_when_locked){
111        jQuery(this.dom_element).removeClass("locked");
112        jQuery(this.dom_element).css(this.position, 0);
113
114        this.rail_locked = false;
115      }
116    // Close when scrolling
117    },
118
119    // Called when reader is resizing
120    whenResizing: function() {
121      this.setPositionSpace();
122        
123      if (this.rail_locked) {
124        jQuery(this.dom_element).css(this.position, this.total_position_space);
125      }
126      else {
127        jQuery(this.dom_element).css(this.position, 0);
128      }
129    // Close when resizing
130    },
131
132    // Track both scroll and mousewheel events
133    scrollMousewheel: function() {
134      if ( jQuery(window).width() > locked_element.min_width ) {
135        locked_element.whenScrolling();
136        locked_element.preventFooterOverlap();
137      }
138    },
139    // Initialize a locked element
140    initialize: function() {
141      // Init values
142      this.element_height = jQuery(this.dom_element).outerHeight();
143      this.footer_height = jQuery(this.footer_dom_element).outerHeight();
144      this.position_top = jQuery(this.dom_element).offset().top - this.top_padding;
145      this.footer_top = jQuery(this.footer_dom_element).outerHeight(true);
146
147      // Set left or right CSS property for locked element
148      this.setPositionSpace();
149
150      // Scroll and mousewheel events
151      if ( jQuery(window).width() > locked_element.min_width ) {
152        
153        // Scroll event
154        jQuery(window).scroll(function() {
155          locked_element.scrollMousewheel();
156        });
157
158        // Mousewheel event
159        jQuery(window).mousewheel(function() {
160          locked_element.scrollMousewheel();
161        });
162      }
163
164      // Resize events
165      if ( jQuery(window).width() > locked_element.min_width ) {
166        jQuery(window).resize(function() {
167          
168          jQuery(right_rail_dom_lock).removeClass('locked');
169
170          locked_element.whenResizing();
171        });
172      }
173    // Close initialize
174    }
175  // Close locked element variable
176  }
177
178  // Initialize object after a new one is called
179  locked_element.initialize();
180// Close locked element
181}
182
183function initLockedElement() {
184  if ( jQuery(right_rail_dom_lock).length > 0 && jQuery(window).width() > right_rail_width_hide) {
185		var right_rail = lockedElement(right_rail_dom_lock, "right", right_rail_width_hide);
186
187    // Prevent jitterness at bottom of the page
188    // By making container next to rail
189    // At least as tall as the rail
190    if ( jQuery(article_dom).length > 0 || jQuery(page_content_dom).length > 0 || jQuery(search_container_dom).length > 0) {
191
192      // Set min height if on article
193      // Otherwise set it to page content DIV
194      if ( jQuery(article_dom).length > 0 ) {
195        var min_height_dom = article_dom;
196      // If we're on a regular page, do the same
197      } else if ( jQuery(page_content_dom).length > 0 ) {
198        var min_height_dom = page_content_dom;
199      // If we're on the search page, do the same
200      } else if ( jQuery(search_container_dom).length > 0 ) {
201        var min_height_dom = search_container_dom;
202      }
203
204      console.log(min_height_dom);
205      jQuery(min_height_dom).css({
206        'min-height': jQuery(right_rail_dom).outerHeight() + 100
207      })
208    }
209	}
210
211	if ( jQuery(social_rail_dom).length > 0 && jQuery(window).width() > social_rail_width_hide) {
212		var social_rail = lockedElement(social_rail_dom, "left", social_rail_width_hide);
213	}
214}
215
216function checkAd() {
217	if (window.googletag && googletag.apiReady) {
218    initLockedElement();
219		clearInterval(checkAdInterval);
220	}
221}

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.