1(function($) { 2 'use strict'; 3 $.fn.sqrNav = function() { 4 $(this).each(function() { 5 6 var nav = $(this); 7 var showNav = nav.find('.sqrnavshow'); 8 var hideNav = nav.find('.sqrnavhide'); 9 var allItems = nav.find('li:has(ul)'); 10 var lastitem; 11 var doubleClickTimeout; 12 var doubleclick = false; 13 14 function handleClick(e) { 15 16 if (lastitem === this && doubleclick) return; 17 18 if (doubleClickTimeout !== undefined) window.clearTimeout(doubleClickTimeout); 19 20 doubleclick = true; 21 22 doubleClickTimeout = window.setTimeout(function() { 23 doubleclick = false; 24 }, 1000); 25 26 if ($(this).parent().hasClass('sqrnavopen')) { 27 $(this).parent('li').removeClass('sqrnavopen'); 28 } else { 29 lastitem = this; 30 allItems.removeClass('sqrnavopen'); 31 $(this).parents('li').addClass('sqrnavopen'); 32 $(this).parent('li').find('input').focus(); 33 } 34 35 e.preventDefault(); 36 e.stopPropagation(); 37 } 38 39 function isMobile() { 40 return nav.children('ul').children('li').css('float') === 'none'; 41 } 42 43 function handleClose(e) { 44 if (!isMobile()) { 45 if ($(e.target).parents('.sqrnav').length === 0) { 46 allItems.removeClass('sqrnavopen'); 47 nav.removeClass('sqrnavopen'); 48 lastitem = undefined; 49 doubleclick = false; 50 if (doubleClickTimeout !== undefined) window.clearTimeout(doubleClickTimeout); 51 } 52 } 53 } 54 55 function handleShowNav(e) { 56 nav.addClass('sqrnavopen'); 57 e.preventDefault(); 58 } 59 60 function handleHideNav(e) { 61 nav.removeClass('sqrnavopen'); 62 e.preventDefault(); 63 } 64 65 allItems.addClass('sqrnavmore').children('a').on('click', handleClick); 66 showNav.on('click', handleShowNav); 67 hideNav.on('click', handleHideNav); 68 $(document).on('click touchstart', handleClose); 69 70 }); 71 72 }; 73 74 $.fn.sqrEyecatcher = function() { 75 $(this).each(function() { 76 var stage = $(this), 77 imgs = $(this).find('img'), 78 ratio = parseInt(imgs.attr('width'), 10) / parseInt(imgs.attr('height')), 79 shifter = $(this).find('.sqreyecatchershifter'), 80 delay = parseInt(stage.attr('data-delay'), 10) * 1000, 81 offset = 0, 82 bullets, 83 height, 84 handleInterval; 85 86 function createBullets() {
87 var bulletContainer = $('<div>', { 88 'class': 'sqreyecatcherbulletcontainer' 89 }).css({ 90 'margin-top': imgs.length * -12 + 'px' 91 }); 92 93 94 stage.append(bulletContainer); 95 96 for (var i = 0; i < imgs.length; i++) { 97 var bullet = $('<a>', { 98 'href': '#' 99 }); 100 bulletContainer.append(bullet); 101 } 102 103 bullets = stage.find('a'); 104 bullets.on('click', handleBulletClick); 105 106 setOffset(); 107 } 108 109 function handleBulletClick(e) { 110 e.preventDefault(); 111 offset = $(this).index(); 112 setOffset(); 113 start(); 114 } 115 116 function setOffset() { 117 bullets.removeClass('sqreyecatcherbulletactive').eq(offset).addClass('sqreyecatcherbulletactive'); 118 shifter.css({ 119 'transition': 'transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1)' 120 }); 121 shifter.css({ 122 'transform': 'translate3d(0,' + (-offset * height + 'px') + ',0)' 123 }); 124 imgs.css({ 125 'opacity': '0' 126 }).eq(offset).css({ 127 'opacity': '1' 128 }); 129 } 130 131 function resize() { 132 var width = Math.floor(stage.width()); 133 height = Math.floor(width / ratio); 134 stage.css({ 135 'height': height + 'px' 136 }); 137 imgs.css({ 138 'width': width + 'px', 139 'height': height + 'px' 140 }); 141 shifter.css({ 142 'transition': 'none', 143 'transform': 'translate3d(0,' + (-offset * height + 'px') + ',0)' 144 }); 145 start(); 146 } 147 148 function start() { 149 if (delay > 0 && imgs.length > 1) { 150 stop(); 151 handleInterval = window.setInterval(nextOffset, delay); 152 } 153 } 154 155 function stop() { 156 if (handleInterval !== undefined && delay > 0) { 157 window.clearInterval(handleInterval); 158 handleInterval = undefined; 159 } 160 } 161 162 function nextOffset() { 163 offset++; 164 if (offset >= imgs.length) offset = 0; 165 setOffset(); 166 } 167 168 resize(); 169 resize(); 170 171 $(window).on('resize', function() { 172 resize(); 173 resize(); 174 }); 175 176 if (imgs.length > 1) { 177 createBullets(); 178 $(window).on('load', start); 179 } 180 }); 181 }; 182 183})(jQuery); 184 185$(document).ready(function() { 186 $('.sqrnav').sqrNav(); 187 $('.sqreyecatcher').sqrEyecatcher(); 188});
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.