1// script handlers here 2jQuery(document).ready(function($) { 3 "use strict" 4 var nrtl = false 5 var ndir = "left" 6 if ($('body').hasClass("rtl")) { 7 nrtl = true; 8 ndir = "right"; 9 }; 10 var loaderElm = '<div class="nekit-loader"><div class="loader-wrap"><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div></div></div>' 11 12 var newsTickerContainer = $(".nekit-ticker-news-wrap") 13 if( newsTickerContainer.length > 0 ) { 14 newsTickerContainer.each(function() { 15 var duration = $(this).data("duration") 16 var tcM = $(this).find( ".ticker-item-wrap" ).marquee({ 17 duration: duration, 18 gap: 0, 19 delayBeforeStart: 0, 20 direction: ndir, 21 duplicated: true, 22 startVisible: true, 23 pauseOnHover: true 24 }); 25 $(this).on( "click", ".nekit-ticker-pause", function() { 26 $(this).find( "i" ).toggleClass( "fa-pause fa-play" ) 27 tcM.marquee( "toggle" ); 28 }) 29 }) 30 } 31 32 var nonceA = frontendData._wpnonce, ajaxUrlA = frontendData.ajaxUrl 33 var widgetContainer = $(".nekit-widget-block.slider-container") 34 if( widgetContainer.length > 0 ) { 35 widgetContainer.each(function() { 36 var innerContainer = $(this).find(".widget-inner") 37 var columnD = innerContainer.data("column-desktop") 38 var columnT = innerContainer.data("column-tablet") 39 var columnM = innerContainer.data("column-mobile") 40 var direction = ( innerContainer.data("slide-direction") == 'vertical') 41 var auto = ( innerContainer.data("slide-auto") == 'yes') 42 var arrows = ( innerContainer.data("slide-controller") == 'yes') 43 var infinite = ( innerContainer.data("slide-infinite") == 'yes') 44 var slidesToScroll = innerContainer.data("slide-number") 45 var speed = innerContainer.data("slide-speed") 46 innerContainer.slick({ 47 infinite: infinite, 48 vertical: direction, 49 dots: false, 50 autoplay: auto, 51 arrows: arrows, 52 slidesToShow: columnD, 53 slidesToScroll: slidesToScroll, 54 speed: speed, 55 nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`, 56 prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`, 57 responsive: [ 58 { 59 breakpoint: 600, 60 settings: { 61 slidesToShow: columnT, 62 slidesToScroll: slidesToScroll 63 } 64 }, 65 { 66 breakpoint: 480, 67 settings: { 68 slidesToShow: columnM, 69 slidesToScroll: slidesToScroll 70 } 71 } 72 ] 73 }) 74 }) 75 } 76 77 // back to top widget script 78 var btTop = $( ".nekit-back-to-top-wrap" ); 79 if( btTop.length ) { 80 btTop.hide() 81 var showAt = btTop.data("show") 82 $(window).scroll(function() { 83 if ( $(this).scrollTop() > showAt ) { 84 btTop.show(); 85 } else { 86 btTop.hide(); 87 } 88 }); 89 btTop.click(function() { 90 // Animate the scrolling motion. 91 $("html, body").animate({scrollTop:0},"slow"); 92 }) 93 } 94 95 // live search widget 96 var liveSearchContainer = $(".nekit-live-search-widget.live-search-wrap") 97 if( liveSearchContainer.length > 0 ) { 98 liveSearchContainer.each(function() { 99 var currentElem = $(this), widgetId = currentElem.parents('.elementor-widget[data-element_type="widget"]').data("id"), dataSettings = JSON.stringify( nekitWidgetData[widgetId] ) 100 // on live search trigger click 101 if( currentElem.hasClass("trigger-form-onclick") ) { 102 currentElem.on( "click", ".search-trigger .search-icon-wrap", function() { 103 var _this = $(this) 104 _this.parent().next().toggle() 105 _this.parent().next().find('input[type="search"]').focus() 106 $(".nekit-search-form-wrap").on( "click", ".close-modal", function() { 107 $(this).parent().hide() 108 }) 109 $(document).mouseup(function (e) { 110 var searchModalContainer = $(".nekit-search-form-wrap"); 111 if (!searchModalContainer.is(e.target) && searchModalContainer.has(e.target).length === 0) { 112 searchModalContainer.hide() 113 }; 114 }) 115 }) 116 } 117 // on search key type 118 if( currentElem.hasClass("search-type--live-search") ) { 119 // close search results on outside click 120 $(document).mouseup(function (e) { 121 var searchResultModalContainer = $(".search-results-wrap"); 122 if ( !searchResultModalContainer.is(e.target) && searchResultModalContainer.has(e.target).length === 0) { 123 searchResultModalContainer.hide() 124 }; 125 }) 126 127 var searchFormContainer = currentElem.find("form") 128 currentElem.on( "change, keyup", '.nekit-search-form-wrap form input[type="search"]', function() { 129 var _this = $(this), searchKey = _this.val() 130 if( searchKey.trim() != '' ) { 131 $.ajax({ 132 method: 'post', 133 url: ajaxUrlA, 134 data: { 135 action: 'nekit_live_search_widget_posts_content', 136 search_key : searchKey.trim(), 137 dataSettings: dataSettings, 138 _wpnonce: nonceA 139 }, 140 beforeSend: function() { 141 searchFormContainer.addClass( 'retrieving-posts' ); 142 searchFormContainer.removeClass( 'results-loaded' ) 143 }, 144 success : function(res) { 145 var parsedRes = res.data 146 currentElem.find(".search-results-wrap").remove() 147 searchFormContainer.after(parsedRes.posts) 148 searchFormContainer.removeClass( 'retrieving-posts' ).addClass( 'results-loaded' ); 149 }, 150 complete: function() { 151 // double check the search key value 152 var searchFieldCurrentVal = currentElem.find('.nekit-search-form-wrap form input[type="search"]').val() 153 if( searchFieldCurrentVal.trim() == '' ) { 154 currentElem.find(".search-results-wrap").remove() 155 searchFormContainer.removeClass( 'retrieving-posts results-loaded' ); 156 } 157 } 158 }) 159 } else { 160 currentElem.find(".search-results-wrap").remove() 161 searchFormContainer.removeClass( 'retrieving-posts results-loaded' ) 162 } 163 }) 164 } 165 }) 166 } 167 168 // date and time widget 169 var datSectionContainer = $(".date-and-time-wrap") 170 if( datSectionContainer.length > 0 ) { 171 setInterval(function() { 172 datSectionContainer.find(".time-count").html(new Date().toLocaleTimeString()) 173 },1000); 174 } 175 176 // mega menu script handler 177 $(window).resize(function() { 178 scriptHandlers.megaMenuWidget() 179 }); 180 181 const scriptHandlers = { 182 init: function() { 183 this.megaMenuWidget() 184 this.navMenuWidget() 185 }, 186 megaMenuWidget: function() { 187 var megaMenuContainer = $(".news-elementor-nav-mega-menu") 188 if( megaMenuContainer.length > 0 ) { 189 megaMenuContainer.each(function() { 190 var megaMenuContainerItem = $(this), toMobileMenu = megaMenuContainerItem.data("mobile") 191 scriptHandlers.addSubmenuDropdownIcon(megaMenuContainerItem) // handle sub menu dropdown 192 if( ! ( $(window).width() > toMobileMenu ) ) { 193 megaMenuContainerItem.addClass("isResponsiveMenu") 194 megaMenuContainerItem.on( "click", ".responsive-menu-trigger", function() { 195 var _this = $(this) 196 _this.addClass("nekit-hamburger-open"); 197 _this.next().addClass("isShow") 198 $('body').addClass("nekit-mega-menu-overlay") 199 scriptHandlers.onElementOutsideClick(_this.next(), function() { 200 _this.next().removeClass("isShow") 201 _this.removeClass("nekit-hamburger-open"); 202 $('body').removeClass("nekit-mega-menu-overlay") 203 }) 204 }) 205 } else { 206 megaMenuContainerItem.removeClass("isResponsiveMenu") 207 } 208 scriptHandlers.handleResponsiveMenu(megaMenuContainerItem) // handle sub menu dropdown 209 }) 210 } 211 }, 212 navMenuWidget: function() { 213 var megaMenuContainer = $(".news-elementor-nav-menu") 214 if( megaMenuContainer.length > 0 ) { 215 megaMenuContainer.each(function() { 216 var megaMenuContainerItem = $(this), toMobileMenu = megaMenuContainerItem.data("mobile") 217 scriptHandlers.addNavSubmenuDropdownIcon(megaMenuContainerItem) // handle sub menu dropdown 218 if( ! ( $(window).width() > toMobileMenu ) ) { 219 megaMenuContainerItem.addClass("isResponsiveMenu") 220 megaMenuContainerItem.on( "click", ".responsive-menu-trigger", function() { 221 var _this = $(this) 222 _this.toggleClass("nekit-hamburger-open"); 223 _this.next().toggleClass("isShow") 224 $('body').addClass("nekit-menu-overlay") 225 scriptHandlers.onElementOutsideClick(_this.next(), function() { 226 _this.next().removeClass("isShow") 227 _this.toggleClass("nekit-hamburger-open"); 228 $('body').removeClass("nekit-menu-overlay") 229 }) 230 }) 231 } else { 232 megaMenuContainerItem.removeClass("isResponsiveMenu") 233 } 234 scriptHandlers.handleNavResponsiveMenu(megaMenuContainerItem) // handle sub menu dropdown 235 }) 236 } 237 }, 238 addSubmenuDropdownIcon: function(megaMenuContainerItem) { 239 var menuItemWithSubmenu = megaMenuContainerItem.find( ".nekit-nav-mega-menu-list-wrap > .nekit-has-mega-menu, .nekit-nav-mega-menu-list-wrap > .nekit-has-sub-menu" ) 240 if( menuItemWithSubmenu.length == 0 ) return; 241 menuItemWithSubmenu.each(function() { 242 var parentMenuItemWithSubmenuInnerElm = $(this).find("> a"); 243 var menuItemWithSubmenuInnerElm = $(this).find(".nekit-sub-menu .nekit-has-sub-menu > a"); 244 var parentIconHasSubmenuClosed = megaMenuContainerItem.data("parent-dropdown"), parentIconHasSubmenuOpened = megaMenuContainerItem.data("parent-upside"), parentIconChildHasSubmenuClosed = megaMenuContainerItem.data("dropdown"), parentIconChildHasSubmenuOpened = megaMenuContainerItem.data("upside"), parentIconPosition = megaMenuContainerItem.data("dropdown-position") 245 if( parentIconPosition == 'before' ) { 246 if( parentIconHasSubmenuClosed != 'no-icon' && parentMenuItemWithSubmenuInnerElm.find("i.nekit-indicator-menu-icon").length == 0 ) parentMenuItemWithSubmenuInnerElm.prepe
246nd('<i class="nekit-indicator-menu-icon ' + parentIconHasSubmenuClosed + ' "></i>') 247 if( parentIconChildHasSubmenuClosed != 'no-icon' && menuItemWithSubmenuInnerElm.find("i.nekit-indicator-menu-icon").length == 0 ) menuItemWithSubmenuInnerElm.prepend('<i class="nekit-indicator-menu-icon ' + parentIconChildHasSubmenuClosed + ' "></i>') 248 } else { 249 if( parentIconHasSubmenuClosed != 'no-icon' && parentMenuItemWithSubmenuInnerElm.find("i.nekit-indicator-menu-icon").length == 0 ) parentMenuItemWithSubmenuInnerElm.append('<i class="nekit-indicator-menu-icon ' + parentIconHasSubmenuClosed + ' "></i>') 250 if( parentIconChildHasSubmenuClosed != 'no-icon' && menuItemWithSubmenuInnerElm.find("i.nekit-indicator-menu-icon").length == 0 ) menuItemWithSubmenuInnerElm.append('<i class="nekit-indicator-menu-icon ' + parentIconChildHasSubmenuClosed + ' "></i>') 251 } 252 // handle click and hover submenu show hide - on parent first menu items 253 if( parentMenuItemWithSubmenuInnerElm.parent().hasClass("appear-event--click") || ( parentMenuItemWithSubmenuInnerElm.parent().hasClass("nekit-has-sub-menu") && parentMenuItemWithSubmenuInnerElm.parents(".news-elementor-nav-mega-menu").hasClass("nekit-submenu-onmouse-click") ) ) { 254 parentMenuItemWithSubmenuInnerElm.on("click",function(e) { 255 e.preventDefault() 256 $(this).next().toggleClass("isShow") 257 if( $(this).next().hasClass("close-event--outside-click") ) scriptHandlers.handleSubmenuClose($(this).next()) 258 if( parentIconChildHasSubmenuOpened != 'no-icon' ) $(this).find("i.nekit-indicator-menu-icon").toggleClass( parentIconHasSubmenuClosed + " " + parentIconHasSubmenuOpened ) 259 // close other sub menu 260 var siblingsMenuItem = $(this).parent( ".nekit-has-sub-menu, .nekit-has-mega-menu" ).siblings( ".nekit-has-sub-menu, .nekit-has-mega-menu" ) 261 if( siblingsMenuItem.length > 0 ) { 262 siblingsMenuItem.find(".nekit-sub-menu, .nekit-mega-menu-container").removeClass("isShow") 263 } 264 }) 265 } else { 266 parentMenuItemWithSubmenuInnerElm.hover(function() { 267 if( parentIconChildHasSubmenuOpened != 'no-icon' ) $(this).find(" > i.nekit-indicator-menu-icon").toggleClass( parentIconHasSubmenuClosed + " " + parentIconHasSubmenuOpened ) 268 // close other sub menu 269 var siblingsMenuItem = $(this).parent( ".nekit-has-sub-menu, .nekit-has-mega-menu" ).siblings( ".nekit-has-sub-menu, .nekit-has-mega-menu" ) 270 if( siblingsMenuItem.length > 0 ) { 271 siblingsMenuItem.find(".nekit-sub-menu, .nekit-mega-menu-container").removeClass("isShow") 272 } 273 }) 274 } 275 276 // handle click and hover submenu show hide - on child sub menu with child items 277 if( menuItemWithSubmenuInnerElm.parent().hasClass("appear-event--click") || ( menuItemWithSubmenuInnerElm.parent().hasClass("nekit-has-sub-menu") && menuItemWithSubmenuInnerElm.parents(".news-elementor-nav-mega-menu").hasClass("nekit-submenu-onmouse-click") ) ) { 278 menuItemWithSubmenuInnerElm.on("click",function(e) { 279 e.preventDefault() 280 $(this).next().toggleClass("isShow") 281 if( menuItemWithSubmenuInnerElm.next().hasClass("close-event--outside-click") ) scriptHandlers.handleSubmenuClose(menuItemWithSubmenuInnerElm.next()) 282 if( parentIconChildHasSubmenuOpened != 'no-icon' ) $(this).find("i.nekit-indicator-menu-icon").toggleClass( parentIconChildHasSubmenuClosed + " " + parentIconChildHasSubmenuOpened ) 283 // close other sub menu 284 var siblingsMenuItem = $(this).parent( ".nekit-has-sub-menu" ).siblings( ".nekit-has-sub-menu" ) 285 if( siblingsMenuItem.length > 0 ) { 286 siblingsMenuItem.find(".nekit-sub-menu").removeClass("isShow") 287 } 288 }) 289 } else { 290 menuItemWithSubmenuInnerElm.hover(function() { 291 if( parentIconChildHasSubmenuOpened != 'no-icon' ) $(this).find(" > i.nekit-indicator-menu-icon").toggleClass( parentIconChildHasSubmenuClosed + " " + parentIconChildHasSubmenuOpened ) 292 }) 293 } 294 }) // for each meta item with mega menu 295 }, 296 addNavSubmenuDropdownIcon: function(megaMenuContainerItem) { 297 var menuItemWithSubmenu = megaMenuContainerItem.find( ".nekit-nav-menu-list-wrap > .nekit-has-sub-menu" ) 298 if( menuItemWithSubmenu.length == 0 ) return; 299 menuItemWithSubmenu.each(function() { 300 var parentMenuItemWithSubmenuInnerElm = $(this).find("> a"); 301 var menuItemWithSubmenuInnerElm = $(this).find(".nekit-sub-menu .nekit-has-sub-menu > a"); 302 var parentIconHasSubmenuClosed = megaMenuContainerItem.data("parent-dropdown"), parentIconHasSubmenuOpened = megaMenuContainerItem.data("parent-upside"), parentIconChildHasSubmenuClosed = megaMenuContainerItem.data("dropdown"), parentIconChildHasSubmenuOpened = megaMenuContainerItem.data("upside"), parentIconPosition = megaMenuContainerItem.data("dropdown-position") 303 if( parentIconPosition == 'before' ) { 304 if( parentIconHasSubmenuClosed != 'no-icon' && parentMenuItemWithSubmenuInnerElm.find("i.nekit-indicator-menu-icon").length == 0 ) parentMenuItemWithSubmenuInnerElm.prepe
304nd('<i class="nekit-indicator-menu-icon ' + parentIconHasSubmenuClosed + ' "></i>') 305 if( parentIconChildHasSubmenuClosed != 'no-icon' && menuItemWithSubmenuInnerElm.find("i.nekit-indicator-menu-icon").length == 0 ) menuItemWithSubmenuInnerElm.prepend('<i class="nekit-indicator-menu-icon ' + parentIconChildHasSubmenuClosed + ' "></i>') 306 } else { 307 if( parentIconHasSubmenuClosed != 'no-icon' && parentMenuItemWithSubmenuInnerElm.find("i.nekit-indicator-menu-icon").length == 0 ) parentMenuItemWithSubmenuInnerElm.append('<i class="nekit-indicator-menu-icon ' + parentIconHasSubmenuClosed + ' "></i>') 308 if( parentIconChildHasSubmenuClosed != 'no-icon' && menuItemWithSubmenuInnerElm.find("i.nekit-indicator-menu-icon").length == 0 ) menuItemWithSubmenuInnerElm.append('<i class="nekit-indicator-menu-icon ' + parentIconChildHasSubmenuClosed + ' "></i>') 309 } 310 // handle click and hover submenu show hide - on parent first menu items 311 if( parentMenuItemWithSubmenuInnerElm.parent().hasClass("appear-event--click") || ( parentMenuItemWithSubmenuInnerElm.parent().hasClass("nekit-has-sub-menu") && parentMenuItemWithSubmenuInnerElm.parents(".news-elementor-nav-menu").hasClass("nekit-submenu-onmouse-click") ) ) { 312 parentMenuItemWithSubmenuInnerElm.on("click",function(e) { 313 e.preventDefault() 314 $(this).next().toggleClass("isShow") 315 if( $(this).next().hasClass("close-event--outside-click") ) scriptHandlers.handleSubmenuClose($(this).next()) 316 if( parentIconChildHasSubmenuOpened != 'no-icon' ) $(this).find("i.nekit-indicator-menu-icon").toggleClass( parentIconHasSubmenuClosed + " " + parentIconHasSubmenuOpened ) 317 // close other sub menu 318 var siblingsMenuItem = $(this).parent( ".nekit-has-sub-menu" ).siblings( ".nekit-has-sub-menu" ) 319 if( siblingsMenuItem.length > 0 ) { 320 siblingsMenuItem.find(".nekit-sub-menu, .nekit-menu-container").removeClass("isShow") 321 } 322 }) 323 } else { 324 parentMenuItemWithSubmenuInnerElm.hover(function() { 325 if( parentIconChildHasSubmenuOpened != 'no-icon' ) $(this).find(" > i.nekit-indicator-menu-icon").toggleClass( parentIconHasSubmenuClosed + " " + parentIconHasSubmenuOpened ) 326 // close other sub menu 327 var siblingsMenuItem = $(this).parent( ".nekit-has-sub-menu" ).siblings( ".nekit-has-sub-menu" ) 328 if( siblingsMenuItem.length > 0 ) { 329 siblingsMenuItem.find(".nekit-sub-menu, .nekit-menu-container").removeClass("isShow") 330 } 331 }) 332 } 333 334 // handle click and hover submenu show hide - on child sub menu with child items 335 if( menuItemWithSubmenuInnerElm.parent().hasClass("appear-event--click") || ( menuItemWithSubmenuInnerElm.parent().hasClass("nekit-has-sub-menu") && menuItemWithSubmenuInnerElm.parents(".news-elementor-nav-menu").hasClass("nekit-submenu-onmouse-click") ) ) { 336 menuItemWithSubmenuInnerElm.on("click",function(e) { 337 e.preventDefault() 338 $(this).next().toggleClass("isShow") 339 if( menuItemWithSubmenuInnerElm.next().hasClass("close-event--outside-click") ) scriptHandlers.handleSubmenuClose(menuItemWithSubmenuInnerElm.next()) 340 if( parentIconChildHasSubmenuOpened != 'no-icon' ) $(this).find("i.nekit-indicator-menu-icon").toggleClass( parentIconChildHasSubmenuClosed + " " + parentIconChildHasSubmenuOpened ) 341 // close other sub menu 342 var siblingsMenuItem = $(this).parent( ".nekit-has-sub-menu" ).siblings( ".nekit-has-sub-menu" ) 343 if( siblingsMenuItem.length > 0 ) { 344 siblingsMenuItem.find(".nekit-sub-menu").removeClass("isShow") 345 } 346 }) 347 } else { 348 menuItemWithSubmenuInnerElm.hover(function() { 349 if( parentIconChildHasSubmenuOpened != 'no-icon' ) $(this).find(" > i.nekit-indicator-menu-icon").toggleClass( parentIconChildHasSubmenuClosed + " " + parentIconChildHasSubmenuOpened ) 350 }) 351 } 352 }) // for each meta item with mega menu 353 }, 354 handleResponsiveMenu: function(megaMenuContainerItem) { 355 if( ! megaMenuContainerItem.hasClass("isResponsiveMenu") ) return; 356 var canvasHeaderIcon = megaMenuContainerItem.data("dropdown-header-icon") 357 megaMenuContainerItem.on("click", ".nekit-nav-mega-menu-container .nekit-nav-mega-menu-list-wrap .nekit-has-mega-menu >a", function(e) { 358 e.preventDefault() 359 var _this = $(this), menuItem = _this.parent() 360 var currentMenuLabel = _this.text() 361 var toShowContainer = menuItem.find(" > .nekit-mega-menu-container") 362 if( ! megaMenuContainerItem.hasClass( "mobile-menu-dropdown-sub-menu-display-type--default" ) ) { 363 toShowContainer.prepend('<div class="header">' + canvasHeaderIcon + '<span class="header-label">' + currentMenuLabel + '</span></div>') 364 } 365 toShowContainer.toggleClass("current-responsive-active-menu-content") 366 }) 367 368 megaMenuContainerItem.on("click", ".nekit-nav-mega-menu-container .nekit-nav-mega-menu-list-wrap .nekit-has-sub-menu > a", function(e) { 369 e.preventDefault() 370 var _this = $(this), menuItem = _this.parent() 371 var currentMenuLabel = _this.text() 372 var toShowContainer = menuItem.find(" > .nekit-sub-menu") 373 if( ! megaMenuContainerItem.hasClass( "mobile-menu-dropdown-sub-menu-display-type--default" ) ) { 374 toShowContainer.prepend('<div class="header">' + canvasHeaderIcon + '<span class="header-label">' + currentMenuLabel + '</span></div>') 375 } 376 toShowContainer.toggleClass("current-responsive-active-menu-content") 377 }) 378 379 // navigate back to the previous menu 380 megaMenuContainerItem.on( "click", ".nekit-nav-mega-menu-container .nekit-nav-mega-menu-list-wrap .current-responsive-active-menu-content .header", function(e) { 381 e.preventDefault() 382 $(this).parent().removeClass("current-responsive-active-menu-content") 383 $(this).remove() 384 }) 385 }, 386 handleNavResponsiveMenu: function(navMenuContainerItem) { 387 if( ! navMenuContainerItem.hasClass("isResponsiveMenu") ) return; 388 var canvasHeaderIcon = navMenuContainerItem.data("dropdown-header-icon") 389 navMenuContainerItem.on("click", ".nekit-nav-menu-container .nekit-nav-menu-list-wrap .nekit-has-sub-menu > a", function(e) { 390 e.preventDefault() 391 var _this = $(this), menuItem = _this.parent() 392 var currentMenuLabel = _this.text() 393 var toShowContainer = menuItem.find(" > .nekit-sub-menu") 394 if( ! navMenuContainerItem.hasClass( "mobile-menu-dropdown-sub-menu-display-type--default" ) ) { 395 toShowContainer.prepend('<div class="header">' + canvasHeaderIcon + '<span class="header-label">' + currentMenuLabel + '</span></div>') 396 } 397 toShowContainer.toggleClass("current-responsive-active-menu-content") 398 }) 399 400 // navigate back to the previous menu 401 navMenuContainerItem.on( "click", ".nekit-nav-menu-container .nekit-nav-menu-list-wrap .current-responsive-active-menu-content .header", function(e) { 402 e.preventDefault() 403 $(this).parent().removeClass("current-responsive-active-menu-content") 404 $(this).remove() 405 }) 406 }, 407 handleSubmenuClose: function(currentSubmenu) { 408 scriptHandlers.onElementOutsideClick(currentSubmenu, function() { 409 currentSubmenu.removeClass("isShow") 410 }) 411 }, 412 onElementOutsideClick: function(currentElement, callback) { 413 $(document).mouseup(function (e) { 414 var container = $(currentElement); 415 if (!container.is(e.target) && container.has(e.target).length === 0) callback(); 416 }) 417 } 418 } 419 scriptHandlers.init() 420 421 // theme mode widget 422 var tmSectionContainer = $('.nekit-theme-mode') 423 if( tmSectionContainer.length > 0 ) { 424 tmSectionContainer.click(function() { 425 var _this = $(this) 426 if( _this.hasClass("light-mode--on") ) { 427 _this.removeClass("light-mode--on").addClass("dark-mode--on") 428 $(".theme-mode").parents('body').toggleClass('nekit_dark_mode') 429 $.cookie( "nekitThemeMode", "dark", { path: '/' } ); 430 } else if(_this.hasClass("dark-mode--on")) { 431 _this.removeClass("dark-mode--on").addClass("light-mode--on") 432 $(".theme-mode").parents('body').toggleClass('nekit_dark_mode') 433 $.cookie( "nekitThemeMode", "light", { path: '/' } ); 434 } 435 }) 436 } 437 438 // full width banner Widget 439 var fwbSectionContainer = $('.nekit-full-width-banner-wrap') 440 if( fwbSectionContainer.length > 0 ){ 441 fwbSectionContainer.each(function(){ 442 var _this = $(this) 443 var fwbArrows = _this.data('arrow') 444 var fwbAutoplay = _this.data('autoplay') 445 var fwbAutoplay = _this.data('autoplay') 446 var fwbFade = _this.data('fade') 447 var fwbInfinite = _this.data('infinite') 448 var fwbSpeed = _this.data('speed') 449 var fwbAutoplaySpeed = _this.data('autoplayspeed') 450 var fwbCenterMode = _this.data('centermode') 451 var fwbCenterPadding = _this.data('centerpadding') + 'px' 452 var fwbprevArrow = _this.data('prevarrow') 453 var fwbnextArrow = _this.data('nextarrow') 454 $(this).slick({ 455 arrows: fwbArrows, 456 autoplay: fwbAutoplay, 457 autoplaySpeed: fwbAutoplaySpeed, 458 fade: fwbFade, 459 infinite: fwbInfinite, 460 speed: fwbSpeed, 461 centerMode: fwbCenterMode, 462 centerPadding: fwbCenterPadding, 463 nextArrow: `<button type="button" class="slick-next"><i class="`+ fwbnextArrow +`"></i></button>`, 464 prevArrow: `<button type="button" class="slick-prev"><i class="`+ fwbprevArrow +`"></i></button>` 465 }) 466 }) 467 } 468 469 // categories collection widget 470 var ccSectionContainer = $('.nekit-categories-collection-wrap.carousel-active') 471 if( ccSectionContainer.length > 0 ) { 472 ccSectionContainer.each(function() { 473 var _this = $(this) 474 var ccParams = { 475 "show_arrows": "yes", 476 "enable_autoplay": "no", 477 "show_fade": "no", 478 "show_infinite": "no", 479 "carousel_speed": 1500, 480 "autoplay_speed": 300, 481 "widget_column": 3, 482 "widget_column_tablet": 2, 483 "widget_column_mobile": 1 484 } 485 var widgetContainer = _this.parents('.elementor-widget-nekit-categories-collection[data-widget_type="nekit-categories-collection.default"]') 486 if( typeof widgetContainer.data('settings') != 'undefined' ) { 487 ccParams = widgetContainer.data('settings') 488 } 489 var ccArrows = _this.data('arrows') 490 var ccAutoplay = _this.data('autoplay') 491 var ccAutoplaySpeed = _this.data('autoplayspeed') 492 var ccFade = _this.data('fade') 493 var ccInfinite = _this.data('infinite') 494 var ccSpeed = _this.data('speed') 495 var ccSlidesToShow = _this.data('slidestoshow') 496 var ccPrevArrow = _this.data('prev') 497 var ccNextArrow = _this.data('next') 498 var ccMobile = _this.data('mobile') 499 var ccTablet = _this.data('tablet') 500 ccFade = ( ccSlidesToShow == 1 && ccFade) 501 _this.slick({ 502 arrows: ( ccParams.show_arrows == 'yes' ), 503 autoplay: ( ccParams.enable_autoplay == 'yes' ), 504 autoplaySpeed: ccParams.autoplay_speed, 505 fade: ( ccParams.show_fade == 'yes' ), 506 infinite: ( ccParams.show_infinite == 'yes' ), 507 speed: ccParams.carousel_speed, 508 slidesToShow: ccParams.widget_column, 509 prevArrow: '<button type="button" class="slick-prev"><i class="' + ccPrevArrow + '"></i></button>', 510 nextArrow: '<button type="button" class="slick-next"><i class="' + ccNextArrow + '"></i></button>', 511 responsive: [ 512 { 513 breakpoint: 769, 514 settings: { 515 slidesToShow: ccParams.widget_column_tablet 516 } 517 }, 518 { 519 breakpoint: 640, 520 settings: { 521 slidesToShow: ccParams.widget_column_mobile 522 } 523 } 524 ] 525 }) 526 }) 527 }; 528 529 // news timeline widget handler 530 var ntSectionContainer = $('.nekit-news-timeline-wrap') 531 if( ntSectionContainer.length > 0 ) { 532 ntSectionContainer.each(function() { 533 var _this = $(this) , sectionOffset = Math.round( _this.offset().top ) , windowHeight = $( window ).height() 534 var windowScrolled = $( window ).scrollTop() , sectionHeight = _this.height() 535 var color = _this.data('color'), defaultColor = _this.data('defaultcolor') 536 if( sectionOffset < ( windowHeight / 2 ) ) { // handle the script if section visible on load 537 var barHeight = ( windowHeight / 2 ) 538 _this.find(".timeline-fixed-bar .progress-bar").css("height",barHeight) 539 // fill the icon color on progress bar scroll 540 var polylineIcon = _this.find(".post-item .polyline-icon") 541 polylineIcon.each(function() { 542 var iconElm = $(this), iconOffset = iconElm.offset().top, iconHeightWithSectionTop = iconOffset - sectionOffset 543 if( barHeight > iconHeightWithSectionTop ) { 544 $(this).css("color",color) 545 } else { 546 $(this).css("color",defaultColor) 547 } 548 }) 549 } 550 $( window ).on("scroll",function() { 551 color = _this.data('color') 552 sectionOffset = Math.round( _this.offset().top ) 553 windowHeight = $( window ).height() 554 windowScrolled = $( window ).scrollTop() 555 sectionHeight = _this.height() 556 if( ( ( sectionOffset - windowScrolled ) - ( windowHeight / 2 ) ) <= 50 ){ //Section Reached 557 var barHeight = Math.abs(Math.round( ( sectionOffset - windowScrolled ) - ( windowHeight / 2 ) )) 558 _this.find(".timeline-fixed-bar .progress-bar").css("height",barHeight) 559 if( barHeight > sectionHeight ){ 560 barHeight = Math.abs(Math.round( sectionHeight )) 561 _this.find(".timeline-fixed-bar .progress-bar").css("height",barHeight) 562 } 563 if($(window).scrollTop() + $(window).height() == $(document).height()){ 564 barHeight = Math.abs(Math.round( sectionHeight )) 565 _this.find(".timeline-fixed-bar .progress-bar").css("height",barHeight) 566 } 567 568 // fill the icon color on progress bar scroll 569 var polylineIcon = _this.find(".post-item .polyline-icon") 570 polylineIcon.each(function() { 571 var iconElm
571= $(this), iconOffset = iconElm.offset().top, iconHeightWithSectionTop = iconOffset - sectionOffset 572 if( barHeight > iconHeightWithSectionTop ) { 573 $(this).css("color",color) 574 } else { 575 $(this).css("color",defaultColor) 576 } 577 }) 578 } else { 579 barHeight = Math.abs(Math.round( 0 )) 580 _this.find(".timeline-fixed-bar .progress-bar").css("height",barHeight) 581 } 582 }) 583 }) 584 } 585 586 // news carousel one script handler 587 var ncOneSection = $(".nekit-carousel-widget") 588 if( ncOneSection.length > 0 ) { 589 ncOneSection.each(function() { 590 var $scope = $(this), nc = $scope.find( ".news-carousel .news-carousel-post-wrap" ); 591 if( nc.length ) { 592 var ncLoop= nc.data("loop") == '1' 593 var ncArrows= nc.data("arrows") == '1' 594 var ncAuto = nc.data("auto") == '1' 595 var ncSpeed = nc.data("speed") 596 var ncColumns = nc.data("columns") 597 var ncColumnsTablet = nc.data("columns-tablet") 598 var ncColumnsMobile = nc.data("columns-mobile") 599 var ncPrevIcon = nc.data("prev-icon") 600 var ncNextIcon = nc.data("next-icon") 601 var ncFade = nc.data("fade") == '1' 602 nc.slick({ 603 dots: false, 604 infinite: ncLoop, 605 arrows: ncArrows, 606 autoplay: ncAuto, 607 rtl: nrtl, 608 speed: ncSpeed, 609 slidesToShow: ncColumns, 610 fade: ncFade, 611 nextArrow: `<button type="button" class="slick-next"><i class="` + ncNextIcon + `"></i></button>`, 612 prevArrow: `<button type="button" class="slick-prev"><i class="` + ncPrevIcon + `"></i></button>`, 613 responsive: [ 614 { 615 breakpoint: 769, 616 settings: { 617 slidesToShow: ncColumnsTablet 618 } 619 }, 620 { 621 breakpoint: 640, 622 settings: { 623 slidesToShow: ncColumnsMobile 624 } 625 } 626 ] 627 }) 628 } 629 }) 630 } 631 632 // handle table of content widget 633 var TocSectionContainer = $(".nekit-single-table-of-content") 634 if( TocSectionContainer.length > 0 ) { 635 $.fn.isInViewport = function() { 636 var elementTop = $(this).offset(); 637 var elementBottom = elementTop + $(this).outerHeight(); 638 var viewportTop = $(window).scrollTop(); 639 var viewportBottom = viewportTop + $(window).height(); 640 return elementBottom > viewportTop && elementTop < viewportBottom; 641 } 642 643 TocSectionContainer.each(function() { 644 const _this = $(this) 645 const containerToRender = $(this).find(".table-of-content-list-wrap") 646 const tocHandler = { 647 init: function() { 648 this.headingTags = [] 649 this.listItemPointer = 0 650 this.headingsToLook = _this.data('anchor') 651 this.headingsMarker = _this.data('marker') 652 this.headingsView = _this.data('view') 653 this.noHeadingsFoundHide = ( _this.data('hide') == 'true' ) 654 this.noHeadingsFoundText = _this.data('text') 655 var contentContainer = $(document).find('.nekit-single-content') 656 this.headingNodes = contentContainer.find(this.headingsToLook) 657 this.handleContentToggle() 658 this.handleToggle() 659 if( this.headingNodes.length > 0 ) { 660 this.getAllHeadingNodes() 661 this.createHeadingTreeView() 662 this.onAnchorRedirect() 663 this.highlightAnchor() 664 } else { 665 if( this.noHeadingsFoundHide ) { 666 _this.remove() 667 } else { 668 containerToRender.html( this.noHeadingsFoundText ); 669 } 670 } 671 }, 672 highlightAnchor() { 673 $(window).scroll(function() { 674 let tocHeadings = $(document).find(".nekit-single-table-of-content .toc-list-item") 675 for( let i = 0 ; i < tocHeadings.length; i++) { 676 if( $(tocHandler.headingNodes[i]).isInViewport() ) { 677 $(tocHeadings[i]).addClass("active").siblings().removeClass("active") 678 } 679 } 680 }); 681 }, 682 onAnchorRedirect: function() { 683 $(document).on( "click", ".nekit-single-table-of-content .toc-heading-title a", function(e) { 684 var hashLink = $(this).attr("href").replace("#","") 685 $("html, body").animate({ 686 scrollTop: $("#" + hashLink ).offset().top - 50 687 }, "slow") 688 e.preventDefault() 689 }) 690 }, 691 getAllHeadingNodes: function() { 692 this.headingNodes.each((index,element) => { 693 // add anchor point for each heading 694 $(element).before('<span id="nekit-toc-heading-anchor--' + index + '" class="nekit-toc-menu-anchor"></span>');
695 let anchorLink = 'nekit-toc-heading-anchor--' + index 696 // generate the stack of heading tags 697 this.headingTags.push({ 698 tag: +element.nodeName.slice(1), 699 text: element.textContent, 700 anchorLink 701 }); 702 }) 703 }, 704 createHeadingTreeView: function() { 705 this.headingTags.forEach((heading, index) => { 706 heading.level = 0; 707 for (let i = index - 1; i >= 0; i--) { 708 const currentOrderedItem = this.headingTags[i]; 709 if (currentOrderedItem.tag <= heading.tag) { 710 heading.level = currentOrderedItem.level; 711 if (currentOrderedItem.tag < heading.tag) { 712 heading.level++; 713 } 714 break; 715 } 716 } 717 }); 718 if( this.headingsView == 'tree' ) { 719 containerToRender.html(this.getTreeHtml(0)); 720 } else { 721 containerToRender.html(this.getFlatHtml()); 722 } 723 if( this.headingsMarker == 'number' ) { 724 var tocContent = containerToRender.find(" > .toc-list-item-wrap") 725 this.giveNumbering(tocContent) 726 } 727 }, 728 giveNumbering: function(tocContent, numberingString = '') { 729 var tocList = tocContent.find( " > .toc-list-item" ) 730 if( tocList.length > 0 ) { 731 tocList.each(function(index) { 732 var _this = $(this), newNumberingString = '<span class="numbering-prefix">' + numberingString + (index + 1).toString() + '.</span>' 733 _this.find(" > .toc-heading-title a").prepend(newNumberingString) 734 var tocInnerContent = _this.find(" > .toc-list-item-wrap") 735 if(tocInnerContent.length > 0) tocHandler.giveNumbering(tocInnerContent,newNumberingString) 736 }) 737 } 738 }, 739 getTreeHtml: function(level) { 740 // generate list wrap 741 let html = `<ul class="toc-list-item-wrap">`; 742 // For each list item, build its markup. 743 var levelCount = 1; 744 while (this.listItemPointer < this.headingTags.length) { 745 const currentItem = this.headingTags[this.listItemPointer]; 746 if (level > currentItem.level) { 747 break; 748 } 749 if (level === currentItem.level) { 750 html += `<li class="toc-list-item">`; 751 html += `<span class="toc-heading-title"><a href="#${currentItem.anchorLink}">`; 752 let liContent = `${currentItem.text}`; 753 html += liContent; 754 html += '</a></span>'; 755 this.listItemPointer++; 756 const nextItem = this.headingTags[this.listItemPointer]; 757 if (nextItem && level < nextItem.level) { 758 html += this.getTreeHtml(nextItem.level); 759 } 760 html += '</li>'; 761 } 762 levelCount++; 763 } 764 html += `</ul>`; 765 return html; 766 }, 767 getFlatHtml: function() { 768 // generate list wrap 769 let html = `<ul class="toc-list-item-wrap">`; 770 // For each list item, build its markup. 771 var levelCount = 0; 772 while (levelCount < this.headingTags.length) { 773 const currentItem = this.headingTags[levelCount]; 774 html += `<li class="toc-list-item">`; 775 html += `<span class="toc-heading-title"><a href="#${currentItem.anchorLink}">`; 776 let liContent = `${currentItem.text}`; 777 html += liContent; 778 html += '</a></span>'; 779 html += '</li>'; 780 levelCount++; 781 } 782 html += `</ul>`; 783 return html; 784 }, 785 handleContentToggle: function() { 786 _this.on( "click", ".toc-content-toggle-button", function() { 787 var contentToggleButton = $(this), minimizedIcon = contentToggleButton.data("minimized"), maximizedIcon = contentToggleButton.data("maximized") 788 containerToRender.slideToggle(400, function() { 789 contentToggleButton.find("i").toggleClass( minimizedIcon + ' ' + maximizedIcon ) 790 }) 791 }) 792 }, 793 handleToggle: function() { 794 _this.on( "click", ".toc-toggle-button", function() { 795 var contentToggleButton = $(this), minimizedIcon = contentToggleButton.data("minimized"), maximizedIcon = contentToggleButton.data("maximized") 796 _this.find(".table-of-content-wrap").slideToggle(400, function() { 797 contentToggleButton.find("i").toggleClass( minimizedIcon + ' ' + maximizedIcon ) 798 }) 799 }) 800 } 801 } 802 tocHandler.init() 803 }) 804 } 805 // main banner one script handler 806 var mbSectionContainer = $(".main-banner-section") 807 if( mbSectionContainer.length > 0 ) { 808 mbSectionContainer.each(function() { 809 var _this = $(this), bannerItemsWrap = _this.find(".main-banner-slider"), bannerItemsTabsWrap = _this.find( ".main-banner-tabs" ) 810 var sAuto = bannerItemsWrap.data("auto"), 811 sArrows = bannerItemsWrap.data("arrows"), 812 sDots = bannerItemsWrap.data("dots"), 813 sLoop = bannerItemsWrap.data("loop"), 814 sSpeed = bannerItemsWrap.data("speed"), 815 sNextIcon = bannerItemsWrap.data("next-icon"),
816 sPrevIcon = bannerItemsWrap.data("prev-icon"), 817 sFade = bannerItemsWrap.data("fade") 818 bannerItemsWrap.slick({ 819 dots: sDots, 820 arrows: sArrows, 821 autoplay: sAuto, 822 infinite: sLoop, 823 speed: sSpeed, 824 rtl: nrtl, 825 fade: sFade, 826 nextArrow: `<button type="button" class="slick-next"><i class="` + sNextIcon + `"></i></button>`, 827 prevArrow: `<button type="button" class="slick-prev"><i class="` + sPrevIcon + `"></i></button>` 828 }); 829 830 // banner-tabs - layout one 831 if( bannerItemsTabsWrap.length > 0 ) { 832 bannerItemsTabsWrap.on( "click", ".banner-tabs li.banner-tab", function() { 833 var _this = $(this), tabItem = _this.attr( "tab-item" ); 834 _this.addClass( "active" ).siblings().removeClass( "active" ); 835 bannerItemsTabsWrap.find( '.banner-tabs-content div[tab-content="' + tabItem + '"]' ).addClass( "active" ).siblings().removeClass( "active" ); 836 }) 837 } 838 839 // main banner popular posts slider events - layout two 840 var bannerPopularPostsWrap = _this.find( ".popular-posts-wrap" ); 841 if( bannerPopularPostsWrap.length ) { 842 var bpcAuto = bannerPopularPostsWrap.data( "auto" ) 843 var bpcArrows = bannerPopularPostsWrap.data( "arrows" ) 844 var bpcLoop = bannerPopularPostsWrap.data( "loop" ) 845 var bpcSpeed = bannerPopularPostsWrap.data("speed") 846 var bpcVertical = bannerPopularPostsWrap.data( "vertical" ); 847 var bpcNextIcon = bannerPopularPostsWrap.data("next-icon") 848 var bpcPrevIcon = bannerPopularPostsWrap.data("prev-icon") 849 if( bpcVertical) { 850 bannerPopularPostsWrap.slick({ 851 vertical: bpcVertical, 852 slidesToShow: 4, 853 dots: false, 854 infinite: bpcLoop, 855 arrows: bpcArrows, 856 autoplay: bpcAuto, 857 speed: bpcSpeed, 858 nextArrow: `<button type="button" class="slick-next"><i class="` + bpcNextIcon + `"></i></button>`, 859 prevArrow: `<button type="button" class="slick-prev"><i class="` + bpcPrevIcon + `"></i></button>` 860 }) 861 } else { 862 bannerPopularPostsWrap.slick({ 863 dots: false, 864 infinite: bpcLoop, 865 arrows: bpcArrows, 866 rtl: nrtl, 867 draggable: true, 868 autoplay: bpcAuto, 869 speed: bpcSpeed, 870 nextArrow: `<button type="button" class="slick-next"><i class="` + bpcNextIcon + `"></i></button>`, 871 prevArrow: `<button type="button" class="slick-prev"><i class="` + bpcPrevIcon + `"></i></button>` 872 }) 873 } 874 } 875 }) 876 } 877 878 // news filter script handler 879 var nnfSectionContainer = $(".nekit-filter-widget") 880 if( nnfSectionContainer.length > 0 ) { 881 nnfSectionContainer.each(function() { 882 var $scope = $(this) 883 var adjustLayout =$(this).data("adjustlayout") 884 if( adjustLayout == 'on' || $(window).resize() ) { 885 var onBurgerIconClick = $scope.find(".tab-title-wrap") 886 var preloadedActiveTabTitle = onBurgerIconClick.find('.isActive').text() 887 $scope.find( '.active-tab' ).text( preloadedActiveTabTitle ) 888 $scope.on('click', '.burger-icon', function() { 889 var _this = $(this) 890 _this.next().toggle() 891 }) 892 } 893 $scope.on("click", ".filter-tab-wrapper .tab-title", function() { 894 var _this = $(this), dataTab = _this.data("tab") 895 if( adjustLayout == 'on' ) { 896 var activeTabTitle = _this.text() 897 _this.parents('.filter-tab-wrapper').find( '.active-tab' ).text( activeTabTitle ) 898 _this.parents('.tab-title-wrap').hide() 899 } 900 var widgetMainClass = _this.parents( ".nekit-filter-widget" ) 901 if( _this.hasClass('active-tab') ) return 902 if( _this.hasClass( 'isActive' ) ) return 903 var classToCheck = '.tab-'+dataTab 904 if( dataTab == 'news-elementor-filter-all' ) classToCheck = '.tab-all' 905 if( dataTab == 'nekit-filter-all' ) { 906 widgetMainClass.find( '.tab-all' ).show().addClass('isActive').siblings( '.news-filter-post-wrap' ).hide().removeClass('isActive') 907 _this.addClass('isActive').siblings().removeClass('isActive') 908 return 909 } 910 var widgetId = _this.parents( '.elementor-widget' ).data( 'id' ) 911 var widgetLayout = _this.parents( '.nekit-filter-widget' ).data('widgetlayout') 912 if( widgetMainClass.find( classToCheck ).length < 1 ) { 913 $.ajax({ 914 type: 'POST', 915 url: ajaxUrlA, 916 data: { 917 action: 'nekit_news_filter_tab_content_change', 918 options: JSON.stringify( nekitWidgetData[ widgetId ] ), 919 category: JSON.stringify(dataTab), 920 widgetCount: JSON.stringify(widgetLayout), 921 _wpnounce: nonceA 922 }, 923 beforeSend: function() { 924 $scope.find( '.news-filter-post-wrap.isActive' ).addClass( 'retrieving-posts' ) 925 $scope.find( '.news-filter-post-wrap.isActive' ).append(loaderElm) 926 }, 927 success: function(result) { 928 widgetMainClass.append( result ) 929 }, 930 complete: function() { 931 $scope.find( '.news-filter-post-wrap.isActive' ).removeClass( 'retrieving-posts' ) 932 widgetMainClass.find( classToCheck ).show().siblings('.news-filter-post-wrap').hide().removeClass('isActive') 933 _this.addClass('isActive').siblings().removeClass('isActive') 934 $scope.find( '.nekit-loader' ).remove() 935 } 936 }) 937 } else { 938 widgetMainClass.find( classToCheck ).show().addClass('isActive').siblings('.news-filter-post-wrap').hide().removeClass('isActive') 939 _this.addClass('isActive').siblings().removeClass('isActive') 940 } 941 }) 942 }) 943 } 944 945 // handle the section custom properties 946 var stickySections = $(".nekit-section--sticky") 947 if( stickySections.length > 0 ) { 948 stickySections.each(function() { 949 var thisSection = $(this), position = thisSection.data("nekit-sticky-position"), condition = thisSection.data("nekit-sticky-condition"), sectionScrollHeight = thisSection.offset().top 950 $(window).on( "scroll", function() { 951 if( $(window).scrollTop() > sectionScrollHeight ) { 952 if( ! thisSection.hasClass( "nekit-section--sticky-active-" + position ) ) thisSection.addClass("nekit-section--sticky-active-" + position) 953 } else { 954 if( thisSection.hasClass( "nekit-section--sticky-active-" + position ) ) thisSection.removeClass("nekit-section--sticky-active-" + position) 955 } 956 }) 957 }) 958 } 959 960 // ticker news two handlers 961 var tnTwoSectionContainer = $('.nekit-ticker-news-two') 962 if( tnTwoSectionContainer.length > 0 ) { 963 tnTwoSectionContainer.each(function() { 964 var _this = $(this) 965 var classToAddSlick = _this.find('.ticker-item-wrap') 966 var arrow = _this.data('arrows') 967 var autoplay = _this.data('autoplay') 968 var autoplaySpeed = _this.data('autoplay-speed') 969 var speed = _this.data('speed') 970 var fade = _this.data('fade') 971 var infinite = _this.data('infinite') 972 var sliderNextArrow = _this.data('nextarrow') 973 var sliderPreviousArrow = _this.data('previousarrow') 974 var nextArrow = '' 975 var previousArrow = '' 976 var sliderVertical = ( fade == true ) ? false : _this.data('vertical') 977 nextArrow = ( _this.data('nextarrow') == '' ) ? '' : `<button type="button" class="slick-next"><i class="` + sliderNextArrow + `"></i></button>` 978 previousArrow = ( _this.data('previousarrow') == '' ) ? '' : `<button type="button" class="slick-prev"><i class="` + sliderPreviousArrow + `"></i></button>` 979 classToAddSlick.slick({ 980 infinite: infinite, 981 arrows: arrow, 982 autoplay: autoplay, 983 speed: speed, 984 fade: fade,
985 autoplaySpeed: autoplaySpeed, 986 nextArrow: nextArrow, 987 prevArrow: previousArrow, 988 vertical: sliderVertical 989 }) 990 }) 991 } 992 993 // archive post handlers 994 var apSectionContainer = $('.nekit-archive-posts-wrap') 995 if( apSectionContainer.length > 0 ) { 996 var ajaxLoadMoreButton = apSectionContainer.find('.nekit-load-more') 997 var classToAppendTo = apSectionContainer.find('.posts-inner-wrap') 998 var maxNumberOfPage = apSectionContainer.data('max-num-page') 999 var noPostsFound = apSectionContainer.data('no-posts-found') 1000 var noPostsFoundDivIncluded = '<div class="no-posts-found">'+ noPostsFound +'</div>' 1001 var pagination = apSectionContainer.data('page') 1002 var maxNumPage = maxNumberOfPage 1003 ajaxLoadMoreButton.click(function() { 1004 if( maxNumberOfPage >= pagination ) { 1005 var _this = $(this) 1006 var elementorParentClass = _this.parents('.elementor-widget') 1007 var widgetId = elementorParentClass.data('id') 1008 pagination++ 1009 $.ajax({ 1010 type: 'POST', 1011 url: ajaxUrlA, 1012 data: { 1013 action: 'nekit_archive_posts_ajax_load_more', 1014 options: JSON.stringify( nekitWidgetData[widgetId] ), 1015 pagination: JSON.stringify( pagination ), 1016 maxNumPage: JSON.stringify( maxNumPage ), 1017 _wpnounce: nonceA 1018 }, 1019 beforeSend: function() { 1020 _this.parent().addClass( 'retrieving-posts' ) 1021 }, 1022 success: function( result ) { 1023 if( result == '' ) { 1024 _this.parent().remove() 1025 apSectionContainer.append( noPostsFoundDivIncluded ) 1026 } 1027 classToAppendTo.append( result ) 1028 }, 1029 complete: function() { 1030 _this.parent().removeClass( 'retrieving-posts' ) 1031 } 1032 }) 1033 } 1034 }) 1035 } 1036 1037 // mega menu width handlers 1038 var nekit_megamenu_width = $('.orientation--horizontal .nekit-megamenu-fit-to-screen'); 1039 nekit_megamenu_width.each(function() { 1040 var parent_elm = $(this).parents('.news-elementor-nav-mega-menu') 1041 $(this).css({'width' : $(window).width() +'px','left' : - parent_elm.offset().left +'px'}) 1042 }) 1043 var nekit_megamenu_section_width = $('.orientation--horizontal .nekit-megamenu-fit-to-section'); 1044 nekit_megamenu_section_width.each(function() { 1045 if( $(this).parents('.elementor-container').length > 0 ) { 1046 var elementor_container = $(this).parents('.elementor-container') 1047 } else { 1048 var parentSection = $(this).parents('.e-parent') 1049 if( parentSection.hasClass( 'e-con-boxed' ) ) { 1050 var elementor_container = parentSection.find( '.e-con-inner' ); 1051 } else { 1052 var elementor_container = parentSection; 1053 } 1054 } 1055 var parent_sec_elm = elementor_container.offset().left; 1056 var inner_parent_sec_elm = $(this).parents('.news-elementor-nav-mega-menu').offset().left; 1057 var left_val = Math.abs(parent_sec_elm - inner_parent_sec_elm); 1058 var section_width = elementor_container.width(); 1059 $(this).css({'width' : section_width +'px','left' : - left_val +'px'}) 1060 }); 1061 $(window).resize(function() { 1062 var nekit_megamenu_width = $('.orientation--horizontal .nekit-megamenu-fit-to-screen'); 1063 nekit_megamenu_width.each(function(){ 1064 var parent_elm = $(this).parents('.news-elementor-nav-mega-menu') 1065 $(this).css({'width' : $(window).width() +'px','left' : - parent_elm.offset().left +'px'}) 1066 }) 1067 1068 var nekit_megamenu_section_width = $('.orientation--horizontal .nekit-megamenu-fit-to-section'); 1069 nekit_megamenu_section_width.each(function(){ 1070 if( $(this).parents('.elementor-container').length > 0 ) { 1071 var elementor_container = $(this).parents('.elementor-container') 1072 } else { 1073 var parentSection = $(this).parents('.e-parent') 1074 if( parentSection.hasClass( 'e-con-boxed' ) ) { 1075 var elementor_container = parentSection.find( '.e-con-inner' ); 1076 } else { 1077 var elementor_container = parentSection; 1078 } 1079 } 1080 var parent_sec_elm = elementor_container.offset().left; 1081 var inner_parent_sec_elm = $(this).parents('.news-elementor-nav-mega-menu').offset().left; 1082 var left_val = Math.abs(parent_sec_elm - inner_parent_sec_elm); 1083 $(this).css({'left' : - left_val +'px'}) 1084 }); 1085 }); 1086 1087 // social share widget 1088 var socialShareContainer = $( '.nekit-social-share' ) 1089 if( socialShareContainer.length > 0 ) { 1090 socialShareContainer.each(function(){ 1091 if( $(this).hasClass( 'social-share--on' ) ) { 1092 var socialSharePrefix = $(this).find( '.social-share-prefix' ) 1093 socialSharePrefix.on( 'click', function(){ 1094 var _this = $(this) 1095 _this.siblings().toggleClass( 'isactive' ) 1096 }) 1097 } 1098 var printButton = socialShareContainer.find( '.print' ) 1099 printButton.on( 'click', function(){ 1100 printButton.find( 'a' ).removeAttr( 'href' ) 1101 window.print() 1102 }) 1103 var copyLinkButton = socialShareContainer.find( '.copy_link' ) 1104 copyLinkButton.on( 'click', function( event ) { 1105 event.preventDefault() 1106 var copyLinkButtonAnchor = copyLinkButton.find( 'a' ) 1107 var linkToCopy = copyLinkButtonAnchor.attr( 'href' ) 1108 navigator.clipboard.writeText( linkToCopy ) 1109 }) 1110 }) 1111 } 1112 1113 // canvas menu 1114 var canvasMenuContainer = $( '.news-elementor-canvas-menu' ) 1115 if( canvasMenuContainer.length > 0 ) { 1116 canvasMenuContainer.each(function() { 1117 var _this = $(this) 1118 _this.on( "click", ".canvas-content-trigger", function() { 1119 var _innerThis = $(this) 1120 _innerThis.next().toggleClass( "isShow" ) 1121 $('body').toggleClass("nekit-canvas-menu-overlay") 1122 }) 1123 scriptHandlers.onElementOutsideClick(_this.find( ".canvas-menu-content" ), function() { 1124 _this.find( ".canvas-menu-content" ).removeClass("isShow") 1125 $('body').removeClass("nekit-canvas-menu-overlay") 1126 }) 1127 }) 1128 } 1129 1130 /** 1131 * Nekit Popup Builder 1132 * MARK: Popup Builder 1133 */ 1134 const NekitPopupBuilder = { 1135 nekitPopupSelector: $( '.nekit-popup-wrapper' ), 1136 nekitTemplateIdPrefix: 'nekit-popup-post-', 1137 init: function(){ 1138 if( this.nekitPopupSelector.length > 0 ) { 1139 this.loadNekitLocalStorageVariables() 1140 this.setTimer() 1141 this.closeButton() 1142 this.closePopupOnESCPress() 1143 this.showPopup() 1144 this.closeAutomaticallyAfter() 1145 this.handleOutsideClicks() 1146 this.closeButtonDelay() 1147 } 1148 }, 1149 /* Close Button Handle */ 1150 closeButton: function(){ 1151 let self = this 1152 this.nekitPopupSelector.each(function(){ 1153 let _this = $(this), 1154 closeButton = _this.find( '.nekit-popup-close' ), 1155 settings = _this.data( 'settings' ), 1156 templateId = self.getPopupId( _this ), /* Popup Id */ 1157 _thisControlValues = self.getControlValuesById( templateId ), 1158 { nekit_show_again_delay: delay, nekit_open_popup: openPopup } = settings; 1159 1160 /* Close Button click event */ 1161 closeButton.on('click', function(){ 1162 if( delay.select !== 'none' && openPopup !== 'custom-trigger' ) { 1163 _thisControlValues[ 'nekit_show_popup_again_timestamp' ] = Date.now() + self.convertToMiliseconds( delay ) /* Determine whether to show popup again or not */ 1164 } 1165 if( delay.select === 'none' ) { 1166 _thisControlValues[ 'nekit_show_again' ] = false 1167 } 1168 localStorage.setItem( 'nekitPopupSettings', JSON.stringify({ ...self.getLocalStorageVariables(), [ templateId ]: _thisControlValues }) ) /* Update the local storage variables */ 1169 self.nekitRemoveClass( _this ) 1170 }) 1171 }) 1172 }, 1173 /* Close Popup on ESC Button Press */ 1174 closePopupOnESCPress: function(){ 1175 let self = this 1176 $(document).on( 'keydown', function( event ) { 1177 let nekitPopupcount = $( '.nekit-popup-wrapper.is-open' ).length 1178 if( nekitPopupcount > 0 && event.key === "Escape" ) { 1179 let nekitPopup = $( '.nekit-popup-wrapper.is-open' )[ nekitPopupcount - 1 ], /* Always the last one. */ 1180 settings = $( nekitPopup ).data( 'settings' ), 1181 { nekit_popup_close_on_esc: isOkToCloseOnESC, nekit_show_again_delay: delay, nekit_open_popup: openPopup } = settings; 1182 1183 if( isOkToCloseOnESC ) { 1184 let templateId = self.getPopupId( $( nekitPopup ) ), /* Popup Id */ 1185 _thisControlValues = self.getControlValuesById( templateId ) 1186 1187 if( delay.select !== 'none' && openPopup !== 'custom-trigger' ) { 1188 _thisControlValues[ 'nekit_show_popup_again_timestamp' ] = Date.now() + self.convertToMiliseconds( delay ) /* Determine whether to show popup again or not */ 1189 } 1190 if( delay.select === 'none' ) { 1191 _thisControlValues[ 'nekit_show_again' ] = false 1192 } 1193 localStorage.setItem( 'nekitPopupSettings', JSON.stringify({ ...self.getLocalStorageVariables(), [ templateId ]: _thisControlValues }) ) /* Update the local storage variables */ 1194 self.nekitRemoveClass( $( nekitPopup ) ) 1195 } 1196 } 1197 }); 1198 }, 1199 /* Close Automatically After */ 1200 closeAutomaticallyAfter: function(){ 1201 this.nekitPopupSelector.each(function(){ 1202 let _this = $(this), 1203 settings = _this.data( 'settings' ), /* Popup Settings */ 1204 { nekit_popup_enable_automatic_closing: enableAutomaticClosing, nekit_delay_close_automatically_after: secondsToCloseAfter } = settings, 1205 milisecondsToCloseAfter = secondsToCloseAfter * 1000; 1206 1207 if( enableAutomaticClosing ) { 1208 setTimeout(function(){ 1209 self.nekitRemoveClass( _this ) 1210 }, milisecondsToCloseAfter ) 1211 } 1212 }) 1213 }, 1214 /* Show popup after how many seconds */ 1215 delayPopupShow: function( popupElement, delay ){ 1216 let self = this 1217 setTimeout(function(){ 1218 self.nekitAddClass( popupElement ) 1219 }, delay ) 1220 }, 1221 /* When to Show popup */ 1222 showPopup: function(){ 1223 let self = this 1224 this.nekitPopupSelector.each(function(){ 1225 let _this = $(this), 1226 templateId = self.getPopupId( _this ), 1227 settings = _this.data( 'settings' ), 1228 templateValues = self.getControlValuesById( templateId ), /* Popup Id */ 1229 { nekit_show_again: isShowAgain, nekit_show_popup_again_timestamp: showAgainTimestamp } = templateValues, 1230 { nekit_open_popup: openPopup, nekit_delay_after_page_load: seconds, nekit_element_id: element, nekit_popup_on_scroll: showOnScroll } = settings 1231 1232 if( ( isShowAgain && Date.now() > showAgainTimestamp || openPopup === 'custom-trigger' ) ) { 1233 switch( openPopup ) { 1234 case 'page-scroll' : 1235 let { nekit_to_show_after_scroll: scroll } = settings, 1236 documentHeight = $(document).height(), 1237 calculatedScroll = documentHeight * ( scroll / 100 ), /* Getting specific height from the total document height. */ 1238 isPopupShown = false 1239 1240 $( document ).on( 'scroll', function(){ 1241 if( $(this).scrollTop() > calculatedScroll && ! isPopupShown ) { 1242 isPopupShown = true 1243 self.nekitAddClass( _this ) 1244 } 1245 }); 1246 break; 1247 case 'scroll-to-element' : 1248 /* Detect the element only once. */ 1249 let hasBeenSeen = false 1250 $( document ).on( 'scroll', function(){ 1251 if( ! hasBeenSeen ) { 1252 let inViewPort = self.isInViewport( $( element ) ) 1253 if( inViewPort ) { 1254 if( showOnScroll !== 'every' ) hasBeenSeen = true 1255 self.nekitAddClass( _this ) 1256 } 1257 } 1258 }); 1259 break; 1260 case 'custom-trigger' : 1261 $( element ).on( 'click', function(){ 1262 self.nekitAddClass( _this ) 1263 }); 1264 break; 1265 default : /* page-load */ 1266 let miliseconds = seconds * 1000 1267 self.delayPopupShow( _this, miliseconds ) 1268 break; 1269 } 1270 } 1271 }) 1272 }, 1273 /* Check if element in viewport */ 1274 isInViewport: function( element ) { 1275 let elementTop = element.offset().top; 1276 let elementBottom = elementTop + element.outerHeight(); 1277 let viewportTop = $( window ).scrollTop(); 1278 let viewportBottom = viewportTop + $( window ).height(); 1279 1280 return elementBottom > viewportTop && elementTop < viewportBottom; 1281 }, 1282 /* Load Local Storage Variables */ 1283 loadNekitLocalStorageVariables: function() { 1284 let self = this, localStorageData = {} 1285 this.nekitPopupSelector.each(function(){ 1286 let _this = $(this), 1287 settings = _this.data( 'settings' ), 1288 { nekit_show_again_delay: newDelay } = settings, 1289 templateId = self.getPopupId( _this ), /* Popup Id */ 1290 defaultTemplateData = { 1291 nekit_show_popup_again_timestamp: 0, 1292 nekit_show_again: true, 1293 nekit_show_again_delay: newDelay 1294 }, 1295 localStorageVariables = self.getLocalStorageVariables(); 1296 1297 /* Execute if local storage is not set. */ 1298 if( localStorageVariables === null ) { 1299 localStorageData = { 1300 ...localStorageData, 1301 [ templateId ]: defaultTemplateData 1302 } 1303 } else {
1304 /* Update local storage value if changed. */ 1305 if( templateId in localStorageVariables ) { 1306 let { nekit_show_again_delay: oldDelay = '' } = self.getControlValuesById( templateId ) 1307 if( newDelay.select !== oldDelay.select || newDelay.number !== oldDelay.number ) { 1308 localStorageData = { 1309 ...localStorageData, 1310 [ templateId ]: defaultTemplateData 1311 } 1312 } else { 1313 /* Don't change local storage values if not changed. */ 1314 localStorageData = { 1315 ...localStorageData, 1316 [ templateId ]: self.getControlValuesById( templateId ) 1317 } 1318 } 1319 } else { 1320 /* Add new data if template id not exists */ 1321 localStorageData = { 1322 ...localStorageData, 1323 [ templateId ]: defaultTemplateData 1324 } 1325 } 1326 } 1327 1328 }) 1329 localStorage.setItem( 'nekitPopupSettings', JSON.stringify( localStorageData ) ) 1330 }, 1331 /* Calculate to milliseconds */ 1332 convertToMiliseconds: function( delay ) { 1333 if( delay === undefined || delay === null ) return 0 1334 let { number, select } = delay 1335 switch( select ) { 1336 case 'second': 1337 return number * 1000 1338 break; 1339 case 'minute': 1340 return number * 60 * 1000 1341 break; 1342 case 'hour': 1343 return number * 60 * 60 * 1000 1344 break; 1345 case 'day': 1346 return number * 24 * 60 * 60 * 1000 1347 break; 1348 } 1349 }, 1350 /* Get local storage variables */ 1351 getLocalStorageVariables: function(){ 1352 let nekitLocalStorageVariables = localStorage.getItem( 'nekitPopupSettings' ) /* Access Local Storage */ 1353 let parsedVariables = JSON.parse( nekitLocalStorageVariables ) /* Parsing the local storage value */ 1354 return parsedVariables 1355 }, 1356 /* Get Control values by Id */ 1357 getControlValuesById: function( id ){ 1358 let nekitVariables = this.getLocalStorageVariables() 1359 return nekitVariables[ id ] 1360 }, 1361 /* Get local storage variables */ 1362 getPopupId: function( element ){ 1363 let _thisIdAttribute = element.attr( 'id' ) /* Fetch Id Attribute of Popup */ 1364 let templateId = _thisIdAttribute.split( this.nekitTemplateIdPrefix )[1] /* Split the id and get its template id */ 1365 return parseInt( templateId ) 1366 }, 1367 /* Set timer */ 1368 setTimer: function(){ 1369 let self = this 1370 setInterval(function(){ 1371 Object.entries( self.getLocalStorageVariables() ).map(([ templateId, templateValues ]) => { 1372 let templateTimestamp = templateValues[ 'nekit_show_popup_again_timestamp' ], 1373 popupIdAttribute = $( '#' + self.nekitTemplateIdPrefix + templateId ), /* Popup Element */ 1374 popupSettings = popupIdAttribute.data( 'settings' ), 1375 { nekit_show_again_delay: delay, nekit_open_popup: openPopup } = popupSettings 1376 /* Show popup again */ 1377 if( ( delay.select !== 'none' ) && ( Date.now() >= templateTimestamp ) && ( templateTimestamp !== 0 ) && ( openPopup !== 'custom-trigger' ) ) { 1378 self.nekitAddClass( popupIdAttribute ) 1379 let newLocalStorageData = { 1380 ...self.getLocalStorageVariables(), 1381 [ templateId ]: { 1382 ...self.getLocalStorageVariables()[ templateId ], 1383 nekit_show_popup_again_timestamp: 0 1384 } 1385 } 1386 localStorage.setItem( 'nekitPopupSettings', JSON.stringify( newLocalStorageData ) ) /* Update the local storage variables */ 1387 } 1388 }) 1389 }, 1000) 1390 }, 1391 /* Handle Outside click */ 1392 handleOutsideClicks: function(){ 1393 let self = this 1394 $( document ).mouseup(function ( e ) { 1395 let nekitPopupcount = $( '.nekit-popup-wrapper.is-open' ).length 1396 if( nekitPopupcount > 0 ) { 1397 let nekitPopup = $( '.nekit-popup-wrapper.is-open' )[ nekitPopupcount - 1 ], /* Always the last one. */ 1398 settings = $( nekitPopup ).data( 'settings' ), 1399 { nekit_popup_enable_closing_on_overlay_click: enableOverlayClick, nekit_show_again_delay: delay, nekit_open_popup: openPopup } = settings; 1400 1401 if( enableOverlayClick ) { 1402 if( $( e.target ).is( $( '.nekit-popup-overlay' ) ) ) { 1403 let templateId = self.getPopupId( $( nekitPopup ) ), /* Popup Id */ 1404 _thisControlValues = self.getControlValuesById( templateId ) 1405 1406 if( delay.select !== 'none' && openPopup !== 'custom-trigger' ) { 1407 _thisControlValues[ 'nekit_show_popup_again_timestamp' ] = Date.now() + self.convertToMiliseconds( delay ) /* Determine whether to show popup again or not */ 1408 } 1409 if( delay.select === 'none' ) { 1410 _thisControlValues[ 'nekit_show_again' ] = false 1411 } 1412 localStorage.setItem( 'nekitPopupSettings', JSON.stringify({ ...self.getLocalStorageVariables(), [ templateId ]: _thisControlValues }) ) /* Update the local storage variables */ 1413 self.nekitRemoveClass( $( nekitPopup ) ) 1414 } 1415 } 1416 } 1417 }) 1418 }, 1419 /* Add class */ 1420 nekitAddClass: function( element ){ 1421 element.addClass( 'is-open' ) 1422 element.parents( 'body' ).addClass( 'nekit-popup-open' ) 1423 let settings = element.data( 'settings' ), /* Popup Settings */ 1424 { nekit_display_as: displayAs, nekit_popup_disable_page_scroll: disablePageScroll } = settings 1425
1426 if( displayAs === 'top-bar' ) { 1427 element.parents( 'body' ).addClass( 'as-' + displayAs ) 1428 $( 'body' ).prepend( element ) 1429 } 1430 if( disablePageScroll && ( displayAs !== 'top-bar' ) ) element.parents( 'body' ).addClass( 'nekit-scroll--disabled' ) 1431 }, 1432 /* Remove class */ 1433 nekitRemoveClass: function( element ){ 1434 let settings = element.data( 'settings' ), /* Popup Settings */ 1435 { nekit_popup_disable_page_scroll: disablePageScroll } = settings 1436 1437 element.removeClass( 'is-open' ) 1438 if( $( '.nekit-popup-wrapper.is-open' ).length <= 0 ) { 1439 element.parents( 'body' ).removeClass( 'nekit-popup-open' ) 1440 } 1441 1442 if( disablePageScroll ) element.parents( 'body' ).removeClass( 'nekit-scroll--disabled' ) 1443 }, 1444 /* Close button Delay */ 1445 closeButtonDelay: function(){ 1446 this.nekitPopupSelector.each(function(){ 1447 let _this = $( this ), 1448 settings = _this.data( 'settings' ), /* Popup Settings */ 1449 { nekit_popup_close_button_display_delay: closeButtonDelay } = settings, 1450 miliseconds = closeButtonDelay * 1000; 1451 1452 setTimeout(function(){ 1453 _this.find( '.nekit-popup-close' ).show() 1454 }, miliseconds ) 1455 }) 1456 } 1457 } 1458 NekitPopupBuilder.init() 1459})
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.