1jQuery( 2function($) { 3 4 $(document).ready(function(){ 5 var contentButton = []; 6 var contentTop = []; 7 var content = []; 8 var lastScrollTop = 0; 9 var scrollDir = ''; 10 var itemClass = ''; 11 var itemHover = ''; 12 var menuSize = null; 13 var stickyHeight = 0; 14 var stickyMarginB = 0; 15 var currentMarginT = 0; 16 var topMargin = 0; 17 $(window).scroll(function(event){ 18 var st = $(this).scrollTop(); 19 if (st > lastScrollTop){ 20 scrollDir = 'down'; 21 } else { 22 scrollDir = 'up'; 23 } 24 lastScrollTop = st; 25 }); 26 $.fn.stickUp = function( options ) { 27 // adding a class to users div 28 $(this).addClass('stuckMenu'); 29 //getting options 30 var objn = 0; 31 if(options != null) { 32 for(var o in options) { 33 if (options.hasOwnProperty(o)){ 34 content[objn] = options[objn]; 35 objn++; 36 } 37 } 38 if(objn == 0) { 39 console.log('error:needs arguments'); 40 } 41 42 itemClass = options.itemClass; 43 itemHover = options.itemHover; 44 if(options.topMargin != null) { 45 if(options.topMargin == 'auto') { 46 topMargin = parseInt($('.stuckMenu').css('margin-top')); 47 } else { 48 if(isNaN(options.topMargin) && options.topMargin.search("px") > 0){ 49 topMargin = parseInt(options.topMargin.replace("px","")); 50 } else if(!isNaN(parseInt(options.topMargin))) { 51 topMargin = parseInt(options.topMargin); 52 } else { 53 console.log("incorrect argument, ignored."); 54 topMargin = 0; 55 } 56 } 57 } else { 58 topMargin = 0; 59 } 60 menuSize = $('.'+itemClass).length; 61 } 62 stickyHeight = parseInt($(this).height()); 63 stickyMarginB = parseInt($(this).css('margin-bottom')); 64 currentMarginT = parseInt($(this).next().closest('div').css('margin-top')); 65 vartop = parseInt($(this).offset().top); 66 //$(this).find('*').removeClass(itemHover); 67 } 68 $(document).on('scroll', function () { 69 var varscroll = parseInt($(document).scrollTop()); 70 71 if (vartop < varscroll + topMargin) { 72 // Add class when scrolling down 73 $('.stuckMenu').addClass('isStuck'); 74 $('.stuckMenu').next().closest('div').css({ 75 'margin-top': stickyHeight + stickyMarginB + currentMarginT + 'px' 76 }); 77 $('.stuckMenu').css("position", "fixed"); 78 $('.isStuck').css({ top: '0px' }); 79 } else { 80 // Remove class when scrolling back up 81 $('.stuckMenu').removeClass('isStuck'); 82 $('.stuckMenu').next().closest('div').css({ 83 'margin-top': currentMarginT + 'px' 84 }); 85 $('.stuckMenu').css("position", "relative"); 86 } 87 }); 88 89 }); 90 91});
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.