PageSourceSearch

https://www.penzionumartina.cz/js/jquery.sticky.js

js penzionumartina.cz collected 2026-10-06 04:38:22 UTC 6,807 bytes, 207 lines download raw bytes

vendor: 4,161 bytes, lines 1-117
1(function($) {
2    var slice = Array.prototype.slice; // save ref to original slice()
3    var splice = Array.prototype.splice; // save ref to original slice()
4
5  var defaults = {
6      topSpacing: 0,
7      bottomSpacing: 0,
8      className: 'is-sticky',
9      wrapperClassName: 'sticky-wrapper',
10      center: false,
11      getWidthFrom: '',
12      widthFromWrapper: true, // works only when .getWidthFrom is empty
13      responsiveWidth: false
14    },
15    $window = $(window),
16    $document = $(document),
17    sticked = [],
18    windowHeight = $window.height(),
19    scroller = function() {
20      var scrollTop = $window.scrollTop(),
21        documentHeight = $document.height(),
22        dwh = documentHeight - windowHeight,
23        extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
24
25      for (var i = 0; i < sticked.length; i++) {
26        var s = sticked[i],
27          elementTop = s.stickyWrapper.offset().top,
28          etse = elementTop - s.topSpacing - extra;
29
30    //update height in case of dynamic content
31    s.stickyWrapper.css('height', s.stickyElement.outerHeight());
32
33        if (scrollTop <= etse) {
34          if (s.currentTop !== null) {
35            s.stickyElement
36              .css({
37                'width': '',
38                'position': '',
39                'top': ''
40              });
41            s.stickyElement.parent().removeClass(s.className);
42            s.stickyElement.trigger('sticky-end', [s]);
43            s.currentTop = null;
44          }
45        }
46        else {
47          var newTop = documentHeight - s.stickyElement.outerHeight()
48            - s.topSpacing - s.bottomSpacing - scrollTop - extra;
49          if (newTop < 0) {
50            newTop = newTop + s.topSpacing;
51          } else {
52            newTop = s.topSpacing;
53          }
54          if (s.currentTop != newTop) {
55            var newWidth;
56            if (s.getWidthFrom) {
57                newWidth = $(s.getWidthFrom).width() || null;
58            } else if (s.widthFromWrapper) {
59                newWidth = s.stickyWrapper.width();
60            }
61            if (newWidth == null) {
62                newWidth = s.stickyElement.width();
63            }
64            s.stickyElement
65              .css('width', newWidth)
66              .css('position', 'fixed')
67              .css('top', newTop);
68
69            s.stickyElement.parent().addClass(s.className);
70
71            if (s.currentTop === null) {
72              s.stickyElement.trigger('sticky-start', [s]);
73            } else {
74              // sticky is started but it have to be repositioned
75              s.stickyElement.trigger('sticky-update', [s]);
76            }
77
78            if (s.currentTop === s.topSpacing && s.currentTop > newTop || s.currentTop === null && newTop < s.topSpacing) {
79              // just reached bottom || just started to stick but bottom is already reached
80              s.stickyElement.trigger('sticky-bottom-reached', [s]);
81            } else if(s.currentTop !== null && newTop === s.topSpacing && s.currentTop < newTop) {
82              // sticky is started && sticked at topSpacing && overflowing from top just finished
83              s.stickyElement.trigger('sticky-bottom-unreached', [s]);
84            }
85
86            s.currentTop = newTop;
87          }
88        }
89      }
90    },
91    resizer = function() {
92      windowHeight = $window.height();
93
94      for (var i = 0; i < sticked.length; i++) {
95        var s = sticked[i];
96        var newWidth = null;
97        if (s.getWidthFrom) {
98            if (s.responsiveWidth === true) {
99                newWidth = $(s.getWidthFrom).width();
100            }
101        } else if(s.widthFromWrapper) {
102            newWidth = s.stickyWrapper.width();
103        }
104        if (newWidth != null) {
105            s.stickyElement.css('width', newWidth);
106        }
107      }
108    },
109    methods = {
110      init: function(options) {
111        var o = $.extend({}, defaults, options);
112        return this.each(function() {
113          var stickyElement = $(this);
114
115          var stickyId = stickyElement.attr('id');
116          var stickyHeight = stickyElement.outerHeight();
117          var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName
118          var wrapper = $('<div></div>')
119            .attr('id', wrapperId)
120            .addClass(o.wrapperClassName);
121
122          stickyElement.wrapAll(wrapper);
123
124          var stickyWrapper = stickyElement.parent();
125
126          if (o.center) {
127            stickyWrapper.css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"});
128          }
129
130          if (stickyElement.css("float") == "right") {
131            stickyElement.css({"float":"none"}).parent().css({"float":"right"});
132          }
133
134          stickyWrapper.css('height', stickyHeight);
135
136          o.stickyElement = stickyElement;
137          o.stickyWrapper = stickyWrapper;
138          o.currentTop    = null;
139
140          sticked.push(o);
141        });
142      },
143      update: scroller,
144      unstick: function(options) {
145        return this.each(function() {
146          var that = this;
147          var unstickyElement = $(that);
148
149          var removeIdx = -1;
150          var i = sticked.length;
151          while (i-- > 0) {
152            if (sticked[i].stickyElement.get(0) === that) {
153                splice.call(sticked,i,1);
154                removeIdx = i;
155            }
156          }
157          if(removeIdx != -1) {
158            unstickyElement.unwrap();
159            unstickyElement
160              .css({
161                'width': '',
162                'position': '',
163                'top': '',
164                'float': ''
165              })
166            ;
167          }
168        });
169      }
170    };
171
172  // should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
173  if (window.addEventListener) {
174    window.addEventListener('scroll', scroller, false);
175    window.addEventListener('resize', resizer, false);
176  } else if (window.attachEvent) {
177    window.attachEvent('onscroll', scroller);
178    window.attachEvent('onresize', resizer);
179  }
180
181  $.fn.sticky = function(method) {
182    if (methods[method]) {
183      return methods[method].apply(this, slice.call(arguments, 1));
184    } else if (typeof method === 'object' || !method ) {
185      return methods.init.apply( this, arguments );
186    } else {
187      $.error('Method ' + method + ' does not exist on jQuery.sticky');
188    }
189  };
190
191  $.fn.unstick = function(method) {
192    if (methods[method]) {
193      return methods[method].apply(this, slice.call(arguments, 1));
194    } else if (typeof method === 'object' || !method ) {
195      return methods.unstick.apply( this, arguments );
196    } else {
197      $.error('Method ' + method + ' does not exist on jQuery.sticky');
198    }
199  };
200  $(function() {
201    setTimeout(scroller, 0);
202  });
203})(jQuery);
204
205$(document).ready(function(){
206      $(".navbar").sticky({topSpacing:0});
207    });

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.