1SgpbEventListener.prototype.sgpbOnScroll = function(listenerObj, eventData) 2{ 3 var scrollValue = eventData['value']; 4 var operator = eventData['operator']; 5 6 if (operator == 'scrollDistance') { 7 var scrollIntValue = parseInt(scrollValue); 8 var showAfter = scrollIntValue; 9 var docHeight = jQuery(document).height(); 10 var winHeight = jQuery(window).height(); 11 12 var height = (docHeight - winHeight); 13 if (scrollValue.indexOf('%') != '-1') { 14 showAfter = (height*scrollIntValue)/100; 15 } 16 if (scrollValue.indexOf('em') != '-1') { 17 scrollIntValue = parseFloat(eventData['value']); 18 var bodyFontSize = jQuery("body").css('font-size'); 19 showAfter = parseInt(bodyFontSize)*scrollIntValue; 20 } 21 if (scrollValue.indexOf('rem') != '-1') { 22 scrollIntValue = parseFloat(eventData['value']); 23 var constOfRem = 16; 24 showAfter = parseInt(constOfRem)*scrollIntValue; 25 } 26 } 27 else if (operator == 'scrollTop') { 28 var lastScrollTop = 0; 29 window.addEventListener('scroll', function() { 30 var currentStatement = window.pageYOffset || document.documentElement.scrollTop; 31 if (currentStatement < lastScrollTop) { 32 if (currentStatement == 0) { 33 listenerObj.getPopupObj().prepareOpen(); 34 } 35 } 36 lastScrollTop = currentStatement <= 0 ? 0 : currentStatement; 37 }, false); 38 } 39 else { 40 showAfter = 0; 41 var element = jQuery(eventData['value']); 42 var elementPosition = element.position(); 43 var elementHeight = element.height(); 44 if (elementPosition && elementPosition.top) { 45 showAfter = elementPosition.top; 46 } 47 /* open popup when the specified target is in the middle of the window */ 48 showAfter = showAfter+(elementHeight/2); 49 } 50 51 var scrollStatus = false; 52 var alreadyOpened = false; 53 var windowHeight = jQuery(window).height(); 54 jQuery(window).on('scroll touchmove', function() { 55 setTimeout(function() { 56 var scrollTop = jQuery(window).scrollTop(); 57 var scrollTopWithHeight = scrollTop + windowHeight/2; 58 if (!alreadyOpened && (scrollTop <= showAfter && scrollTopWithHeight >= showAfter)) { 59 if (scrollStatus == false) { 60 listenerObj.getPopupObj().prepareOpen(); 61 scrollStatus = true; 62 alreadyOpened = true; 63 } 64 } 65 /* if the value smaller than the window height, it should be opened on any scroll */ 66 if ((windowHeight > showAfter) && !alreadyOpened) { 67 listenerObj.getPopupObj().prepareOpen(); 68 scrollStatus = true; 69 alreadyOpened = true; 70 } 71 }, 100); 72 }); 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.