1$(document).ready(function() { 2 var $window = $(window); 3 var $header = $("#contactstop"); 4 var $content = $("#content"); 5 var $topPart = $("#contactstop_content1"); 6 // ÐобавлÑем пеÑеменнÑÑ Ð´Ð»Ñ Ð²ÑоÑой ÑаÑÑи, ÑÑÐ¾Ð±Ñ Ð¿ÑовеÑÑÑÑ ÐµÑ Ð½Ð°Ð»Ð¸Ñие 7 var $bottomPart = $("#contactstop_content2"); 8 9 if (!$header.length || !$content.length) return; 10 11 var topPartHeight = 0; 12 var headerHeight = 0; 13 14 function updateDimensions() { 15 topPartHeight = $topPart.length ? $topPart.outerHeight() : 0; 16 headerHeight = $header.outerHeight(); 17 onScroll(); 18 } 19 20 function onScroll() { 21 var scrollTop = $window.scrollTop(); 22 23 // ÐÐ ÐÐÐÐ ÐÐ: ÐÑÑÑ Ð»Ð¸ вÑоÑÐ°Ñ ÑаÑÑÑ Ñапки? 24 var hasBottomPart = $bottomPart.length > 0; 25 26 // ÐÐÐÐÐРТРÐÐÐÐÐ Ð: 27 // ÐÑли еÑÑÑ Ð²ÑоÑÐ°Ñ ÑаÑÑÑ, ждем пока пÑоÑкÑоллиÑÑÑ Ð¿ÐµÑÐ²Ð°Ñ (topPartHeight). 28 // ÐÑли вÑоÑой ÑаÑÑи неÑ, ÑикÑиÑÑем ÑÑÐ°Ð·Ñ ÐºÐ°Ðº ÑолÑко наÑали ÑкÑоллиÑÑ (0). 29 var triggerPoint = hasBottomPart ? topPartHeight : 0; 30 31 // ÐÐÐÐÐРСÐÐÐÐÐ: 32 // ÐÑли еÑÑÑ Ð²ÑоÑÐ°Ñ ÑаÑÑÑ, Ñдвигаем ÑÐ°Ð¿ÐºÑ Ð²Ð²ÐµÑÑ Ð½Ð° вÑÑоÑÑ Ð¿ÐµÑвой (-topPartHeight). 33 // ÐÑли вÑоÑой ÑаÑÑи неÑ, не Ñдвигаем ниÑего (0), ÑÑÐ¾Ð±Ñ Ñапка бÑла видна Ñеликом. 34 var offsetTop = hasBottomPart ? topPartHeight : 0; 35 36 // ÐобавлÑем ÑÑловие: scrollTop > triggerPoint. 37 // ÐÐ»Ñ Ð²Ð°ÑианÑа без вÑоÑой ÑаÑÑи можно добавиÑÑ scrollTop > 0, ÑÑÐ¾Ð±Ñ Ð½Ðµ ÑикÑиÑоваÑÑ Ð½Ð° Ñамом веÑÑ Ñ, еÑли ÑÑо не нÑжно. 38 if (scrollTop >= triggerPoint && headerHeight > 0) 39 { 40 $header.css({ 41 'position': 'fixed', 42 'top': '-' + offsetTop + 'px', // ÐÑполÑзÑем вÑÑиÑленнÑй Ñдвиг 43 'width': '100%', 44 'z-index': '1000' 45 }); 46 $content.css('marginTop', headerHeight + 'px'); 47 48 if (window.stickySidebarInstance) 49 { 50 window.stickySidebarInstance.updateSticky(); 51 } 52 } 53 else 54 { 55 $header.css({ 56 'position': 'relative', 57 'top': '0px', 58 'width': '', 59 'z-index': '' 60 }); 61 $content.css('marginTop', '0px'); 62 } 63 } 64 65 $window.on('resize', updateDimensions); 66 $window.on('scroll', onScroll); 67 68 $window.on('load', function() { 69 updateDimensions(); 70 }); 71 72 updateDimensions(); 73});
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.