1/*! 2 * ScriptName: shared.js 3 * 4 * FoodConnection 5 * http://foodconnection.jp/ 6 * http://foodconnection.vn/ 7 * 8 */ 9// Fixed Navigator PC 10$(document).ready(function () { 11 $.fn.isOnScreen = function () { 12 var win = $(window) 13 var viewport = { 14 top: win.scrollTop(), 15 left: win.scrollLeft(), 16 } 17 viewport.right = viewport.left + win.width() 18 viewport.bottom = viewport.top + win.height() 19 var bounds = this.offset() 20 bounds.right = bounds.left + this.outerWidth() 21 bounds.bottom = bounds.top + this.outerHeight() 22 return !( 23 viewport.right < bounds.left || 24 viewport.left > bounds.right || 25 viewport.bottom < bounds.top || 26 viewport.top > bounds.bottom 27 ) 28 } 29 30 $(window).scroll(scrollToFixed) 31 32 scrollToFixed() 33 34 function scrollToFixed() { 35 if (!$('header').isOnScreen()) { 36 $('.fixed-bottom').addClass('fixed-bottom-show') 37 $('.fixed-nav').addClass('fixed-nav-show') 38 return 39 } 40 $('.fixed-nav').removeClass('fixed-nav-show') 41 $('.fixed-bottom').removeClass('fixed-bottom-show') 42 return 43 } 44}) 45 46// Toggle Hamburger 47$(document).ready(function () { 48 var lastScrollTop = 49 $(window).scrollTop() || document.documentElement.scrollTop 50 51 $(window).scroll(function () { 52 var scrollTop = $(this).scrollTop() 53 if (scrollTop) { 54 lastScrollTop = scrollTop 55 } 56 }) 57 58 $('.hamburger').click(toggleHamburger) 59 60 $('.menu-toggle') 61 .find('a') 62 .not('.btn.unsmooth, a[href^="tel:"]') 63 .click(toggleHamburger) 64 65 $(document).on('closed', '.remodal', function () { 66 $('html, body').stop().animate({ scrollTop: lastScrollTop }, 200) 67 }) 68 69 $(window).resize(function () { 70 if ($(window).width() > 768 && $('body').hasClass('nav--opened')) { 71 toggleHamburger() 72 } 73 }) 74 75 function toggleHamburger() { 76 if (!$('body').hasClass('nav--opened')) { 77 $('.hamburger').addClass('is-active') 78 $('body').addClass('nav--opened') 79 $('body').css({ 80 top: '-' + lastScrollTop + 'px', 81 width: '100%', 82 'padding-right': '17px', 83 position: 'fixed', 84 }) 85 } else { 86 $('.hamburger').removeClass('is-active') 87 $('body').removeClass('nav--opened') 88 $('body').css({ 89 'padding-right': '0', 90 position: 'static', 91 }) 92 $(window).scrollTop(lastScrollTop) 93 } 94 } 95})
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.