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 setTimeout(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 = $(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', '.filter-tab-wrapper', function() { 889 var _this = $(this) 890 if( adjustLayout == 'on' ) _this.find( '.tab-title-wrap' ).toggle() 891 scriptHandlers.onElementOutsideClick( _this, function() { 892 _this.find( '.tab-title-wrap' ).hide() 893 }) 894 }) 895 } 896 $scope.on("click", ".filter-tab-wrapper .tab-title", function() { 897 var _this = $(this), dataTab = _this.data("tab") 898 if( adjustLayout == 'on' ) { 899 var activeTabTitle = _this.text() 900 _this.parents('.filter-tab-wrapper').find( '.active-tab' ).text( activeTabTitle ) 901 _this.parents('.tab-title-wrap').hide() 902 } 903 var widgetMainClass = _this.parents( ".nekit-filter-widget" ) 904 if( _this.hasClass('active-tab') ) return 905 if( _this.hasClass( 'isActive' ) ) return 906 var classToCheck = '.tab-'+dataTab 907 if( dataTab == 'news-elementor-filter-all' ) classToCheck = '.tab-all' 908 if( dataTab == 'nekit-filter-all' ) { 909 widgetMainClass.find( '.tab-all' ).show().addClass('isActive').siblings( '.news-filter-post-wrap' ).hide().removeClass('isActive') 910 _this.addClass('isActive').siblings().removeClass('isActive') 911 return 912 } 913 var widgetId = _this.parents( '.elementor-widget' ).data( 'id' ) 914 var widgetLayout = _this.parents( '.nekit-filter-widget' ).data('widgetlayout') 915 if( widgetMainClass.find( classToCheck ).length < 1 ) { 916 $.ajax({
917 type: 'POST', 918 url: ajaxUrlA, 919 data: { 920 action: 'nekit_news_filter_tab_content_change', 921 options: JSON.stringify( nekitWidgetData[ widgetId ] ), 922 category: JSON.stringify(dataTab), 923 widgetCount: JSON.stringify(widgetLayout), 924 _wpnounce: nonceA 925 }, 926 beforeSend: function() { 927 $scope.find( '.news-filter-post-wrap.isActive' ).addClass( 'retrieving-posts' ) 928 $scope.find( '.news-filter-post-wrap.isActive' ).append(loaderElm) 929 }, 930 success: function(result) { 931 widgetMainClass.append( result ) 932 }, 933 complete: function() { 934 $scope.find( '.news-filter-post-wrap.isActive' ).removeClass( 'retrieving-posts' ) 935 widgetMainClass.find( classToCheck ).show().siblings('.news-filter-post-wrap').hide().removeClass('isActive') 936 _this.addClass('isActive').siblings().removeClass('isActive') 937 $scope.find( '.nekit-loader' ).remove() 938 } 939 }) 940 } else { 941 widgetMainClass.find( classToCheck ).show().addClass('isActive').siblings('.news-filter-post-wrap').hide().removeClass('isActive') 942 _this.addClass('isActive').siblings().removeClass('isActive') 943 } 944 }) 945 }) 946 } 947 948 // handle the section custom properties 949 var stickySections = $(".nekit-section--sticky") 950 if( stickySections.length > 0 ) { 951 stickySections.each(function() { 952 var thisSection = $(this), position = thisSection.data("nekit-sticky-position"), condition = thisSection.data("nekit-sticky-condition"), sectionScrollHeight = thisSection.offset().top 953 $(window).on( "scroll", function() { 954 if( $(window).scrollTop() > sectionScrollHeight ) { 955 if( ! thisSection.hasClass( "nekit-section--sticky-active-" + position ) ) thisSection.addClass("nekit-section--sticky-active-" + position) 956 } else { 957 if( thisSection.hasClass( "nekit-section--sticky-active-" + position ) ) thisSection.removeClass("nekit-section--sticky-active-" + position) 958 } 959 }) 960 }) 961 } 962 963 // ticker news two handlers 964 var tnTwoSectionContainer = $('.nekit-ticker-news-two') 965 if( tnTwoSectionContainer.length > 0 ) { 966 tnTwoSectionContainer.each(function() { 967 var _this = $(this) 968 var classToAddSlick = _this.find('.ticker-item-wrap') 969 var arrow = _this.data('arrows') 970 var autoplay = _this.data('autoplay') 971 var autoplaySpeed = _this.data('autoplay-speed') 972 var speed = _this.data('speed') 973 var fade = _this.data('fade') 974 var infinite = _this.data('infinite') 975 var sliderNextArrow = _this.data('nextarrow') 976 var sliderPreviousArrow = _this.data('previousarrow') 977 var nextArrow = '' 978 var previousArrow = '' 979 var sliderVertical = ( fade == true ) ? false : _this.data('vertical') 980 nextArrow = ( _this.data('nextarrow') == '' ) ? '' : `<button type="button" class="slick-next"><i class="` + sliderNextArrow + `"></i></button>` 981 previousArrow = ( _this.data('previousarrow') == '' ) ? '' : `<button type="button" class="slick-prev"><i class="` + sliderPreviousArrow + `"></i></button>` 982 classToAddSlick.slick({ 983 infinite: infinite, 984 arrows: arrow, 985 autoplay: autoplay, 986 speed: speed, 987 fade: fade, 988 autoplaySpeed: autoplaySpeed, 989 nextArrow: nextArrow, 990 prevArrow: previousArrow, 991 vertical: sliderVertical 992 }) 993 }) 994 } 995 996 // archive post handlers 997 var apSectionContainer = $('.nekit-archive-posts-wrap') 998 if( apSectionContainer.length > 0 ) { 999 var ajaxLoadMoreButton = apSectionContainer.find('.nekit-load-more') 1000 var classToAppendTo = apSectionContainer.find('.posts-inner-wrap') 1001 var maxNumberOfPage = apSectionContainer.data('max-num-page') 1002 var noPostsFound = apSectionContainer.data('no-posts-found') 1003 var noPostsFoundDivIncluded = '<div class="no-posts-found">'+ noPostsFound +'</div>' 1004 var pagination = apSectionContainer.data('page') 1005 var maxNumPage = maxNumberOfPage 1006 ajaxLoadMoreButton.click(function() { 1007 if( maxNumberOfPage >= pagination ) { 1008 var _this = $(this) 1009 var elementorParentClass = _this.parents('.elementor-widget') 1010 var widgetId = elementorParentClass.data('id') 1011 pagination++ 1012 $.ajax({
1013 type: 'POST', 1014 url: ajaxUrlA, 1015 data: { 1016 action: 'nekit_archive_posts_ajax_load_more', 1017 options: JSON.stringify( nekitWidgetData[widgetId] ), 1018 pagination: JSON.stringify( pagination ), 1019 maxNumPage: JSON.stringify( maxNumPage ), 1020 _wpnounce: nonceA 1021 }, 1022 beforeSend: function() { 1023 _this.parent().addClass( 'retrieving-posts' ) 1024 }, 1025 success: function( result ) { 1026 if( result == '' ) { 1027 _this.parent().remove() 1028 apSectionContainer.append( noPostsFoundDivIncluded ) 1029 } 1030 classToAppendTo.append( result ) 1031 }, 1032 complete: function() { 1033 _this.parent().removeClass( 'retrieving-posts' ) 1034 } 1035 }) 1036 } 1037 }) 1038 } 1039 1040 // mega menu width handlers 1041 var nekit_megamenu_width = $('.orientation--horizontal .nekit-megamenu-fit-to-screen'); 1042 nekit_megamenu_width.each(function() { 1043 var parent_elm = $(this).parents('.news-elementor-nav-mega-menu') 1044 $(this).css({'width' : $(window).width() +'px','left' : - parent_elm.offset().left +'px'}) 1045 }) 1046 var nekit_megamenu_section_width = $('.orientation--horizontal .nekit-megamenu-fit-to-section'); 1047 nekit_megamenu_section_width.each(function() { 1048 if( $(this).parents('.elementor-container').length > 0 ) { 1049 var elementor_container = $(this).parents('.elementor-container') 1050 } else { 1051 var parentSection = $(this).parents('.e-parent') 1052 if( parentSection.hasClass( 'e-con-boxed' ) ) { 1053 var elementor_container = parentSection.find( '.e-con-inner' ); 1054 } else { 1055 var elementor_container = parentSection; 1056 } 1057 } 1058 var parent_sec_elm = elementor_container.offset().left; 1059 var inner_parent_sec_elm = $(this).parents('.news-elementor-nav-mega-menu').offset().left; 1060 var left_val = Math.abs(parent_sec_elm - inner_parent_sec_elm); 1061 var section_width = elementor_container.width(); 1062 $(this).css({'width' : section_width +'px','left' : - left_val +'px'}) 1063 }); 1064 $(window).resize(function() { 1065 var nekit_megamenu_width = $('.orientation--horizontal .nekit-megamenu-fit-to-screen'); 1066 nekit_megamenu_width.each(function(){ 1067 var parent_elm = $(this).parents('.news-elementor-nav-mega-menu') 1068 $(this).css({'width' : $(window).width() +'px','left' : - parent_elm.offset().left +'px'}) 1069 }) 1070 1071 var nekit_megamenu_section_width = $('.orientation--horizontal .nekit-megamenu-fit-to-section'); 1072 nekit_megamenu_section_width.each(function(){ 1073 if( $(this).parents('.elementor-container').length > 0 ) { 1074 var elementor_container = $(this).parents('.elementor-container') 1075 } else { 1076 var parentSection = $(this).parents('.e-parent') 1077 if( parentSection.hasClass( 'e-con-boxed' ) ) { 1078 var elementor_container = parentSection.find( '.e-con-inner' ); 1079 } else { 1080 var elementor_container = parentSection; 1081 } 1082 } 1083 var parent_sec_elm = elementor_container.offset().left; 1084 var inner_parent_sec_elm = $(this).parents('.news-elementor-nav-mega-menu').offset().left; 1085 var left_val = Math.abs(parent_sec_elm - inner_parent_sec_elm); 1086 $(this).css({'left' : - left_val +'px'}) 1087 }); 1088 }); 1089 1090 // social share widget 1091 var socialShareContainer = $( '.nekit-social-share' ) 1092 if( socialShareContainer.length > 0 ) { 1093 socialShareContainer.each(function(){ 1094 if( $(this).hasClass( 'social-share--on' ) ) { 1095 var socialSharePrefix = $(this).find( '.social-share-prefix' ) 1096 socialSharePrefix.on( 'click', function(){ 1097 var _this = $(this) 1098 _this.siblings().toggleClass( 'isactive' ) 1099 }) 1100 } 1101 var printButton = socialShareContainer.find( '.print' ) 1102 printButton.on( 'click', function(){ 1103 printButton.find( 'a' ).removeAttr( 'href' ) 1104 window.print() 1105 }) 1106 var copyLinkButton = socialShareContainer.find( '.copy_link' ) 1107 copyLinkButton.on( 'click', function( event ) { 1108 event.preventDefault() 1109 var copyLinkButtonAnchor = copyLinkButton.find( 'a' ) 1110 var linkToCopy = copyLinkButtonAnchor.attr( 'href' ) 1111 navigator.clipboard.writeText( linkToCopy ) 1112 }) 1113 }) 1114 } 1115 1116 // canvas menu 1117 var canvasMenuContainer = $( '.news-elementor-canvas-menu' ) 1118 if( canvasMenuContainer.length > 0 ) { 1119 canvasMenuContainer.each(function() { 1120 var _this = $(this) 1121 _this.on( "click", ".canvas-content-trigger", function() { 1122 var _innerThis = $(this) 1123 _innerThis.next().toggleClass( "isShow" ) 1124 $('body').toggleClass("nekit-canvas-menu-overlay") 1125 }) 1126 scriptHandlers.onElementOutsideClick(_this.find( ".canvas-menu-content" ), function() { 1127 _this.find( ".canvas-menu-content" ).removeClass("isShow") 1128 $('body').removeClass("nekit-canvas-menu-overlay") 1129 }) 1130 }) 1131 } 1132 1133 /** 1134 * Nekit Popup Builder 1135 * MARK: Popup Builder 1136 */ 1137 const NekitPopupBuilder = { 1138 nekitPopupSelector: $( '.nekit-popup-wrapper' ), 1139 nekitTemplateIdPrefix: 'nekit-popup-post-', 1140 init: function(){ 1141 if( this.nekitPopupSelector.length > 0 ) { 1142 this.loadNekitLocalStorageVariables() 1143 this.setTimer() 1144 this.closeButton() 1145 this.closePopupOnESCPress() 1146 this.showPopup() 1147 this.closeAutomaticallyAfter() 1148 this.handleOutsideClicks() 1149 this.closeButtonDelay() 1150 } 1151 }, 1152 /* Close Button Handle */ 1153 closeButton: function(){ 1154 let self = this 1155 this.nekitPopupSelector.each(function(){ 1156 let _this = $(this), 1157 closeButton = _this.find( '.nekit-popup-close' ), 1158 settings = _this.data( 'settings' ), 1159 templateId = self.getPopupId( _this ), /* Popup Id */ 1160 _thisControlValues = self.getControlValuesById( templateId ), 1161 { nekit_show_again_delay: delay, nekit_open_popup: openPopup } = settings; 1162 1163 /* Close Button click event */ 1164 closeButton.on('click', function(){ 1165 if( delay.select !== 'none' && openPopup !== 'custom-trigger' ) { 1166 _thisControlValues[ 'nekit_show_popup_again_timestamp' ] = Date.now() + self.convertToMiliseconds( delay ) /* Determine whether to show popup again or not */ 1167 } 1168 if( delay.select === 'none' ) { 1169 _thisControlValues[ 'nekit_show_again' ] = false 1170 } 1171 localStorage.setItem( 'nekitPopupSettings', JSON.stringify({ ...self.getLocalStorageVariables(), [ templateId ]: _thisControlValues }) ) /* Update the local storage variables */ 1172 self.nekitRemoveClass( _this ) 1173 }) 1174 }) 1175 }, 1176 /* Close Popup on ESC Button Press */ 1177 closePopupOnESCPress: function(){ 1178 let self = this 1179 $(document).on( 'keydown', function( event ) { 1180 let nekitPopupcount = $( '.nekit-popup-wrapper.is-open' ).length 1181 if( nekitPopupcount > 0 && event.key === "Escape" ) { 1182 let nekitPopup = $( '.nekit-popup-wrapper.is-open' )[ nekitPopupcount - 1 ], /* Always the last one. */ 1183 settings = $( nekitPopup ).data( 'settings' ), 1184 { nekit_popup_close_on_esc: isOkToCloseOnESC, nekit_show_again_delay: delay, nekit_open_popup: openPopup } = settings; 1185 1186 if( isOkToCloseOnESC ) { 1187 let templateId = self.getPopupId( $( nekitPopup ) ), /* Popup Id */ 1188 _thisControlValues = self.getControlValuesById( templateId ) 1189 1190 if( delay.select !== 'none' && openPopup !== 'custom-trigger' ) { 1191 _thisControlValues[ 'nekit_show_popup_again_timestamp' ] = Date.now() + self.convertToMiliseconds( delay ) /* Determine whether to show popup again or not */ 1192 } 1193 if( delay.select === 'none' ) { 1194 _thisControlValues[ 'nekit_show_again' ] = false 1195 } 1196 localStorage.setItem( 'nekitPopupSettings', JSON.stringify({ ...self.getLocalStorageVariables(), [ templateId ]: _thisControlValues }) ) /* Update the local storage variables */ 1197 self.nekitRemoveClass( $( nekitPopup ) ) 1198 } 1199 } 1200 }); 1201 }, 1202 /* Close Automatically After */ 1203 closeAutomaticallyAfter: function(){ 1204 let self = this 1205 this.nekitPopupSelector.each(function(){ 1206 let _this = $(this), 1207 settings = _this.data( 'settings' ), /* Popup Settings */ 1208 { nekit_popup_enable_automatic_closing: enableAutomaticClosing, nekit_delay_close_automatically_after: secondsToCloseAfter } = settings, 1209 milisecondsToCloseAfter = secondsToCloseAfter * 1000; 1210 1211 if( enableAutomaticClosing ) { 1212 setTimeout(function(){ 1213 self.nekitRemoveClass( _this ) 1214 }, milisecondsToCloseAfter ) 1215 } 1216 }) 1217 }, 1218 /* Show popup after how many seconds */ 1219 delayPopupShow: function( popupElement, delay ){ 1220 let self = this 1221 setTimeout(function(){ 1222 self.nekitAddClass( popupElement ) 1223 }, delay ) 1224 }, 1225 /* When to Show popup */ 1226 showPopup: function(){ 1227 let self = this 1228 this.nekitPopupSelector.each(function(){ 1229 let _this = $(this), 1230 templateId = self.getPopupId( _this ), 1231 settings = _this.data( 'settings' ), 1232 templateValues = self.getControlValuesById( templateId ), /* Popup Id */ 1233 { nekit_show_again: isShowAgain, nekit_show_popup_again_timestamp: showAgainTimestamp } = templateValues, 1234 { nekit_open_popup: openPopup, nekit_delay_after_page_load: seconds, nekit_element_id: element, nekit_popup_on_scroll: showOnScroll } = settings 1235 1236 if( ( isShowAgain && Date.now() > showAgainTimestamp || openPopup === 'custom-trigger' ) ) { 1237 switch( openPopup ) { 1238 case 'page-scroll' : 1239 let { nekit_to_show_after_scroll: scroll } = settings, 1240 documentHeight = $(document).height(), 1241 calculatedScroll = documentHeight * ( scroll / 100 ), /* Getting specific height from the total document height. */ 1242 isPopupShown = false 1243 1244 $( document ).on( 'scroll', function(){ 1245 if( $(this).scrollTop() > calculatedScroll && ! isPopupShown ) { 1246 isPopupShown = true 1247 self.nekitAddClass( _this ) 1248 } 1249 }); 1250 break; 1251 case 'scroll-to-element' : 1252 /* Detect the element only once. */ 1253 let hasBeenSeen = false 1254 $( document ).on( 'scroll', function(){ 1255 if( ! hasBeenSeen ) { 1256 let inViewPort = self.isInViewport( $( element ) ) 1257 if( inViewPort ) { 1258 if( showOnScroll !== 'every' ) hasBeenSeen = true 1259 self.nekitAddClass( _this ) 1260 } 1261 } 1262 }); 1263 break; 1264 case 'custom-trigger' : 1265 $( element ).on( 'click', function(){ 1266 self.nekitAddClass( _this ) 1267 }); 1268 break; 1269 default : /* page-load */ 1270 let miliseconds = seconds * 1000 1271 self.delayPopupShow( _this, miliseconds ) 1272 break; 1273 } 1274 } 1275 }) 1276 }, 1277 /* Check if element in viewport */ 1278 isInViewport: function( element ) { 1279 let elementTop = element.offset().top; 1280 let elementBottom = elementTop + element.outerHeight(); 1281 let viewportTop = $( window ).scrollTop(); 1282 let viewportBottom = viewportTop + $( window ).height(); 1283 1284 return elementBottom > viewportTop && elementTop < viewportBottom; 1285 }, 1286 /* Load Local Storage Variables */ 1287 loadNekitLocalStorageVariables: function() { 1288 let self = this, localStorageData = {} 1289 this.nekitPopupSelector.each(function(){ 1290 let _this = $(this), 1291 settings = _this.data( 'settings' ), 1292 { nekit_show_again_delay: newDelay } = settings, 1293 templateId = self.getPopupId( _this ), /* Popup Id */ 1294 defaultTemplateData = { 1295 nekit_show_popup_again_timestamp: 0, 1296 nekit_show_again: true, 1297 nekit_show_again_delay: newDelay 1298 }, 1299 localStorageVariables = self.getLocalStorageVariables(); 1300 1301 /* Execute if local storage is not set. */ 1302 if( localStorageVariables === null ) { 1303 localStorageData = { 1304 ...localStorageData, 1305 [ templateId ]: defaultTemplateData 1306 } 1307 } else {
1308 /* Update local storage value if changed. */ 1309 if( templateId in localStorageVariables ) { 1310 let { nekit_show_again_delay: oldDelay = '' } = self.getControlValuesById( templateId ) 1311 if( newDelay.select !== oldDelay.select || newDelay.number !== oldDelay.number ) { 1312 localStorageData = { 1313 ...localStorageData, 1314 [ templateId ]: defaultTemplateData 1315 } 1316 } else { 1317 /* Don't change local storage values if not changed. */ 1318 localStorageData = { 1319 ...localStorageData, 1320 [ templateId ]: self.getControlValuesById( templateId ) 1321 } 1322 } 1323 } else { 1324 /* Add new data if template id not exists */ 1325 localStorageData = { 1326 ...localStorageData, 1327 [ templateId ]: defaultTemplateData 1328 } 1329 } 1330 } 1331 1332 }) 1333 localStorage.setItem( 'nekitPopupSettings', JSON.stringify( localStorageData ) ) 1334 }, 1335 /* Calculate to milliseconds */ 1336 convertToMiliseconds: function( delay ) { 1337 if( delay === undefined || delay === null ) return 0 1338 let { number, select } = delay 1339 switch( select ) { 1340 case 'second': 1341 return number * 1000 1342 break; 1343 case 'minute': 1344 return number * 60 * 1000 1345 break; 1346 case 'hour': 1347 return number * 60 * 60 * 1000 1348 break; 1349 case 'day': 1350 return number * 24 * 60 * 60 * 1000 1351 break; 1352 } 1353 }, 1354 /* Get local storage variables */ 1355 getLocalStorageVariables: function(){ 1356 let nekitLocalStorageVariables = localStorage.getItem( 'nekitPopupSettings' ) /* Access Local Storage */ 1357 let parsedVariables = JSON.parse( nekitLocalStorageVariables ) /* Parsing the local storage value */ 1358 return parsedVariables 1359 }, 1360 /* Get Control values by Id */ 1361 getControlValuesById: function( id ){ 1362 let nekitVariables = this.getLocalStorageVariables() 1363 return nekitVariables[ id ] 1364 }, 1365 /* Get local storage variables */ 1366 getPopupId: function( element ){ 1367 let _thisIdAttribute = element.attr( 'id' ) /* Fetch Id Attribute of Popup */ 1368 let templateId = _thisIdAttribute.split( this.nekitTemplateIdPrefix )[1] /* Split the id and get its template id */ 1369 return parseInt( templateId ) 1370 }, 1371 /* Set timer */ 1372 setTimer: function(){ 1373 let self = this 1374 setTimeout(function(){ 1375 Object.entries( self.getLocalStorageVariables() ).map(([ templateId, templateValues ]) => { 1376 let templateTimestamp = templateValues[ 'nekit_show_popup_again_timestamp' ], 1377 popupIdAttribute = $( '#' + self.nekitTemplateIdPrefix + templateId ), /* Popup Element */ 1378 popupSettings = popupIdAttribute.data( 'settings' ), 1379 { nekit_show_again_delay: delay, nekit_open_popup: openPopup } = popupSettings 1380 /* Show popup again */ 1381 if( ( delay.select !== 'none' ) && ( Date.now() >= templateTimestamp ) && ( templateTimestamp !== 0 ) && ( openPopup !== 'custom-trigger' ) ) { 1382 self.nekitAddClass( popupIdAttribute ) 1383 let newLocalStorageData = { 1384 ...self.getLocalStorageVariables(), 1385 [ templateId ]: { 1386 ...self.getLocalStorageVariables()[ templateId ], 1387 nekit_show_popup_again_timestamp: 0 1388 } 1389 } 1390 localStorage.setItem( 'nekitPopupSettings', JSON.stringify( newLocalStorageData ) ) /* Update the local storage variables */ 1391 } 1392 }) 1393 }, 1000) 1394 }, 1395 /* Handle Outside click */ 1396 handleOutsideClicks: function(){ 1397 let self = this 1398 $( document ).mouseup(function ( e ) { 1399 let nekitPopupcount = $( '.nekit-popup-wrapper.is-open' ).length 1400 if( nekitPopupcount > 0 ) { 1401 let nekitPopup = $( '.nekit-popup-wrapper.is-open' )[ nekitPopupcount - 1 ], /* Always the last one. */ 1402 settings = $( nekitPopup ).data( 'settings' ), 1403 { nekit_popup_enable_closing_on_overlay_click: enableOverlayClick, nekit_show_again_delay: delay, nekit_open_popup: openPopup } = settings; 1404 1405 if( enableOverlayClick ) { 1406 if( $( e.target ).is( $( '.nekit-popup-overlay' ) ) ) { 1407 let templateId = self.getPopupId( $( nekitPopup ) ), /* Popup Id */ 1408 _thisControlValues = self.getControlValuesById( templateId ) 1409 1410 if( delay.select !== 'none' && openPopup !== 'custom-trigger' ) { 1411 _thisControlValues[ 'nekit_show_popup_again_timestamp' ] = Date.now() + self.convertToMiliseconds( delay ) /* Determine whether to show popup again or not */ 1412 } 1413 if( delay.select === 'none' ) { 1414 _thisControlValues[ 'nekit_show_again' ] = false 1415 } 1416 localStorage.setItem( 'nekitPopupSettings', JSON.stringify({ ...self.getLocalStorageVariables(), [ templateId ]: _thisControlValues }) ) /* Update the local storage variables */ 1417 self.nekitRemoveClass( $( nekitPopup ) ) 1418 } 1419 } 1420 } 1421 }) 1422 }, 1423 /* Add class */ 1424 nekitAddClass: function( element ){ 1425 element.addClass( 'is-open' ) 1426 element.parents( 'body' ).addClass( 'nekit-popup-open' ) 1427 let settings = element.data( 'settings' ), /* Popup Settings */ 1428 { nekit_display_as: displayAs, nekit_popup_disable_page_scroll: disablePageScroll } = settings 1429
1430 if( displayAs === 'top-bar' ) { 1431 element.parents( 'body' ).addClass( 'as-' + displayAs ) 1432 $( 'body' ).prepend( element ) 1433 } 1434 if( disablePageScroll && ( displayAs !== 'top-bar' ) ) element.parents( 'body' ).addClass( 'nekit-scroll--disabled' ) 1435 }, 1436 /* Remove class */ 1437 nekitRemoveClass: function( element ){ 1438 let settings = element.data( 'settings' ), /* Popup Settings */ 1439 { nekit_popup_disable_page_scroll: disablePageScroll } = settings 1440 1441 element.removeClass( 'is-open' ) 1442 if( $( '.nekit-popup-wrapper.is-open' ).length <= 0 ) { 1443 element.parents( 'body' ).removeClass( 'nekit-popup-open' ) 1444 } 1445 1446 if( disablePageScroll ) element.parents( 'body' ).removeClass( 'nekit-scroll--disabled' ) 1447 }, 1448 /* Close button Delay */ 1449 closeButtonDelay: function(){ 1450 this.nekitPopupSelector.each(function(){ 1451 let _this = $( this ), 1452 settings = _this.data( 'settings' ), /* Popup Settings */ 1453 { nekit_popup_close_button_display_delay: closeButtonDelay } = settings, 1454 miliseconds = closeButtonDelay * 1000; 1455 1456 setTimeout(function(){ 1457 _this.find( '.nekit-popup-close' ).show() 1458 }, miliseconds ) 1459 }) 1460 } 1461 } 1462 NekitPopupBuilder.init() 1463 1464 /* Sticky Post Handle */ 1465 let stickyPostContainer = $( '.nekit-sticky-posts' ) 1466 if( stickyPostContainer.length > 0 ) { 1467 stickyPostContainer.on( 'click', '.indicator.active', function(){ 1468 let _this = $( this ), 1469 hiddenPosts = _this.parent().siblings( '.post.hide' ), 1470 postsToShow = _this.parent().siblings( '.post.show' ); 1471 1472 _this.removeClass( 'active' ).siblings().addClass( 'active' ) 1473 hiddenPosts.removeClass( 'hide' ).addClass( 'show' ) 1474 postsToShow.removeClass( 'show' ).addClass( 'hide' ) 1475 }) 1476 1477 /* Adding z-index */ 1478 let initialZindex = stickyPostContainer.find( '.post' ).length 1479 stickyPostContainer.find( '.post' ).each(function(){ 1480 let _this = $( this ) 1481 _this.css({ 1482 'z-index': initialZindex-- 1483 }) 1484 }) 1485 } 1486 1487 /* Nekit Stories */ 1488 const NekitStories = { 1489 container: null, 1490 containerIndex: null, 1491 storyModalContainer: null, 1492 mainSwiperInstance: null, 1493 allInnerSwipers: {}, 1494 nextSlideTimeout: null, 1495 modalCloseTimeout: null, 1496 widgetId: null, 1497 widgetSettings: null, 1498 init: function(){ 1499 this.openModal() 1500 }, 1501 /* Open Story Modal */ 1502 openModal: function(){ 1503 let self = this 1504 $( '.nekit-stories .stories' ).on( 'click', '.story:not(".no-gallery")', function(){ 1505 let _this = $( this ), 1506 _thisIndex = _this.parent().children( '.story:not(".no-gallery")' ).index( _this ); 1507 self.container = _this.parents( '.nekit-stories' ) 1508 self.storyModalContainer = self.container.find( '.stories-modal' ) 1509 self.widgetId = self.container.parents( '.elementor-widget[data-element_type="widget"]' ).data( "id" ) 1510 self.widgetSettings = nekitWidgetData[ self.widgetId ] 1511 1512 console.log( _thisIndex ) 1513 self.storyModalContainer.addClass( 'show' ) 1514 self.mainSwiper(); 1515 self.initializeInnerSwiper( _thisIndex ); 1516 self.mainSwiperInstance.slideTo( _thisIndex, 0, false ); 1517 $( 'body' ).addClass( 'story-modal--on' ) 1518 self.pauseStoryModal() 1519 self.handleCrossButton() 1520 }) 1521 }, 1522 /* Handle cross button click in story modal */ 1523 handleCrossButton: function(){ 1524 let self = this 1525 this.storyModalContainer.on( 'click', '.close-modal', function(){ 1526 self.closeModal() 1527 }) 1528 }, 1529 /* Close Story Modal */ 1530 closeModal: function(){ 1531 this.storyModalContainer.removeClass( 'show' ) 1532 Object.values( this.allInnerSwipers ).forEach( swiper => swiper.destroy( true, true ) ) 1533 this.allInnerSwipers = {} 1534 this.mainSwiperInstance.destroy( true, true ) 1535 this.storyModalContainer.find( '.pause-story' ).removeClass( 'paused' ).addClass( 'playing' ) 1536 clearTimeout( this.nextSlideTimeout ); 1537 clearTimeout( this.modalCloseTimeout ); 1538 $( 'body' ).removeClass( 'story-modal--on' ) 1539 }, 1540 /* Pause Story Modal */ 1541 pauseStoryModal: function(){ 1542 let self = this, 1543 playIcon = this.widgetSettings[ 'play_icon' ], 1544 pauseIcon = this.widgetSettings[ 'pause_icon' ]; 1545 this.storyModalContainer.on( 'click', '.pause-story', function(){ 1546 let _this = $( this ), 1547 index = _this.parents( '.swiper-slide' ).index(); 1548 1549 _this.toggleClass( 'playing paused' ) 1550 if( _this.hasClass( 'paused' ) ) { 1551 _this.find( 'i' ).removeClass().addClass( playIcon.value ) 1552 self.allInnerSwipers[ index ].autoplay.pause() 1553 } else { 1554 _this.find( 'i' ).removeClass().addClass( pauseIcon.value ) 1555 self.allInnerSwipers[ index ].autoplay.resume() 1556 } 1557 }) 1558 }, 1559 /* Initialize Swiper JS in .main-swiper */ 1560 mainSwiper: function(){ 1561 let self = this, 1562 { effect, speed } = this.widgetSettings[ 'main_swiper_settings' ]; 1563 this.mainSwiperInstance = new Swiper( this.container.find( ".main-swiper" )[0], { 1564 effect, 1565 speed, 1566 grabCursor: false, 1567 loop: false, 1568 allowTouchMove: true, 1569 cubeEffect: { 1570 shadow: false, 1571 slideShadows: false 1572 }, 1573 navigation: { 1574 nextEl: this.container.find( ".swiper-arrow.next" )[ 0 ], 1575 prevEl: this.container.find( ".swiper-arrow.prev" )[ 0 ] 1576 }, 1577 on: { 1578 slideChange: function( swiper ) { 1579 let { activeIndex, params } = swiper 1580 clearTimeout( self.nextSlideTimeout ); 1581 self.initializeInnerSwiper( activeIndex ); 1582 setTimeout(() => { 1583 self.destroyInnerSwipersExceptActive( activeIndex ); 1584 }, 500); 1585 } 1586 } 1587 }); 1588 }, 1589 /* Initialize Swiper JS in .inner-swiper */ 1590 initializeInnerSwiper: function( innerSwiperIndex ){ 1591 if( this.allInnerSwipers[ innerSwiperIndex ] ) return /* Prevent re-initialization */ 1592 let self = this, 1593 innerSwiper = null, 1594 { effect, speed, direction, autoplay_speed: auto
1594playSpeed } = this.widgetSettings[ 'inner_swiper_settings' ]; 1595 1596 innerSwiper = new Swiper( this.storyModalContainer.find( '.inner-swiper' )[ innerSwiperIndex ], { 1597 direction, 1598 speed, 1599 effect, 1600 loop: false, 1601 allowTouchMove: false, 1602 autoplay: { 1603 delay: autoplaySpeed, 1604 disableOnInteraction: false, 1605 pauseOnMouseEnter: false 1606 }, 1607 pagination: { 1608 el: ".inner-swiper .swiper-pagination", 1609 clickable: true, 1610 renderBullet: function(index, className) { 1611 return `<span class="${ className }"><span class="progress-bar"></span></span>`; 1612 } 1613 }, 1614 navigation: { 1615 nextEl: ".inner-swiper-arrow.next", 1616 prevEl: ".inner-swiper-arrow.prev" 1617 }, 1618 on: { 1619 init: function( swiper ) { 1620 self.disableNavigationButtons( swiper ); 1621 self.addAmbient( swiper ) 1622 }, 1623 autoplayTimeLeft: self.storyProgress, 1624 reachEnd: function( swiper ) { 1625 if ( self.mainSwiperInstance.activeIndex === self.mainSwiperInstance.slides.length - 1 ) { 1626 /* Close Story modal if last story is showing */ 1627 self.modalCloseTimeout = setTimeout(() => { 1628 if( swiper.autoplay ) swiper.autoplay.stop(); 1629 self.closeModal(); 1630 }, 2300 ); 1631 } else { 1632 /* Show next story */ 1633 self.nextSlideTimeout = setTimeout(() => { 1634 self.mainSwiperInstance.slideNext(); 1635 }, 2300 ); 1636 } 1637 }, 1638 slideChange: function( swiper ){ 1639 let { activeIndex, slides } = swiper 1640 self.disableNavigationButtons( swiper ) 1641 if( self.modalCloseTimeout !== null && ( activeIndex !== slides.length - 1 ) ) { 1642 clearTimeout( self.modalCloseTimeout ) 1643 } 1644 if( activeIndex !== slides.length - 1 ) { 1645 clearTimeout( self.nextSlideTimeout ) 1646 } 1647 if( activeIndex !== 0 ) self.addAmbient( swiper ) 1648 } 1649 } 1650 }); 1651 this.allInnerSwipers[ innerSwiperIndex ] = innerSwiper 1652 }, 1653 /* Disable .main-swiper navigation buttons */ 1654 disableNavigationButtons: function( swiperInstance ){ 1655 let { activeIndex, slides } = swiperInstance 1656 // if last slide 1657 if( activeIndex - slides.length - 1 ) { 1658 this.storyModalContainer.find( '.main-swiper .swiper-arrow.next' ).removeClass( 'disabled' ) 1659 } else { 1660 this.storyModalContainer.find( '.main-swiper .swiper-arrow.next' ).addClass( 'disabled' ) 1661 } 1662 1663 // if first slide 1664 if( activeIndex === 0 ) { 1665 this.storyModalContainer.find( '.main-swiper .swiper-arrow.prev' ).removeClass( 'disabled' ) 1666 } else { 1667 this.storyModalContainer.find( '.main-swiper .swiper-arrow.prev' ).addClass( 'disabled' ) 1668 } 1669 }, 1670 /* Destroy all instances of .inner-swiper except active one */ 1671 destroyInnerSwipersExceptActive: function( activeIndex ){ 1672 let self = this 1673 Object.keys( this.allInnerSwipers ).forEach(( index ) => { 1674 let parsedIndex = parseInt( index ) 1675 if( activeIndex !== parsedIndex ) { 1676 self.allInnerSwipers[ parsedIndex ].destroy( true, true ) 1677 delete self.allInnerSwipers[ parsedIndex ]; 1678 } 1679 }) 1680 }, 1681 /* Story Progress */ 1682 storyProgress: function( swiper, time, progress ){ 1683 let { pagination } = swiper, 1684 activeBullet = $( pagination.el ).find( '.swiper-pagination-bullet-active' ); 1685 let widthPercent = Math.floor( ( 1 - progress ) * 100 ) 1686 activeBullet.find( '.progress-bar' ).css({ 1687 width: widthPercent + '%' 1688 }) 1689 activeBullet.prevAll( '.swiper-pagination-bullet' ).find( '.progress-bar' ).css({ 1690 'width': '100%' 1691 }) 1692 activeBullet.nextAll( '.swiper-pagination-bullet' ).find( '.progress-bar' ).css({ 1693 'width': '0%' 1694 }) 1695 }, 1696 /* Add ambient */ 1697 addAmbient: function( swiper ) { 1698 let { activeIndex, slides } = swiper, 1699 currentSlide = $( slides[ activeIndex ] ), 1700 storyImage = currentSlide.find( '.story-image' ).attr( 'src' ); 1701 1702 this.container.find( '.ambient-wrapper' ).css({ 1703 'background-image': 'url('+ storyImage +')' 1704 }) 1705 } 1706 } 1707 1708 NekitStories.init() 1709})
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.