1/*==================================================== 2 TABLE OF CONTENT 3 1. function declearetion 4 2. Initialization 5====================================================*/ 6 7/*=========================== 8 1. function declearetion 9 ==========================*/ 10var themeApp = { 11 responsiveIframe: function() { 12 $('.post').fitVids(); 13 }, 14 sidebarConfig:function() { 15 if(typeof sidebar_left !== 'undefined' && sidebar_left == true) { 16 $('.main-content').addClass('col-md-push-4'); 17 $('.sidebar').addClass('col-md-pull-8'); 18 } 19 }, 20 facebook:function() { 21 if (typeof facebook_page_url !== 'undefined' && facebook_page_url !== '') { 22 var fbw = Math.max(180, Math.min(500, Math.floor($('.fb').width()) || 340)); 23 var fb_page = '<iframe src="https://www.facebook.com/plugins/page.php?href='+encodeURIComponent(facebook_page_url)+'&tabs=timeline&width='+fbw+'&height=500&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true" width="'+fbw+'" height="500" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>'; 24 $('.fb').append(fb_page); 25 } 26 }, 27 flickr:function() { 28 if (typeof flickr_id !== 'undefined' && flickr_id !== '') { 29 $('.flkr-widget').jflickrfeed({ 30 limit: 8, 31 qstrings: { 32 id: flickr_id 33 }, 34 itemTemplate: 35 '<li>' + 36 '<a href="{{link}}" title="{{title}}" target="_blank"><img src="{{image_s}}" alt="{{title}}" /></a>' + 37 '</li>' 38 }); 39 } 40 }, 41 highlighter: function() { 42 $('pre code').each(function(i, block) { 43 hljs.highlightBlock(block); 44 }); 45 }, 46 backToTop: function() { 47 $(window).scroll(function(){ 48 if ($(this).scrollTop() > 100) { 49 $('#back-to-top').fadeIn(); 50 } else { 51 $('#back-to-top').fadeOut(); 52 } 53 }); 54 $('#back-to-top').on('click', function(e){ 55 e.preventDefault(); 56 $('html, body').animate({scrollTop : 0},1000); 57 return false; 58 }); 59 }, 60 adjustTileHeight: function() { 61 var tile = $('.archive .about-author, .archive .tag-wrapper'); 62 var max_height = 0; 63 if(tile.length > 0) { 64 $.each(tile, function(){ 65 var h = $(this).height(); 66 max_height = h > max_height ? h : max_height; 67 }); 68 tile.height(max_height); 69 } 70 }, 71 gallery: function() { 72 var images = document.querySelectorAll('.kg-gallery-image img'); 73 images.forEach(function (image) { 74 var container = image.closest('.kg-gallery-image'); 75 var width = image.attributes.width.value; 76 var height = image.attributes.height.value; 77 var ratio = width / height; 78 container.style.flex = ratio + ' 1 0%'; 79 }); 80 mediumZoom('.kg-gallery-image img', { 81 margin: 30 82 }); 83 }, 84 notifications: function() { 85 // Parse the URL parameter 86 function getParameterByName(name, url) { 87 if (!url) url = window.location.href; 88 name = name.replace(/[\[\]]/g, '\\$&'); 89 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), 90 results = regex.exec(url); 91 if (!results) return null; 92 if (!results[2]) return ''; 93 return decodeURIComponent(results[2].replace(/\+/g, ' ')); 94 } 95 96 // Give the parameter a variable name 97 var action = getParameterByName('action'); 98 var stripe = getParameterByName('stripe'); 99 var success = getParameterByName('success'); 100 if (action == 'subscribe') { 101 $('body').addClass("subscribe-success"); 102 } 103 if (action == 'signup') { 104 window.location = '/signup/?action=checkout'; 105 } 106 if (action == 'checkout') { 107 $('body').addClass("signup-success"); 108 } 109 if (action == 'signin' && success=="true") { 110 $('body').addClass("signin-success"); 111 } 112 if (action == 'signin' && success== 'false') { 113 $('body').addClass('signin-failure'); 114 } 115 if (stripe == 'success') { 116 $('body').addClass("checkout-success"); 117 } 118 if (stripe == 'cancel') { 119 $('body').addClass('checkout-cancel'); 120 } 121 if(stripe == 'billing-update-success') { 122 $('body').addClass('billing-update-success'); 123 } 124 if(stripe == 'billing-update-cancel') { 125 $('body').addClass('billing-update-cancel'); 126 } 127 128 $('.notification-close').click(function () { 129 $(this).parent().addClass('closed'); 130 var uri = window.location.toString(); 131 if (uri.indexOf("?") > 0) { 132 var clean_uri = uri.substring(0, uri.indexOf("?")); 133 window.history.replaceState({}, document.title, clean_uri); 134 } 135 }); 136 137 }, 138 siteSearch: function() { 139 $('#searchmodal').on('shown.bs.modal', function(){ 140 $('#search-input').focus(); 141 }); 142 $('#searchmodal').on('hidden.bs.modal', function() { 143 $('#search-input').val(''); 144 $("#search-results").html(''); 145 $("#search-counter").html(''); 146 }); 147 var searchinGhost = new SearchinGhost({ 148 key: api_key, 149 inputId: ['search-input'], 150 outputId: ['search-results'], 151 outputChildsType: false, 152 limit: 50, 153 postsFields: ['title', 'url', 'excerpt', 'custom_excerpt', 'published_at'],
154 postsExtraFields: ['tags'], 155 156 template: function(post) { 157 var o = ''; 158 o += '<div class="result"><a href="' + post.url + '">'; 159 o += '<div class="h5">' + post.title + '</div>'; 160 o += '<div class="date">' + post.published_at + '</div></a></div>'; 161 return o; 162 }, 163 onSearchEnd: function(posts) { 164 $("#search-counter").html(`${posts.length} posts found`); 165 } 166 }); 167 }, 168 init: function() { 169 themeApp.responsiveIframe(); 170 themeApp.sidebarConfig(); 171 themeApp.facebook(); 172 themeApp.flickr(); 173 themeApp.highlighter(); 174 themeApp.backToTop(); 175 themeApp.adjustTileHeight(); 176 themeApp.gallery(); 177 themeApp.notifications(); 178 themeApp.siteSearch(); 179 } 180} 181 182/*=========================== 1832. Initialization 184==========================*/ 185$(document).ready(function(){ 186 themeApp.init(); 187}); 188 189// Quote Share Widget - Web Share API for mobile 190(function() { 191 if (navigator.share) { 192 var shareBtns = document.querySelectorAll('.quote-share'); 193 for (var i = 0; i < shareBtns.length; i++) { 194 shareBtns[i].style.display = 'inline-flex'; 195 shareBtns[i].addEventListener('click', function() { 196 var wrap = this.closest('.widget-quote-share'); 197 var img = wrap.querySelector('.quote-image'); 198 var title = document.title || 'Share this quote'; 199 var url = window.location.href; 200 fetch(img.src) 201 .then(function(res) { return res.blob(); }) 202 .then(function(blob) { 203 var file = new File([blob], 'quote.jpg', { type: blob.type }); 204 navigator.share({ title: title, url: url, files: [file] }).catch(function() {}); 205 }) 206 .catch(function() { 207 navigator.share({ title: title, url: url }).catch(function() {}); 208 }); 209 }); 210 } 211 } 212})();
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.