1(function($){ 2 $.fn.tmStickUp=function(options){ 3 4 var getOptions = { 5 correctionSelector: $('.correctionSelector') 6 , listenSelector: $('.listenSelector') 7 , active: false 8 , pseudo: true 9 } 10 $.extend(getOptions, options); 11 12 var 13 _this = $(this) 14 , _window = $(window) 15 , _document = $(document) 16 , thisOffsetTop = 0 17 , thisOuterHeight = 0 18 , thisMarginTop = 0 19 , thisPaddingTop = 0 20 , documentScroll = 0 21 , pseudoBlock 22 , lastScrollValue = 0 23 , scrollDir = '' 24 , tmpScrolled 25 ; 26 27 init(); 28 function init(){ 29 thisOffsetTop = parseInt(_this.offset().top); 30 thisMarginTop = parseInt(_this.css("margin-top")); 31 thisOuterHeight = parseInt(_this.outerHeight(true)); 32 33 if(getOptions.pseudo){ 34 $('<div class="pseudoStickyBlock"></div>').insertAfter(_this); 35 pseudoBlock = $('.pseudoStickyBlock'); 36 pseudoBlock.css({"position":"relative", "display":"block"}); 37 } 38 39 if(getOptions.active){ 40 addEventsFunction(); 41 } 42 }//end init 43 44 function addEventsFunction(){ 45 _document.on('scroll', function() { 46 tmpScrolled = $(this).scrollTop(); 47 if (tmpScrolled > lastScrollValue){ 48 scrollDir = 'down'; 49 } else { 50 scrollDir = 'up'; 51 } 52 lastScrollValue = tmpScrolled; 53 54 if(getOptions.correctionSelector.length != 0){ 55 correctionValue = getOptions.correctionSelector.outerHeight(true); 56 }else{ 57 correctionValue = 0; 58 } 59 60 documentScroll = parseInt(_window.scrollTop()); 61 if(thisOffsetTop - correctionValue < documentScroll){ 62 _this.addClass('isStuck'); 63 getOptions.listenSelector.addClass('isStuck'); 64 if(getOptions.pseudo){ 65 _this.css({position:"fixed", top:correctionValue}); 66 pseudoBlock.css({"height":thisOuterHeight}); 67 }else{ 68 _this.css({position:"fixed", top:correctionValue}); 69 } 70 }else{ 71 _this.removeClass('isStuck'); 72 getOptions.listenSelector.removeClass('isStuck'); 73 if(getOptions.pseudo){ 74 _this.css({position:"relative", top:0}); 75 pseudoBlock.css({"height":0}); 76 }else{ 77 _this.css({position:"absolute", top:0}); 78 } 79 } 80 }).trigger('scroll'); 81 } 82 }//end tmStickUp function 83})(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.