"use strict";
var _eventMore = false;
var _nasa_clear_mess_error;
/* Functions base */
function after_load_ajax_list($, destroy_masonry) {
var _destroy_masonry = typeof destroy_masonry !== 'undefined' ? destroy_masonry : false;
/**
* Trigger after load ajax - first event
*/
$('body').trigger('nasa_after_load_ajax_first', [_destroy_masonry]);
/**
* Init Top Categories
*/
$('body').trigger('nasa_init_topbar_categories');
/**
* Init widgets
*/
init_widgets($);
/*
* Parallax Breadcrumb
*/
if (!_eventMore) {
$('body').trigger('nasa_parallax_breadcrum');
}
/**
* init wishlist icons
*/
init_wishlist_icons($);
/**
* init Compare icons
*/
init_compare_icons($);
_eventMore = false;
$('body').trigger('nasa_after_load_ajax');
}
/**
* Tabs slide
*
* @param {type} $
* @param {type} _this
* @param {type} exttime
* @returns {undefined}
*/
function nasa_tab_slide_style($, _this, exttime) {
exttime = !exttime ? 500 : exttime;
if ($(_this).find('.nasa-slide-tab').length <= 0) {
$(_this).append('
');
}
var _tab = $(_this).find('.nasa-slide-tab');
var _act = $(_this).find('.nasa-tab.active');
if ($(_this).find('.nasa-tab-icon').length) {
$(_this).find('.nasa-tab > a').css({'padding': '15px 30px'});
}
var _width_border = parseInt($(_this).css("border-top-width"));
_width_border = !_width_border ? 0 : _width_border;
var _pos = $(_act).position();
$(_tab).show().animate({
'height': $(_act).height() + (2*_width_border),
'width': $(_act).width() + (2*_width_border),
'top': _pos.top - _width_border,
'left': _pos.left - _width_border
}, exttime);
}
/**
* Load Compare
*
* @param {type} $
* @returns {undefined}
*/
var _compare_init = false;
var _compare_loading = false;
function load_compare($) {
if ($('#tmpl-nasa-mini-compare').length) {
var _compare = $('#tmpl-nasa-mini-compare').html();
$('#tmpl-nasa-mini-compare').replaceWith(_compare);
}
if ($('.nasa-compare-list-bottom').length && !_compare_init) {
_compare_init = true;
_compare_loading = true;
if (
typeof nasa_ajax_params !== 'undefined' &&
typeof nasa_ajax_params.wc_ajax_url !== 'undefined'
) {
var _urlAjax = nasa_ajax_params.wc_ajax_url.toString().replace('%%endpoint%%', 'nasa_load_compare');
var _compare_table = $('.nasa-wrap-table-compare').length ? true : false;
$.ajax({
url: _urlAjax,
type: 'post',
dataType: 'json',
cache: false,
data: {
compare_table: _compare_table
},
beforeSend: function () {
/* if ($('.nasa-compare-list-bottom').find('.nasa-loader').length <= 0) {
$('.nasa-compare-list-bottom').append('');
} */
},
success: function (res) {
if (typeof res.success !== 'undefined' && res.success === '1') {
$('.nasa-compare-list-bottom').html(res.content);
}
// $('.nasa-compare-list-bottom').find('.nasa-loader').remove();
_compare_loading = false;
},
error: function () {
_compare_loading = false;
}
});
}
}
}
/**
* Add Compare
*
* @param {type} _id
* @param {type} $
* @returns {undefined}
*/
function add_compare_product(_id, $) {
if (
typeof nasa_ajax_params !== 'undefined' &&
typeof nasa_ajax_params.wc_ajax_url !== 'undefined'
) {
if ($('#tmpl-nasa-mini-compare').length) {
var _compare = $('#tmpl-nasa-mini-compare').html();
$('#tmpl-nasa-mini-compare').replaceWith(_compare);
}
_compare_init = true;
var _urlAjax = nasa_ajax_params.wc_ajax_url.toString().replace('%%endpoint%%', 'nasa_add_compare_product');
var _compare_table = $('.nasa-wrap-table-compare').length ? true : false;
if (_compare_loading) {
setTimeout(function() {
add_compare_product(_id, $);
}, 200);
} else {
$.ajax({
url: _urlAjax,
type: 'post',
dataType: 'json',
cache: false,
data: {
pid: _id,
compare_table: _compare_table
},
beforeSend: function () {
// load_compare($);
show_compare($);
if ($('.nasa-compare-list-bottom').find('.nasa-loader').length <= 0) {
$('.nasa-compare-list-bottom').append('');
}
},
success: function (res) {
if (typeof res.result_compare !== 'undefined' && res.result_compare === 'success') {
if (res.mini_compare !== 'no-change') {
if ($('.nasa-compare-list').length) {
$('.nasa-compare-list').replaceWith(res.mini_compare);
}
if ($('.nasa-mini-number.compare-number').length) {
$('.nasa-mini-number.compare-number').html(convert_count_items($, res.count_compare));
if (res.count_compare === 0) {
if (!$('.nasa-mini-number.compare-number').hasClass('nasa-product-empty')) {
$('.nasa-mini-number.compare-number').addClass('nasa-product-empty');
}
} else {
if ($('.nasa-mini-number.compare-number').hasClass('nasa-product-empty')) {
$('.nasa-mini-number.compare-number').removeClass('nasa-product-empty');
}
}
}
if (_compare_table) {
$('.nasa-wrap-table-compare').replaceWith(res.result_table);
}
}
if (!$('.nasa-compare[data-prod="' + _id + '"]').hasClass('added')) {
$('.nasa-compare[data-prod="' + _id + '"]').addClass('added');
}
if (!$('.nasa-compare[data-prod="' + _id + '"]').hasClass('nasa-added')) {
$('.nasa-compare[data-prod="' + _id + '"]').addClass('nasa-added');
$('.nasa-compare[data-prod="' + _id + '"]').find(".nasa-icon-text-wrap").animate({ scrollTop: 24 }, 400 );
}
$('body').trigger('nasa_added_compare_product');
}
$('.nasa-compare-list-bottom').find('.nasa-loader').remove();
},
error: function () {
}
});
}
}
}
/**
* Remove Compare
*
* @param {type} _id
* @param {type} $
* @returns {undefined}
*/
function remove_compare_product(_id, $) {
if (
typeof nasa_ajax_params !== 'undefined' &&
typeof nasa_ajax_params.wc_ajax_url !== 'undefined'
) {
if ($('#tmpl-nasa-mini-compare').length) {
var _compare = $('#tmpl-nasa-mini-compare').html();
$('#tmpl-nasa-mini-compare').replaceWith(_compare);
}
_compare_init = true;
var _urlAjax = nasa_ajax_params.wc_ajax_url.toString().replace('%%endpoint%%', 'nasa_remove_compare_product');
var _compare_table = $('.nasa-wrap-table-compare').length ? true : false;
$.ajax({
url: _urlAjax,
type: 'post',
dataType: 'json',
cache: false,
data: {
pid: _id,
compare_table: _compare_table
},
beforeSend: function () {
if ($('.nasa-compare-list-bottom').find('.nasa-loader').length <= 0) {
$('.nasa-compare-list-bottom').append('');
}
if ($('table.nasa-table-compare tr.remove-item td.nasa-compare-view-product_' + _id).length) {
$('table.nasa-table-compare').css('opacity', '0.3').prepend('');
}
},
success: function (res) {
if (typeof res.result_compare !== 'undefined' && res.result_compare === 'success') {
if (res.mini_compare !== 'no-change') {
if ($('.nasa-compare-list').length) {
$('.nasa-compare-list').replaceWith(res.mini_compare);
}
$('.nasa-compare[data-prod="' + _id + '"]').removeClass('added');
$('.nasa-compare[data-prod="' + _id + '"]').removeClass('nasa-added');
$('.nasa-compare[data-prod="' + _id + '"]').find(".nasa-icon-text-wrap").animate({ scrollTop: 0 }, 400 );
if ($('.nasa-mini-number.compare-number').length) {
$('.nasa-mini-number.compare-number').html(convert_count_items($, res.count_compare));
if (res.count_compare === 0) {
if (!$('.nasa-mini-number.compare-number').hasClass('nasa-product-empty')) {
$('.nasa-mini-number.compare-number').addClass('nasa-product-empty');
}
} else {
if ($('.nasa-mini-number.compare-number').hasClass('nasa-product-empty')) {
$('.nasa-mini-number.compare-number').removeClass('nasa-product-empty');
}
}
}
if (_compare_table) {
$('.nasa-wrap-table-compare').replaceWith(res.result_table);
}
}
$('body').trigger('nasa_removed_compare_product');
setTimeout(function () {
if (res.count_compare === 0) {
$('.nasa-close-mini-compare').trigger('click');
}
}, 2000);
}
$('table.nasa-table-compare').find('.nasa-loader').remove();
$('.nasa-compare-list-bottom').find('.nasa-loader').remove();
},
error: function() {
}
});
}
}
/**
* Remove All Compare
*
* @param {type} $
* @returns {undefined}
*/
function remove_all_compare_product($) {
if (
typeof nasa_ajax_params !== 'undefined' &&
typeof nasa_ajax_params.wc_ajax_url !== 'undefined'
) {
if ($('#tmpl-nasa-mini-compare').length) {
var _compare = $('#tmpl-nasa-mini-compare').html();
$('#tmpl-nasa-mini-compare').replaceWith(_compare);
}
_compare_init = true;
var _urlAjax = nasa_ajax_params.wc_ajax_url.toString().replace('%%endpoint%%', 'nasa_remove_all_compare');
var _compare_table = $('.nasa-wrap-table-compare').length ? true : false;
$.ajax({
url: _urlAjax,
type: 'post',
dataType: 'json',
cache: false,
data: {
compare_table: _compare_table
},
beforeSend: function () {
if ($('.nasa-compare-list-bottom').find('.nasa-loader').length <= 0) {
$('.nasa-compare-list-bottom').append('');
}
},
success: function (res) {
if (res.result_compare === 'success') {
if (res.mini_compare !== 'no-change') {
if ($('.nasa-compare-list').length) {
$('.nasa-compare-list').replaceWith(res.mini_compare);
}
$('.nasa-compare.ns-has-wrap.nasa-added').find(".nasa-icon-text-wrap").animate({ scrollTop: 0 }, 400 );
$('.nasa-compare').removeClass('added');
$('.nasa-compare').removeClass('nasa-added');
if ($('.nasa-mini-number.compare-number').length) {
$('.nasa-mini-number.compare-number').html('0');
if (!$('.nasa-mini-number.compare-number').hasClass('nasa-product-empty')) {
$('.nasa-mini-number.compare-number').addClass('nasa-product-empty');
}
}
if (_compare_table) {
$('.nasa-wrap-table-compare').replaceWith(res.result_table);
}
}
$('body').trigger('nasa_removed_all_compare_product');
setTimeout(function () {
$('.nasa-compare-success').fadeOut(200);
$('.nasa-compare-exists').fadeOut(200);
$('.nasa-close-mini-compare').trigger('click');
}, 1000);
}
$('.nasa-compare-list-bottom').find('.nasa-loader').remove();
},
error: function() {
}
});
}
}
/**
* Show compare
*
* @param {type} $
* @returns {undefined}
*/
function show_compare($) {
/**
* Append stylesheet Off Canvas
*/
$('body').trigger('nasa_append_style_off_canvas');
if ($('.nasa-compare-list-bottom').length) {
if($('.ns-cart-popup-wrap').length && $('.ns-cart-popup-wrap').hasClass('nasa-active')) {
$('.ns-cart-popup-wrap .popup-cart-close').trigger('click');
}
$('.black-window').fadeIn(200).addClass('desk-window');
if (!$('body').hasClass('m-ovhd')) {
$('body').addClass('m-ovhd');
}
if ($('.nasa-show-compare').length && !$('.nasa-show-compare').hasClass('nasa-showed')) {
$('.nasa-show-compare').addClass('nasa-showed');
}
if (!$('.nasa-compare-list-bottom').hasClass('nasa-active')) {
$('.nasa-compare-list-bottom').addClass('nasa-active');
}
}
}
/**
* Hide compare
*
* @param {type} $
* @returns {undefined}
*/
function hide_compare($) {
if ($('.nasa-compare-list-bottom').length && $('.nasa-compare-list-bottom').hasClass('nasa-active')) {
$('.black-window').removeClass('desk-window');
$('.black-window').fadeOut(500);
$('body').removeClass('m-ovhd');
if ($('.nasa-show-compare').length && $('.nasa-show-compare').hasClass('nasa-showed')) {
$('.nasa-show-compare').removeClass('nasa-showed');
}
$('.nasa-compare-list-bottom').removeClass('nasa-active');
}
}
/**
* Single add to cart
*
* @param {type} $
* @param {type} _this
* @param {type} _id
* @param {type} _quantity
* @param {type} _type
* @param {type} _variation_id
* @param {type} _variation
* @param {type} _data_wishlist
* @returns {undefined|Boolean}
*/
function nasa_single_add_to_cart($, _this, _id, _quantity, _type, _variation_id, _variation, _data_wishlist) {
var _form = $(_this).parents('form.cart');
var _from_mini_cart = false;
if (_type === 'grouped') {
if ($(_form).length) {
if ($(_form).find('.nasa-custom-fields input[name="nasa_cart_sidebar"]').length) {
$(_form).find('.nasa-custom-fields input[name="nasa_cart_sidebar"]').val('1');
} else {
$(_form).find('.nasa-custom-fields').append('');
}
$(_form).submit();
}
return;
}
else {
if (
typeof nasa_ajax_params !== 'undefined' &&
typeof nasa_ajax_params.wc_ajax_url !== 'undefined'
) {
var _urlAjax = nasa_ajax_params.wc_ajax_url.toString().replace('%%endpoint%%', 'nasa_single_add_to_cart');
var _data_cart_item_key = null;
var _data = {
product_id: _id,
quantity: _quantity,
product_type: _type,
variation_id: _variation_id,
variation: _variation,
data_wislist: _data_wishlist
};
if ($(_this).hasClass('btn-add-from-minicart')) {
_from_mini_cart = true;
_data_cart_item_key = $(_this).attr('data-cart_item_key');
if ($(_this).parents('#cart-sidebar').length) {
var _pa = $(_this).parents('#cart-sidebar');
var _remove_btn = $(_pa).find('.nasa-minicart-items .remove_from_cart_button[data-cart_item_key="'+_data_cart_item_key+'"]');
$(_pa).addClass('nasa_update_from_mini_cart');
$(_remove_btn).parents('.mini-cart-item').remove();
}
}
$('body').trigger('adding_to_cart', [_this,_data]);
if ($(_form).length) {
if (_type === 'simple') {
$(_form).find('.nasa-custom-fields').append('');
}
_data = $(_form).serializeArray();
$(_form).find('.nasa-custom-fields [name="add-to-cart"]').remove();
}
if (_from_mini_cart) {
$(_this).parents('#cart-sidebar').find('.ext-node.active .nasa-close-node').trigger('click');
$('.nasa-change_variation_mini_cart').addClass('nasa-cart-variation-updating');
$.ajax({
type: 'POST',
url: nasa_ajax_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'remove_from_cart' ),
data: {
cart_item_key : _data_cart_item_key
},
success: function(response) {
nasa_ajax_single_add_to_cart($,_urlAjax,_data,_this,_id);
},
error: function() {
},
dataType: 'json'
});
} else {
nasa_ajax_single_add_to_cart($,_urlAjax,_data,_this,_id);
}
}
}
return false;
}
/**
* Ajax add to cart
*/
function nasa_ajax_single_add_to_cart($,_urlAjax,_data,_this,_id) {
$.ajax({
url: _urlAjax,
type: 'post',
dataType: 'json',
cache: false,
data: _data,
beforeSend: function () {
$(_this).removeClass('added');
$(_this).removeClass('nasa-added');
$(_this).addClass('loading');
if (
$('.ns_btn-fixed .single_add_to_cart_button').length &&
!$('.ns_btn-fixed .single_add_to_cart_button').hasClass('loading')
) {
$('.ns_btn-fixed .single_add_to_cart_button').addClass('loading');
}
},
success: function (res) {
$(_this).removeClass('loading');
if (res.error) {
if ($(_this).hasClass('add-to-cart-grid') && !$(_this).hasClass('btn-from-wishlist')) {
window.location.href = res.product_url;
} else {
set_nasa_notice($, res.message);
if (typeof _nasa_clear_mess_error !== 'undefined') {
clearTimeout(_nasa_clear_mess_error);
}
_nasa_clear_mess_error = setTimeout(function () {
if ($('.nasa-close-notice').length) {
$('.nasa-close-notice').trigger('click');
}
}, 5000);
if ($('.ns-cart-popup-wrap').length) {
$('.ns-cart-popup-wrap').removeClass('crazy-loading').find('.nasa-stclose.popup-cart-close').trigger('click');
}
if ($('#cart-sidebar').length && $('#cart-sidebar').hasClass('nasa-active')) {
$('#cart-sidebar').find('.nasa-sidebar-close a').trigger('click');
$('#cart-sidebar').removeClass('crazy-loading');
$('body').trigger('wc_fragment_refresh');
}
if ($('.single_add_to_cart_button').length) {
$('.single_add_to_cart_button').removeClass('loading');
}
}
} else {
if (typeof res.redirect !== 'undefined' && res.redirect) {
window.location.href = res.redirect;
} else {
var fragments = res.fragments;
if (fragments) {
$.each(fragments, function (key, value) {
$(key).addClass('updating');
$(key).replaceWith(value);
});
if (!$(_this).hasClass('added')) {
$(_this).addClass('added');
}
if (!$(_this).hasClass('nasa-added')) {
$(_this).addClass('nasa-added');
}
}
if ($('.wishlist_sidebar').length) {
if (typeof res.wishlist !== 'undefined') {
$('.wishlist_sidebar').replaceWith(res.wishlist);
setTimeout(function() {
init_wishlist_icons($, true);
}, 350);
if ($('.nasa-mini-number.wishlist-number').length) {
var sl_wislist = parseInt(res.wishlistcount);
$('.nasa-mini-number.wishlist-number').html(convert_count_items($, sl_wislist));
if (sl_wislist > 0) {
$('.nasa-mini-number.wishlist-number').removeClass('nasa-product-empty');
}
else if (sl_wislist === 0 && !$('.wishlist-number').hasClass('nasa-product-empty')) {
$('.nasa-mini-number.wishlist-number').addClass('nasa-product-empty');
}
}
if ($('.add-to-wishlist-' + _id).length) {
$('.add-to-wishlist-' + _id).find('.yith-wcwl-add-button').show();
$('.add-to-wishlist-' + _id).find('.yith-wcwl-wishlistaddedbrowse').hide();
$('.add-to-wishlist-' + _id).find('.yith-wcwl-wishlistexistsbrowse').hide();
}
}
}
if ($('.page-shopping-cart').length === 1) {
$.ajax({
url: window.location.href,
type: 'get',
dataType: 'html',
cache: false,
data: {},
success: function (res) {
var $html = $.parseHTML(res);
if ($('.nasa-shopping-cart-form').length === 1) {
var $new_form = $('.nasa-shopping-cart-form', $html);
var $new_totals = $('.cart_totals', $html);
var $notices = $('.woocommerce-error, .woocommerce-message, .woocommerce-info', $html);
$('.nasa-shopping-cart-form').replaceWith($new_form);
if ($notices.length) {
$('.nasa-shopping-cart-form').before($notices);
}
$('.cart_totals').replaceWith($new_totals);
} else {
var $new_content = $('.page-shopping-cart', $html);
$('.page-shopping-cart').replaceWith($new_content);
}
$('body').trigger('updated_cart_totals');
$('body').trigger('updated_wc_div');
$('.nasa-shopping-cart-form').find('[name=update_cart]').prop('disabled', true);
}
});
}
$('body').trigger('added_to_cart', [res.fragments, res.cart_hash, _this]);
}
}
}
});
}
/**
* Bundle Yith popup
*
* @param {type} $
* @param {type} _this
* @returns {undefined}
*/
function load_combo_popup($, _this) {
if (
typeof nasa_ajax_params !== 'undefined' &&
typeof nasa_ajax_params.wc_ajax_url !== 'undefined'
) {
var _urlAjax = nasa_ajax_params.wc_ajax_url.toString().replace('%%endpoint%%', 'nasa_combo_products');
var item = $(_this).parents('.product-item');
if (!$(_this).hasClass('nasaing')) {
$('.btn-combo-link').addClass('nasaing');
var pid = $(_this).attr('data-prod');
if (pid) {
$.ajax({
url: _urlAjax,
type: 'post',
dataType: 'json',
cache: false,
data: {
id: pid,
'title_columns': 2
},
beforeSend: function () {
$(item).append('');
$(item).find('.product-inner').css('opacity', '0.3');
},
success: function (res) {
/**
* Open Magnific
*/
$('body').trigger('ns_magnific_popup_open', [{
mainClass: 'my-mfp-slide-bottom nasa-combo-popup-wrap',
closeMarkup: '',
items: {
src: '',
type: 'inline'
},
removalDelay: 300,
callbacks: {
afterClose: function() {
}
}
}]);
$('body').trigger('nasa_load_slick_slider');
setTimeout(function () {
$('.btn-combo-link').removeClass('nasaing');
$(item).find('.nasa-loader').remove();
$(item).find('.product-inner').css('opacity', '1');
if (typeof wow_enable !== 'undefined' && wow_enable) {
var _data_animate, _delay;
$('.nasa-combo-popup').find('.product-item').each(function() {
var _this = $(this);
_data_animate = $(_this).attr('data-wow');
_delay = parseInt($(_this).attr('data-wow-delay'));
$(_this).css({
'visibility': 'visible',
'animation-delay': _delay + 'ms',
'animation-name': _data_animate
}).addClass('animated');
});
} else {
$('.nasa-combo-popup').find('.product-item').css({'visibility': 'visible'});
}
}, 500);
},
error: function () {
$('.btn-combo-link').removeClass('nasaing');
}
});
}
}
}
}
/**
*
* @param {type} $
* @param {type} _menu_item
* @returns {undefined}
*/
function recursive_convert_item($, _menu_item) {
var _cursor = $(_menu_item).next();
if ($(_cursor).length && !$(_cursor).hasClass('nasa-main') && !$(_cursor).hasClass('nasa-wrap-mains')) {
$(_menu_item).find('.sub-menu').append(_cursor);
recursive_convert_item($, _menu_item);
}
}
/**
* Convert Mega menu
*
* @param {type} $
* @param {type} _menu
* @returns {jQuery}
*/
function convert_mega_menu($, _menu) {
var _mega = $(_menu).clone();
if ($(_mega).find('.nav-column-links > .sub-menu > .menu-item.nasa-main').length) {
$(_mega).find('.nav-column-links > .sub-menu > .menu-item.nasa-main').each(function() {
var _this = $(this);
var _sub_parent = $(_this).parent();
if ($(_sub_parent).find('.nasa-wrap-mains').length < 1) {
$(_sub_parent).append('');
}
if (!$(_this).hasClass('menu-item-has-children')) {
$(_this).addClass('menu-item-has-children');
}
if (!$(_this).hasClass('menu-parent-item')) {
$(_this).addClass('menu-parent-item');
}
if ($(_this).find('.sub-menu').length < 1) {
$(_this).append('');
}
recursive_convert_item($, _this);
$(_sub_parent).find('.nasa-wrap-mains').append(_this);
});
$(_mega).find('.nav-column-links > .sub-menu > .nasa-wrap-mains').each(function() {
var _parent = $(this).parent().parent().parent();
$(_parent).after($(this).html());
$(this).remove();
});
}
return $(_mega).html();
}
/**
* Mobile Menu
*
* @type init_menu_mobile.mini_acc|init_menu_mobile.head_menu|String
* @param {type} $
* @returns {undefined}
*/
function init_menu_mobile($, reset) {
var _reset = typeof reset === 'undefined' ? false : reset;
if (_reset) {
$('#nasa-menu-sidebar-content .nasa-menu-for-mobile').remove();
}
$('body').trigger('nasa_before_init_menu_mobile');
if ($('#nasa-menu-sidebar-content .nasa-menu-for-mobile').length <= 0) {
var _mobileDetect = $('body').hasClass('nasa-in-mobile') ? true : false;
var _mobile_menu = '';
var _main_menu = '';
if ($('.nasa-main-menu').length) {
var _mega = $('.nasa-main-menu');
_main_menu += convert_mega_menu($, _mega);
if (_mobileDetect) {
$(_mega).remove();
}
}
if ($('.header-type-builder .header-nav, #masthead ul.hfe-nav-menu').length) {
$('.header-type-builder .header-nav, #masthead ul.hfe-nav-menu').each(function() {
var _this = $(this);
if (!$(_this).hasClass('ns-included')) {
var _sticky = $(_this).parents('.elementor-element.elementor-sticky').length ? $(_this).parents('.elementor-element.elementor-sticky') : false;
if (_sticky) {
var _dataid = $(_sticky).attr('data-id');
if (_dataid && $('.elementor-element[data-id="' + _dataid + '"]').length) {
$('.elementor-element[data-id="' + _dataid + '"]').find('.header-nav, ul.hfe-nav-menu').addClass('ns-included');
}
} else {
$(_this).addClass('ns-included');
}
var _mega = $(_this);
_main_menu += convert_mega_menu($, _mega);
}
});
}
/**
* Vertical menu in Header
*/
if ($('.nasa-vertical-header .vertical-menu-wrapper').length){
var _vmega = $('.nasa-vertical-header .vertical-menu-wrapper');
var ver_menu = convert_mega_menu($, _vmega);
var ver_menu_title = $('.nasa-vertical-header .nasa-title-vertical-menu').html();
var ver_menu_warp = '';
if ($('.nasa-vertical-header').hasClass('nasa-focus-menu')) {
_mobile_menu = ver_menu_warp + _main_menu;
} else {
_mobile_menu += _main_menu + ver_menu_warp;
}
if (_mobileDetect) {
$('.nasa-vertical-header').remove();
}
}
/**
* Had not Vertical menu in Header
*/
else {
_mobile_menu = _main_menu;
}
/**
* Heading
*/
if ($('#heading-menu-mobile').length) {
_mobile_menu = '' + _mobile_menu;
}
/**
* Vertical Menu in content page
*/
if ($('.nasa-shortcode-menu.vertical-menu').length) {
$('.nasa-shortcode-menu.vertical-menu').each(function() {
var _this = $(this);
var ver_menu_title_sc = $(_this).find('.section-title').length ? $(_this).find('.section-title').html() : $(_this).find('.nasa-title-menu:eq(0)').html();
var ver_menu_sc = $(_this).find('.vertical-menu-wrapper').html();
if (!$('#nasa-menu-sidebar-content').hasClass('nasa-standard')) {
ver_menu_title_sc = '';
} else {
ver_menu_title_sc = '' + ver_menu_title_sc + '';
}
var ver_menu_warp_sc = '';
_mobile_menu += ver_menu_warp_sc;
if (_mobileDetect) {
$(_this).remove();
}
});
}
/**
* Topbar menu
*/
if ($('.nasa-topbar-menu').length) {
_mobile_menu += $('.nasa-topbar-menu').html();
if (_mobileDetect) {
$('.nasa-topbar-menu').remove();
}
}
/**
* Mobile account
*/
if ($('#tmpl-nasa-mobile-account').length) {
if ($('#nasa-menu-sidebar-content').hasClass('nasa-standard') && $('#tmpl-nasa-mobile-account').find('.nasa-menu-item-account').length) {
_mobile_menu += '';
} else {
_mobile_menu += '';
}
$('#tmpl-nasa-mobile-account').remove();
}
/**
* Switch language
*/
var switch_lang = '';
if ($('.header-switch-languages').length) {
switch_lang = $('.header-switch-languages').html();
if (_mobileDetect) {
$('.header-switch-languages').remove();
}
}
if ($('.header-multi-languages').length) {
switch_lang = $('.header-multi-languages').html();
if (_mobileDetect) {
$('.header-multi-languages').remove();
}
}
if ($('#nasa-menu-sidebar-content').hasClass('nasa-standard')) {
_mobile_menu = '';
} else {
_mobile_menu = '';
}
if ($('#nasa-menu-sidebar-content #mobile-navigation').length) {
$('#nasa-menu-sidebar-content #mobile-navigation').replaceWith(_mobile_menu);
} else {
$('#nasa-menu-sidebar-content .nasa-mobile-nav-wrap').append(_mobile_menu);
}
var _nav = $('#nasa-menu-sidebar-content #mobile-navigation');
if ($(_nav).find('.nasa-select-currencies').length) {
var _currency = $(_nav).find('.nasa-select-currencies');
/**
* For WPML - Multi Currencies
*/
if ($(_currency).find('.wcml_currency_switcher').length) {
var _class = $(_currency).find('.wcml_currency_switcher').attr('class');
_class += ' menu-item-has-children root-item li_accordion nasa-select-currencies';
var _currencyObj = $(_currency).find('.wcml-cs-active-currency').clone();
$(_currencyObj).addClass(_class);
$(_currencyObj).find('.wcml-cs-submenu').addClass('sub-menu');
if (!$(_currencyObj).find('.wcml-cs-submenu').hasClass('wcml_currency_switcher')) {
$(_currencyObj).find('.wcml-cs-submenu').addClass('wcml_currency_switcher');
}
$(_nav).find('.nasa-select-currencies').replaceWith(_currencyObj);
}
/**
* For Others
*/
$('body').trigger('nasa_after_render_currencies_switcher', [_currency]);
}
/**
* Re-render Attrs
*/
$(_nav).find('.root-item > a').removeAttr('style');
$(_nav).find('.nav-dropdown').attr('class', 'nav-dropdown-mobile').removeAttr('style');
$(_nav).find('.nav-column-links').addClass('nav-dropdown-mobile');
/**
* Fix for nasa-core not active.
*/
$(_nav).find('.sub-menu').each(function() {
if (!$(this).parent('.nav-dropdown-mobile').length) {
$(this).wrap('');
}
});
$(_nav).find('.nav-dropdown-mobile').find('.sub-menu').removeAttr('style');
$(_nav).find('hr.hr-nasa-megamenu').remove();
$(_nav).find('li').each(function(){
if ($(this).find('.sub-menu').length){
$(this).addClass('li_accordion');
if ($(this).hasClass('current-menu-ancestor') || $(this).hasClass('current-menu-parent') || $(this).hasClass('current-menu-item')){
$(this).addClass('active');
$(this).prepend('');
} else {
$(this).prepend('').find('>.nav-dropdown-mobile').hide();
}
}
});
$(_nav).find('a').removeAttr('style');
$(_nav).find('.menu-show-more').remove();
$('body').trigger('nasa_after_load_mobile_menu');
}
}
/**
* position Mobile menu
*
* @param {type} $
* @returns {undefined}
*/
function position_menu_mobile($) {
if ($('#nasa-menu-sidebar-content').length && $('#mobile-navigation').length) {
if ($('#mobile-navigation').length && $('#mobile-navigation').attr('data-show') !== '1') {
$('#nasa-menu-sidebar-content').removeClass('nasa-active');
var _h_adminbar = $('#wpadminbar').length ? $('#wpadminbar').height() : 0;
if (_h_adminbar > 0) {
$('#nasa-menu-sidebar-content').css({'top': _h_adminbar});
}
}
}
}
/**
* Init Mini Wishlist Icon
*
* @param {type} $
* @returns {undefined}
*/
function init_mini_wishlist($) {
if ($('input[name="nasa_wishlist_cookie_name"]').length) {
var _wishlistArr = get_wishlist_ids($);
if (_wishlistArr.length) {
if ($('.nasa-mini-number.wishlist-number').length) {
var sl_wislist = _wishlistArr.length;
$('.nasa-mini-number.wishlist-number').html(convert_count_items($, sl_wislist));
if (sl_wislist > 0) {
$('.nasa-mini-number.wishlist-number').removeClass('nasa-product-empty');
}
if (sl_wislist === 0 && !$('.wishlist-number').hasClass('nasa-product-empty')) {
$('.nasa-mini-number.wishlist-number').addClass('nasa-product-empty');
}
}
}
}
}
/**
* init Wishlist icons
*
* @param {type} $
* @param {type} init
* @returns {undefined}
*/
function init_wishlist_icons($, init) {
var _init = typeof init === 'undefined' ? false : init;
/**
* NasaTheme Wishlist
*/
if ($('input[name="nasa_wishlist_cookie_name"]').length) {
var _wishlistArr = get_wishlist_ids($);
if (_wishlistArr.length) {
$('.btn-wishlist').each(function() {
var _this = $(this);
var _prod = $(_this).attr('data-prod');
if (_wishlistArr.indexOf(_prod) !== -1) {
if (!$(_this).hasClass('nasa-added')) {
$(_this).addClass('nasa-added');
if($(_this).hasClass('ns-has-wrap')) {
$(_this).find(".nasa-icon-text-wrap").animate({
scrollTop: 24
}, 400);
}
}
if (!$(_this).find('.wishlist-icon').hasClass('added')) {
$(_this).find('.wishlist-icon').addClass('added');
}
}
else if (_init) {
if ($(_this).hasClass('nasa-added')) {
$(_this).removeClass('nasa-added');
}
if ($(_this).find('.wishlist-icon').hasClass('added')) {
$(_this).find('.wishlist-icon').removeClass('added');
}
}
});
}
}
}
/**
* init Compare icons
*
* @param {type} $
* @param {type} _init
* @returns {undefined}
*/
function init_compare_icons($, _init) {
var init = typeof _init !== 'undefined' ? _init : false;
var _comparetArr = get_compare_ids($);
if (init && $('.nasa-mini-number.compare-number').length) {
var _slCompare = _comparetArr.length;
$('.nasa-mini-number.compare-number').html(convert_count_items($, _slCompare));
if (_slCompare <= 0) {
if (!$('.nasa-mini-number.compare-number').hasClass('nasa-product-empty')) {
$('.nasa-mini-number.compare-number').addClass('nasa-product-empty');
}
} else {
$('.nasa-mini-number.compare-number').removeClass('nasa-product-empty');
}
}
if (_comparetArr.length && $('.btn-compare').length) {
$('.btn-compare').each(function() {
var _this = $(this);
var _prod = $(_this).attr('data-prod');
if (_comparetArr.indexOf(_prod) !== -1) {
if (!$(_this).hasClass('added')) {
$(_this).addClass('added');
}
if (!$(_this).hasClass('nasa-added')) {
$(_this).addClass('nasa-added');
$(_this).find(".nasa-icon-text-wrap").animate({ scrollTop: 24 }, 400 );
}
} else {
$(_this).removeClass('added');
$(_this).removeClass('nasa-added');
$(_this).find(".nasa-icon-text-wrap").animate({ scrollTop: 0 }, 400 );
}
});
}
}
/**
* Event after added to cart
* Popup Your Order
*
* @param {type} $
* @returns {undefined}
*/
function after_added_to_cart($) {
if ($('.ns-cart-popup-wrap').length) {
/**
* Check has items
*/
if ($('.ns-cart-popup-wrap .woocommerce-cart-form__cart-item').length || $('.ns-cart-popup-wrap .ns-cart-popup-v2').length) {
if ($('.nasa-static-sidebar').hasClass('nasa-active')) {
$('.nasa-static-sidebar').removeClass('nasa-active');
}
var _event_add = $('.ns-cart-popup-wrap .ns-cart-popup-v2').length ? 'popup_2' : 'popup';
if (_event_add === 'popup') {
$('.ns-cart-popup-wrap').show();
if ($('.ns-cart-popup-wrap .nasa-slick-slider').length) {
$('body').trigger('nasa_reload_slick_slider_private', [$('.ns-cart-popup-wrap')]);
}
}
setTimeout(function() {
if (_event_add === 'popup') {
$('.ns-cart-popup-wrap').addClass('nasa-active');
$('.black-window').fadeIn(200).addClass('desk-window');
}
$('body').trigger('get_content_popup_v2', [true]);
}, 50);
}
/**
* With Empty item in cart
*/
else {
$('.ns-cart-popup-wrap .popup-cart-close').trigger('click');
}
}
}
/**
* Reload MiniCart
*
* @param {type} $
* @returns {undefined}
*/
function reload_mini_cart($) {
$('body').trigger('wc_fragment_refresh');
}
/**
* Init Shipping free notification
*
* @param {type} $
* @returns {undefined}
*/
function init_shipping_free_notification($, confetti) {
if ($('.nasa-total-condition').length) {
var _confetti = typeof confetti !== 'undefined' ? confetti : false;
if ($('form.nasa-shopping-cart-form').length && $('#cart-sidebar .nasa-total-condition').length) {
$('#cart-sidebar .nasa-total-condition').remove();
}
if ($('.ns-cart-popup').length && $('.ns-cart-popup').parents('.mfp-container').find('#nasa-confetti').length <= 0) {
if ($('#cart-sidebar').find('#nasa-confetti').length) {
$('.ns-cart-popup').parents('.mfp-container').append('