1/** 2 * qalam.frontend.js 3 * 4 * @package Qalam 5 * @since 1.0.0 6 * @version 1.5.1 7 */ 8jQuery(document).ready(function ($) { 9 10 'use strict'; 11 var sticky_navbar = function () { 12 var navbar = $('.sticky-nav'), 13 admin_bar = $('#wpadminbar'), 14 nav_offset = 0, 15 adminbar_ht = 0, 16 sticky = 0; 17 18 if ($(window).width() < 426) { 19 navbar = $('.hst-1 .sticky-nav, .hst-2 .nav-1, .hst-3 .nav-2, .hst-4 .nav-2'); 20 } 21 22 // If user logged in and admin bar enabled 23 if (admin_bar.length > 0 && $(window).width() > 425) { 24 adminbar_ht = admin_bar.outerHeight(); 25 } 26 27 if (navbar.length > 0) { 28 nav_offset = navbar.offset(); 29 sticky = nav_offset.top - adminbar_ht; 30 if (qlm_frontend && qlm_frontend.sticky_nav) { 31 $(window).on('scroll', function () { 32 //if ($(window).width() > 768) { 33 if ($(this).scrollTop() > sticky) { 34 navbar.addClass('sticky-enabled').css({"top": adminbar_ht}); 35 $('body').addClass('fixed-nav'); 36 } else { 37 navbar.removeClass('sticky-enabled').css({"top": 0}); 38 $('body').removeClass('fixed-nav'); 39 } 40 //} 41 }); 42 } 43 } 44 }; 45 46 sticky_navbar(); 47 48 $(window).resize(sticky_navbar); 49 50 // Search trigger 51 $('.search-trigger').on('click', function (e) { 52 e.preventDefault(); 53 var drawer = $(this).closest('.search-icon').find('.search-drawer'), 54 searchfield = $(this).closest('.search-icon').find('.search-field'); 55 $(drawer).toggleClass('active'); 56 setTimeout(function () { 57 searchfield.focus(); 58 }, 50); 59 60 if ($(this).is('.inline')) { 61 $(this).toggleClass('search-btn-active'); 62 } 63 }); 64 65 // Scroll to top button 66 $(window).on('scroll', function () { 67 var win = $(this), 68 sharing_pos = $('body.single').find('.qlm-sharing-container').offset(), 69 share_btn = $('.qlm-sharing-inline > li.no-popup > a.qlm-more'); 70 71 if ($(this).scrollTop() > 100) { 72 $('.scroll-to-top').addClass('btn-active'); 73 } else { 74 $('.scroll-to-top').removeClass('btn-active'); 75 } 76 if (sharing_pos) { 77 if (win.scrollTop() > sharing_pos.top) { 78 share_btn.addClass('is-fixed'); 79 if ($(this).scrollTop() > (sharing_pos.top + 100)) { 80 share_btn.addClass('slide-in'); 81 } else { 82 share_btn.removeClass('slide-in'); 83 } 84 } else { 85 share_btn.removeClass('is-fixed'); 86 } 87 } 88 }); 89 90 $('.scroll-to-top a').click(function () { 91 $('html, body').animate({ 92 scrollTop: 0 93 }, 500); 94 return false; 95 }); 96 97 // Masonry 98 $(window).on('load', function () { 99 // Masonry 100 if ($.isFunction($.fn.masonry)) { 101 $('.masonry-enabled').masonry({ 102 itemSelector: 'article.hentry', 103 isOriginLeft: !($('body').is('.rtl')) 104 }); 105 } 106 107 }); 108 109 // Sharing popup 110 function qalam_share_window() { 111 $('.qalam-sharing li:not(.no-popup) a').on('click', function (e) { 112 e.preventDefault(); 113 var href = $(this).attr('href'); 114 window.open(href, '_blank', 'width=600,height=400,menubar=0,resizable=1,scrollbars=0,status=1', true); 115 }); 116 } 117 qalam_share_window(); 118 119 function qalam_animate_post_nav() { 120 var didScroll, 121 lastScrollTop = 0; 122 123 $(window).scroll(function (event) { 124 didScroll = true; 125 }); 126 127 setInterval(function () { 128 if (didScroll) { 129 hasScrolled(); 130 didScroll = false; 131 } 132 }, 300); 133 134 function hasScrolled() { 135 var st = $(window).scrollTop(); 136 137 if (st <= 400) { 138 // Post Nav buttons on left and right 139 $('.post-navigation').removeClass('show-nav'); 140 } 141 142 // Post navigation 143 if (st > lastScrollTop) { 144 // Scroll Down 145 $('.post-navigation').removeClass('show-nav').addClass('hide-nav'); 146 } else { 147 // Scroll Up 148 if (st + $(window).height() < $(document).height()) { 149 $('.post-navigation').removeClass('hide-nav').addClass('show-nav'); 150 } 151 } 152 153 lastScrollTop = st; 154 } 155 } 156 157 qalam_animate_post_nav(); 158 159 // Show comments on click 160 $('#comments-trigger').on('click', function (e) { 161 e.preventDefault(); 162 $('#comments').slideDown(); 163 $(this).fadeOut(); 164 });
165 166 // Add accordion like submenu items to responsive menu 167 function responsive_menu_items() { 168 var sub_menus = $('.resp-menu').find('.menu-item-has-children, .page_item_has_children'), 169 expand_menus, 170 expand_text = qlm_frontend !== 'undefined' ? qlm_frontend.expand : 'Toggle child menu'; 171 172 if (sub_menus.length) { 173 $(sub_menus).each(function () { 174 $(this).append('<a class="expand-menu" href="#" title="' + expand_text + '"><i class="fa fa-angle-down"></i></a>').find('.sub-menu').hide(); 175 }); 176 } 177 178 expand_menus = $('.resp-menu').find('.expand-menu'); 179 180 if (expand_menus.length) { 181 $(expand_menus).on('click', function (e) { 182 var icon = $(this).find('.fa'); 183 icon.toggleClass('rotate-180'); 184 $(this).prev().slideToggle(300); 185 e.preventDefault(); 186 }); 187 } 188 189 } 190 191 responsive_menu_items(); 192 $('.resp-menu').find('.current-menu-item').parents('ul.sub-menu').show(); 193 194 // Toggle body classes for responsive menu 195 $('.menu-trigger, .overlay-mask, .close-menu').click(function (e) { 196 $('body').toggleClass('show-nav'); 197 e.preventDefault(); 198 }); 199 200 // Sharing popup window 201 function qlm_share_window() { 202 $('.qlm-sharing-list li:not(.no-popup) a, .qlm-sharing-inline li:not(.no-popup) a').on('click', function (e) { 203 e.preventDefault(); 204 var href = $(this).attr('href'); 205 window.open(href, '_blank', 'width=600,height=400,menubar=0,resizable=1,scrollbars=0,status=1', true); 206 }); 207 } 208 qlm_share_window(); 209 210 // Sharing more link 211 $('.qlm-sharing-inline > li > a.qlm-more').on('click', function (e) { 212 e.preventDefault(); 213 $(this).closest('.qlm-sharing-container').find('.sharing-overlay').toggleClass('is-open'); 214 $('body').toggleClass('overlay-active'); 215 }); 216 217 // Close sharing modal box 218 $('.qlm-sharing-list > li.sharing-modal-handle > a.close-sharing').on('click', function (e) { 219 e.preventDefault(); 220 $(this).closest('.sharing-overlay').removeClass('is-open'); 221 $('body').removeClass('overlay-active'); 222 }); 223 224 $('.sharing-overlay').on('click', function (e) { 225 e.preventDefault(); 226 $(this).removeClass('is-open'); 227 $('body').removeClass('overlay-active'); 228 }); 229 230 $(document).keyup(function (e) { 231 if (e.keyCode === 27) { 232 $('.sharing-overlay').removeClass('is-open'); 233 } 234 }); 235 236 $('.sharing-overlay').on('click', '.qlm-sharing-list', function (e) { 237 e.stopPropagation(); 238 }); 239 240 // Print button 241 $('.qlm-print a').click(function (e) { 242 e.preventDefault(); 243 $('.sharing-overlay').removeClass('is-open'); 244 window.print(); 245 }); 246 247 248 $(document).on('click', '.search-trigger, .search-drawer .search-field', function (e) { 249 e.stopPropagation(); 250 }); 251 252 // Search button actions 253 $('.search-icon > a.search-trigger.ovrlay').on('click', function () { 254 $(this).next('.search-overlay').toggleClass('enabled'); 255 $('body').toggleClass('search-overlay-active'); 256 }); 257 258 $('.search-overlay').on('click', function () { 259 $(this).removeClass('enabled'); 260 $('body').removeClass('search-overlay-active'); 261 }); 262 263 $('.search-inner > .search-form, .aws-container').on('click', function (e) { 264 e.stopPropagation(); 265 }); 266 267 $(document).on('keyup', '.search-overlay', function (e) { 268 if (e.keyCode === 27) { 269 $(this).removeClass('enabled'); 270 $('body').removeClass('search-overlay-active'); 271 } 272 }); 273});
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.