1/*! 2 * ScriptName: shared.js 3 * 4 * FoodConnection 5 * http://foodconnection.jp/ 6 * http://foodconnection.vn/ 7 * 8 */ 9 10 11 12var lastScrollTop = 0; 13$(window).scroll(function() { 14 var st = $(this).scrollTop(); 15 if (lastScrollTop != 0) { 16 if (st < lastScrollTop) { 17 $("#pagetop").addClass("visible"); 18 if (st < 10) { 19 $("#pagetop").removeClass("visible"); 20 } 21 } else if (st > lastScrollTop) { 22 $("#pagetop").removeClass("visible"); 23 } 24 } 25 lastScrollTop = st; 26}); 27 28$("body").on("click", "#pagetop", function() { 29 if (!$(this).hasClass("in-scroll")) { 30 $(this).addClass("in-scroll"); 31 32 var $scrollDuration = $.inArray($(this).attr("data-duration"), ["slow", "normal", "fast"]) >= 0 || parseInt($(this).attr("data-duration")) > 0 ? $(this).attr("data-duration") : "slow"; 33 34 $("html, body").stop().animate({ 35 scrollTop: 0 36 }, $scrollDuration, function() { 37 $("#pagetop").removeClass("in-scroll"); 38 $("#pagetop").removeClass("visible"); 39 }); 40 41 } 42}); 43// END: scroll to top 44 45$(document).ready(function() { 46 $('body').removeClass('navOpen'); 47 $(".hamburger").click(function() { 48 if ($('body').hasClass('navOpen')) { 49 $('body').addClass('navClose'); 50 $('body').removeClass('navOpen'); 51 $('body').css({ 52 'position': 'static', 53 'top': 'auto', 54 'width': 'auto' 55 }); 56 57 } else { 58 $('body').addClass('navOpen'); 59 $('body').removeClass('navClose'); 60 } 61 }); 62 63 $("#menu_toggle a").click(function() { 64 $('body').removeClass('navOpen'); 65 $('body').addClass('navClose'); 66 $('body').css({ 67 'position': 'static', 68 'top': 'auto', 69 'width': 'auto' 70 }); 71 }); 72 $(".copy-link").click(function() { 73 $(this).addClass('copy-link-none'); 74 }); 75 76 $("#menu_toggle a").click(function() { 77 $('body').removeClass('nav--opened'); 78 $('.hamburger').removeClass('is-active'); 79 }); 80 81 new WOW().init(); 82 83 $(window).on('resize load scroll orientationchange', function() { 84 //var navPos = $('.nav-target').offset().top; 85 var ScrollPos = $(window).scrollTop(); 86 if (ScrollPos > 0) { 87 $("body").addClass('has_nav'); 88 } else { 89 $("body").removeClass('has_nav'); 90 } 91 }); 92 93 94}); 95function scrollFixed(section, item, offset = 0) { 96 if($(window).scrollTop() + offset >= section.offset().top && $(window).scrollTop() + item.outerHeight() < section.offset().top + section.outerHeight()) { 97 item.addClass('fixed'); 98 item.removeClass('end'); 99 } 100 if($(window).scrollTop() + item.outerHeight() + offset >= section.offset().top + section.outerHeight()) { 101 item.removeClass('fixed'); 102 item.addClass('end'); 103 } 104 if($(window).scrollTop() + offset < section.offset().top && $(window).scrollTop() < section.offset().top) { 105 item.removeClass('fixed'); 106 item.removeClass('end'); 107 } 108} 109 110// BEGIN: fix scroll iOS 111var overflowIsHidden = function(node) { 112 var style = getComputedStyle(node); 113 return style.overflow === "hidden" || style.overflowX === "hidden" || style.overflowY === "hidden"; 114} 115 116var isItScrollableWithoutVisibleScrollbars = function(el) { 117 if (el === null) return false; 118 119 var isScrollable = false, 120 hasScrollbars = false; 121 122 isScrollable = el.scrollHeight > el.offsetHeight ? true : false; // first, lets find out if it has scrollable content 123 // isScrollable = el.scrollHeight + 1 > el.clientHeight ? true : false; // first, lets find out if it has scrollable content 124 125 if (isScrollable) hasScrollbars = (el.offsetWidth > el.scrollWidth) ? true : false; // if it's scrollable, let's see if it likely has scrollbars 126 // if (isScrollable) hasScrollbars = (el.offsetWidth > el.scrollWidth - 1) ? true : false; // if it's scrollable, let's see if it likely has scrollbars 127 128 if (isScrollable && !hasScrollbars && !overflowIsHidden(el)) return true; 129 else return false; 130}; 131 132document.addEventListener("touchmove", function(e) { 133 if (document.body.classList.contains("nav--opened")) { 134 if ($(e.target).parents("#menu_toggle").length < 1) e.preventDefault(); 135 else if (!isItScrollableWithoutVisibleScrollbars(document.getElementById("menu_toggle"))) e.preventDefault(); 136 } 137}, { 138 passive: false 139}); 140 141window.addEventListener("resize", function() { 142 var _event_ = new Event("touchmove"); 143 144 document.dispatchEvent(_event_); // trigger 145}, { 146 passive: false 147}); 148// END: fix scroll iOS 149 150
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.