1define("fc/ui/sticky_banner", ['jquery', 'fc/utils', 'setup'], function ($, fc_utils) { 2 var module = {}; 3 4 module.sidebar = (function() { 5 var threshold = null; 6 var max_threshold = null; 7 var vertical_middle_offset; 8 var $sticky; 9 10 function _computeSticky() { 11 var w_height = $(window).height(); 12 var min_offset_top = $(".navbar-header").height(); 13 14 if (w_height - min_offset_top < $sticky.height()) { 15 threshold = null; 16 max_threshold = null; 17 return; 18 } 19 20 vertical_middle_offset = ((w_height - $sticky.height()) / 2); 21 vertical_middle_offset = Math.max(vertical_middle_offset, min_offset_top); 22 23 threshold = $('.adsense-sticky-slide').offset().top - vertical_middle_offset; 24 25 max_threshold = $("#sidebar").offset().top + $("#sidebar").height() - (w_height - vertical_middle_offset); 26 } 27 28 function _setSticky() { 29 var currentScrollTop = $(window).scrollTop(); 30 31 if (threshold && currentScrollTop > threshold) { 32 $('.adsense-sticky-wrapper').addClass('adsense-sticky-attach'); 33 $sticky.css('top', vertical_middle_offset); 34 35 if (max_threshold && currentScrollTop > max_threshold) { 36 $('.adsense-sticky-wrapper').addClass('adsense-sticky-attach-end'); 37 } 38 else { 39 $('.adsense-sticky-wrapper').removeClass('adsense-sticky-attach-end'); 40 } 41 } 42 else { 43 $('.adsense-sticky-wrapper').removeClass('adsense-sticky-attach'); 44 $('.adsense-sticky-wrapper').removeClass('adsense-sticky-attach-end'); 45 $sticky.css('top', 0); 46 } 47 } 48 49 function _bind() { 50 fc_utils.responsive.respondOnDocumentResize(); 51 52 $(document).on('window_resize, document_resize', $('body'), function() { 53 _computeSticky(); 54 _setSticky(); 55 }); 56 57 $(window).scroll(function() { 58 _setSticky(); 59 }); 60 } 61 62 function init() { 63 if ($('#sidebar').is(':visible') && $('#sidebar .adsense .banner-sticky').length > 0) { 64 $('#sidebar').addClass('adsense-sticky'); 65 66 if ($("#content").height() > $("#sidebar").height()) { 67 $('#sidebar').addClass('adsense-sticky-active'); 68 69 // animate only last banner 70 $sticky = $('#sidebar .adsense .banner-sticky').last(); 71 72 $('.adsense-sticky-wrapper').width($sticky.closest('.adsense').width()); 73 74 _bind(); 75 76 _computeSticky(); 77 _setSticky(); 78 } 79 else { 80 $('#sidebar').removeClass('adsense-sticky'); 81 } 82 } 83 } 84 85 return { 86 'init': init 87 }; 88 })(); 89 90 return module; 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.