1(function($){ 2 // Search 3 var $searchWrap = $('#search-form-wrap'), 4 isSearchAnim = false, 5 searchAnimDuration = 200; 6 7 var startSearchAnim = function(){ 8 isSearchAnim = true; 9 }; 10 11 var stopSearchAnim = function(callback){ 12 setTimeout(function(){ 13 isSearchAnim = false; 14 callback && callback(); 15 }, searchAnimDuration); 16 }; 17 18 $('#nav-search-btn').on('click', function(){ 19 if (isSearchAnim) return; 20 21 startSearchAnim(); 22 $searchWrap.addClass('on'); 23 stopSearchAnim(function(){ 24 $('.search-form-input').focus(); 25 }); 26 }); 27 28 $('.search-form-input').on('blur', function(){ 29 startSearchAnim(); 30 $searchWrap.removeClass('on'); 31 stopSearchAnim(); 32 }); 33 34 // Share 35 $('body').on('click', function(){ 36 $('.article-share-box.on').removeClass('on'); 37 }).on('click', '.article-share-link', function(e){ 38 e.stopPropagation(); 39 40 var $this = $(this), 41 url = $this.attr('data-url'), 42 encodedUrl = encodeURIComponent(url), 43 id = 'article-share-box-' + $this.attr('data-id'), 44 offset = $this.offset(); 45 46 if ($('#' + id).length){ 47 var box = $('#' + id); 48 49 if (box.hasClass('on')){ 50 box.removeClass('on'); 51 return; 52 } 53 } else { 54 var html = [ 55 '<div id="' + id + '" class="article-share-box">', 56 '<input class="article-share-input" value="' + url + '">', 57 '<div class="article-share-links">', 58 '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>', 59 '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>', 60 '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="article-share-pinterest" target="_blank" title="Pinterest"></a>', 61 '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="article-share-google" target="_blank" title="Google+"></a>', 62 '</div>', 63 '</div>' 64 ].join(''); 65 66 var box = $(html); 67 68 $('body').append(box); 69 } 70 71 $('.article-share-box.on').hide(); 72 73 box.css({ 74 top: offset.top + 25, 75 left: offset.left 76 }).addClass('on'); 77 }).on('click', '.article-share-box', function(e){ 78 e.stopPropagation(); 79 }).on('click', '.article-share-box-input', function(){ 80 $(this).select(); 81 }).on('click', '.article-share-box-link', function(e){ 82 e.preventDefault(); 83 e.stopPropagation(); 84 85 window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450'); 86 }); 87 88 // Caption 89 $('.article-entry').each(function(i){ 90 $(this).find('img').each(function(){ 91 if ($(this).parent().hasClass('fancybox')) return; 92 93 var alt = this.alt; 94 95 if (alt) $(this).after('<span class="caption">' + alt + '</span>'); 96 97 $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>'); 98 }); 99 100 $(this).find('.fancybox').each(function(){ 101 $(this).attr('rel', 'article' + i); 102 }); 103 }); 104 105 if ($.fancybox){ 106 $('.fancybox').fancybox(); 107 } 108 109 // Mobile nav 110 var $container = $('#container'), 111 isMobileNavAnim = false, 112 mobileNavAnimDuration = 200; 113 114 var startMobileNavAnim = function(){ 115 isMobileNavAnim = true; 116 }; 117 118 var stopMobileNavAnim = function(){ 119 setTimeout(function(){ 120 isMobileNavAnim = false; 121 }, mobileNavAnimDuration); 122 } 123 124 $('#main-nav-toggle').on('click', function(){ 125 if (isMobileNavAnim) return; 126 127 startMobileNavAnim(); 128 $container.toggleClass('mobile-nav-on'); 129 stopMobileNavAnim(); 130 }); 131 132 $('#wrap').on('click', function(){ 133 if (isMobileNavAnim || !$container.hasClass('mobile-nav-on')) return; 134 135 $container.removeClass('mobile-nav-on'); 136 }); 137})(jQuery);
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.