Initial Commit N° : 001 - V.4.3.3
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Document ready
|
||||
*/
|
||||
jQuery(document).ready(function($){
|
||||
"use strict";
|
||||
|
||||
if ($('.countdown').length > 0) {
|
||||
$.countdown.regionalOptions[''] = {
|
||||
labels: [
|
||||
nasa_countdown_l10n.years,
|
||||
nasa_countdown_l10n.months,
|
||||
nasa_countdown_l10n.weeks,
|
||||
nasa_countdown_l10n.days,
|
||||
nasa_countdown_l10n.hours,
|
||||
nasa_countdown_l10n.minutes,
|
||||
nasa_countdown_l10n.seconds
|
||||
],
|
||||
labels1: [
|
||||
nasa_countdown_l10n.year,
|
||||
nasa_countdown_l10n.month,
|
||||
nasa_countdown_l10n.week,
|
||||
nasa_countdown_l10n.day,
|
||||
nasa_countdown_l10n.hour,
|
||||
nasa_countdown_l10n.minute,
|
||||
nasa_countdown_l10n.second
|
||||
],
|
||||
compactLabels: ['y', 'm', 'w', 'd'],
|
||||
whichLabels: null,
|
||||
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
||||
timeSeparator: ':',
|
||||
isRTL: true
|
||||
};
|
||||
|
||||
$.countdown.setDefaults($.countdown.regionalOptions['']);
|
||||
|
||||
$('.countdown').each(function () {
|
||||
var count = $(this);
|
||||
if (!$(count).hasClass('countdown-loaded')) {
|
||||
var austDay = new Date(count.data('countdown'));
|
||||
$(count).countdown({
|
||||
until: austDay,
|
||||
padZeroes: true
|
||||
});
|
||||
|
||||
if($(count).hasClass('pause')) {
|
||||
$(count).countdown('pause');
|
||||
}
|
||||
|
||||
$(count).addClass('countdown-loaded');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,551 @@
|
||||
/**
|
||||
* Document ready
|
||||
*
|
||||
* For Dokan store
|
||||
*/
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Remove Crazy Load Effect
|
||||
*/
|
||||
if ($('.nasa-crazy-load.crazy-loading').length) {
|
||||
$('.nasa-crazy-load.crazy-loading').removeClass('crazy-loading');
|
||||
}
|
||||
|
||||
if ($('.nasa-login-register-ajax').length && $('#nasa-login-register-form').length) {
|
||||
/**
|
||||
* Compatible with Dokan
|
||||
*/
|
||||
if (typeof dokan !== 'undefined' && typeof DokanValidateMsg !== 'undefined') {
|
||||
popup_registration_dokan($);
|
||||
}
|
||||
}
|
||||
|
||||
$('body').on('nasa_login_register_ajax_inited', function() {
|
||||
if ($('.nasa-login-register-ajax').length && $('#nasa-login-register-form').length) {
|
||||
/**
|
||||
* Compatible with Dokan
|
||||
*/
|
||||
if (typeof dokan !== 'undefined' && typeof DokanValidateMsg !== 'undefined') {
|
||||
popup_registration_dokan($);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* DOKAN Sidebar
|
||||
*/
|
||||
if ($('.dokan-store-sidebar').length && $('.dokan-single-store').length) {
|
||||
$('body').prepend(
|
||||
'<a class="toggle-sidebar-dokan hidden-tag" href="javascript:void(0);">' +
|
||||
'<svg viewBox="0 0 32 32" width="26" height="24" fill="currentColor"><path d="M 4 7 L 4 9 L 28 9 L 28 7 Z M 4 15 L 4 17 L 28 17 L 28 15 Z M 4 23 L 4 25 L 28 25 L 28 23 Z"/></svg>' +
|
||||
'</a>'
|
||||
);
|
||||
|
||||
$('.dokan-store-sidebar').prepend('<a href="javascript:void(0);" class="hidden-tag nasa-close-sidebar"><svg class="nasa-rotate-180" width="15" height="15" viewBox="0 0 512 512" fill="currentColor"><path d="M135 512c3 0 4 0 6 0 15-4 26-21 40-33 62-61 122-122 187-183 9-9 27-24 29-33 3-14-8-23-17-32-67-66-135-131-202-198-11-9-24-27-33-29-18-4-28 8-31 21 0 0 0 2 0 2 1 1 1 6 3 10 3 8 18 20 27 28 47 47 95 93 141 139 19 18 39 36 55 55-62 64-134 129-199 193-8 9-24 21-26 32-3 18 8 24 20 28z"/></svg></a>');
|
||||
|
||||
$('body').on('click', '.toggle-sidebar-dokan', function() {
|
||||
$('.black-window').fadeIn(200);
|
||||
|
||||
if (!$('body').hasClass('m-ovhd')) {
|
||||
$('body').addClass('m-ovhd');
|
||||
}
|
||||
|
||||
if (!$('.dokan-store-sidebar').hasClass('nasa-active')) {
|
||||
$('.dokan-store-sidebar').addClass('nasa-active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($('#wpadminbar').length) {
|
||||
var _mobileView = $('.nasa-check-reponsive.nasa-switch-check').length && $('.nasa-check-reponsive.nasa-switch-check').width() === 1 ? true : false;
|
||||
var _inMobile = $('body').hasClass('nasa-in-mobile') ? true : false;
|
||||
|
||||
if (_mobileView || _inMobile) {
|
||||
var height_adminbar = $('#wpadminbar').height();
|
||||
|
||||
if ($('.dokan-store-sidebar').length && $('.dokan-single-store').length) {
|
||||
$('.dokan-store-sidebar').css({'top' : height_adminbar});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($('.nasa-change-view').length && $('.dokan-store-products-filter-area').length) {
|
||||
$('.dokan-store-products-filter-area').append($('.nasa-change-view'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Even change layout
|
||||
*/
|
||||
$('body').on('click', '.nasa-change-layout', function() {
|
||||
var _this = $(this);
|
||||
if ($(_this).hasClass('active')) {
|
||||
return false;
|
||||
} else {
|
||||
change_layout_dokan_store($, _this);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Clone group btn for list layout
|
||||
*/
|
||||
dokan_clone_group_btns_product_item($);
|
||||
$('body').on('nasa_store_changed_layout_list', function() {
|
||||
dokan_clone_group_btns_product_item($);
|
||||
});
|
||||
|
||||
/**
|
||||
* Remove Change view in Nasa Store List
|
||||
*/
|
||||
if ($('.nasa-store-lists-filters .toggle-view').length) {
|
||||
setTimeout(function() {
|
||||
if ($('.nasa-store-lists-filters .toggle-view [data-view="grid-view"]').length) {
|
||||
$('.nasa-store-lists-filters .toggle-view [data-view="grid-view"]').trigger('click');
|
||||
}
|
||||
|
||||
$('.nasa-store-lists-filters .toggle-view').remove();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
/* End Document Ready */
|
||||
});
|
||||
|
||||
/**
|
||||
* Dokan Registration
|
||||
*/
|
||||
function popup_registration_dokan($) {
|
||||
var Popup_Dokan_Vendor_Registration = {
|
||||
|
||||
init: function () {
|
||||
var form = $('form.register');
|
||||
|
||||
// bind events
|
||||
$('.user-role input[type=radio]', form).on('change', this.showSellerForm);
|
||||
$('.tc_check_box', form).on('click', this.onTOC);
|
||||
$('#shop-phone', form).keydown(this.ensurePhoneNumber);
|
||||
$('#company-name', form).on('focusout', this.generateSlugFromCompany);
|
||||
|
||||
$('#seller-url', form).keydown(this.constrainSlug);
|
||||
$('#seller-url', form).keyup(this.renderUrl);
|
||||
$('#seller-url', form).on('focusout', this.checkSlugAvailability);
|
||||
|
||||
this.validationLocalized();
|
||||
},
|
||||
|
||||
validate: function (self) {
|
||||
|
||||
$('form.register').validate({
|
||||
errorPlacement: function (error, element) {
|
||||
var form_group = $(element).closest('.form-group');
|
||||
form_group.addClass('has-error').append(error);
|
||||
},
|
||||
success: function (label, element) {
|
||||
$(element).closest('.form-group').removeClass('has-error');
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
showSellerForm: function () {
|
||||
var value = $(this).val();
|
||||
|
||||
if (value === 'seller') {
|
||||
$('.show_if_seller').find('input, select').removeAttr('disabled');
|
||||
$('.show_if_seller').slideDown();
|
||||
|
||||
if ($('.tc_check_box').length > 0) {
|
||||
$('button[name=register]').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
} else {
|
||||
$('.show_if_seller').find('input, select').attr('disabled', 'disabled');
|
||||
$('.show_if_seller').slideUp();
|
||||
|
||||
if ($('.tc_check_box').length > 0) {
|
||||
$('button[name=register]').removeAttr('disabled');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onTOC: function () {
|
||||
var chk_value = $(this).val();
|
||||
|
||||
if ($(this).prop("checked")) {
|
||||
$('input[name=register]').removeAttr('disabled');
|
||||
$('button[name=register]').removeAttr('disabled');
|
||||
$('input[name=dokan_migration]').removeAttr('disabled');
|
||||
} else {
|
||||
$('input[name=register]').attr('disabled', 'disabled');
|
||||
$('button[name=register]').attr('disabled', 'disabled');
|
||||
$('input[name=dokan_migration]').attr('disabled', 'disabled');
|
||||
}
|
||||
},
|
||||
|
||||
ensurePhoneNumber: function (e) {
|
||||
// Allow: backspace, delete, tab, escape, enter and .
|
||||
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 91, 107, 109, 110, 187, 189, 190]) !== -1 ||
|
||||
// Allow: Ctrl+A
|
||||
(e.keyCode == 65 && e.ctrlKey === true) ||
|
||||
// Allow: home, end, left, right
|
||||
(e.keyCode >= 35 && e.keyCode <= 39)) {
|
||||
// let it happen, don't do anything
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that it is a number and stop the keypress
|
||||
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
generateSlugFromCompany: function () {
|
||||
var value = $(this).val();
|
||||
|
||||
if (!value) {
|
||||
value = "";
|
||||
}
|
||||
|
||||
value = decodeURIComponent(value);
|
||||
|
||||
$('#seller-url').val(value);
|
||||
$('#url-alart').text(value);
|
||||
$('#seller-url').focus();
|
||||
},
|
||||
|
||||
constrainSlug: function (e) {
|
||||
var text = $(this).val();
|
||||
|
||||
// Allow: backspace, delete, tab, escape, enter and .
|
||||
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 91, 109, 110, 173, 189, 190]) !== -1 ||
|
||||
// Allow: Ctrl+A
|
||||
(e.keyCode == 65 && e.ctrlKey === true) ||
|
||||
// Allow: home, end, left, right
|
||||
(e.keyCode >= 35 && e.keyCode <= 39)) {
|
||||
// let it happen, don't do anything
|
||||
return;
|
||||
}
|
||||
|
||||
if ((e.shiftKey || (e.keyCode < 65 || e.keyCode > 90) && (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
checkSlugAvailability: function () {
|
||||
var self = $(this),
|
||||
data = {
|
||||
action: 'shop_url',
|
||||
url_slug: self.val(),
|
||||
_nonce: dokan.nonce
|
||||
};
|
||||
|
||||
if (self.val() === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
var row = self.closest('.form-row');
|
||||
row.block({
|
||||
message: null,
|
||||
overlayCSS: {
|
||||
background: '#fff url(' + dokan.ajax_loader + ') no-repeat center',
|
||||
opacity: 0.6
|
||||
}
|
||||
});
|
||||
|
||||
$.post(dokan.ajaxurl, data, function (resp) {
|
||||
|
||||
if (resp.success === true) {
|
||||
$('#url-alart').removeClass('text-danger').addClass('text-success');
|
||||
$('#url-alart-mgs').removeClass('text-danger').addClass('text-success').text(dokan.seller.available);
|
||||
} else {
|
||||
$('#url-alart').removeClass('text-success').addClass('text-danger');
|
||||
$('#url-alart-mgs').removeClass('text-success').addClass('text-danger').text(dokan.seller.notAvailable);
|
||||
}
|
||||
|
||||
row.unblock();
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
renderUrl: function () {
|
||||
$('#url-alart').text($(this).val());
|
||||
},
|
||||
|
||||
validationLocalized: function () {
|
||||
var dokan_messages = DokanValidateMsg;
|
||||
|
||||
dokan_messages.maxlength = $.validator.format(dokan_messages.maxlength_msg);
|
||||
dokan_messages.minlength = $.validator.format(dokan_messages.minlength_msg);
|
||||
dokan_messages.rangelength = $.validator.format(dokan_messages.rangelength_msg);
|
||||
dokan_messages.range = $.validator.format(dokan_messages.range_msg);
|
||||
dokan_messages.max = $.validator.format(dokan_messages.max_msg);
|
||||
dokan_messages.min = $.validator.format(dokan_messages.min_msg);
|
||||
|
||||
$.validator.messages = dokan_messages;
|
||||
}
|
||||
};
|
||||
|
||||
if ($('input[name="nasa-caching-enable"]').length && $('input[name="nasa-caching-enable"]').val() === '1') {
|
||||
$('body').on('nasa_after_load_static_content', function() {
|
||||
if ($('#nasa-login-register-form form.register').length) {
|
||||
Popup_Dokan_Vendor_Registration.init();
|
||||
|
||||
$('.show_if_seller').find('input, select').attr('disabled', 'disabled');
|
||||
|
||||
// trigger change if there is an error while registering
|
||||
var shouldTrigger = $('.woocommerce ul').hasClass('woocommerce-error') && !$('.show_if_seller').is(':hidden');
|
||||
|
||||
if (shouldTrigger) {
|
||||
var form = $('form.register');
|
||||
|
||||
$('.user-role input[type=radio]', form).trigger('change');
|
||||
}
|
||||
|
||||
// disable migration button if checkbox isn't checked
|
||||
if ($('.tc_check_box').length > 0) {
|
||||
$('input[name=dokan_migration]').attr('disabled', 'disabled');
|
||||
$('input[name=register]').attr('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
else {
|
||||
if ($('#nasa-login-register-form form.register').length) {
|
||||
Popup_Dokan_Vendor_Registration.init();
|
||||
|
||||
$('.show_if_seller').find('input, select').attr('disabled', 'disabled');
|
||||
|
||||
// trigger change if there is an error while registering
|
||||
var shouldTrigger = $('.woocommerce ul').hasClass('woocommerce-error') && !$('.show_if_seller').is(':hidden');
|
||||
|
||||
if (shouldTrigger) {
|
||||
var form = $('form.register');
|
||||
|
||||
$('.user-role input[type=radio]', form).trigger('change');
|
||||
}
|
||||
|
||||
// disable migration button if checkbox isn't checked
|
||||
if ($('.tc_check_box').length > 0) {
|
||||
$('input[name=dokan_migration]').attr('disabled', 'disabled');
|
||||
$('input[name=register]').attr('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change layout Grid | List Dokan Store
|
||||
*
|
||||
* @param {type} $
|
||||
* @param {type} _this
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function change_layout_dokan_store($, _this) {
|
||||
var value_view, item_row, class_items;
|
||||
|
||||
var _url = new URL(window.location.href);
|
||||
|
||||
var _destroy = false;
|
||||
|
||||
if ($(_this).hasClass('productList')) {
|
||||
value_view = 'list';
|
||||
_destroy = true;
|
||||
$('.nasa-content-page-products .products').removeClass('grid').addClass('list');
|
||||
|
||||
$('body').trigger('nasa_store_changed_layout_list');
|
||||
} else {
|
||||
var columns = $(_this).attr('data-columns');
|
||||
class_items = 'products grid';
|
||||
|
||||
switch (columns) {
|
||||
case '2' :
|
||||
item_row = 2;
|
||||
value_view = 'grid-2';
|
||||
class_items += ' large-block-grid-2';
|
||||
break;
|
||||
case '3' :
|
||||
item_row = 3;
|
||||
value_view = 'grid-3';
|
||||
class_items += ' large-block-grid-3';
|
||||
break;
|
||||
|
||||
case '5' :
|
||||
item_row = 5;
|
||||
value_view = 'grid-5';
|
||||
class_items += ' large-block-grid-5';
|
||||
break;
|
||||
|
||||
case '6' :
|
||||
item_row = 5;
|
||||
value_view = 'grid-6';
|
||||
class_items += ' large-block-grid-6';
|
||||
break;
|
||||
|
||||
case '4' :
|
||||
default :
|
||||
item_row = 4;
|
||||
value_view = 'grid-4';
|
||||
class_items += ' large-block-grid-4';
|
||||
break;
|
||||
}
|
||||
|
||||
var count = $('.nasa-content-page-products .products').find('.product-warp-item').length;
|
||||
if (count > 0) {
|
||||
var _wrap_all = $('.nasa-content-page-products .products');
|
||||
var _col_small = $(_wrap_all).attr('data-columns_small');
|
||||
var _col_medium = $(_wrap_all).attr('data-columns_medium');
|
||||
|
||||
switch (_col_small) {
|
||||
case '2' :
|
||||
class_items += ' small-block-grid-2';
|
||||
break;
|
||||
case '1' :
|
||||
default :
|
||||
class_items += ' small-block-grid-1';
|
||||
break;
|
||||
}
|
||||
|
||||
switch (_col_medium) {
|
||||
case '3' :
|
||||
class_items += ' medium-block-grid-3';
|
||||
break;
|
||||
case '4' :
|
||||
class_items += ' medium-block-grid-4';
|
||||
break;
|
||||
case '2' :
|
||||
default :
|
||||
class_items += ' medium-block-grid-2';
|
||||
break;
|
||||
}
|
||||
|
||||
$('.nasa-content-page-products .products').attr('class', class_items);
|
||||
}
|
||||
|
||||
$('body').trigger('nasa_store_changed_layout_grid', [columns, class_items]);
|
||||
}
|
||||
|
||||
$(".nasa-change-layout").removeClass("active");
|
||||
$(_this).addClass("active");
|
||||
|
||||
if ($(_this).hasClass('df')) {
|
||||
_url.searchParams.delete('view-layout');
|
||||
} else {
|
||||
_url.searchParams.set('view-layout', value_view);
|
||||
}
|
||||
|
||||
window.history.pushState(_url.href, '', _url.href);
|
||||
|
||||
$('body').trigger('nasa_before_change_view');
|
||||
|
||||
if (!_destroy) {
|
||||
$('body').trigger('nasa_before_change_view_timeout', [_destroy]);
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$('body').trigger('nasa_before_change_view_timeout', [_destroy]);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clone group btn loop products
|
||||
*
|
||||
* @param {type} $
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function dokan_clone_group_btns_product_item($) {
|
||||
var _list = $('.products').length && $('.products').hasClass('list') ? true : false;
|
||||
|
||||
if (_list && $('.nasa-content-page-products .product-item').length) {
|
||||
$('.nasa-content-page-products .product-item').each(function() {
|
||||
var _wrap = $(this);
|
||||
|
||||
if (!$(_wrap).hasClass('nasa-list-cloned')) {
|
||||
$(_wrap).addClass('nasa-list-cloned');
|
||||
|
||||
if ($(_wrap).find('.group-btn-in-list').length < 1) {
|
||||
$(_wrap).append('<div class="group-btn-in-list nasa-group-btns hidden-tag"></div>');
|
||||
}
|
||||
|
||||
var _place = $(_wrap).find('.group-btn-in-list');
|
||||
var _price = '';
|
||||
if ($(_wrap).find('.price-wrap').length) {
|
||||
_price = $(_wrap).find('.price-wrap').html();
|
||||
} else if ($(_wrap).find('.price').length) {
|
||||
_price = $(_wrap).find('.price').clone().wrap('<div class="price-wrap"></div>').parent().html();
|
||||
}
|
||||
|
||||
if (_price !== '') {
|
||||
$(_place).append('<div class="price-wrap">' + _price + '</div>');
|
||||
}
|
||||
|
||||
if ($(_wrap).find('.nasa-list-stock-wrap').length) {
|
||||
$(_place).append($(_wrap).find('.nasa-list-stock-wrap').html());
|
||||
$(_wrap).find('.nasa-list-stock-wrap').remove();
|
||||
}
|
||||
|
||||
if ($(_wrap).find('.btn-link').length && $(_place).length) {
|
||||
var _add = $(_wrap).find('.add-to-cart-grid').clone();
|
||||
|
||||
if ($(_add).length) {
|
||||
$(_place).append(_add);
|
||||
}
|
||||
|
||||
$(_wrap).find('.btn-link').each(function() {
|
||||
var _btn = $(this).clone();
|
||||
if (!$(_btn).hasClass('add-to-cart-grid')) {
|
||||
$(_place).append(_btn);
|
||||
}
|
||||
});
|
||||
|
||||
if ($(_place).find('.btn-link').length) {
|
||||
$(_place).find('.btn-link').each(function() {
|
||||
if (
|
||||
$(this).find('.nasa-icon-text').length <= 0 &&
|
||||
// $(this).find('.nasa-icon').length &&
|
||||
$(this).attr('data-icon-text')
|
||||
) {
|
||||
$(this).append(
|
||||
'<span class="nasa-icon-text">' +
|
||||
$(this).attr('data-icon-text') +
|
||||
'</span>'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($(_place).find('.btn-wishlist.btn-link').length && $(_place).find('.add-to-cart-grid.btn-link').length) {
|
||||
$(_place).find('.add-to-cart-grid.btn-link').after($(_place).find('.btn-wishlist.btn-link'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deal Time
|
||||
*/
|
||||
if ($(_wrap).find('.nasa-sc-pdeal-countdown .countdown').length) {
|
||||
var _countdown = $(_wrap).find('.nasa-sc-pdeal-countdown').clone();
|
||||
$(_countdown).find('.countdown').removeClass('is-countdown');
|
||||
$(_countdown).find('.countdown').removeClass('countdown-rtl');
|
||||
$(_countdown).find('.countdown').removeClass('countdown-loaded');
|
||||
|
||||
$(_countdown).find('.countdown').html('');
|
||||
|
||||
if ($(_wrap).find('.product-info-wrap .nasa-sc-pdeal-countdown').length) {
|
||||
$(_wrap).find('.product-info-wrap .nasa-sc-pdeal-countdown').replaceWith(_countdown);
|
||||
} else {
|
||||
if ($(_wrap).find('.product-des-wrap').length) {
|
||||
$(_wrap).find('.product-des-wrap').before(_countdown);
|
||||
} else {
|
||||
$(_wrap).find('.product-info-wrap').append(_countdown);
|
||||
}
|
||||
}
|
||||
|
||||
$('body').trigger('nasa_load_countdown');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,546 @@
|
||||
/* Document ready */
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Check if a node is blocked for processing.
|
||||
*
|
||||
* @param {JQuery Object} $node
|
||||
* @return {bool} True if the DOM Element is UI Blocked, false if not.
|
||||
*/
|
||||
var mini_cart_ext_is_blocked = function($node) {
|
||||
return $node.is('.processing') || $node.parents('.processing').length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Block a node visually for processing.
|
||||
*
|
||||
* @param {JQuery Object} $node
|
||||
*/
|
||||
var mini_cart_ext_block = function($node) {
|
||||
$('body').trigger('nasa_publish_coupon_refresh');
|
||||
|
||||
if (!mini_cart_ext_is_blocked($node)) {
|
||||
var $color = $('body').hasClass('nasa-dark') ? '#000' : '#fff';
|
||||
|
||||
$node.addClass('processing').block({
|
||||
message: null,
|
||||
overlayCSS: {
|
||||
background: $color,
|
||||
opacity: 0.6
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Unblock a node after processing is complete.
|
||||
*
|
||||
* @param {JQuery Object} $node
|
||||
*/
|
||||
var mini_cart_ext_unblock = function($node) {
|
||||
$node.removeClass('processing').unblock();
|
||||
|
||||
if ($node.find('.nasa-close-node').length) {
|
||||
$node.find('.nasa-close-node').trigger('click');
|
||||
}
|
||||
|
||||
$('body').trigger('nasa_publish_coupon_refresh');
|
||||
|
||||
if ($('#cart-sidebar select.country_to_state, #cart-sidebar input.country_to_state').length) {
|
||||
$('#cart-sidebar select.country_to_state, #cart-sidebar input.country_to_state').trigger('change');
|
||||
$(document.body).trigger('country_to_state_changed'); // Trigger select2 to load.
|
||||
}
|
||||
};
|
||||
|
||||
var mini_cart_ext_url = function(endpoint) {
|
||||
return ext_mini_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', endpoint);
|
||||
};
|
||||
|
||||
/**
|
||||
* Show mess
|
||||
* @param {type} mess
|
||||
* @returns {undefined}
|
||||
*/
|
||||
var _ext_remove_mess;
|
||||
var mini_cart_ext_mess = function(mess) {
|
||||
$('.ext-mini-cart-wrap .mess-wrap').remove();
|
||||
$('.ext-mini-cart-wrap').append('<div class="mess-wrap">' + mess + '</div>');
|
||||
|
||||
if (_ext_remove_mess) {
|
||||
clearTimeout(_ext_remove_mess);
|
||||
}
|
||||
|
||||
_ext_remove_mess = setTimeout(function() {
|
||||
$('.ext-mini-cart-wrap .mess-wrap').remove();
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
$('body').on('nasa_opened_cart_sidebar', function() {
|
||||
if (!$('body').hasClass('canvas-on')) {
|
||||
$('body').addClass('canvas-on');
|
||||
}
|
||||
|
||||
$('body').trigger('ns_render_ext_mini_cart_nonce');
|
||||
$('body').trigger('nasa_publish_coupon_refresh');
|
||||
});
|
||||
|
||||
$('body').on('nasa_after_close_fog_window', function() {
|
||||
$('body').removeClass('canvas-on');
|
||||
});
|
||||
|
||||
/**
|
||||
* Close Node
|
||||
*/
|
||||
$('body').on('click', '.nasa-close-node', function() {
|
||||
var _cart = $(this).parents('.nasa-static-sidebar');
|
||||
var _node = $(this).parents('.ext-node');
|
||||
|
||||
if($(this).parents('.ns-cart-popup-wrap').length) {
|
||||
_cart = $(this).parents('.ns-cart-popup');
|
||||
}
|
||||
|
||||
if ($(_cart).length) {
|
||||
$(_cart).removeClass('ext-loading');
|
||||
}
|
||||
|
||||
if ($(_node).length) {
|
||||
$(_node).removeClass('active');
|
||||
}
|
||||
|
||||
if ($(_node).hasClass('mini-cart-change-variation')) {
|
||||
nasa_quick_viewimg = false;
|
||||
setTimeout(function(){
|
||||
$(_node).find('.product-lightbox').remove();
|
||||
},100);
|
||||
}
|
||||
|
||||
$(_cart).find('.close-nodes').remove();
|
||||
});
|
||||
|
||||
/**
|
||||
* Global Close
|
||||
*/
|
||||
$('body').on('click', '.nasa-static-sidebar .close-nodes, .ns-cart-popup .close-nodes', function() {
|
||||
var _wrap = $(this).parents('.ns-cart-popup-wrap').length ? $(this).parents('.ns-cart-popup') : $(this).parents('.nasa-static-sidebar');;
|
||||
var _close = $(_wrap).find('.ext-nodes-wrap .ext-node.active .nasa-close-node');
|
||||
|
||||
if ($(_close).length) {
|
||||
$(_close).trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Open ext mini cart
|
||||
*/
|
||||
$('body').on('click', '.ext-mini-cart', function() {
|
||||
var _act = $(this).attr('data-act'),
|
||||
_cart = $(this).parents('.nasa-static-sidebar');
|
||||
|
||||
if($(this).parents('.ns-cart-popup-wrap').length) {
|
||||
_cart = $(this).parents('.ns-cart-popup');
|
||||
}
|
||||
|
||||
if ($(_cart).find('.ext-mini-cart-wrap').length && !$(_cart).find('.ext-mini-cart-wrap').hasClass('nasa-disable')) {
|
||||
|
||||
if (!$('body').hasClass('canvas-on')) {
|
||||
$('body').addClass('canvas-on');
|
||||
}
|
||||
|
||||
if (!$(_cart).hasClass('ext-loading')) {
|
||||
$(_cart).addClass('ext-loading');
|
||||
}
|
||||
|
||||
if ($(_cart).find('.close-nodes').length < 1) {
|
||||
$(_cart).append('<a href="javascript:void(0);" class="close-nodes"></a>');
|
||||
}
|
||||
|
||||
$(_cart).find('.ext-nodes-wrap .ext-node').removeClass('active');
|
||||
|
||||
if ($(_cart).find('.ext-nodes-wrap .ext-node.mini-cart-' + _act).length) {
|
||||
$(_cart).find('.ext-nodes-wrap .ext-node.mini-cart-' + _act).addClass('active');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* ext mini cart Note
|
||||
*/
|
||||
$('body').on('click', '#mini-cart-save_note', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $(this);
|
||||
var _wnote = $(_this).parents('.ext-node');
|
||||
|
||||
if (!$(_this).hasClass('nasa-disable')) {
|
||||
$(_this).addClass('nasa-disable');
|
||||
|
||||
var _wrap = $(_this).parents('.nasa-static-sidebar');
|
||||
if ($(_wrap).length < 1) {
|
||||
_wrap = $(_this).parents('.widget_shopping_cart_content');
|
||||
}
|
||||
|
||||
var _note = $('.mini-cart-note textarea[name="order_comments"]').val();
|
||||
|
||||
mini_cart_ext_block(_wrap);
|
||||
|
||||
$(_wnote).removeClass('active');
|
||||
|
||||
$.ajax({
|
||||
url: mini_cart_ext_url('nasa_mini_cart_note'),
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
data: {
|
||||
order_comments: _note
|
||||
},
|
||||
success: function(data) {
|
||||
$('#cart-sidebar').find('.woocommerce-error, .woocommerce-message, .woocommerce-info').remove();
|
||||
$(_this).removeClass('nasa-disable');
|
||||
|
||||
if (data) {
|
||||
if (data.fragments) {
|
||||
$.each(data.fragments, function(key, value) {
|
||||
if ($(key).length) {
|
||||
$(key).replaceWith(value);
|
||||
}
|
||||
});
|
||||
|
||||
// $('body').trigger('added_to_cart', [data.fragments, data.cart_hash, _this]);
|
||||
$('body').trigger('wc_fragments_refreshed');
|
||||
// $('body').trigger('wc_fragment_refresh');
|
||||
|
||||
/**
|
||||
* notification free shipping
|
||||
*/
|
||||
$('body').trigger('nasa_init_shipping_free_notification');
|
||||
}
|
||||
|
||||
/**
|
||||
* mess
|
||||
*/
|
||||
if (data.mess) {
|
||||
mini_cart_ext_mess(data.mess);
|
||||
}
|
||||
}
|
||||
|
||||
$('body').trigger('mini_cart_mobile_layout_change');
|
||||
|
||||
mini_cart_ext_unblock(_wrap);
|
||||
},
|
||||
complete: function() {
|
||||
mini_cart_ext_unblock(_wrap);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('wc_fragments_refreshed', function() {
|
||||
if ($('#cart-sidebar select.country_to_state, #cart-sidebar input.country_to_state').length) {
|
||||
$('#cart-sidebar select.country_to_state, #cart-sidebar input.country_to_state').trigger('change');
|
||||
$(document.body).trigger('country_to_state_changed'); // Trigger select2 to load.
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Publish Coupons
|
||||
*/
|
||||
$('body').on('nasa_publish_coupon_refresh', function() {
|
||||
if ($('.mini-cart-coupon .publish-coupon').length) {
|
||||
$('.mini-cart-coupon .publish-coupon').each(function() {
|
||||
var _this = $(this);
|
||||
var _code = $(_this).attr('data-code');
|
||||
|
||||
$(_this).removeClass('nasa-actived');
|
||||
|
||||
if ($('.coupon-wrap[data-code="' + _code + '"]').length) {
|
||||
$(_this).addClass('nasa-actived');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* From Publish Coupon
|
||||
*/
|
||||
$('body').on('click', '.mini-cart-coupon .publish-coupon:not(.nasa-actived)', function() {
|
||||
var _this = (this);
|
||||
var _code = $(_this).attr('data-code');
|
||||
|
||||
if ($('#mini-cart-add-coupon_code').length) {
|
||||
$('#mini-cart-add-coupon_code').val(_code).trigger('change');
|
||||
|
||||
if ($('#mini-cart-apply_coupon').length) {
|
||||
$('#mini-cart-apply_coupon').trigger('click');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Apply Coupon
|
||||
*/
|
||||
$('body').on('click', '#mini-cart-apply_coupon', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $(this);
|
||||
var _wnote = $(_this).parents('.ext-node');
|
||||
|
||||
var _nonce = $('.mini-cart-ajax-nonce input[name=apply_coupon_nonce]').length ? $('.mini-cart-ajax-nonce input[name=apply_coupon_nonce]').val() : null;
|
||||
|
||||
if (_nonce && !$(_this).hasClass('nasa-disable')) {
|
||||
$(_this).addClass('nasa-disable');
|
||||
|
||||
var _wrap = $(_this).parents('.nasa-static-sidebar');
|
||||
if ($(_wrap).length < 1) {
|
||||
_wrap = $(_this).parents('.widget_shopping_cart_content');
|
||||
}
|
||||
|
||||
var coupon = $('input#mini-cart-add-coupon_code').val();
|
||||
|
||||
if (coupon) {
|
||||
mini_cart_ext_block(_wrap);
|
||||
$(_wnote).removeClass('active');
|
||||
|
||||
var _data = {
|
||||
security: _nonce,
|
||||
coupon_code: coupon
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: mini_cart_ext_url('nasa_mini_cart_apply_coupon'),
|
||||
data: _data,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
$('#cart-sidebar').find('.woocommerce-error, .woocommerce-message, .woocommerce-info').remove();
|
||||
$(_this).removeClass('nasa-disable');
|
||||
|
||||
if (data) {
|
||||
if (data.fragments) {
|
||||
$.each(data.fragments, function(key, value) {
|
||||
if ($(key).length) {
|
||||
$(key).replaceWith(value);
|
||||
}
|
||||
});
|
||||
|
||||
// $('body').trigger('added_to_cart', [data.fragments, data.cart_hash, _this]);
|
||||
$('body').trigger('wc_fragments_refreshed');
|
||||
// $('body').trigger('wc_fragment_refresh');
|
||||
|
||||
/**
|
||||
* notification free shipping
|
||||
*/
|
||||
$('body').trigger('nasa_init_shipping_free_notification');
|
||||
}
|
||||
|
||||
/**
|
||||
* mess
|
||||
*/
|
||||
if (data.mess) {
|
||||
mini_cart_ext_mess(data.mess);
|
||||
}
|
||||
|
||||
$('input#mini-cart-add-coupon_code').val('').trigger('change');
|
||||
}
|
||||
|
||||
$('body').trigger('mini_cart_mobile_layout_change');
|
||||
|
||||
mini_cart_ext_unblock(_wrap);
|
||||
},
|
||||
complete: function() {
|
||||
mini_cart_ext_unblock(_wrap);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$(_this).removeClass('nasa-disable');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Remove Coupon
|
||||
*/
|
||||
$('body').on('click', '.widget_shopping_cart_content .woocommerce-remove-coupon', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $(this);
|
||||
|
||||
var _nonce = $('.mini-cart-ajax-nonce input[name=remove_coupon_nonce]').length ? $('.mini-cart-ajax-nonce input[name=remove_coupon_nonce]').val() : null;
|
||||
|
||||
if (_nonce && !$(_this).hasClass('nasa-disable')) {
|
||||
$(_this).addClass('nasa-disable');
|
||||
|
||||
var _wrap = $(_this).parents('.nasa-static-sidebar');
|
||||
if ($(_wrap).length < 1) {
|
||||
_wrap = $(_this).parents('.widget_shopping_cart_content');
|
||||
}
|
||||
|
||||
mini_cart_ext_block(_wrap);
|
||||
|
||||
var coupon = $(_this).attr('data-coupon');
|
||||
|
||||
var _data = {
|
||||
security: _nonce,
|
||||
coupon: coupon
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: mini_cart_ext_url('nasa_mini_cart_remove_coupon'),
|
||||
data: _data,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
$('#cart-sidebar').find('.woocommerce-error, .woocommerce-message, .woocommerce-info').remove();
|
||||
$(_this).removeClass('nasa-disable');
|
||||
|
||||
if (data) {
|
||||
if (data.fragments) {
|
||||
$.each(data.fragments, function(key, value) {
|
||||
if ($(key).length) {
|
||||
$(key).replaceWith(value);
|
||||
}
|
||||
});
|
||||
|
||||
// $('body').trigger('added_to_cart', [data.fragments, data.cart_hash, _this]);
|
||||
$('body').trigger('wc_fragments_refreshed');
|
||||
// $('body').trigger('wc_fragment_refresh');
|
||||
|
||||
/**
|
||||
* notification free shipping
|
||||
*/
|
||||
$('body').trigger('nasa_init_shipping_free_notification');
|
||||
}
|
||||
|
||||
/**
|
||||
* mess
|
||||
*/
|
||||
if (data.mess) {
|
||||
mini_cart_ext_mess(data.mess);
|
||||
}
|
||||
}
|
||||
|
||||
mini_cart_ext_unblock(_wrap);
|
||||
},
|
||||
complete: function() {
|
||||
mini_cart_ext_unblock(_wrap);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Calculate Shipping Rate
|
||||
*/
|
||||
$('body').on('click', '.mini-cart-shipping [name="calc_shipping"]', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $(this);
|
||||
var _wnote = $(_this).parents('.ext-node');
|
||||
|
||||
if (!$(_this).hasClass('nasa-disable')) {
|
||||
$(_this).addClass('nasa-disable');
|
||||
|
||||
var _wrap = $(_this).parents('.nasa-static-sidebar');
|
||||
var $form = $(_this).parents('form');
|
||||
|
||||
mini_cart_ext_block(_wrap);
|
||||
$(_wnote).removeClass('active');
|
||||
|
||||
$('<input />').attr('type', 'hidden')
|
||||
.attr('name', 'calc_shipping')
|
||||
.attr('value', 'x')
|
||||
.appendTo($form);
|
||||
|
||||
var _data = $form.serialize();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: mini_cart_ext_url('nasa_mini_cart_calculate_shipping'),
|
||||
data: _data,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
$('#cart-sidebar').find('.woocommerce-error, .woocommerce-message, .woocommerce-info').remove();
|
||||
$(_this).removeClass('nasa-disable');
|
||||
|
||||
if (data) {
|
||||
if (data.fragments) {
|
||||
$.each(data.fragments, function(key, value) {
|
||||
if ($(key).length) {
|
||||
$(key).replaceWith(value);
|
||||
}
|
||||
});
|
||||
|
||||
// $('body').trigger('added_to_cart', [data.fragments, data.cart_hash, _this]);
|
||||
$('body').trigger('wc_fragments_refreshed');
|
||||
// $('body').trigger('wc_fragment_refresh');
|
||||
|
||||
/**
|
||||
* notification free shipping
|
||||
*/
|
||||
$('body').trigger('nasa_init_shipping_free_notification');
|
||||
}
|
||||
|
||||
/**
|
||||
* mess
|
||||
*/
|
||||
if (data.mess) {
|
||||
mini_cart_ext_mess(data.mess);
|
||||
}
|
||||
}
|
||||
|
||||
$('body').trigger('mini_cart_mobile_layout_change');
|
||||
|
||||
mini_cart_ext_unblock(_wrap);
|
||||
},
|
||||
complete: function() {
|
||||
mini_cart_ext_unblock(_wrap);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Refresh nonce code
|
||||
*/
|
||||
var ns_ext_now = Date.now();
|
||||
|
||||
$('body').on('ns_render_ext_mini_cart_nonce', function() {
|
||||
if ($('#cart-sidebar select.country_to_state, #cart-sidebar input.country_to_state').length) {
|
||||
$('#cart-sidebar select.country_to_state, #cart-sidebar input.country_to_state').trigger('change');
|
||||
$(document.body).trigger('country_to_state_changed'); // Trigger select2 to load.
|
||||
}
|
||||
|
||||
var ns_now_click = Date.now();
|
||||
|
||||
/**
|
||||
* Accept with 10 min ago
|
||||
*/
|
||||
if ($('#cart-sidebar .mini-cart-ajax-nonce').length <= 0 && (ns_now_click - ns_ext_now) / 1000 / 60 < 10) {
|
||||
$.ajax({
|
||||
url: mini_cart_ext_url('nasa_ext_cart_ajax_nonce'),
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
data: {},
|
||||
success: function(data) {
|
||||
if (data) {
|
||||
if (data.fds) {
|
||||
$('#cart-sidebar').append(data.fds);
|
||||
}
|
||||
|
||||
if (data.scalc && $('input#woocommerce-shipping-calculator-nonce').length) {
|
||||
$('input#woocommerce-shipping-calculator-nonce').val(data.scalc);
|
||||
}
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/* End Document Ready */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,307 @@
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
$.confetti = new function() {
|
||||
// globals
|
||||
var canvas;
|
||||
var ctx;
|
||||
var W;
|
||||
var H;
|
||||
var mp = 300; //max particles
|
||||
var particles = [];
|
||||
var angle = 0;
|
||||
var tiltAngle = 0;
|
||||
var confettiActive = true;
|
||||
var animationComplete = true;
|
||||
var deactivationTimerHandler;
|
||||
var reactivationTimerHandler;
|
||||
var animationHandler;
|
||||
var _inited = false;
|
||||
|
||||
// objects
|
||||
|
||||
var particleColors = {
|
||||
// colorOptions: ["DodgerBlue", "OliveDrab", "Gold", "pink", "SlateBlue", "lightblue", "Violet", "PaleGreen", "SteelBlue", "SandyBrown", "Chocolate", "Crimson"],
|
||||
colorOptions: ["#EF2964", "#00C09D", "#2D87B0", "#48485E", "#EFFF1D"],
|
||||
colorIndex: 0,
|
||||
colorIncrementer: 0,
|
||||
colorThreshold: 10,
|
||||
getColor: function () {
|
||||
if (this.colorIncrementer >= 10) {
|
||||
this.colorIncrementer = 0;
|
||||
this.colorIndex++;
|
||||
if (this.colorIndex >= this.colorOptions.length) {
|
||||
this.colorIndex = 0;
|
||||
}
|
||||
}
|
||||
this.colorIncrementer++;
|
||||
return this.colorOptions[this.colorIndex];
|
||||
}
|
||||
};
|
||||
|
||||
function confettiParticle(color) {
|
||||
this.x = Math.random() * W; // x-coordinate
|
||||
this.y = (Math.random() * H) - H; //y-coordinate
|
||||
this.r = RandomFromTo(5, 15); //radius;
|
||||
this.d = (Math.random() * mp) + 10; //density;
|
||||
this.color = color;
|
||||
this.tilt = Math.floor(Math.random() * 10) - 10;
|
||||
this.tiltAngleIncremental = (Math.random() * 0.07) + 0.05;
|
||||
this.tiltAngle = 0;
|
||||
|
||||
this.draw = function () {
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = this.r / 2;
|
||||
ctx.strokeStyle = this.color;
|
||||
ctx.moveTo(this.x + this.tilt + (this.r / 4), this.y);
|
||||
ctx.lineTo(this.x + this.tilt, this.y + this.tilt + (this.r / 4));
|
||||
return ctx.stroke();
|
||||
};
|
||||
}
|
||||
|
||||
function init() {
|
||||
SetGlobals();
|
||||
|
||||
$(window).on('resize', function () {
|
||||
W = window.innerWidth;
|
||||
H = window.innerHeight;
|
||||
canvas.width = W;
|
||||
canvas.height = H;
|
||||
});
|
||||
}
|
||||
|
||||
function SetGlobals() {
|
||||
if ($('#nasa-confetti').length < 1) {
|
||||
if ($('form.nasa-shopping-cart-form').length) {
|
||||
$('body').append('<canvas id="nasa-confetti" style="display: none;"></canvas>');
|
||||
}
|
||||
else if ($('#cart-sidebar').length) {
|
||||
$('#cart-sidebar').append('<canvas id="nasa-confetti" style="display: none;"></canvas>');
|
||||
}
|
||||
else {
|
||||
$('body').append('<canvas id="nasa-confetti" style="display: none;"></canvas>');
|
||||
}
|
||||
|
||||
if ($('#ns-cart-popup').length) {
|
||||
$('#ns-cart-popup').parents('.ns-cart-popup-wrap').prepend('<canvas id="nasa-confetti-popup" style="display: none; position: relative; z-index: 9;"></canvas>');
|
||||
}
|
||||
}
|
||||
|
||||
if ($('#review_form_wrapper').length && $('#nasa-confetti-review').length < 1) {
|
||||
$('#review_form_wrapper').prepend('<canvas id="nasa-confetti-review" style="display: none;"></canvas>');
|
||||
}
|
||||
|
||||
canvas = document.getElementById("nasa-confetti");
|
||||
if ($('#ns-cart-popup').parents('.ns-cart-popup-wrap').hasClass('nasa-active')) {
|
||||
canvas = document.getElementById("nasa-confetti-popup");
|
||||
}
|
||||
|
||||
if ($('#review_form_wrapper').hasClass('ns-show')) {
|
||||
canvas = document.getElementById("nasa-confetti-review");
|
||||
}
|
||||
|
||||
ctx = canvas.getContext("2d");
|
||||
W = window.innerWidth;
|
||||
H = window.innerHeight;
|
||||
canvas.width = W;
|
||||
canvas.height = H;
|
||||
|
||||
_inited = true;
|
||||
}
|
||||
|
||||
function InitializeConfetti() {
|
||||
canvas.style.display = 'block';
|
||||
particles = [];
|
||||
animationComplete = false;
|
||||
for (var i = 0; i < mp; i++) {
|
||||
var particleColor = particleColors.getColor();
|
||||
particles.push(new confettiParticle(particleColor));
|
||||
}
|
||||
StartConfetti();
|
||||
}
|
||||
|
||||
function Draw() {
|
||||
|
||||
if ($('body').hasClass('nasa-in-mobile')) {
|
||||
mp = 50;
|
||||
} else {
|
||||
mp = 300;
|
||||
}
|
||||
|
||||
ctx.clearRect(0, 0, W, H);
|
||||
var results = [];
|
||||
for (var i = 0; i < mp; i++) {
|
||||
(function (j) {
|
||||
results.push(particles[j].draw());
|
||||
})(i);
|
||||
}
|
||||
Update();
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function RandomFromTo(from, to) {
|
||||
return Math.floor(Math.random() * (to - from + 1) + from);
|
||||
}
|
||||
|
||||
|
||||
function Update() {
|
||||
var remainingFlakes = 0;
|
||||
var particle;
|
||||
angle += 0.01;
|
||||
tiltAngle += 0.1;
|
||||
|
||||
for (var i = 0; i < mp; i++) {
|
||||
particle = particles[i];
|
||||
if (animationComplete) return;
|
||||
|
||||
if (!confettiActive && particle.y < -15) {
|
||||
particle.y = H + 100;
|
||||
continue;
|
||||
}
|
||||
|
||||
stepParticle(particle, i);
|
||||
|
||||
if (particle.y <= H) {
|
||||
remainingFlakes++;
|
||||
}
|
||||
CheckForReposition(particle, i);
|
||||
}
|
||||
|
||||
if (remainingFlakes === 0) {
|
||||
StopConfetti();
|
||||
}
|
||||
}
|
||||
|
||||
function CheckForReposition(particle, index) {
|
||||
if ((particle.x > W + 20 || particle.x < -20 || particle.y > H) && confettiActive) {
|
||||
if (index % 5 > 0 || index % 2 == 0) //66.67% of the flakes
|
||||
{
|
||||
repositionParticle(particle, Math.random() * W, -10, Math.floor(Math.random() * 10) - 10);
|
||||
} else {
|
||||
if (Math.sin(angle) > 0) {
|
||||
//Enter from the left
|
||||
repositionParticle(particle, -5, Math.random() * H, Math.floor(Math.random() * 10) - 10);
|
||||
} else {
|
||||
//Enter from the right
|
||||
repositionParticle(particle, W + 5, Math.random() * H, Math.floor(Math.random() * 10) - 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stepParticle(particle, particleIndex) {
|
||||
particle.tiltAngle += particle.tiltAngleIncremental;
|
||||
particle.y += (Math.cos(angle + particle.d) + 10 + particle.r / 2) / 2;
|
||||
particle.x += Math.sin(angle);
|
||||
particle.tilt = (Math.sin(particle.tiltAngle - (particleIndex / 3))) * 10;
|
||||
}
|
||||
|
||||
function repositionParticle(particle, xCoordinate, yCoordinate, tilt) {
|
||||
particle.x = xCoordinate;
|
||||
particle.y = yCoordinate;
|
||||
particle.tilt = tilt;
|
||||
}
|
||||
|
||||
function StartConfetti() {
|
||||
if (!_inited) {
|
||||
init();
|
||||
}
|
||||
|
||||
W = window.innerWidth;
|
||||
H = window.innerHeight;
|
||||
canvas.width = W;
|
||||
canvas.height = H;
|
||||
(function animloop() {
|
||||
if (animationComplete) return null;
|
||||
animationHandler = requestAnimFrame(animloop);
|
||||
return Draw();
|
||||
})();
|
||||
}
|
||||
|
||||
function ClearTimers() {
|
||||
clearTimeout(reactivationTimerHandler);
|
||||
clearTimeout(animationHandler);
|
||||
}
|
||||
|
||||
function DeactivateConfetti() {
|
||||
confettiActive = false;
|
||||
ClearTimers();
|
||||
}
|
||||
|
||||
function StopConfetti() {
|
||||
if (!_inited) {
|
||||
init();
|
||||
}
|
||||
|
||||
animationComplete = true;
|
||||
if (typeof ctx === 'undefined') return;
|
||||
ctx.clearRect(0, 0, W, H);
|
||||
canvas.style.display = 'none';
|
||||
}
|
||||
|
||||
function RestartConfetti() {
|
||||
if (!_inited) {
|
||||
init();
|
||||
}
|
||||
|
||||
ClearTimers();
|
||||
StopConfetti();
|
||||
reactivationTimerHandler = setTimeout(function () {
|
||||
confettiActive = true;
|
||||
animationComplete = false;
|
||||
InitializeConfetti();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
window.requestAnimFrame = (function () {
|
||||
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {
|
||||
return window.setTimeout(callback, 1000 / 60);
|
||||
};
|
||||
})();
|
||||
|
||||
this.init = init;
|
||||
this.start = InitializeConfetti;
|
||||
this.stop = DeactivateConfetti;
|
||||
this.restart = RestartConfetti;
|
||||
};
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
$('body').on('nasa_confetti_init', function() {
|
||||
$.confetti.init();
|
||||
});
|
||||
|
||||
/**
|
||||
* Re-Start
|
||||
*/
|
||||
$('body').on('nasa_confetti_start', function(e, t) {
|
||||
$.confetti.start();
|
||||
|
||||
if (typeof t !== 'undefined') {
|
||||
setTimeout(function() {
|
||||
$('body').trigger('nasa_confetti_stop');
|
||||
}, t);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Re-Start
|
||||
*/
|
||||
$('body').on('nasa_confetti_restart', function(e, t) {
|
||||
$.confetti.restart();
|
||||
|
||||
if (typeof t !== 'undefined') {
|
||||
setTimeout(function() {
|
||||
$('body').trigger('nasa_confetti_stop');
|
||||
}, t);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Stop
|
||||
*/
|
||||
$('body').on('nasa_confetti_stop', function() {
|
||||
$.confetti.stop();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
/*!
|
||||
* jQuery Cookie Plugin v1.4.1
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2013 Klaus Hartl
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// CommonJS
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function encode(s) {
|
||||
return config.raw ? s : encodeURIComponent(s);
|
||||
}
|
||||
|
||||
function decode(s) {
|
||||
return config.raw ? s : decodeURIComponent(s);
|
||||
}
|
||||
|
||||
function stringifyCookieValue(value) {
|
||||
return encode(config.json ? JSON.stringify(value) : String(value));
|
||||
}
|
||||
|
||||
function parseCookieValue(s) {
|
||||
if (s.indexOf('"') === 0) {
|
||||
// This is a quoted cookie as according to RFC2068, unescape...
|
||||
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||
}
|
||||
|
||||
try {
|
||||
// Replace server-side written pluses with spaces.
|
||||
// If we can't decode the cookie, ignore it, it's unusable.
|
||||
// If we can't parse the cookie, ignore it, it's unusable.
|
||||
s = decodeURIComponent(s.replace(pluses, ' '));
|
||||
return config.json ? JSON.parse(s) : s;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
function read(s, converter) {
|
||||
var value = config.raw ? s : parseCookieValue(s);
|
||||
return $.isFunction(converter) ? converter(value) : value;
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// Write
|
||||
|
||||
if (value !== undefined && !$.isFunction(value)) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setTime(+t + days * 864e+5);
|
||||
}
|
||||
|
||||
return (document.cookie = [
|
||||
encode(key), '=', stringifyCookieValue(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// Read
|
||||
|
||||
var result = key ? undefined : {};
|
||||
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all. Also prevents odd result when
|
||||
// calling $.cookie().
|
||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var name = decode(parts.shift());
|
||||
var cookie = parts.join('=');
|
||||
|
||||
if (key && key === name) {
|
||||
// If second argument (value) is a function it's a converter...
|
||||
result = read(cookie, value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Prevent storing a cookie that we couldn't decode.
|
||||
if (!key && (cookie = read(cookie)) !== undefined) {
|
||||
result[name] = cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Must not alter options, thus extending a fresh object...
|
||||
$.cookie(key, '', $.extend({}, options, {expires: -1}));
|
||||
return !$.cookie(key);
|
||||
};
|
||||
|
||||
}));
|
||||
@@ -0,0 +1,472 @@
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
if(typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], function($){
|
||||
factory($);
|
||||
});
|
||||
} else if(typeof module === 'object' && module.exports) {
|
||||
module.exports = (root.EasyZoom = factory(require('jquery')));
|
||||
} else {
|
||||
root.EasyZoom = factory(root.jQuery);
|
||||
}
|
||||
}(this, function ($) {
|
||||
'use strict';
|
||||
|
||||
var zoomImgOverlapX;
|
||||
var zoomImgOverlapY;
|
||||
var ratioX;
|
||||
var ratioY;
|
||||
var pointerPositionX;
|
||||
var pointerPositionY;
|
||||
|
||||
var defaults = {
|
||||
|
||||
// The text to display within the notice box while loading the zoom image.
|
||||
loadingNotice: 'Loading image',
|
||||
|
||||
// The text to display within the notice box if an error occurs when loading the zoom image.
|
||||
errorNotice: 'The image could not be loaded',
|
||||
|
||||
// The time (in milliseconds) to display the error notice.
|
||||
errorDuration: 2500,
|
||||
|
||||
// Attribute to retrieve the zoom image URL from.
|
||||
linkAttribute: 'href',
|
||||
|
||||
// Prevent clicks on the zoom image link.
|
||||
preventClicks: true,
|
||||
|
||||
// Callback function to execute before the flyout is displayed.
|
||||
beforeShow: $.noop,
|
||||
|
||||
// Callback function to execute before the flyout is removed.
|
||||
beforeHide: $.noop,
|
||||
|
||||
// Callback function to execute when the flyout is displayed.
|
||||
onShow: $.noop,
|
||||
|
||||
// Callback function to execute when the flyout is removed.
|
||||
onHide: $.noop,
|
||||
|
||||
// Callback function to execute when the cursor is moved while over the image.
|
||||
onMove: $.noop
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* EasyZoom
|
||||
* @constructor
|
||||
* @param {Object} target
|
||||
* @param {Object} options (Optional)
|
||||
*/
|
||||
function EasyZoom(target, options) {
|
||||
this.$target = $(target);
|
||||
this.opts = $.extend({}, defaults, options, this.$target.data());
|
||||
|
||||
this.isOpen === undefined && this._init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init
|
||||
* @private
|
||||
*/
|
||||
EasyZoom.prototype._init = function() {
|
||||
this.$link = this.$target.find('a');
|
||||
this.$image = this.$target.find('img');
|
||||
|
||||
this.$flyout = $('<div class="easyzoom-flyout" />');
|
||||
this.$notice = $('<div class="easyzoom-notice" />');
|
||||
|
||||
this.$target.on({
|
||||
'mousemove.easyzoom touchmove.easyzoom': $.proxy(this._onMove, this),
|
||||
'mouseleave.easyzoom touchend.easyzoom': $.proxy(this._onLeave, this),
|
||||
'mouseenter.easyzoom touchstart.easyzoom': $.proxy(this._onEnter, this)
|
||||
});
|
||||
|
||||
this.opts.preventClicks && this.$target.on('click.easyzoom', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Show
|
||||
* @param {MouseEvent|TouchEvent} e
|
||||
* @param {Boolean} testMouseOver (Optional)
|
||||
*/
|
||||
EasyZoom.prototype.show = function(e, testMouseOver) {
|
||||
var self = this;
|
||||
|
||||
if (this.opts.beforeShow.call(this) === false) return;
|
||||
|
||||
if (!this.isReady) {
|
||||
return this._loadImage(this.$link.attr(this.opts.linkAttribute), function() {
|
||||
if (self.isMouseOver || !testMouseOver) {
|
||||
self.show(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.$target.append(this.$flyout);
|
||||
|
||||
var targetWidth = this.$target.outerWidth();
|
||||
var targetHeight = this.$target.outerHeight();
|
||||
|
||||
var flyoutInnerWidth = this.$flyout.width();
|
||||
var flyoutInnerHeight = this.$flyout.height();
|
||||
|
||||
var zoomImgWidth = this.$zoom.width();
|
||||
var zoomImgHeight = this.$zoom.height();
|
||||
|
||||
zoomImgOverlapX = zoomImgWidth - flyoutInnerWidth;
|
||||
zoomImgOverlapY = zoomImgHeight - flyoutInnerHeight;
|
||||
|
||||
// For when the zoom image is smaller than the flyout element.
|
||||
if (zoomImgOverlapX < 0) zoomImgOverlapX = 0;
|
||||
if (zoomImgOverlapY < 0) zoomImgOverlapY = 0;
|
||||
|
||||
ratioX = zoomImgOverlapX / targetWidth;
|
||||
ratioY = zoomImgOverlapY / targetHeight;
|
||||
|
||||
this.isOpen = true;
|
||||
|
||||
this.opts.onShow.call(this);
|
||||
|
||||
e && this._move(e);
|
||||
};
|
||||
|
||||
/**
|
||||
* On enter
|
||||
* @private
|
||||
* @param {Event} e
|
||||
*/
|
||||
EasyZoom.prototype._onEnter = function(e) {
|
||||
var touches = e.originalEvent.touches;
|
||||
|
||||
this.isMouseOver = true;
|
||||
|
||||
if (!touches || touches.length == 1) {
|
||||
e.preventDefault();
|
||||
this.show(e, true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* On move
|
||||
* @private
|
||||
* @param {Event} e
|
||||
*/
|
||||
EasyZoom.prototype._onMove = function(e) {
|
||||
if (!this.isOpen) return;
|
||||
|
||||
e.preventDefault();
|
||||
this._move(e);
|
||||
};
|
||||
|
||||
/**
|
||||
* On leave
|
||||
* @private
|
||||
*/
|
||||
EasyZoom.prototype._onLeave = function() {
|
||||
this.isMouseOver = false;
|
||||
this.isOpen && this.hide();
|
||||
};
|
||||
|
||||
/**
|
||||
* On load
|
||||
* @private
|
||||
* @param {Event} e
|
||||
*/
|
||||
EasyZoom.prototype._onLoad = function(e) {
|
||||
// IE may fire a load event even on error so test the image dimensions
|
||||
if (!e.currentTarget.width) return;
|
||||
|
||||
this.isReady = true;
|
||||
|
||||
this.$notice.detach();
|
||||
this.$flyout.html(this.$zoom);
|
||||
this.$target.removeClass('is-loading').addClass('is-ready');
|
||||
|
||||
e.data.call && e.data();
|
||||
};
|
||||
|
||||
/**
|
||||
* On error
|
||||
* @private
|
||||
*/
|
||||
EasyZoom.prototype._onError = function() {
|
||||
var self = this;
|
||||
|
||||
this.$notice.text(this.opts.errorNotice);
|
||||
this.$target.removeClass('is-loading').addClass('is-error');
|
||||
|
||||
this.detachNotice = setTimeout(function() {
|
||||
self.$notice.detach();
|
||||
self.detachNotice = null;
|
||||
}, this.opts.errorDuration);
|
||||
};
|
||||
|
||||
/**
|
||||
* Load image
|
||||
* @private
|
||||
* @param {String} href
|
||||
* @param {Function} callback
|
||||
*/
|
||||
EasyZoom.prototype._loadImage = function(href, callback) {
|
||||
var zoom = new Image();
|
||||
|
||||
this.$target
|
||||
.addClass('is-loading')
|
||||
.append(this.$notice.text(this.opts.loadingNotice));
|
||||
|
||||
this.$zoom = $(zoom)
|
||||
.on('error', $.proxy(this._onError, this))
|
||||
.on('load', callback, $.proxy(this._onLoad, this));
|
||||
|
||||
zoom.style.position = 'absolute';
|
||||
zoom.src = href;
|
||||
};
|
||||
|
||||
/**
|
||||
* Move
|
||||
* @private
|
||||
* @param {Event} e
|
||||
*/
|
||||
EasyZoom.prototype._move = function(e) {
|
||||
|
||||
if (e.type.indexOf('touch') === 0) {
|
||||
var touchlist = e.touches || e.originalEvent.touches;
|
||||
pointerPositionX = touchlist[0].pageX;
|
||||
pointerPositionY = touchlist[0].pageY;
|
||||
} else {
|
||||
pointerPositionX = e.pageX || pointerPositionX;
|
||||
pointerPositionY = e.pageY || pointerPositionY;
|
||||
}
|
||||
|
||||
var targetOffset = this.$target.offset();
|
||||
var relativePositionX = pointerPositionY - targetOffset.top;
|
||||
var relativePositionY = pointerPositionX - targetOffset.left;
|
||||
var moveX = Math.ceil(relativePositionX * ratioY);
|
||||
var moveY = Math.ceil(relativePositionY * ratioX);
|
||||
|
||||
// Close if outside
|
||||
if (moveY < 0 || moveX < 0 || moveY > zoomImgOverlapX || moveX > zoomImgOverlapY) {
|
||||
this.hide();
|
||||
} else {
|
||||
var top = moveX * -1;
|
||||
var left = moveY * -1;
|
||||
|
||||
this.$zoom.css({
|
||||
top: top,
|
||||
left: left
|
||||
});
|
||||
|
||||
this.opts.onMove.call(this, top, left);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide
|
||||
*/
|
||||
EasyZoom.prototype.hide = function() {
|
||||
if (!this.isOpen) return;
|
||||
if (this.opts.beforeHide.call(this) === false) return;
|
||||
|
||||
this.$flyout.detach();
|
||||
this.isOpen = false;
|
||||
|
||||
this.opts.onHide.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Swap
|
||||
* @param {String} standardSrc
|
||||
* @param {String} zoomHref
|
||||
* @param {String|Array} srcset (Optional)
|
||||
*/
|
||||
EasyZoom.prototype.swap = function(standardSrc, zoomHref, srcset) {
|
||||
this.hide();
|
||||
this.isReady = false;
|
||||
|
||||
this.detachNotice && clearTimeout(this.detachNotice);
|
||||
|
||||
this.$notice.parent().length && this.$notice.detach();
|
||||
|
||||
this.$target.removeClass('is-loading is-ready is-error');
|
||||
|
||||
this.$image.attr({
|
||||
src: standardSrc,
|
||||
srcset: Array.isArray(srcset) ? srcset.join() : srcset
|
||||
});
|
||||
|
||||
this.$link.attr(this.opts.linkAttribute, zoomHref);
|
||||
};
|
||||
|
||||
/**
|
||||
* Teardown
|
||||
*/
|
||||
EasyZoom.prototype.teardown = function() {
|
||||
this.hide();
|
||||
|
||||
this.$target
|
||||
.off('.easyzoom')
|
||||
.removeClass('is-loading is-ready is-error');
|
||||
|
||||
this.detachNotice && clearTimeout(this.detachNotice);
|
||||
|
||||
delete this.$link;
|
||||
delete this.$zoom;
|
||||
delete this.$image;
|
||||
delete this.$notice;
|
||||
delete this.$flyout;
|
||||
|
||||
delete this.isOpen;
|
||||
delete this.isReady;
|
||||
};
|
||||
|
||||
// jQuery plugin wrapper
|
||||
$.fn.easyZoom = function(options) {
|
||||
return this.each(function() {
|
||||
var api = $.data(this, 'easyZoom');
|
||||
|
||||
if (!api) {
|
||||
$.data(this, 'easyZoom', new EasyZoom(this, options));
|
||||
} else if (api.isOpen === undefined) {
|
||||
api._init();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return EasyZoom;
|
||||
}));
|
||||
|
||||
/**
|
||||
* Ready init easyZoom
|
||||
* @type type
|
||||
*/
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
var _zoom = $('body').hasClass('product-zoom') ? true : false;
|
||||
|
||||
if (_zoom && !check_ontouchstart()) {
|
||||
|
||||
var _product_zoom = $('.main-images.no-easyzoom').length ? false : true;
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
if (_product_zoom) {
|
||||
$('.easyzoom').easyZoom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disabled easyZoom in ipad
|
||||
*/
|
||||
$('body').on('touchstart', '*', function() {
|
||||
var _product_zoom = $('.main-images.no-easyzoom').length ? false : true;
|
||||
if (_product_zoom && $('.easyzoom').length > 0) {
|
||||
$('.easyzoom').each(function() {
|
||||
var _easyZoom = $(this);
|
||||
if (!$(_easyZoom).hasClass('nasa-disabled-touchstart')) {
|
||||
var _easyZoom_init = $(_easyZoom).easyZoom();
|
||||
var api_easyZoom = _easyZoom_init.data('easyZoom');
|
||||
api_easyZoom.teardown();
|
||||
|
||||
$(_easyZoom).addClass('nasa-disabled-touchstart');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('nasa_before_changed_src_main_img', function() {
|
||||
var _product_zoom = $('.main-images.no-easyzoom').length ? false : true;
|
||||
|
||||
if (_product_zoom && $('.easyzoom').length) {
|
||||
if ($('.easyzoom .nasa-disabled-touchstart').length <= 0) {
|
||||
$('.easyzoom').easyZoom();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('nasa_after_changed_src_main_img', function(ev, image_large, image_link) {
|
||||
var _api_easyZoom = false;
|
||||
var _product_zoom = $('.main-images.no-easyzoom').length ? false : true;
|
||||
|
||||
if (_product_zoom && $('.easyzoom').length) {
|
||||
if ($('.easyzoom .nasa-disabled-touchstart').length <= 0) {
|
||||
var _api_easyZoom = $('.easyzoom').data('easyZoom');
|
||||
}
|
||||
}
|
||||
|
||||
if (_api_easyZoom) {
|
||||
_api_easyZoom.swap(image_large, image_link);
|
||||
|
||||
var _imgChange = $('.main-images .nasa-item-main-image-wrap[data-key="0"] img');
|
||||
|
||||
if ($(_imgChange).hasClass('jetpack-lazy-image')) {
|
||||
$(_imgChange).attr('src', image_large);
|
||||
|
||||
$(_imgChange)
|
||||
.removeAttr('srcset')
|
||||
.removeAttr('data-lazy-src');
|
||||
}
|
||||
}
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
$('body').on('nasa_changed_gallery_variable_single', function() {
|
||||
reset_easy_zoom($);
|
||||
});
|
||||
|
||||
$('body').on('nasa_product_gallery_remove_crazy', function() {
|
||||
reset_easy_zoom($);
|
||||
});
|
||||
|
||||
$('body').on('nasa_reset_easy_zoom', function() {
|
||||
reset_easy_zoom($);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Reset easyZoom
|
||||
*
|
||||
* @param {type} $
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function reset_easy_zoom($) {
|
||||
var _zoom = $('body').hasClass('product-zoom') ? true : false;
|
||||
var _product_zoom = $('.main-images.no-easyzoom').length ? false : true;
|
||||
|
||||
if (_zoom && _product_zoom && $('.easyzoom .nasa-disabled-touchstart').length <= 0) {
|
||||
if ($('.easyzoom').length > 0) {
|
||||
$('.easyzoom').each(function() {
|
||||
var _this = $(this);
|
||||
if (!$(_this).hasClass('nasa-loaded')) {
|
||||
if ($(_this).find('> a').attr('href') === '') {
|
||||
var _href = $(_this).find('> a').attr('data-o_href');
|
||||
if (_href) {
|
||||
$(_this).find('> a').attr('href', _href);
|
||||
}
|
||||
}
|
||||
|
||||
$(_this).addClass('nasa-loaded');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('.easyzoom').easyZoom();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check device ontouchstart support
|
||||
* if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0))
|
||||
*
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function check_ontouchstart() {
|
||||
return ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0);
|
||||
}
|
||||
@@ -0,0 +1,887 @@
|
||||
/*! Magnific Popup
|
||||
* http://dimsemenov.com/plugins/magnific-popup/
|
||||
* Copyright (c) 2013 Dmitry Semenov; */
|
||||
(function (e) {
|
||||
var t,
|
||||
n,
|
||||
i,
|
||||
o,
|
||||
r,
|
||||
a,
|
||||
s,
|
||||
l = "Close",
|
||||
c = "BeforeClose",
|
||||
d = "AfterClose",
|
||||
u = "BeforeAppend",
|
||||
p = "MarkupParse",
|
||||
f = "Open",
|
||||
m = "Change",
|
||||
g = "mfp",
|
||||
h = "." + g,
|
||||
v = "mfp-ready",
|
||||
C = "mfp-removing",
|
||||
y = "mfp-prevent-close",
|
||||
w = function () {},
|
||||
b = !!window.jQuery,
|
||||
I = e(window),
|
||||
x = function (e, n) {
|
||||
t.ev.on(g + e + h, n);
|
||||
},
|
||||
k = function (t, n, i, o) {
|
||||
var r = document.createElement("div");
|
||||
return (r.className = "mfp-" + t), i && (r.innerHTML = i), o ? n && n.appendChild(r) : ((r = e(r)), n && r.appendTo(n)), r;
|
||||
},
|
||||
T = function (n, i) {
|
||||
t.ev.triggerHandler(g + n, i), t.st.callbacks && ((n = n.charAt(0).toLowerCase() + n.slice(1)), t.st.callbacks[n] && t.st.callbacks[n].apply(t, e.isArray(i) ? i : [i]));
|
||||
},
|
||||
E = function (n) {
|
||||
return (n === s && t.currTemplate.closeBtn) || ((t.currTemplate.closeBtn = e(t.st.closeMarkup.replace("%title%", t.st.tClose))), (s = n)), t.currTemplate.closeBtn;
|
||||
},
|
||||
_ = function () {
|
||||
e.magnificPopup.instance || ((t = new w()), t.init(), (e.magnificPopup.instance = t));
|
||||
},
|
||||
S = function () {
|
||||
var e = document.createElement("p").style,
|
||||
t = ["ms", "O", "Moz", "Webkit"];
|
||||
if (void 0 !== e.transition) return !0;
|
||||
for (; t.length; ) if (t.pop() + "Transition" in e) return !0;
|
||||
return !1;
|
||||
};
|
||||
(w.prototype = {
|
||||
constructor: w,
|
||||
init: function () {
|
||||
var _uad = typeof navigator.userAgentData !== 'undefined' ? navigator.userAgentData : false;
|
||||
(t.isIE7 = _uad ? false : (-1 !== navigator.appVersion.indexOf("MSIE 7."))),
|
||||
(t.isIE8 = _uad ? false : ( -1 !== navigator.appVersion.indexOf("MSIE 8."))),
|
||||
(t.isLowIE = t.isIE7 || t.isIE8),
|
||||
(t.isAndroid = (_uad && typeof _uad.platform !== 'undefined' && /android/gi.test(_uad.platform)) || /android/gi.test(navigator.appVersion)),
|
||||
(t.isIOS = (_uad && typeof _uad.platform !== 'undefined' && /ios|iphone|ipad|ipod/gi.test(_uad.platform)) || /iphone|ipad|ipod/gi.test(navigator.appVersion)),
|
||||
(t.supportsTransition = S()),
|
||||
(t.probablyMobile = (_uad && typeof _uad.mobile !== 'undefined' && _uad.mobile) || t.isAndroid || t.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent)),
|
||||
(o = e(document)),
|
||||
(t.popupsCache = {});
|
||||
},
|
||||
open: function (n) {
|
||||
i || (i = e(document.body));
|
||||
var r;
|
||||
if (n.isObj === !1) {
|
||||
(t.items = n.items.toArray()), (t.index = 0);
|
||||
var s,
|
||||
l = n.items;
|
||||
for (r = 0; l.length > r; r++)
|
||||
if (((s = l[r]), s.parsed && (s = s.el[0]), s === n.el[0])) {
|
||||
t.index = r;
|
||||
break;
|
||||
}
|
||||
} else (t.items = e.isArray(n.items) ? n.items : [n.items]), (t.index = n.index || 0);
|
||||
if (t.isOpen) return t.updateItemHTML(), void 0;
|
||||
(t.types = []),
|
||||
(a = ""),
|
||||
(t.ev = n.mainEl && n.mainEl.length ? n.mainEl.eq(0) : o),
|
||||
n.key ? (t.popupsCache[n.key] || (t.popupsCache[n.key] = {}), (t.currTemplate = t.popupsCache[n.key])) : (t.currTemplate = {}),
|
||||
(t.st = e.extend(!0, {}, e.magnificPopup.defaults, n)),
|
||||
(t.fixedContentPos = "auto" === t.st.fixedContentPos ? !t.probablyMobile : t.st.fixedContentPos),
|
||||
t.st.modal && ((t.st.closeOnContentClick = !1), (t.st.closeOnBgClick = !1), (t.st.showCloseBtn = !1), (t.st.enableEscapeKey = !1)),
|
||||
t.bgOverlay ||
|
||||
((t.bgOverlay = k("bg").on("click" + h, function () {
|
||||
t.close();
|
||||
})),
|
||||
(t.wrap = k("wrap")
|
||||
.attr("tabindex", -1)
|
||||
.on("click" + h, function (e) {
|
||||
t._checkIfClose(e.target) && t.close();
|
||||
})),
|
||||
(t.container = k("container", t.wrap))),
|
||||
(t.contentContainer = k("content")),
|
||||
t.st.preloader && (t.preloader = k("preloader", t.container, t.st.tLoading));
|
||||
var c = e.magnificPopup.modules;
|
||||
for (r = 0; c.length > r; r++) {
|
||||
var d = c[r];
|
||||
(d = d.charAt(0).toUpperCase() + d.slice(1)), t["init" + d].call(t);
|
||||
}
|
||||
T("BeforeOpen"),
|
||||
t.st.showCloseBtn &&
|
||||
(t.st.closeBtnInside
|
||||
? (x(p, function (e, t, n, i) {
|
||||
n.close_replaceWith = E(i.type);
|
||||
}),
|
||||
(a += " mfp-close-btn-in"))
|
||||
: t.wrap.append(E())),
|
||||
t.st.alignTop && (a += " mfp-align-top"),
|
||||
t.fixedContentPos ? t.wrap.css({ overflow: t.st.overflowY, overflowX: "hidden", overflowY: t.st.overflowY }) : t.wrap.css({ top: I.scrollTop(), position: "absolute" }),
|
||||
(t.st.fixedBgPos === !1 || ("auto" === t.st.fixedBgPos && !t.fixedContentPos)) && t.bgOverlay.css({ height: o.height(), position: "absolute" }),
|
||||
t.st.enableEscapeKey &&
|
||||
o.on("keyup" + h, function (e) {
|
||||
27 === e.keyCode && t.close();
|
||||
}),
|
||||
I.on("resize" + h, function () {
|
||||
t.updateSize();
|
||||
}),
|
||||
t.st.closeOnContentClick || (a += " mfp-auto-cursor"),
|
||||
a && t.wrap.addClass(a);
|
||||
var u = (t.wH = I.height()),
|
||||
m = {};
|
||||
if (t.fixedContentPos && t._hasScrollBar(u)) {
|
||||
var g = t._getScrollbarSize();
|
||||
g && (m.marginRight = g);
|
||||
}
|
||||
t.fixedContentPos && (t.isIE7 ? e("body, html").css("overflow", "hidden") : (m.overflow = "hidden"));
|
||||
var C = t.st.mainClass;
|
||||
return (
|
||||
t.isIE7 && (C += " mfp-ie7"),
|
||||
C && t._addClassToMFP(C),
|
||||
t.updateItemHTML(),
|
||||
T("BuildControls"),
|
||||
e("html").css(m),
|
||||
t.bgOverlay.add(t.wrap).prependTo(t.st.prependTo || i),
|
||||
(t._lastFocusedEl = document.activeElement),
|
||||
setTimeout(function () {
|
||||
t.content ? (t._addClassToMFP(v), t._setFocus()) : t.bgOverlay.addClass(v), o.on("focusin" + h, t._onFocusIn);
|
||||
}, 16),
|
||||
(t.isOpen = !0),
|
||||
t.updateSize(u),
|
||||
T(f),
|
||||
n
|
||||
);
|
||||
},
|
||||
close: function () {
|
||||
t.isOpen &&
|
||||
(T(c),
|
||||
(t.isOpen = !1),
|
||||
t.st.removalDelay && !t.isLowIE && t.supportsTransition
|
||||
? (t._addClassToMFP(C),
|
||||
setTimeout(function () {
|
||||
t._close();
|
||||
}, t.st.removalDelay))
|
||||
: t._close());
|
||||
},
|
||||
_close: function () {
|
||||
T(l);
|
||||
var n = C + " " + v + " ";
|
||||
if ((t.bgOverlay.detach(), t.wrap.detach(), t.container.empty(), t.st.mainClass && (n += t.st.mainClass + " "), t._removeClassFromMFP(n), t.fixedContentPos)) {
|
||||
var i = { marginRight: "" };
|
||||
t.isIE7 ? e("body, html").css("overflow", "") : (i.overflow = ""), e("html").css(i);
|
||||
}
|
||||
o.off("keyup" + h + " focusin" + h),
|
||||
t.ev.off(h),
|
||||
t.wrap.attr("class", "mfp-wrap").removeAttr("style"),
|
||||
t.bgOverlay.attr("class", "mfp-bg"),
|
||||
t.container.attr("class", "mfp-container"),
|
||||
!t.st.showCloseBtn || (t.st.closeBtnInside && t.currTemplate[t.currItem.type] !== !0) || (t.currTemplate.closeBtn && t.currTemplate.closeBtn.detach()),
|
||||
t._lastFocusedEl && e(t._lastFocusedEl).focus(),
|
||||
(t.currItem = null),
|
||||
(t.content = null),
|
||||
(t.currTemplate = null),
|
||||
(t.prevHeight = 0),
|
||||
T(d);
|
||||
},
|
||||
updateSize: function (e) {
|
||||
if (t.isIOS) {
|
||||
var n = document.documentElement.clientWidth / window.innerWidth,
|
||||
i = window.innerHeight * n;
|
||||
t.wrap.css("height", i), (t.wH = i);
|
||||
} else t.wH = e || I.height();
|
||||
t.fixedContentPos || t.wrap.css("height", t.wH), T("Resize");
|
||||
},
|
||||
updateItemHTML: function () {
|
||||
var n = t.items[t.index];
|
||||
t.contentContainer.detach(), t.content && t.content.detach(), n.parsed || (n = t.parseEl(t.index));
|
||||
var i = n.type;
|
||||
if ((T("BeforeChange", [t.currItem ? t.currItem.type : "", i]), (t.currItem = n), !t.currTemplate[i])) {
|
||||
var o = t.st[i] ? t.st[i].markup : !1;
|
||||
T("FirstMarkupParse", o), (t.currTemplate[i] = o ? e(o) : !0);
|
||||
}
|
||||
r && r !== n.type && t.container.removeClass("mfp-" + r + "-holder");
|
||||
var a = t["get" + i.charAt(0).toUpperCase() + i.slice(1)](n, t.currTemplate[i]);
|
||||
t.appendContent(a, i), (n.preloaded = !0), T(m, n), (r = n.type), t.container.prepend(t.contentContainer), T("AfterChange");
|
||||
},
|
||||
appendContent: function (e, n) {
|
||||
(t.content = e),
|
||||
e ? (t.st.showCloseBtn && t.st.closeBtnInside && t.currTemplate[n] === !0 ? t.content.find(".mfp-close").length || t.content.append(E()) : (t.content = e)) : (t.content = ""),
|
||||
T(u),
|
||||
t.container.addClass("mfp-" + n + "-holder"),
|
||||
t.contentContainer.append(t.content);
|
||||
},
|
||||
parseEl: function (n) {
|
||||
var i = t.items[n],
|
||||
o = i.type;
|
||||
if (((i = i.tagName ? { el: e(i) } : { data: i, src: i.src }), i.el)) {
|
||||
for (var r = t.types, a = 0; r.length > a; a++)
|
||||
if (i.el.hasClass("mfp-" + r[a])) {
|
||||
o = r[a];
|
||||
break;
|
||||
}
|
||||
(i.src = i.el.attr("data-mfp-src")), i.src || (i.src = i.el.attr("href"));
|
||||
}
|
||||
return (i.type = o || t.st.type || "inline"), (i.index = n), (i.parsed = !0), (t.items[n] = i), T("ElementParse", i), t.items[n];
|
||||
},
|
||||
addGroup: function (e, n) {
|
||||
var i = function (i) {
|
||||
(i.mfpEl = this), t._openClick(i, e, n);
|
||||
};
|
||||
n || (n = {});
|
||||
var o = "click.magnificPopup";
|
||||
(n.mainEl = e), n.items ? ((n.isObj = !0), e.off(o).on(o, i)) : ((n.isObj = !1), n.delegate ? e.off(o).on(o, n.delegate, i) : ((n.items = e), e.off(o).on(o, i)));
|
||||
},
|
||||
_openClick: function (n, i, o) {
|
||||
var r = void 0 !== o.midClick ? o.midClick : e.magnificPopup.defaults.midClick;
|
||||
if (r || (2 !== n.which && !n.ctrlKey && !n.metaKey)) {
|
||||
var a = void 0 !== o.disableOn ? o.disableOn : e.magnificPopup.defaults.disableOn;
|
||||
if (a)
|
||||
if (e.isFunction(a)) {
|
||||
if (!a.call(t)) return !0;
|
||||
} else if (a > I.width()) return !0;
|
||||
n.type && (n.preventDefault(), t.isOpen && n.stopPropagation()), (o.el = e(n.mfpEl)), o.delegate && (o.items = i.find(o.delegate)), t.open(o);
|
||||
}
|
||||
},
|
||||
updateStatus: function (e, i) {
|
||||
if (t.preloader) {
|
||||
n !== e && t.container.removeClass("mfp-s-" + n), i || "loading" !== e || (i = t.st.tLoading);
|
||||
var o = { status: e, text: i };
|
||||
T("UpdateStatus", o),
|
||||
(e = o.status),
|
||||
(i = o.text),
|
||||
t.preloader.html(i),
|
||||
t.preloader.find("a").on("click", function (e) {
|
||||
e.stopImmediatePropagation();
|
||||
}),
|
||||
t.container.addClass("mfp-s-" + e),
|
||||
(n = e);
|
||||
}
|
||||
},
|
||||
_checkIfClose: function (n) {
|
||||
if (!e(n).hasClass(y)) {
|
||||
var i = t.st.closeOnContentClick,
|
||||
o = t.st.closeOnBgClick;
|
||||
if (i && o) return !0;
|
||||
if (!t.content || e(n).hasClass("mfp-close") || (t.preloader && n === t.preloader[0])) return !0;
|
||||
if (n === t.content[0] || e.contains(t.content[0], n)) {
|
||||
if (i) return !0;
|
||||
} else if (o && e.contains(document, n)) return !0;
|
||||
return !1;
|
||||
}
|
||||
},
|
||||
_addClassToMFP: function (e) {
|
||||
t.bgOverlay.addClass(e), t.wrap.addClass(e);
|
||||
},
|
||||
_removeClassFromMFP: function (e) {
|
||||
this.bgOverlay.removeClass(e), t.wrap.removeClass(e);
|
||||
},
|
||||
_hasScrollBar: function (e) {
|
||||
return (t.isIE7 ? o.height() : document.body.scrollHeight) > (e || I.height());
|
||||
},
|
||||
_setFocus: function () {
|
||||
(t.st.focus ? t.content.find(t.st.focus).eq(0) : t.wrap).focus();
|
||||
},
|
||||
_onFocusIn: function (n) {
|
||||
return n.target === t.wrap[0] || e.contains(t.wrap[0], n.target) ? void 0 : (t._setFocus(), !1);
|
||||
},
|
||||
_parseMarkup: function (t, n, i) {
|
||||
var o;
|
||||
i.data && (n = e.extend(i.data, n)),
|
||||
T(p, [t, n, i]),
|
||||
e.each(n, function (e, n) {
|
||||
if (void 0 === n || n === !1) return !0;
|
||||
if (((o = e.split("_")), o.length > 1)) {
|
||||
var i = t.find(h + "-" + o[0]);
|
||||
if (i.length > 0) {
|
||||
var r = o[1];
|
||||
"replaceWith" === r ? i[0] !== n[0] && i.replaceWith(n) : "img" === r ? (i.is("img") ? i.attr("src", n) : i.replaceWith('<img src="' + n + '" class="' + i.attr("class") + '" />')) : i.attr(o[1], n);
|
||||
}
|
||||
} else t.find(h + "-" + e).html(n);
|
||||
});
|
||||
},
|
||||
_getScrollbarSize: function () {
|
||||
if (void 0 === t.scrollbarSize) {
|
||||
var e = document.createElement("div");
|
||||
(e.id = "mfp-sbm"),
|
||||
(e.style.cssText = "width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;"),
|
||||
document.body.appendChild(e),
|
||||
(t.scrollbarSize = e.offsetWidth - e.clientWidth),
|
||||
document.body.removeChild(e);
|
||||
}
|
||||
return t.scrollbarSize;
|
||||
},
|
||||
}),
|
||||
(e.magnificPopup = {
|
||||
instance: null,
|
||||
proto: w.prototype,
|
||||
modules: [],
|
||||
open: function (t, n) {
|
||||
return _(), (t = t ? e.extend(!0, {}, t) : {}), (t.isObj = !0), (t.index = n || 0), this.instance.open(t);
|
||||
},
|
||||
close: function () {
|
||||
return e.magnificPopup.instance && e.magnificPopup.instance.close();
|
||||
},
|
||||
registerModule: function (t, n) {
|
||||
n.options && (e.magnificPopup.defaults[t] = n.options), e.extend(this.proto, n.proto), this.modules.push(t);
|
||||
},
|
||||
defaults: {
|
||||
disableOn: 0,
|
||||
key: null,
|
||||
midClick: !1,
|
||||
mainClass: "",
|
||||
preloader: !0,
|
||||
focus: "",
|
||||
closeOnContentClick: !1,
|
||||
closeOnBgClick: !0,
|
||||
closeBtnInside: !0,
|
||||
showCloseBtn: !0,
|
||||
enableEscapeKey: !0,
|
||||
modal: !1,
|
||||
alignTop: !1,
|
||||
removalDelay: 0,
|
||||
prependTo: null,
|
||||
fixedContentPos: "auto",
|
||||
fixedBgPos: "auto",
|
||||
overflowY: "auto",
|
||||
closeMarkup: '<button title="%title%" type="button" class="mfp-close">×</button>',
|
||||
tClose: "Close (Esc)",
|
||||
tLoading: "Loading...",
|
||||
},
|
||||
}),
|
||||
(e.fn.magnificPopup = function (n) {
|
||||
_();
|
||||
var i = e(this);
|
||||
if ("string" == typeof n)
|
||||
if ("open" === n) {
|
||||
var o,
|
||||
r = b ? i.data("magnificPopup") : i[0].magnificPopup,
|
||||
a = parseInt(arguments[1], 10) || 0;
|
||||
r.items ? (o = r.items[a]) : ((o = i), r.delegate && (o = o.find(r.delegate)), (o = o.eq(a))), t._openClick({ mfpEl: o }, i, r);
|
||||
} else t.isOpen && t[n].apply(t, Array.prototype.slice.call(arguments, 1));
|
||||
else (n = e.extend(!0, {}, n)), b ? i.data("magnificPopup", n) : (i[0].magnificPopup = n), t.addGroup(i, n);
|
||||
return i;
|
||||
});
|
||||
var P,
|
||||
O,
|
||||
z,
|
||||
M = "inline",
|
||||
B = function () {
|
||||
z && (O.after(z.addClass(P)).detach(), (z = null));
|
||||
};
|
||||
e.magnificPopup.registerModule(M, {
|
||||
options: { hiddenClass: "hide", markup: "", tNotFound: "Content not found" },
|
||||
proto: {
|
||||
initInline: function () {
|
||||
t.types.push(M),
|
||||
x(l + "." + M, function () {
|
||||
B();
|
||||
});
|
||||
},
|
||||
getInline: function (n, i) {
|
||||
if ((B(), n.src)) {
|
||||
var o = t.st.inline,
|
||||
r = e(n.src);
|
||||
if (r.length) {
|
||||
var a = r[0].parentNode;
|
||||
a && a.tagName && (O || ((P = o.hiddenClass), (O = k(P)), (P = "mfp-" + P)), (z = r.after(O).detach().removeClass(P))), t.updateStatus("ready");
|
||||
} else t.updateStatus("error", o.tNotFound), (r = e("<div>"));
|
||||
return (n.inlineElement = r), r;
|
||||
}
|
||||
return t.updateStatus("ready"), t._parseMarkup(i, {}, n), i;
|
||||
},
|
||||
},
|
||||
});
|
||||
var F,
|
||||
H = "ajax",
|
||||
L = function () {
|
||||
F && i.removeClass(F);
|
||||
},
|
||||
A = function () {
|
||||
L(), t.req && t.req.abort();
|
||||
};
|
||||
e.magnificPopup.registerModule(H, {
|
||||
options: { settings: null, cursor: "mfp-ajax-cur", tError: '<a href="%url%">The content</a> could not be loaded.' },
|
||||
proto: {
|
||||
initAjax: function () {
|
||||
t.types.push(H), (F = t.st.ajax.cursor), x(l + "." + H, A), x("BeforeChange." + H, A);
|
||||
},
|
||||
getAjax: function (n) {
|
||||
F && i.addClass(F), t.updateStatus("loading");
|
||||
var o = e.extend(
|
||||
{
|
||||
url: n.src,
|
||||
success: function (i, o, r) {
|
||||
var a = { data: i, xhr: r };
|
||||
T("ParseAjax", a),
|
||||
t.appendContent(e(a.data), H),
|
||||
(n.finished = !0),
|
||||
L(),
|
||||
t._setFocus(),
|
||||
setTimeout(function () {
|
||||
t.wrap.addClass(v);
|
||||
}, 16),
|
||||
t.updateStatus("ready"),
|
||||
T("AjaxContentAdded");
|
||||
},
|
||||
error: function () {
|
||||
L(), (n.finished = n.loadError = !0), t.updateStatus("error", t.st.ajax.tError.replace("%url%", n.src));
|
||||
},
|
||||
},
|
||||
t.st.ajax.settings
|
||||
);
|
||||
return (t.req = e.ajax(o)), "";
|
||||
},
|
||||
},
|
||||
});
|
||||
var j,
|
||||
N = function (n) {
|
||||
if (n.data && void 0 !== n.data.title) return n.data.title;
|
||||
var i = t.st.image.titleSrc;
|
||||
if (i) {
|
||||
if (e.isFunction(i)) return i.call(t, n);
|
||||
if (n.el) return n.el.attr(i) || "";
|
||||
}
|
||||
return "";
|
||||
};
|
||||
e.magnificPopup.registerModule("image", {
|
||||
options: {
|
||||
markup:
|
||||
'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',
|
||||
cursor: "mfp-zoom-out-cur",
|
||||
titleSrc: "title",
|
||||
verticalFit: !0,
|
||||
tError: '<a href="%url%">The image</a> could not be loaded.',
|
||||
},
|
||||
proto: {
|
||||
initImage: function () {
|
||||
var e = t.st.image,
|
||||
n = ".image";
|
||||
t.types.push("image"),
|
||||
x(f + n, function () {
|
||||
"image" === t.currItem.type && e.cursor && i.addClass(e.cursor);
|
||||
}),
|
||||
x(l + n, function () {
|
||||
e.cursor && i.removeClass(e.cursor), I.off("resize" + h);
|
||||
}),
|
||||
x("Resize" + n, t.resizeImage),
|
||||
t.isLowIE && x("AfterChange", t.resizeImage);
|
||||
},
|
||||
resizeImage: function () {
|
||||
var e = t.currItem;
|
||||
if (e && e.img && t.st.image.verticalFit) {
|
||||
var n = 0;
|
||||
t.isLowIE && (n = parseInt(e.img.css("padding-top"), 10) + parseInt(e.img.css("padding-bottom"), 10)), e.img.css("max-height", t.wH - n);
|
||||
}
|
||||
},
|
||||
_onImageHasSize: function (e) {
|
||||
e.img && ((e.hasSize = !0), j && clearInterval(j), (e.isCheckingImgSize = !1), T("ImageHasSize", e), e.imgHidden && (t.content && t.content.removeClass("mfp-loading"), (e.imgHidden = !1)));
|
||||
},
|
||||
findImageSize: function (e) {
|
||||
var n = 0,
|
||||
i = e.img[0],
|
||||
o = function (r) {
|
||||
j && clearInterval(j),
|
||||
(j = setInterval(function () {
|
||||
return i.naturalWidth > 0 ? (t._onImageHasSize(e), void 0) : (n > 200 && clearInterval(j), n++, 3 === n ? o(10) : 40 === n ? o(50) : 100 === n && o(500), void 0);
|
||||
}, r));
|
||||
};
|
||||
o(1);
|
||||
},
|
||||
getImage: function (n, i) {
|
||||
var o = 0,
|
||||
r = function () {
|
||||
n &&
|
||||
(n.img[0].complete
|
||||
? (n.img.off(".mfploader"), n === t.currItem && (t._onImageHasSize(n), t.updateStatus("ready")), (n.hasSize = !0), (n.loaded = !0), T("ImageLoadComplete"))
|
||||
: (o++, 200 > o ? setTimeout(r, 100) : a()));
|
||||
},
|
||||
a = function () {
|
||||
n && (n.img.off(".mfploader"), n === t.currItem && (t._onImageHasSize(n), t.updateStatus("error", s.tError.replace("%url%", n.src))), (n.hasSize = !0), (n.loaded = !0), (n.loadError = !0));
|
||||
},
|
||||
s = t.st.image,
|
||||
l = i.find(".mfp-img");
|
||||
if (l.length) {
|
||||
var c = document.createElement("img");
|
||||
(c.className = "mfp-img"),
|
||||
(n.img = e(c).on("load.mfploader", r).on("error.mfploader", a)),
|
||||
(c.src = n.src),
|
||||
l.is("img") && (n.img = n.img.clone()),
|
||||
(c = n.img[0]),
|
||||
c.naturalWidth > 0 ? (n.hasSize = !0) : c.width || (n.hasSize = !1);
|
||||
}
|
||||
return (
|
||||
t._parseMarkup(i, { title: N(n), img_replaceWith: n.img }, n),
|
||||
t.resizeImage(),
|
||||
n.hasSize
|
||||
? (j && clearInterval(j), n.loadError ? (i.addClass("mfp-loading"), t.updateStatus("error", s.tError.replace("%url%", n.src))) : (i.removeClass("mfp-loading"), t.updateStatus("ready")), i)
|
||||
: (t.updateStatus("loading"), (n.loading = !0), n.hasSize || ((n.imgHidden = !0), i.addClass("mfp-loading"), t.findImageSize(n)), i)
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
var W,
|
||||
R = function () {
|
||||
return void 0 === W && (W = void 0 !== document.createElement("p").style.MozTransform), W;
|
||||
};
|
||||
e.magnificPopup.registerModule("zoom", {
|
||||
options: {
|
||||
enabled: !1,
|
||||
easing: "ease-in-out",
|
||||
duration: 300,
|
||||
opener: function (e) {
|
||||
return e.is("img") ? e : e.find("img");
|
||||
},
|
||||
},
|
||||
proto: {
|
||||
initZoom: function () {
|
||||
var e,
|
||||
n = t.st.zoom,
|
||||
i = ".zoom";
|
||||
if (n.enabled && t.supportsTransition) {
|
||||
var o,
|
||||
r,
|
||||
a = n.duration,
|
||||
s = function (e) {
|
||||
var t = e.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),
|
||||
i = "all " + n.duration / 1e3 + "s " + n.easing,
|
||||
o = { position: "fixed", zIndex: 9999, left: 0, top: 0, "-webkit-backface-visibility": "hidden" },
|
||||
r = "transition";
|
||||
return (o["-webkit-" + r] = o["-moz-" + r] = o["-o-" + r] = o[r] = i), t.css(o), t;
|
||||
},
|
||||
d = function () {
|
||||
t.content.css("visibility", "visible");
|
||||
};
|
||||
x("BuildControls" + i, function () {
|
||||
if (t._allowZoom()) {
|
||||
if ((clearTimeout(o), t.content.css("visibility", "hidden"), (e = t._getItemToZoom()), !e)) return d(), void 0;
|
||||
(r = s(e)),
|
||||
r.css(t._getOffset()),
|
||||
t.wrap.append(r),
|
||||
(o = setTimeout(function () {
|
||||
r.css(t._getOffset(!0)),
|
||||
(o = setTimeout(function () {
|
||||
d(),
|
||||
setTimeout(function () {
|
||||
r.remove(), (e = r = null), T("ZoomAnimationEnded");
|
||||
}, 16);
|
||||
}, a));
|
||||
}, 16));
|
||||
}
|
||||
}),
|
||||
x(c + i, function () {
|
||||
if (t._allowZoom()) {
|
||||
if ((clearTimeout(o), (t.st.removalDelay = a), !e)) {
|
||||
if (((e = t._getItemToZoom()), !e)) return;
|
||||
r = s(e);
|
||||
}
|
||||
r.css(t._getOffset(!0)),
|
||||
t.wrap.append(r),
|
||||
t.content.css("visibility", "hidden"),
|
||||
setTimeout(function () {
|
||||
r.css(t._getOffset());
|
||||
}, 16);
|
||||
}
|
||||
}),
|
||||
x(l + i, function () {
|
||||
t._allowZoom() && (d(), r && r.remove(), (e = null));
|
||||
});
|
||||
}
|
||||
},
|
||||
_allowZoom: function () {
|
||||
return "image" === t.currItem.type;
|
||||
},
|
||||
_getItemToZoom: function () {
|
||||
return t.currItem.hasSize ? t.currItem.img : !1;
|
||||
},
|
||||
_getOffset: function (n) {
|
||||
var i;
|
||||
i = n ? t.currItem.img : t.st.zoom.opener(t.currItem.el || t.currItem);
|
||||
var o = i.offset(),
|
||||
r = parseInt(i.css("padding-top"), 10),
|
||||
a = parseInt(i.css("padding-bottom"), 10);
|
||||
o.top -= e(window).scrollTop() - r;
|
||||
var s = { width: i.width(), height: (b ? i.innerHeight() : i[0].offsetHeight) - a - r };
|
||||
return R() ? (s["-moz-transform"] = s.transform = "translate(" + o.left + "px," + o.top + "px)") : ((s.left = o.left), (s.top = o.top)), s;
|
||||
},
|
||||
},
|
||||
});
|
||||
var Z = "iframe",
|
||||
q = "//about:blank",
|
||||
D = function (e) {
|
||||
if (t.currTemplate[Z]) {
|
||||
var n = t.currTemplate[Z].find("iframe");
|
||||
n.length && (e || (n[0].src = q), t.isIE8 && n.css("display", e ? "block" : "none"));
|
||||
}
|
||||
};
|
||||
e.magnificPopup.registerModule(Z, {
|
||||
options: {
|
||||
markup: '<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen allow="autoplay *; fullscreen *"></iframe></div>',
|
||||
srcAction: "iframe_src",
|
||||
patterns: {
|
||||
youtube: { index: "youtube.com", id: "v=", src: "//www.youtube.com/embed/%id%?autoplay=1" },
|
||||
vimeo: {
|
||||
index: 'vimeo.com/',
|
||||
id: function(url) {
|
||||
var m = url.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/);
|
||||
if ( !m || !m[5] ) return null;
|
||||
return m[5];
|
||||
},
|
||||
src: '//player.vimeo.com/video/%id%?autoplay=1'
|
||||
},
|
||||
gmaps: { index: "//maps.google.", src: "%id%&output=embed" },
|
||||
},
|
||||
},
|
||||
proto: {
|
||||
initIframe: function () {
|
||||
t.types.push(Z),
|
||||
x("BeforeChange", function (e, t, n) {
|
||||
t !== n && (t === Z ? D() : n === Z && D(!0));
|
||||
}),
|
||||
x(l + "." + Z, function () {
|
||||
D();
|
||||
});
|
||||
},
|
||||
getIframe: function (n, i) {
|
||||
var o = n.src,
|
||||
r = t.st.iframe;
|
||||
e.each(r.patterns, function () {
|
||||
return o.indexOf(this.index) > -1 ? (this.id && (o = "string" == typeof this.id ? o.substr(o.lastIndexOf(this.id) + this.id.length, o.length) : this.id.call(this, o)), (o = this.src.replace("%id%", o)), !1) : void 0;
|
||||
});
|
||||
var a = {};
|
||||
return r.srcAction && (a[r.srcAction] = o), t._parseMarkup(i, a, n), t.updateStatus("ready"), i;
|
||||
},
|
||||
},
|
||||
});
|
||||
var K = function (e) {
|
||||
var n = t.items.length;
|
||||
return e > n - 1 ? e - n : 0 > e ? n + e : e;
|
||||
},
|
||||
Y = function (e, t, n) {
|
||||
return e.replace(/%curr%/gi, t + 1).replace(/%total%/gi, n);
|
||||
};
|
||||
e.magnificPopup.registerModule("gallery", {
|
||||
options: {
|
||||
enabled: !1,
|
||||
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
|
||||
preload: [0, 2],
|
||||
navigateByImgClick: !0,
|
||||
arrows: !0,
|
||||
tPrev: "Previous (Left arrow key)",
|
||||
tNext: "Next (Right arrow key)",
|
||||
tCounter: "%curr% of %total%",
|
||||
},
|
||||
proto: {
|
||||
initGallery: function () {
|
||||
var n = t.st.gallery,
|
||||
i = ".mfp-gallery",
|
||||
r = Boolean(e.fn.mfpFastClick);
|
||||
return (
|
||||
(t.direction = !0),
|
||||
n && n.enabled
|
||||
? ((a += " mfp-gallery"),
|
||||
x(f + i, function () {
|
||||
n.navigateByImgClick &&
|
||||
t.wrap.on("click" + i, ".mfp-img", function () {
|
||||
return t.items.length > 1 ? (t.next(), !1) : void 0;
|
||||
}),
|
||||
o.on("keydown" + i, function (e) {
|
||||
37 === e.keyCode ? t.prev() : 39 === e.keyCode && t.next();
|
||||
});
|
||||
}),
|
||||
x("UpdateStatus" + i, function (e, n) {
|
||||
n.text && (n.text = Y(n.text, t.currItem.index, t.items.length));
|
||||
}),
|
||||
x(p + i, function (e, i, o, r) {
|
||||
var a = t.items.length;
|
||||
o.counter = a > 1 ? Y(n.tCounter, r.index, a) : "";
|
||||
}),
|
||||
x("BuildControls" + i, function () {
|
||||
if (t.items.length > 1 && n.arrows && !t.arrowLeft) {
|
||||
var i = n.arrowMarkup,
|
||||
o = (t.arrowLeft = e(i.replace(/%title%/gi, n.tPrev).replace(/%dir%/gi, "left")).addClass(y)),
|
||||
a = (t.arrowRight = e(i.replace(/%title%/gi, n.tNext).replace(/%dir%/gi, "right")).addClass(y)),
|
||||
s = r ? "mfpFastClick" : "click";
|
||||
o[s](function () {
|
||||
t.prev();
|
||||
}),
|
||||
a[s](function () {
|
||||
t.next();
|
||||
}),
|
||||
t.isIE7 && (k("b", o[0], !1, !0), k("a", o[0], !1, !0), k("b", a[0], !1, !0), k("a", a[0], !1, !0)),
|
||||
t.container.append(o.add(a));
|
||||
}
|
||||
}),
|
||||
x(m + i, function () {
|
||||
t._preloadTimeout && clearTimeout(t._preloadTimeout),
|
||||
(t._preloadTimeout = setTimeout(function () {
|
||||
t.preloadNearbyImages(), (t._preloadTimeout = null);
|
||||
}, 16));
|
||||
}),
|
||||
x(l + i, function () {
|
||||
o.off(i), t.wrap.off("click" + i), t.arrowLeft && r && t.arrowLeft.add(t.arrowRight).destroyMfpFastClick(), (t.arrowRight = t.arrowLeft = null);
|
||||
}),
|
||||
void 0)
|
||||
: !1
|
||||
);
|
||||
},
|
||||
next: function () {
|
||||
(t.direction = !0), (t.index = K(t.index + 1)), t.updateItemHTML();
|
||||
},
|
||||
prev: function () {
|
||||
(t.direction = !1), (t.index = K(t.index - 1)), t.updateItemHTML();
|
||||
},
|
||||
goTo: function (e) {
|
||||
(t.direction = e >= t.index), (t.index = e), t.updateItemHTML();
|
||||
},
|
||||
preloadNearbyImages: function () {
|
||||
var e,
|
||||
n = t.st.gallery.preload,
|
||||
i = Math.min(n[0], t.items.length),
|
||||
o = Math.min(n[1], t.items.length);
|
||||
for (e = 1; (t.direction ? o : i) >= e; e++) t._preloadItem(t.index + e);
|
||||
for (e = 1; (t.direction ? i : o) >= e; e++) t._preloadItem(t.index - e);
|
||||
},
|
||||
_preloadItem: function (n) {
|
||||
if (((n = K(n)), !t.items[n].preloaded)) {
|
||||
var i = t.items[n];
|
||||
i.parsed || (i = t.parseEl(n)),
|
||||
T("LazyLoad", i),
|
||||
"image" === i.type &&
|
||||
(i.img = e('<img class="mfp-img" />')
|
||||
.on("load.mfploader", function () {
|
||||
i.hasSize = !0;
|
||||
})
|
||||
.on("error.mfploader", function () {
|
||||
(i.hasSize = !0), (i.loadError = !0), T("LazyLoadError", i);
|
||||
})
|
||||
.attr("src", i.src)),
|
||||
(i.preloaded = !0);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
var U = "retina";
|
||||
e.magnificPopup.registerModule(U, {
|
||||
options: {
|
||||
replaceSrc: function (e) {
|
||||
return e.src.replace(/\.\w+$/, function (e) {
|
||||
return "@2x" + e;
|
||||
});
|
||||
},
|
||||
ratio: 1,
|
||||
},
|
||||
proto: {
|
||||
initRetina: function () {
|
||||
if (window.devicePixelRatio > 1) {
|
||||
var e = t.st.retina,
|
||||
n = e.ratio;
|
||||
(n = isNaN(n) ? n() : n),
|
||||
n > 1 &&
|
||||
(x("ImageHasSize." + U, function (e, t) {
|
||||
t.img.css({ "max-width": t.img[0].naturalWidth / n, width: "100%" });
|
||||
}),
|
||||
x("ElementParse." + U, function (t, i) {
|
||||
i.src = e.replaceSrc(i, n);
|
||||
}));
|
||||
}
|
||||
},
|
||||
},
|
||||
}),
|
||||
(function () {
|
||||
var t = 1e3,
|
||||
n = "ontouchstart" in window,
|
||||
i = function () {
|
||||
I.off("touchmove" + r + " touchend" + r);
|
||||
},
|
||||
o = "mfpFastClick",
|
||||
r = "." + o;
|
||||
(e.fn.mfpFastClick = function (o) {
|
||||
return e(this).each(function () {
|
||||
var a,
|
||||
s = e(this);
|
||||
if (n) {
|
||||
var l, c, d, u, p, f;
|
||||
s.on("touchstart" + r, function (e) {
|
||||
(u = !1),
|
||||
(f = 1),
|
||||
(p = e.originalEvent ? e.originalEvent.touches[0] : e.touches[0]),
|
||||
(c = p.clientX),
|
||||
(d = p.clientY),
|
||||
I.on("touchmove" + r, function (e) {
|
||||
(p = e.originalEvent ? e.originalEvent.touches : e.touches), (f = p.length), (p = p[0]), (Math.abs(p.clientX - c) > 10 || Math.abs(p.clientY - d) > 10) && ((u = !0), i());
|
||||
}).on("touchend" + r, function (e) {
|
||||
i(),
|
||||
u ||
|
||||
f > 1 ||
|
||||
((a = !0),
|
||||
e.preventDefault(),
|
||||
clearTimeout(l),
|
||||
(l = setTimeout(function () {
|
||||
a = !1;
|
||||
}, t)),
|
||||
o());
|
||||
});
|
||||
});
|
||||
}
|
||||
s.on("click" + r, function () {
|
||||
a || o();
|
||||
});
|
||||
});
|
||||
}),
|
||||
(e.fn.destroyMfpFastClick = function () {
|
||||
e(this).off("touchstart" + r + " click" + r), n && I.off("touchmove" + r + " touchend" + r);
|
||||
});
|
||||
})(),
|
||||
_();
|
||||
})(window.jQuery || window.Zepto);
|
||||
|
||||
/**
|
||||
* Document ready
|
||||
*/
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
$('body').on('ns_magnific_popup_init', function(e, _tag, _stdclass) {
|
||||
if ($(_tag).length) {
|
||||
$(_tag).magnificPopup(_stdclass);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Open
|
||||
*/
|
||||
$('body').on('ns_magnific_popup_open', function(e, _stdclass) {
|
||||
$.magnificPopup.open(_stdclass);
|
||||
});
|
||||
|
||||
/**
|
||||
* Open with time
|
||||
*/
|
||||
$('body').on('ns_magnific_popup_open_time', function(e, _stdclass, time) {
|
||||
$.magnificPopup.open(_stdclass, time);
|
||||
});
|
||||
|
||||
/**
|
||||
* Open Private
|
||||
*/
|
||||
$('body').on('ns_magnific_popup_open_private', function(e, _tag) {
|
||||
if ($(_tag).length) {
|
||||
$(_tag).magnificPopup('open');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Open Parent
|
||||
*/
|
||||
$('body').on('ns_magnific_popup_parent', function(e, _tag, _stdclass) {
|
||||
if ($(_tag).length) {
|
||||
var _parent = $(_tag).parent();
|
||||
|
||||
if ($(_parent).length) {
|
||||
$(_parent).magnificPopup(_stdclass);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Close
|
||||
*/
|
||||
$('body').on('ns_magnific_popup_close', function() {
|
||||
$.magnificPopup.close();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,697 @@
|
||||
/*!
|
||||
* Stellar.js v0.6.2
|
||||
* http://markdalgleish.com/projects/stellar.js
|
||||
*
|
||||
* Copyright 2013, Mark Dalgleish
|
||||
* This content is released under the MIT license
|
||||
* http://markdalgleish.mit-license.org
|
||||
*/
|
||||
|
||||
;(function ($, window, document, undefined) {
|
||||
|
||||
var pluginName = 'stellar',
|
||||
defaults = {
|
||||
scrollProperty: 'scroll',
|
||||
positionProperty: 'position',
|
||||
horizontalScrolling: true,
|
||||
verticalScrolling: true,
|
||||
horizontalOffset: 0,
|
||||
verticalOffset: 0,
|
||||
responsive: false,
|
||||
parallaxBackgrounds: true,
|
||||
parallaxElements: true,
|
||||
hideDistantElements: true,
|
||||
hideElement: function ($elem) {
|
||||
$elem.hide();
|
||||
},
|
||||
showElement: function ($elem) {
|
||||
$elem.show();
|
||||
}
|
||||
},
|
||||
scrollProperty = {
|
||||
scroll: {
|
||||
getLeft: function ($elem) {
|
||||
return $elem.scrollLeft();
|
||||
},
|
||||
setLeft: function ($elem, val) {
|
||||
$elem.scrollLeft(val);
|
||||
},
|
||||
|
||||
getTop: function ($elem) {
|
||||
return $elem.scrollTop();
|
||||
},
|
||||
setTop: function ($elem, val) {
|
||||
$elem.scrollTop(val);
|
||||
}
|
||||
},
|
||||
position: {
|
||||
getLeft: function ($elem) {
|
||||
return parseInt($elem.css('left'), 10) * -1;
|
||||
},
|
||||
getTop: function ($elem) {
|
||||
return parseInt($elem.css('top'), 10) * -1;
|
||||
}
|
||||
},
|
||||
margin: {
|
||||
getLeft: function ($elem) {
|
||||
return parseInt($elem.css('margin-left'), 10) * -1;
|
||||
},
|
||||
getTop: function ($elem) {
|
||||
return parseInt($elem.css('margin-top'), 10) * -1;
|
||||
}
|
||||
},
|
||||
transform: {
|
||||
getLeft: function ($elem) {
|
||||
var computedTransform = getComputedStyle($elem[0])[prefixedTransform];
|
||||
return (computedTransform !== 'none' ? parseInt(computedTransform.match(/(-?[0-9]+)/g)[4], 10) * -1 : 0);
|
||||
},
|
||||
getTop: function ($elem) {
|
||||
var computedTransform = getComputedStyle($elem[0])[prefixedTransform];
|
||||
return (computedTransform !== 'none' ? parseInt(computedTransform.match(/(-?[0-9]+)/g)[5], 10) * -1 : 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
positionProperty = {
|
||||
position: {
|
||||
setLeft: function ($elem, left) {
|
||||
$elem.css('left', left);
|
||||
},
|
||||
setTop: function ($elem, top) {
|
||||
$elem.css('top', top);
|
||||
}
|
||||
},
|
||||
transform: {
|
||||
setPosition: function ($elem, left, startingLeft, top, startingTop) {
|
||||
$elem[0].style[prefixedTransform] = 'translate3d(' + (left - startingLeft) + 'px, ' + (top - startingTop) + 'px, 0)';
|
||||
}
|
||||
}
|
||||
},
|
||||
// Returns a function which adds a vendor prefix to any CSS property name
|
||||
vendorPrefix = (function () {
|
||||
var prefixes = /^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,
|
||||
style = $('script')[0].style,
|
||||
prefix = '',
|
||||
prop;
|
||||
|
||||
for (prop in style) {
|
||||
if (prefixes.test(prop)) {
|
||||
prefix = prop.match(prefixes)[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ('WebkitOpacity' in style) {
|
||||
prefix = 'Webkit';
|
||||
}
|
||||
if ('KhtmlOpacity' in style) {
|
||||
prefix = 'Khtml';
|
||||
}
|
||||
|
||||
return function (property) {
|
||||
return prefix + (prefix.length > 0 ? property.charAt(0).toUpperCase() + property.slice(1) : property);
|
||||
};
|
||||
}()),
|
||||
prefixedTransform = vendorPrefix('transform'),
|
||||
supportsBackgroundPositionXY = $('<div />', {style: 'background:#fff'}).css('background-position-x') !== undefined,
|
||||
setBackgroundPosition = (supportsBackgroundPositionXY ?
|
||||
function ($elem, x, y) {
|
||||
$elem.css({
|
||||
'background-position-x': x,
|
||||
'background-position-y': y
|
||||
});
|
||||
} :
|
||||
function ($elem, x, y) {
|
||||
$elem.css('background-position', x + ' ' + y);
|
||||
}
|
||||
),
|
||||
getBackgroundPosition = (supportsBackgroundPositionXY ?
|
||||
function ($elem) {
|
||||
return [
|
||||
$elem.css('background-position-x'),
|
||||
$elem.css('background-position-y')
|
||||
];
|
||||
} :
|
||||
function ($elem) {
|
||||
return $elem.css('background-position').split(' ');
|
||||
}
|
||||
),
|
||||
requestAnimFrame = (
|
||||
window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function (callback) {
|
||||
setTimeout(callback, 1000 / 60);
|
||||
}
|
||||
);
|
||||
|
||||
function Plugin(element, options) {
|
||||
this.element = element;
|
||||
this.options = $.extend({}, defaults, options);
|
||||
|
||||
this._defaults = defaults;
|
||||
this._name = pluginName;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
Plugin.prototype = {
|
||||
init: function () {
|
||||
this.options.name = pluginName + '_' + Math.floor(Math.random() * 1e9);
|
||||
|
||||
this._defineElements();
|
||||
this._defineGetters();
|
||||
this._defineSetters();
|
||||
this._handleWindowLoadAndResize();
|
||||
this._detectViewport();
|
||||
|
||||
this.refresh({firstLoad: true});
|
||||
|
||||
if (this.options.scrollProperty === 'scroll') {
|
||||
this._handleScrollEvent();
|
||||
} else {
|
||||
this._startAnimationLoop();
|
||||
}
|
||||
},
|
||||
_defineElements: function () {
|
||||
if (this.element === document.body)
|
||||
this.element = window;
|
||||
this.$scrollElement = $(this.element);
|
||||
this.$element = (this.element === window ? $('body') : this.$scrollElement);
|
||||
this.$viewportElement = (this.options.viewportElement !== undefined ? $(this.options.viewportElement) : (this.$scrollElement[0] === window || this.options.scrollProperty === 'scroll' ? this.$scrollElement : this.$scrollElement.parent()));
|
||||
},
|
||||
_defineGetters: function () {
|
||||
var self = this,
|
||||
scrollPropertyAdapter = scrollProperty[self.options.scrollProperty];
|
||||
|
||||
this._getScrollLeft = function () {
|
||||
return scrollPropertyAdapter.getLeft(self.$scrollElement);
|
||||
};
|
||||
|
||||
this._getScrollTop = function () {
|
||||
return scrollPropertyAdapter.getTop(self.$scrollElement);
|
||||
};
|
||||
},
|
||||
_defineSetters: function () {
|
||||
var self = this,
|
||||
scrollPropertyAdapter = scrollProperty[self.options.scrollProperty],
|
||||
positionPropertyAdapter = positionProperty[self.options.positionProperty],
|
||||
setScrollLeft = scrollPropertyAdapter.setLeft,
|
||||
setScrollTop = scrollPropertyAdapter.setTop;
|
||||
|
||||
this._setScrollLeft = (typeof setScrollLeft === 'function' ? function (val) {
|
||||
setScrollLeft(self.$scrollElement, val);
|
||||
} : $.noop);
|
||||
|
||||
this._setScrollTop = (typeof setScrollTop === 'function' ? function (val) {
|
||||
setScrollTop(self.$scrollElement, val);
|
||||
} : $.noop);
|
||||
|
||||
this._setPosition = positionPropertyAdapter.setPosition ||
|
||||
function ($elem, left, startingLeft, top, startingTop) {
|
||||
if (self.options.horizontalScrolling) {
|
||||
positionPropertyAdapter.setLeft($elem, left, startingLeft);
|
||||
}
|
||||
|
||||
if (self.options.verticalScrolling) {
|
||||
positionPropertyAdapter.setTop($elem, top, startingTop);
|
||||
}
|
||||
};
|
||||
},
|
||||
_handleWindowLoadAndResize: function () {
|
||||
var self = this,
|
||||
$window = $(window);
|
||||
|
||||
if (self.options.responsive) {
|
||||
$window.on('load.' + this.name, function () {
|
||||
self.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
$window.on('resize.' + this.name, function () {
|
||||
self._detectViewport();
|
||||
|
||||
if (self.options.responsive) {
|
||||
self.refresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
refresh: function (options) {
|
||||
var self = this,
|
||||
oldLeft = self._getScrollLeft(),
|
||||
oldTop = self._getScrollTop();
|
||||
|
||||
if (!options || !options.firstLoad) {
|
||||
this._reset();
|
||||
}
|
||||
|
||||
this._setScrollLeft(0);
|
||||
this._setScrollTop(0);
|
||||
|
||||
this._setOffsets();
|
||||
this._findParticles();
|
||||
this._findBackgrounds();
|
||||
|
||||
// Fix for WebKit background rendering bug
|
||||
if (options && options.firstLoad && /WebKit/.test(navigator.userAgent)) {
|
||||
$(window).on('load', function () {
|
||||
var oldLeft = self._getScrollLeft(),
|
||||
oldTop = self._getScrollTop();
|
||||
|
||||
self._setScrollLeft(oldLeft + 1);
|
||||
self._setScrollTop(oldTop + 1);
|
||||
|
||||
self._setScrollLeft(oldLeft);
|
||||
self._setScrollTop(oldTop);
|
||||
});
|
||||
}
|
||||
|
||||
this._setScrollLeft(oldLeft);
|
||||
this._setScrollTop(oldTop);
|
||||
},
|
||||
_detectViewport: function () {
|
||||
var viewportOffsets = this.$viewportElement.offset(),
|
||||
hasOffsets = viewportOffsets !== null && viewportOffsets !== undefined;
|
||||
|
||||
this.viewportWidth = this.$viewportElement.width();
|
||||
this.viewportHeight = this.$viewportElement.height();
|
||||
|
||||
this.viewportOffsetTop = (hasOffsets ? viewportOffsets.top : 0);
|
||||
this.viewportOffsetLeft = (hasOffsets ? viewportOffsets.left : 0);
|
||||
},
|
||||
_findParticles: function () {
|
||||
var self = this,
|
||||
scrollLeft = this._getScrollLeft(),
|
||||
scrollTop = this._getScrollTop();
|
||||
|
||||
if (this.particles !== undefined) {
|
||||
for (var i = this.particles.length - 1; i >= 0; i--) {
|
||||
this.particles[i].$element.data('stellar-elementIsActive', undefined);
|
||||
}
|
||||
}
|
||||
|
||||
this.particles = [];
|
||||
|
||||
if (!this.options.parallaxElements)
|
||||
return;
|
||||
|
||||
this.$element.find('[data-stellar-ratio]').each(function (i) {
|
||||
var $this = $(this),
|
||||
horizontalOffset,
|
||||
verticalOffset,
|
||||
positionLeft,
|
||||
positionTop,
|
||||
marginLeft,
|
||||
marginTop,
|
||||
$offsetParent,
|
||||
offsetLeft,
|
||||
offsetTop,
|
||||
parentOffsetLeft = 0,
|
||||
parentOffsetTop = 0,
|
||||
tempParentOffsetLeft = 0,
|
||||
tempParentOffsetTop = 0;
|
||||
|
||||
// Ensure this element isn't already part of another scrolling element
|
||||
if (!$this.data('stellar-elementIsActive')) {
|
||||
$this.data('stellar-elementIsActive', this);
|
||||
} else if ($this.data('stellar-elementIsActive') !== this) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.options.showElement($this);
|
||||
|
||||
// Save/restore the original top and left CSS values in case we refresh the particles or destroy the instance
|
||||
if (!$this.data('stellar-startingLeft')) {
|
||||
$this.data('stellar-startingLeft', $this.css('left'));
|
||||
$this.data('stellar-startingTop', $this.css('top'));
|
||||
} else {
|
||||
$this.css('left', $this.data('stellar-startingLeft'));
|
||||
$this.css('top', $this.data('stellar-startingTop'));
|
||||
}
|
||||
|
||||
positionLeft = $this.position().left;
|
||||
positionTop = $this.position().top;
|
||||
|
||||
// Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8)
|
||||
marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10);
|
||||
marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10);
|
||||
|
||||
offsetLeft = $this.offset().left - marginLeft;
|
||||
offsetTop = $this.offset().top - marginTop;
|
||||
|
||||
// Calculate the offset parent
|
||||
$this.parents().each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if ($this.data('stellar-offset-parent') === true) {
|
||||
parentOffsetLeft = tempParentOffsetLeft;
|
||||
parentOffsetTop = tempParentOffsetTop;
|
||||
$offsetParent = $this;
|
||||
|
||||
return false;
|
||||
} else {
|
||||
tempParentOffsetLeft += $this.position().left;
|
||||
tempParentOffsetTop += $this.position().top;
|
||||
}
|
||||
});
|
||||
|
||||
// Detect the offsets
|
||||
horizontalOffset = ($this.data('stellar-horizontal-offset') !== undefined ? $this.data('stellar-horizontal-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-horizontal-offset') !== undefined ? $offsetParent.data('stellar-horizontal-offset') : self.horizontalOffset));
|
||||
verticalOffset = ($this.data('stellar-vertical-offset') !== undefined ? $this.data('stellar-vertical-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-vertical-offset') !== undefined ? $offsetParent.data('stellar-vertical-offset') : self.verticalOffset));
|
||||
|
||||
// Add our object to the particles collection
|
||||
self.particles.push({
|
||||
$element: $this,
|
||||
$offsetParent: $offsetParent,
|
||||
isFixed: $this.css('position') === 'fixed',
|
||||
horizontalOffset: horizontalOffset,
|
||||
verticalOffset: verticalOffset,
|
||||
startingPositionLeft: positionLeft,
|
||||
startingPositionTop: positionTop,
|
||||
startingOffsetLeft: offsetLeft,
|
||||
startingOffsetTop: offsetTop,
|
||||
parentOffsetLeft: parentOffsetLeft,
|
||||
parentOffsetTop: parentOffsetTop,
|
||||
stellarRatio: ($this.data('stellar-ratio') !== undefined ? $this.data('stellar-ratio') : 1),
|
||||
width: $this.outerWidth(true),
|
||||
height: $this.outerHeight(true),
|
||||
isHidden: false
|
||||
});
|
||||
});
|
||||
},
|
||||
_findBackgrounds: function () {
|
||||
var self = this,
|
||||
scrollLeft = this._getScrollLeft(),
|
||||
scrollTop = this._getScrollTop(),
|
||||
$backgroundElements;
|
||||
|
||||
this.backgrounds = [];
|
||||
|
||||
if (!this.options.parallaxBackgrounds)
|
||||
return;
|
||||
|
||||
$backgroundElements = this.$element.find('[data-stellar-background-ratio]');
|
||||
|
||||
if (this.$element.data('stellar-background-ratio')) {
|
||||
$backgroundElements = $backgroundElements.add(this.$element);
|
||||
}
|
||||
|
||||
$backgroundElements.each(function () {
|
||||
var $this = $(this),
|
||||
backgroundPosition = getBackgroundPosition($this),
|
||||
horizontalOffset,
|
||||
verticalOffset,
|
||||
positionLeft,
|
||||
positionTop,
|
||||
marginLeft,
|
||||
marginTop,
|
||||
offsetLeft,
|
||||
offsetTop,
|
||||
$offsetParent,
|
||||
parentOffsetLeft = 0,
|
||||
parentOffsetTop = 0,
|
||||
tempParentOffsetLeft = 0,
|
||||
tempParentOffsetTop = 0;
|
||||
|
||||
// Ensure this element isn't already part of another scrolling element
|
||||
if (!$this.data('stellar-backgroundIsActive')) {
|
||||
$this.data('stellar-backgroundIsActive', this);
|
||||
} else if ($this.data('stellar-backgroundIsActive') !== this) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save/restore the original top and left CSS values in case we destroy the instance
|
||||
if (!$this.data('stellar-backgroundStartingLeft')) {
|
||||
$this.data('stellar-backgroundStartingLeft', backgroundPosition[0]);
|
||||
$this.data('stellar-backgroundStartingTop', backgroundPosition[1]);
|
||||
} else {
|
||||
setBackgroundPosition($this, $this.data('stellar-backgroundStartingLeft'), $this.data('stellar-backgroundStartingTop'));
|
||||
}
|
||||
|
||||
// Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8)
|
||||
marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10);
|
||||
marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10);
|
||||
|
||||
offsetLeft = $this.offset().left - marginLeft - scrollLeft;
|
||||
offsetTop = $this.offset().top - marginTop - scrollTop;
|
||||
|
||||
// Calculate the offset parent
|
||||
$this.parents().each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if ($this.data('stellar-offset-parent') === true) {
|
||||
parentOffsetLeft = tempParentOffsetLeft;
|
||||
parentOffsetTop = tempParentOffsetTop;
|
||||
$offsetParent = $this;
|
||||
|
||||
return false;
|
||||
} else {
|
||||
tempParentOffsetLeft += $this.position().left;
|
||||
tempParentOffsetTop += $this.position().top;
|
||||
}
|
||||
});
|
||||
|
||||
// Detect the offsets
|
||||
horizontalOffset = ($this.data('stellar-horizontal-offset') !== undefined ? $this.data('stellar-horizontal-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-horizontal-offset') !== undefined ? $offsetParent.data('stellar-horizontal-offset') : self.horizontalOffset));
|
||||
verticalOffset = ($this.data('stellar-vertical-offset') !== undefined ? $this.data('stellar-vertical-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-vertical-offset') !== undefined ? $offsetParent.data('stellar-vertical-offset') : self.verticalOffset));
|
||||
|
||||
self.backgrounds.push({
|
||||
$element: $this,
|
||||
$offsetParent: $offsetParent,
|
||||
isFixed: $this.css('background-attachment') === 'fixed',
|
||||
horizontalOffset: horizontalOffset,
|
||||
verticalOffset: verticalOffset,
|
||||
startingValueLeft: backgroundPosition[0],
|
||||
startingValueTop: backgroundPosition[1],
|
||||
startingBackgroundPositionLeft: (isNaN(parseInt(backgroundPosition[0], 10)) ? 0 : parseInt(backgroundPosition[0], 10)),
|
||||
startingBackgroundPositionTop: (isNaN(parseInt(backgroundPosition[1], 10)) ? 0 : parseInt(backgroundPosition[1], 10)),
|
||||
startingPositionLeft: $this.position().left,
|
||||
startingPositionTop: $this.position().top,
|
||||
startingOffsetLeft: offsetLeft,
|
||||
startingOffsetTop: offsetTop,
|
||||
parentOffsetLeft: parentOffsetLeft,
|
||||
parentOffsetTop: parentOffsetTop,
|
||||
stellarRatio: ($this.data('stellar-background-ratio') === undefined ? 1 : $this.data('stellar-background-ratio'))
|
||||
});
|
||||
});
|
||||
},
|
||||
_reset: function () {
|
||||
var particle,
|
||||
startingPositionLeft,
|
||||
startingPositionTop,
|
||||
background,
|
||||
i;
|
||||
|
||||
for (i = this.particles.length - 1; i >= 0; i--) {
|
||||
particle = this.particles[i];
|
||||
startingPositionLeft = particle.$element.data('stellar-startingLeft');
|
||||
startingPositionTop = particle.$element.data('stellar-startingTop');
|
||||
|
||||
this._setPosition(particle.$element, startingPositionLeft, startingPositionLeft, startingPositionTop, startingPositionTop);
|
||||
|
||||
this.options.showElement(particle.$element);
|
||||
|
||||
particle.$element.data('stellar-startingLeft', null).data('stellar-elementIsActive', null).data('stellar-backgroundIsActive', null);
|
||||
}
|
||||
|
||||
for (i = this.backgrounds.length - 1; i >= 0; i--) {
|
||||
background = this.backgrounds[i];
|
||||
|
||||
background.$element.data('stellar-backgroundStartingLeft', null).data('stellar-backgroundStartingTop', null);
|
||||
|
||||
setBackgroundPosition(background.$element, background.startingValueLeft, background.startingValueTop);
|
||||
}
|
||||
},
|
||||
destroy: function () {
|
||||
this._reset();
|
||||
|
||||
this.$scrollElement.off('resize.' + this.name).off('scroll.' + this.name);
|
||||
this._animationLoop = $.noop;
|
||||
|
||||
$(window).off('load.' + this.name).off('resize.' + this.name);
|
||||
},
|
||||
_setOffsets: function () {
|
||||
var self = this,
|
||||
$window = $(window);
|
||||
|
||||
$window.off('resize.horizontal-' + this.name).off('resize.vertical-' + this.name);
|
||||
|
||||
if (typeof this.options.horizontalOffset === 'function') {
|
||||
this.horizontalOffset = this.options.horizontalOffset();
|
||||
$window.on('resize.horizontal-' + this.name, function () {
|
||||
self.horizontalOffset = self.options.horizontalOffset();
|
||||
});
|
||||
} else {
|
||||
this.horizontalOffset = this.options.horizontalOffset;
|
||||
}
|
||||
|
||||
if (typeof this.options.verticalOffset === 'function') {
|
||||
this.verticalOffset = this.options.verticalOffset();
|
||||
$window.on('resize.vertical-' + this.name, function () {
|
||||
self.verticalOffset = self.options.verticalOffset();
|
||||
});
|
||||
} else {
|
||||
this.verticalOffset = this.options.verticalOffset;
|
||||
}
|
||||
},
|
||||
_repositionElements: function () {
|
||||
var scrollLeft = this._getScrollLeft(),
|
||||
scrollTop = this._getScrollTop(),
|
||||
horizontalOffset,
|
||||
verticalOffset,
|
||||
particle,
|
||||
fixedRatioOffset,
|
||||
background,
|
||||
bgLeft,
|
||||
bgTop,
|
||||
isVisibleVertical = true,
|
||||
isVisibleHorizontal = true,
|
||||
newPositionLeft,
|
||||
newPositionTop,
|
||||
newOffsetLeft,
|
||||
newOffsetTop,
|
||||
i;
|
||||
|
||||
// First check that the scroll position or container size has changed
|
||||
if (this.currentScrollLeft === scrollLeft && this.currentScrollTop === scrollTop && this.currentWidth === this.viewportWidth && this.currentHeight === this.viewportHeight) {
|
||||
return;
|
||||
} else {
|
||||
this.currentScrollLeft = scrollLeft;
|
||||
this.currentScrollTop = scrollTop;
|
||||
this.currentWidth = this.viewportWidth;
|
||||
this.currentHeight = this.viewportHeight;
|
||||
}
|
||||
|
||||
// Reposition elements
|
||||
for (i = this.particles.length - 1; i >= 0; i--) {
|
||||
particle = this.particles[i];
|
||||
|
||||
fixedRatioOffset = (particle.isFixed ? 1 : 0);
|
||||
|
||||
// Calculate position, then calculate what the particle's new offset will be (for visibility check)
|
||||
if (this.options.horizontalScrolling) {
|
||||
newPositionLeft = (scrollLeft + particle.horizontalOffset + this.viewportOffsetLeft + particle.startingPositionLeft - particle.startingOffsetLeft + particle.parentOffsetLeft) * -(particle.stellarRatio + fixedRatioOffset - 1) + particle.startingPositionLeft;
|
||||
newOffsetLeft = newPositionLeft - particle.startingPositionLeft + particle.startingOffsetLeft;
|
||||
} else {
|
||||
newPositionLeft = particle.startingPositionLeft;
|
||||
newOffsetLeft = particle.startingOffsetLeft;
|
||||
}
|
||||
|
||||
if (this.options.verticalScrolling) {
|
||||
newPositionTop = (scrollTop + particle.verticalOffset + this.viewportOffsetTop + particle.startingPositionTop - particle.startingOffsetTop + particle.parentOffsetTop) * -(particle.stellarRatio + fixedRatioOffset - 1) + particle.startingPositionTop;
|
||||
newOffsetTop = newPositionTop - particle.startingPositionTop + particle.startingOffsetTop;
|
||||
} else {
|
||||
newPositionTop = particle.startingPositionTop;
|
||||
newOffsetTop = particle.startingOffsetTop;
|
||||
}
|
||||
|
||||
// Check visibility
|
||||
if (this.options.hideDistantElements) {
|
||||
isVisibleHorizontal = !this.options.horizontalScrolling || newOffsetLeft + particle.width > (particle.isFixed ? 0 : scrollLeft) && newOffsetLeft < (particle.isFixed ? 0 : scrollLeft) + this.viewportWidth + this.viewportOffsetLeft;
|
||||
isVisibleVertical = !this.options.verticalScrolling || newOffsetTop + particle.height > (particle.isFixed ? 0 : scrollTop) && newOffsetTop < (particle.isFixed ? 0 : scrollTop) + this.viewportHeight + this.viewportOffsetTop;
|
||||
}
|
||||
|
||||
if (isVisibleHorizontal && isVisibleVertical) {
|
||||
if (particle.isHidden) {
|
||||
this.options.showElement(particle.$element);
|
||||
particle.isHidden = false;
|
||||
}
|
||||
|
||||
this._setPosition(particle.$element, newPositionLeft, particle.startingPositionLeft, newPositionTop, particle.startingPositionTop);
|
||||
} else {
|
||||
if (!particle.isHidden) {
|
||||
this.options.hideElement(particle.$element);
|
||||
particle.isHidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reposition backgrounds
|
||||
for (i = this.backgrounds.length - 1; i >= 0; i--) {
|
||||
background = this.backgrounds[i];
|
||||
|
||||
fixedRatioOffset = (background.isFixed ? 0 : 1);
|
||||
bgLeft = (this.options.horizontalScrolling ? (scrollLeft + background.horizontalOffset - this.viewportOffsetLeft - background.startingOffsetLeft + background.parentOffsetLeft - background.startingBackgroundPositionLeft) * (fixedRatioOffset - background.stellarRatio) + 'px' : background.startingValueLeft);
|
||||
bgTop = (this.options.verticalScrolling ? (scrollTop + background.verticalOffset - this.viewportOffsetTop - background.startingOffsetTop + background.parentOffsetTop - background.startingBackgroundPositionTop) * (fixedRatioOffset - background.stellarRatio) + 'px' : background.startingValueTop);
|
||||
|
||||
setBackgroundPosition(background.$element, bgLeft, bgTop);
|
||||
}
|
||||
},
|
||||
_handleScrollEvent: function () {
|
||||
var self = this,
|
||||
ticking = false;
|
||||
|
||||
var update = function () {
|
||||
self._repositionElements();
|
||||
ticking = false;
|
||||
};
|
||||
|
||||
var requestTick = function () {
|
||||
if (!ticking) {
|
||||
requestAnimFrame(update);
|
||||
ticking = true;
|
||||
}
|
||||
};
|
||||
|
||||
this.$scrollElement.on('scroll.' + this.name, requestTick);
|
||||
requestTick();
|
||||
},
|
||||
_startAnimationLoop: function () {
|
||||
var self = this;
|
||||
|
||||
this._animationLoop = function () {
|
||||
requestAnimFrame(self._animationLoop);
|
||||
self._repositionElements();
|
||||
};
|
||||
this._animationLoop();
|
||||
}
|
||||
};
|
||||
|
||||
$.fn[pluginName] = function (options) {
|
||||
var args = arguments;
|
||||
if (options === undefined || typeof options === 'object') {
|
||||
return this.each(function () {
|
||||
if (!$.data(this, 'plugin_' + pluginName)) {
|
||||
$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
|
||||
}
|
||||
});
|
||||
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
||||
return this.each(function () {
|
||||
var instance = $.data(this, 'plugin_' + pluginName);
|
||||
if (instance instanceof Plugin && typeof instance[options] === 'function') {
|
||||
instance[options].apply(instance, Array.prototype.slice.call(args, 1));
|
||||
}
|
||||
if (options === 'destroy') {
|
||||
$.data(this, 'plugin_' + pluginName, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$[pluginName] = function (options) {
|
||||
var $window = $(window);
|
||||
return $window.stellar.apply($window, Array.prototype.slice.call(arguments, 0));
|
||||
};
|
||||
|
||||
// Expose the scroll and position property function hashes so they can be extended
|
||||
$[pluginName].scrollProperty = scrollProperty;
|
||||
$[pluginName].positionProperty = positionProperty;
|
||||
|
||||
// Expose the plugin class so it can be modified
|
||||
window.Stellar = Plugin;
|
||||
}(jQuery, this, document));
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
"use strict";
|
||||
|
||||
if ($('.nasa-parallax-stellar').length) {
|
||||
$(window).stellar();
|
||||
}
|
||||
|
||||
$('body').on('nasa_parallax_breadcrum', function() {
|
||||
if ($('.nasa-parallax-stellar').length) {
|
||||
$(window).stellar('refresh');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,792 @@
|
||||
/* Document ready */
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
var _mobileView = $('.nasa-check-reponsive.nasa-switch-check').length && $('.nasa-check-reponsive.nasa-switch-check').width() === 1 ? true : false;
|
||||
|
||||
/**
|
||||
* Fix vertical mega menu
|
||||
*/
|
||||
var width_default = 200;
|
||||
$('body').on('mousemove', '.vertical-menu-container .nasa-megamenu', function() {
|
||||
var _wrap = $(this).parents('.vertical-menu-wrapper');
|
||||
var _h_vertical = $(_wrap).outerHeight();
|
||||
|
||||
$(_wrap).find('.nasa-megamenu').removeClass('nasa-curent-hover');
|
||||
$(_wrap).addClass('nasa-curent-hover');
|
||||
|
||||
/**
|
||||
* For WPBakery
|
||||
*/
|
||||
var _row = $(_wrap).parents('.row').length ? $(_wrap).parents('.row') : $(_wrap).parents('.nasa-row');
|
||||
|
||||
/**
|
||||
* For Elementor
|
||||
*/
|
||||
if ($(_row).length <= 0) {
|
||||
_row = $(_wrap).parents('.elementor-container');
|
||||
}
|
||||
|
||||
var _w_mega, _w_mega_df, _w_ss;
|
||||
var total_w = $(_row).length ? $(_row).width() : 900;
|
||||
|
||||
$(_wrap).find('.nasa-megamenu').each(function() {
|
||||
var _this = $(this);
|
||||
|
||||
var current_w = $(_this).outerWidth();
|
||||
_w_mega = _w_mega_df = total_w - current_w;
|
||||
|
||||
if ($(_this).hasClass('cols-5') || $(_this).hasClass('fullwidth')) {
|
||||
_w_mega = _w_mega - 20;
|
||||
} else {
|
||||
if ($(_this).hasClass('cols-2')) {
|
||||
_w_mega = _w_mega / 5 * 2 + 50;
|
||||
_w_ss = width_default * 2;
|
||||
_w_mega = (_w_ss > _w_mega && _w_ss < _w_mega_df) ? _w_ss : _w_mega;
|
||||
}
|
||||
else if ($(_this).hasClass('cols-3')) {
|
||||
_w_mega = _w_mega / 5 * 3 + 50;
|
||||
_w_ss = width_default * 3;
|
||||
_w_mega = (_w_ss > _w_mega && _w_ss < _w_mega_df) ? _w_ss : _w_mega;
|
||||
}
|
||||
else if ($(_this).hasClass('cols-4')) {
|
||||
_w_mega = _w_mega / 5 * 4 + 50;
|
||||
_w_ss = width_default * 4;
|
||||
_w_mega = (_w_ss > _w_mega && _w_ss < _w_mega_df) ? _w_ss : _w_mega;
|
||||
}
|
||||
}
|
||||
|
||||
$(_this).find('>.nav-dropdown').css({'width': _w_mega}).show();
|
||||
if ($(_this).find('>.nav-dropdown >.sub-menu').length) {
|
||||
$(_this).find('>.nav-dropdown >.sub-menu').css({'min-height': _h_vertical});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('mouseover', '.vertical-menu-wrapper .menu-item-has-children.default-menu', function() {
|
||||
var _wrap = $(this).parents('.vertical-menu-wrapper');
|
||||
$(this).find('> .nav-dropdown > .sub-menu').css({'width': width_default});
|
||||
|
||||
/**
|
||||
* For WPBakery
|
||||
*/
|
||||
var _row = $(_wrap).parents('.row').length ? $(_wrap).parents('.row') : $(_wrap).parents('.nasa-row');
|
||||
|
||||
/**
|
||||
* For Elementor
|
||||
*/
|
||||
if ($(_row).length <= 0) {
|
||||
_row = $(_wrap).parents('.elementor-container');
|
||||
}
|
||||
|
||||
var _w_mega, _w_mega_df, _w_ss;
|
||||
var total_w = $(_row).length ? $(_row).width() : 900;
|
||||
|
||||
$(_wrap).find('.nasa-megamenu').each(function() {
|
||||
var _this = $(this);
|
||||
|
||||
var current_w = $(_this).outerWidth();
|
||||
_w_mega = _w_mega_df = total_w - current_w;
|
||||
|
||||
if ($(_this).hasClass('cols-5') || $(_this).hasClass('fullwidth')) {
|
||||
_w_mega = _w_mega - 20;
|
||||
} else {
|
||||
if ($(_this).hasClass('cols-2')) {
|
||||
_w_mega = _w_mega / 5 * 2 + 50;
|
||||
_w_ss = width_default * 2;
|
||||
_w_mega = (_w_ss > _w_mega && _w_ss < _w_mega_df) ? _w_ss : _w_mega;
|
||||
}
|
||||
else if ($(_this).hasClass('cols-3')) {
|
||||
_w_mega = _w_mega / 5 * 3 + 50;
|
||||
_w_ss = width_default * 3;
|
||||
_w_mega = (_w_ss > _w_mega && _w_ss < _w_mega_df) ? _w_ss : _w_mega;
|
||||
}
|
||||
else if ($(_this).hasClass('cols-4')) {
|
||||
_w_mega = _w_mega / 5 * 4 + 50;
|
||||
_w_ss = width_default * 4;
|
||||
_w_mega = (_w_ss > _w_mega && _w_ss < _w_mega_df) ? _w_ss : _w_mega;
|
||||
}
|
||||
}
|
||||
|
||||
$(_this).find('>.nav-dropdown').css({'width': _w_mega});
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('nasa_index_menu_root_items', function() {
|
||||
if (!$('.nasa-header-canvas #site-navigation').hasClass('indexed')) {
|
||||
if ($('.nasa-header-canvas #site-navigation .root-item').length) {
|
||||
var _k = 0;
|
||||
$('.nasa-header-canvas #site-navigation .root-item').each(function() {
|
||||
$(this).attr('data-index', _k);
|
||||
_k++;
|
||||
});
|
||||
}
|
||||
|
||||
$('.nasa-header-canvas #site-navigation').addClass('indexed');
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('nasa_header_canvas', function() {
|
||||
if ($('.nasa-header-canvas #site-navigation').length) {
|
||||
$('body').trigger('nasa_index_menu_root_items');
|
||||
|
||||
if ($('.nasa-header-canvas #site-navigation .root-item.act').length < 1) {
|
||||
var _current = null;
|
||||
if ($('.nasa-header-canvas #site-navigation .root-item.current-menu-item').length) {
|
||||
_current = $('.nasa-header-canvas #site-navigation .root-item.current-menu-item').eq(0);
|
||||
} else if ($('.nasa-header-canvas #site-navigation .root-item.current-menu-ancestor').length) {
|
||||
_current = $('.nasa-header-canvas #site-navigation .root-item.current-menu-ancestor').eq(0);
|
||||
} else if ($('.nasa-header-canvas #site-navigation .root-item.current-menu-parent').length) {
|
||||
_current = $('.nasa-header-canvas #site-navigation .root-item.current-menu-parent').eq(0);
|
||||
} else {
|
||||
_current = $('.nasa-header-canvas #site-navigation .root-item:first-child');
|
||||
}
|
||||
|
||||
if ($(_current).length) {
|
||||
$(_current).addClass('act');
|
||||
$('body').trigger('nasa_render_template', [_current]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('mousemove', '.nasa-header-canvas #site-navigation .root-item', function() {
|
||||
var _this = $(this);
|
||||
|
||||
$('body').trigger('nasa_index_menu_root_items');
|
||||
|
||||
var _index = $(_this).attr('data-index');
|
||||
$('.nasa-header-canvas #site-navigation .root-item').each(function() {
|
||||
var _cur = $(this).attr('data-index');
|
||||
if (_index === _cur) {
|
||||
if (!$(this).hasClass('act')) {
|
||||
$(this).addClass('act');
|
||||
}
|
||||
} else {
|
||||
$(this).removeClass('act');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* After Load Ajax
|
||||
*/
|
||||
$('body').on('nasa_after_loaded_ajax_complete', function() {
|
||||
$('body').trigger('nasa_header_canvas');
|
||||
});
|
||||
|
||||
/**
|
||||
* Header Responsive
|
||||
*/
|
||||
init_header_responsive($);
|
||||
|
||||
/**
|
||||
* Fix width menu vertical
|
||||
*/
|
||||
resize_megamenu_vertical($);
|
||||
|
||||
$('body').on('click', '.vroot-show-more', function() {
|
||||
var _wrap = $(this).parents('.vertical-menu-wrapper');
|
||||
|
||||
$(_wrap).find('.vroot-hidden').fadeIn();
|
||||
|
||||
$(_wrap).find('.menu-show-more').remove();
|
||||
});
|
||||
|
||||
var _loadingBeforeResize;
|
||||
if (!_mobileView && $(window).width() < 1200) {
|
||||
_loadingBeforeResize = setTimeout(function() {
|
||||
/**
|
||||
* Main menu Reponsive
|
||||
*/
|
||||
load_responsive_main_menu($);
|
||||
}, 5);
|
||||
}
|
||||
|
||||
$(window).on('resize', function() {
|
||||
_mobileView = $('.nasa-check-reponsive.nasa-switch-check').length && $('.nasa-check-reponsive.nasa-switch-check').width() === 1 ? true : false;
|
||||
|
||||
if ($('.nasa-modern-layout.nasa-show').length) {
|
||||
var _form_search = $('.nasa-modern-layout.nasa-show');
|
||||
$('body').trigger('search_icon_position', [_form_search]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Header Responsive
|
||||
*/
|
||||
if (_mobileView) {
|
||||
init_header_responsive($);
|
||||
}
|
||||
|
||||
/**
|
||||
* Active Filter cat top
|
||||
*/
|
||||
init_top_categories_filter($);
|
||||
|
||||
if (!_mobileView) {
|
||||
/* Fix width menu vertical */
|
||||
if ($('.wide-nav .vertical-menu-container').length) {
|
||||
$('.wide-nav .vertical-menu-container').each(function() {
|
||||
var _v_menu = $(this);
|
||||
if ($(_v_menu).parents('.vitems-root').length < 1) {
|
||||
var _v_width = $(_v_menu).parents('.nasa-vertical-header').length ? $(_v_menu).parents('.nasa-vertical-header').width() : 0;
|
||||
_v_width = _v_width < 280 ? 280: _v_width;
|
||||
$(_v_menu).css({'width': _v_width});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (typeof _loadingBeforeResize !== 'undefined') {
|
||||
clearTimeout(_loadingBeforeResize);
|
||||
}
|
||||
_loadingBeforeResize = setTimeout(function() {
|
||||
/**
|
||||
* Main menu Reponsive
|
||||
*/
|
||||
load_responsive_main_menu($);
|
||||
}, 1100);
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('nasa_init_topbar_categories', function() {
|
||||
init_top_categories_filter($);
|
||||
});
|
||||
|
||||
/**
|
||||
* nasa-top-cat-filter
|
||||
*/
|
||||
init_top_categories_filter($);
|
||||
|
||||
/**
|
||||
* hover top categories filter
|
||||
*/
|
||||
$('body').on('mouseover', '.nasa-top-cat-filter .root-item', function() {
|
||||
var _obj = $(this),
|
||||
_wrap = $(_obj).parents('.nasa-top-cat-filter');
|
||||
|
||||
$(_wrap).find('.root-item').removeClass('nasa-current-top');
|
||||
$(_obj).addClass('nasa-current-top');
|
||||
|
||||
var _pos = $(_obj).position();
|
||||
|
||||
var _note_act = $(_wrap).find('> .nasa-current-note');
|
||||
|
||||
$(_note_act).css({
|
||||
width: $(_obj).width(),
|
||||
left: _pos.left,
|
||||
top: ($(_obj).height() - 1) + _pos.top - 1
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* hover top child categories filter
|
||||
*/
|
||||
$('body').on('mouseover', '.nasa-top-cat-filter .children .cat-item', function() {
|
||||
var _obj = $(this),
|
||||
_wrap = $(_obj).parent('.children');
|
||||
var _note_act = $(_wrap).find('>.nasa-current-note');
|
||||
|
||||
if ($(_note_act).length <= 0) {
|
||||
$(_wrap).prepend('<li class="nasa-current-note"></li>');
|
||||
_note_act = $(_wrap).find('>.nasa-current-note');
|
||||
}
|
||||
|
||||
$(_wrap).find('.cat-item').removeClass('nasa-current-child');
|
||||
$(_obj).addClass('nasa-current-child');
|
||||
|
||||
var _pos = $(_obj).position();
|
||||
|
||||
$(_note_act).css({
|
||||
width: $(_obj).width(),
|
||||
left: _pos.left,
|
||||
top: ($(_obj).height() - 1) + _pos.top - 1
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* In Desktop Search
|
||||
* @type Boolean
|
||||
*/
|
||||
var _hotkeyInit = false;
|
||||
$('body').on('click', '.desk-search', function(e) {
|
||||
var _this_click = $(this);
|
||||
var _root_search = $(_this_click).parents('.nasa-wrap-event-search');
|
||||
if ($(_root_search).find('.nasa-tmpl-search').length) {
|
||||
var _content = $(_root_search).find('.nasa-tmpl-search').html();
|
||||
$(_root_search).find('.nasa-tmpl-search').replaceWith(_content);
|
||||
}
|
||||
|
||||
if (!$(_this_click).hasClass('nasa-disable')) {
|
||||
$(_this_click).addClass('nasa-disable');
|
||||
|
||||
setTimeout(function() {
|
||||
var _focus_input = $(_this_click).parents('.nasa-wrap-event-search').find('.nasa-show-search-form');
|
||||
var _opened = $(_this_click).attr('data-open');
|
||||
|
||||
if (_opened === '0') {
|
||||
$('#header-content').find('.nasa-show-search-form').after('<div class="nasa-tranparent" />');
|
||||
} else {
|
||||
$('#header-content').find('.nasa-tranparent').remove();
|
||||
}
|
||||
|
||||
$('body').trigger('search_icon_position', [_focus_input]);
|
||||
|
||||
$('.desk-search').each(function() {
|
||||
var _this = $(this);
|
||||
var _root_wrap = $(_this).parents('.nasa-wrap-event-search');
|
||||
var _elements = $(_root_wrap).find('.nasa-elements-wrap');
|
||||
|
||||
var _search = $(_root_wrap).find('.nasa-show-search-form');
|
||||
|
||||
if (typeof _opened === 'undefined' || _opened === '0') {
|
||||
$(_this).attr('data-open', '1');
|
||||
if (!$(_search).hasClass('nasa-show')) {
|
||||
$(_search).addClass('nasa-show');
|
||||
}
|
||||
|
||||
if (!$(_search).hasClass('nasa-modern-layout')) {
|
||||
$(_elements).addClass('nasa-invisible');
|
||||
}
|
||||
} else {
|
||||
$(_this).attr('data-open', '0');
|
||||
if ($(_search).hasClass('nasa-show')) {
|
||||
$(_search).removeClass('nasa-show');
|
||||
}
|
||||
|
||||
$(_elements).removeClass('nasa-invisible');
|
||||
}
|
||||
});
|
||||
|
||||
if (_hotkeyInit) {
|
||||
setTimeout(function() {
|
||||
$(_this_click).removeClass('nasa-disable');
|
||||
|
||||
if ($(_focus_input).find('label').length) {
|
||||
$(_focus_input).find('label').trigger('click');
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
$(_this_click).removeClass('nasa-disable');
|
||||
|
||||
/**
|
||||
* Hot keywords search
|
||||
*/
|
||||
setTimeout(function() {
|
||||
_hotkeyInit = true;
|
||||
var _oldStr = '';
|
||||
|
||||
if ($(_focus_input).find('input[name="s"]').length) {
|
||||
var _inputCurrent = $(_focus_input).find('input[name="s"]');
|
||||
_oldStr = $(_inputCurrent).val();
|
||||
|
||||
if (_oldStr !== '') {
|
||||
$(_inputCurrent).val(_oldStr);
|
||||
}
|
||||
|
||||
auto_fill_input_placeholder($, _inputCurrent);
|
||||
|
||||
if ($(_focus_input).find('label').length) {
|
||||
$(_focus_input).find('label').trigger('click');
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$('body').on('search_icon_position', function(e, _form_input) {
|
||||
if ($(_form_input).hasClass('nasa-modern-layout')) {
|
||||
if ($('#header-content .nasa-tranparent').length && !$('#header-content .nasa-tranparent').hasClass('bg-black')) {
|
||||
$('#header-content .nasa-tranparent').addClass('bg-black');
|
||||
}
|
||||
|
||||
if ($('#wpadminbar').length) {
|
||||
var _top = $('#wpadminbar').height();
|
||||
$(_form_input).css({'top': _top});
|
||||
}
|
||||
|
||||
if ($(_form_input).find('.nasa-icon-submit-page').length) {
|
||||
var _icon = $(_form_input).find('.nasa-icon-submit-page');
|
||||
var _input_off = $(_form_input).find('input[name="s"]').offset();
|
||||
var _width = $('body').hasClass('nasa-rtl') ? 0 : $(_form_input).find('input[name="s"]').width() - $(_icon).width();
|
||||
$(_icon).css({
|
||||
left: _input_off.left + _width,
|
||||
right: 'auto',
|
||||
visibility: 'visible',
|
||||
opacity: '0.3'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* nasa-top-cat-filter
|
||||
*/
|
||||
$('body').on('click', '.filter-cat-icon', function() {
|
||||
var _this_click = $(this);
|
||||
|
||||
if (!$(_this_click).hasClass('nasa-disable')) {
|
||||
$(_this_click).addClass('nasa-disable');
|
||||
|
||||
if ($('#nasa-main-cat-filter .nasa-tmpl').length) {
|
||||
var _content = $('#nasa-main-cat-filter .nasa-tmpl').html();
|
||||
$('#nasa-main-cat-filter .nasa-tmpl').replaceWith(_content);
|
||||
|
||||
if ($('#nasa-main-cat-filter .current-cat').length) {
|
||||
$('#nasa-main-cat-filter').find('.current-cat-parent, .current-cat').trigger('mouseover');
|
||||
} else {
|
||||
$('#nasa-main-cat-filter .root-item:first-child').trigger('mouseover');
|
||||
}
|
||||
}
|
||||
|
||||
$('.nasa-elements-wrap').addClass('nasa-invisible');
|
||||
$('#header-content .nasa-top-cat-filter-wrap').addClass('nasa-show');
|
||||
if ($('.nasa-has-filter-ajax').length <= 0) {
|
||||
$('#header-content .nasa-top-cat-filter-wrap').before('<div class="nasa-tranparent-filter nasa-hide-for-mobile" />');
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
$(_this_click).removeClass('nasa-disable');
|
||||
}, 600);
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('mouseover', '.product-item', function() {
|
||||
var _this = $(this);
|
||||
var _toggle = $('input[name="nasa-toggle-width-product-content"]').length ? parseInt($('input[name="nasa-toggle-width-product-content"]').val()) : 180;
|
||||
|
||||
if ($(_this).outerWidth() < _toggle) {
|
||||
if (
|
||||
$(_this).find('.add-to-cart-grid').length &&
|
||||
!$(_this).find('.add-to-cart-grid').hasClass('nasa-disabled-hover')
|
||||
) {
|
||||
$(_this).find('.add-to-cart-grid').addClass('nasa-disabled-hover');
|
||||
}
|
||||
|
||||
if (
|
||||
$(_this).find('.nasa-sc-pdeal-countdown') &&
|
||||
!$(_this).find('.nasa-sc-pdeal-countdown').hasClass('nasa-countdown-small')) {
|
||||
$(_this).find('.nasa-sc-pdeal-countdown').addClass('nasa-countdown-small');
|
||||
}
|
||||
} else {
|
||||
if ($(_this).find('.add-to-cart-grid').length) {
|
||||
$(_this).find('.add-to-cart-grid').removeClass('nasa-disabled-hover');
|
||||
}
|
||||
|
||||
if ($(_this).find('.nasa-sc-pdeal-countdown')) {
|
||||
$(_this).find('.nasa-sc-pdeal-countdown').removeClass('nasa-countdown-small');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* For Header Type 5
|
||||
*/
|
||||
$('body').on('click', '.nasa-menu-off', function() {
|
||||
init_header_responsive($);
|
||||
|
||||
if ($('#nasa-menu-sidebar-content').length && !$('#nasa-menu-sidebar-content').hasClass('all-screen')) {
|
||||
$('#nasa-menu-sidebar-content').addClass('all-screen');
|
||||
}
|
||||
|
||||
if ($('.nasa-mobile-menu_toggle').length) {
|
||||
$('.nasa-mobile-menu_toggle').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* For Header Type 7
|
||||
*/
|
||||
$('body').on('click', '.nasa-header-off', function() {
|
||||
$('body').trigger('nasa_header_canvas');
|
||||
|
||||
if ($('.nasa-header-canvas').length && !$('.nasa-header-canvas').hasClass('nasa-active')) {
|
||||
$('.nasa-header-canvas').addClass('nasa-active');
|
||||
}
|
||||
|
||||
if (!$('body').hasClass('ovhd')) {
|
||||
$('body').addClass('ovhd');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* After loaded ajax store
|
||||
*/
|
||||
$('body').on('nasa_after_loaded_ajax_complete', function(e) {
|
||||
init_header_responsive($);
|
||||
resize_megamenu_vertical($);
|
||||
load_responsive_main_menu($);
|
||||
});
|
||||
|
||||
/* End Document Ready */
|
||||
});
|
||||
|
||||
/**
|
||||
* Main menu Reponsive
|
||||
*
|
||||
* @param {type} $
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function load_responsive_main_menu($) {
|
||||
var _disable = $('body').hasClass('disable-flexible-menu') ? true : false;
|
||||
|
||||
if (!_disable) {
|
||||
var _mobileView = $('.nasa-check-reponsive.nasa-switch-check').length && $('.nasa-check-reponsive.nasa-switch-check').width() === 1 ? true : false;
|
||||
|
||||
if (!_mobileView && $('.nasa-menus-wrapper-reponsive').length) {
|
||||
var _wwin = $(window).width();
|
||||
|
||||
var _maxrow = 1200;
|
||||
|
||||
if ($('[name="nsmw-page"]').length) {
|
||||
_maxrow = parseInt($('[name="nsmw-page"]').attr('content'));
|
||||
}
|
||||
|
||||
else if ($('[name="nsmw-cat"]').length) {
|
||||
_maxrow = parseInt($('[name="nsmw-cat"]').attr('content'));
|
||||
}
|
||||
|
||||
else if ($('[name="nsmw-theme"]').length) {
|
||||
_maxrow = parseInt($('[name="nsmw-theme"]').val());
|
||||
}
|
||||
|
||||
$('.nasa-menus-wrapper-reponsive').each(function() {
|
||||
|
||||
var _this = $(this);
|
||||
|
||||
var _tl = _wwin/_maxrow;
|
||||
if (_tl < 1) {
|
||||
var _x = $(_this).attr('data-padding_x');
|
||||
var _params = {'font-size': (100*_tl).toString() + '%'};
|
||||
|
||||
if (!$('body').hasClass('nasa-rtl')) {
|
||||
_params['margin-right'] = (_tl*_x).toString() + 'px';
|
||||
_params['margin-left'] = '0';
|
||||
} else {
|
||||
_params['margin-left'] = (_tl*_x).toString() + 'px';
|
||||
_params['margin-right'] = '0';
|
||||
}
|
||||
|
||||
$(_this).find('.header-nav > li > a').css(_params);
|
||||
|
||||
if ($(_this).find('.nasa-title-vertical-menu').length) {
|
||||
$(_this).find('.nasa-title-vertical-menu').css({
|
||||
'font-size': (100*_tl).toString() + '%'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
$(_this).find('.header-nav > li > a').removeAttr('style');
|
||||
if ($(_this).find('.nasa-title-vertical-menu').length) {
|
||||
$(_this).find('.nasa-title-vertical-menu').removeAttr('style');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize Menu Vertical
|
||||
*
|
||||
* @param {type} $
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function resize_megamenu_vertical($) {
|
||||
if ($('.wide-nav .vertical-menu-container').length) {
|
||||
$('.wide-nav .vertical-menu-container').each(function() {
|
||||
var _v_menu = $(this);
|
||||
|
||||
if ($(_v_menu).parents('.vitems-root').length < 1) {
|
||||
var _v_width = $(_v_menu).parents('.nasa-vertical-header').length ? $(_v_menu).parents('.nasa-vertical-header').width() : 0;
|
||||
_v_width = _v_width < 280 ? 280: _v_width;
|
||||
$(_v_menu).css({'width': _v_width});
|
||||
} else {
|
||||
var _vroot = $(_v_menu).parents('.vitems-root');
|
||||
var _limit = parseInt($(_vroot).attr('data-limit'));
|
||||
|
||||
if (_limit && $(_v_menu).find('.menu-item').length > _limit) {
|
||||
|
||||
var _text = $(_vroot).attr('data-more');
|
||||
var _k = 0;
|
||||
|
||||
$(_v_menu).find('.menu-item').each(function() {
|
||||
var _item = $(this);
|
||||
if (_k >= _limit) {
|
||||
$(_item).addClass('vroot-hidden');
|
||||
}
|
||||
_k++;
|
||||
});
|
||||
|
||||
$(_v_menu).find('.vertical-menu-wrapper').append('<li class="menu-show-more"><a class="vroot-show-more" href="javascript:void(0);" rel="nofollow"><svg class="margin-right-5 rtl-margin-right-0 rtl-margin-left-5" width="15" height="15" viewBox="0 0 32 32" fill="currentColor"><path d="M16 2.672c-7.362 0-13.328 5.966-13.328 13.328s5.966 13.328 13.328 13.328c7.362 0 13.328-5.966 13.328-13.328s-5.966-13.328-13.328-13.328zM16 28.262c-6.761 0-12.262-5.501-12.262-12.262s5.501-12.262 12.262-12.262c6.761 0 12.262 5.501 12.262 12.262s-5.501 12.262-12.262 12.262z"/><path d="M16.533 8.003h-1.066v7.464h-7.428v1.066h7.428v7.428h1.066v-7.428h7.464v-1.066h-7.464z"/></svg>' + _text + '</a></li>');
|
||||
}
|
||||
}
|
||||
|
||||
// if ($(_v_menu).hasClass('nasa-allways-show')) {
|
||||
// $(_v_menu).addClass('nasa-active');
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Top categories filter
|
||||
*
|
||||
* @param {type} $
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function init_top_categories_filter($) {
|
||||
if ($('.nasa-top-cat-filter').length) {
|
||||
var _act;
|
||||
var _obj;
|
||||
|
||||
$('.nasa-top-cat-filter').each(function() {
|
||||
var _this_filter = $(this);
|
||||
var _root_item = $(_this_filter).find('.root-item');
|
||||
_act = false;
|
||||
_obj = null;
|
||||
if ($(_root_item).length) {
|
||||
|
||||
$(_root_item).each(function() {
|
||||
var _this = $(this);
|
||||
if ($(_this).hasClass('active')) {
|
||||
$(_this).addClass('nasa-current-top');
|
||||
_obj = $(_this);
|
||||
_act = true;
|
||||
}
|
||||
|
||||
$(_this).find('.children .nasa-current-note').remove();
|
||||
});
|
||||
|
||||
if (!_act) {
|
||||
$(_root_item).each(function() {
|
||||
var _this = $(this);
|
||||
if ($(_this).hasClass('cat-parent') && !_act) {
|
||||
$(_this).addClass('nasa-current-top');
|
||||
_obj = $(_this);
|
||||
_act = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (_obj !== null) {
|
||||
var init_width = $(_obj).width();
|
||||
if (init_width) {
|
||||
var _pos = $(_obj).position();
|
||||
var _note_act = $(_obj).parents('.nasa-top-cat-filter').find('.nasa-current-note');
|
||||
$(_note_act).css({
|
||||
// visibility: 'visible',
|
||||
width: init_width,
|
||||
left: _pos.left,
|
||||
top: ($(_obj).height() - 1)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* init Header Responsive
|
||||
*
|
||||
* @param {type} $
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function init_header_responsive($) {
|
||||
if (
|
||||
$('.header-type-builder').length < 1 &&
|
||||
$('#tmpl-nasa-responsive-header').length &&
|
||||
($('.nasa-menu-off').length || ($('.nasa-mobile-check').length && $('.nasa-mobile-check').width()))
|
||||
) {
|
||||
if ($('#masthead').length && $('#masthead').find('.header-responsive').length <= 0) {
|
||||
var _cart_clone = $('.cart-inner').length ? $('.cart-inner').clone() : null;
|
||||
|
||||
var _header = $('#tmpl-nasa-responsive-header').html();
|
||||
|
||||
if (_header !== '') {
|
||||
$('#masthead').prepend(_header);
|
||||
|
||||
if (_cart_clone) {
|
||||
$('.header-responsive .cart-inner').html($(_cart_clone).html());
|
||||
$('body').trigger('ns_header_responsive_loaded');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto fill text to input
|
||||
*
|
||||
* @param {type} $
|
||||
* @param {type} _input
|
||||
* @param {type} index
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function auto_fill_input_placeholder($, _input, index) {
|
||||
var _index = typeof index !== 'undefined' ? index : 0;
|
||||
if (_index === 0) {
|
||||
$(_input).trigger('focus');
|
||||
}
|
||||
|
||||
if (!$(_input).hasClass('nasa-placeholder')) {
|
||||
$(_input).addClass('nasa-placeholder');
|
||||
var _place = $(_input).attr('placeholder');
|
||||
$(_input).attr('data-placeholder', _place);
|
||||
}
|
||||
|
||||
var str = $(_input).attr('data-suggestions');
|
||||
|
||||
if (str && _index <= str.length) {
|
||||
if (!$(_input).hasClass('nasa-filling')) {
|
||||
$(_input).addClass('nasa-filling');
|
||||
}
|
||||
|
||||
$(_input).attr('placeholder', str.substr(0, _index++));
|
||||
|
||||
setTimeout(function() {
|
||||
auto_fill_input_placeholder($, _input, _index);
|
||||
}, 90);
|
||||
} else {
|
||||
if (!$(_input).hasClass('nasa-done')) {
|
||||
$(_input).addClass('nasa-done');
|
||||
}
|
||||
|
||||
$(_input).removeClass('nasa-filling');
|
||||
|
||||
setTimeout(function() {
|
||||
reverse_fill_input_placeholder($, _input);
|
||||
}, 400);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse fill text to input
|
||||
*
|
||||
* @param {type} $
|
||||
* @param {type} _input
|
||||
* @param {type} index
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function reverse_fill_input_placeholder($, _input, index) {
|
||||
var _str = $(_input).attr('data-suggestions');
|
||||
var _index = typeof index !== 'undefined' ? index : (_str ? _str.length : 0);
|
||||
if (_index > 0) {
|
||||
$(_input).attr('placeholder', _str.substr(0, _index--));
|
||||
|
||||
setTimeout(function() {
|
||||
reverse_fill_input_placeholder($, _input, _index);
|
||||
}, 20);
|
||||
} else {
|
||||
var _place = $(_input).attr('data-placeholder');
|
||||
$(_input).attr('placeholder', _place);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+2066
File diff suppressed because it is too large
Load Diff
Vendored
+1
@@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(n){"use strict";n(".countdown").length>0&&(n.countdown.regionalOptions[""]={labels:[nasa_countdown_l10n.years,nasa_countdown_l10n.months,nasa_countdown_l10n.weeks,nasa_countdown_l10n.days,nasa_countdown_l10n.hours,nasa_countdown_l10n.minutes,nasa_countdown_l10n.seconds],labels1:[nasa_countdown_l10n.year,nasa_countdown_l10n.month,nasa_countdown_l10n.week,nasa_countdown_l10n.day,nasa_countdown_l10n.hour,nasa_countdown_l10n.minute,nasa_countdown_l10n.second],compactLabels:["y","m","w","d"],whichLabels:null,digits:["0","1","2","3","4","5","6","7","8","9"],timeSeparator:":",isRTL:!0},n.countdown.setDefaults(n.countdown.regionalOptions[""]),n(".countdown").each(function(){var o=n(this);if(!n(o).hasClass("countdown-loaded")){var a=new Date(o.data("countdown"));n(o).countdown({until:a,padZeroes:!0}),n(o).hasClass("pause")&&n(o).countdown("pause"),n(o).addClass("countdown-loaded")}}))});
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+3
File diff suppressed because one or more lines are too long
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+1
@@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(t){"use strict";t.confetti=new function(){function n(t){this.x=Math.random()*g,this.y=Math.random()*v-v,this.r=r(5,15),this.d=Math.random()*b+10,this.color=t,this.tilt=Math.floor(10*Math.random())-10,this.tiltAngleIncremental=.07*Math.random()+.05,this.tiltAngle=0,this.draw=function(){return y.beginPath(),y.lineWidth=this.r/2,y.strokeStyle=this.color,y.moveTo(this.x+this.tilt+this.r/4,this.y),y.lineTo(this.x+this.tilt,this.y+this.tilt+this.r/4),y.stroke()}}function e(){i(),t(window).on("resize",function(){g=window.innerWidth,v=window.innerHeight,w.width=g,w.height=v})}function i(){t("#nasa-confetti").length<1&&(t("form.nasa-shopping-cart-form").length?t("body").append('<canvas id="nasa-confetti" style="display: none;"></canvas>'):t("#cart-sidebar").length?t("#cart-sidebar").append('<canvas id="nasa-confetti" style="display: none;"></canvas>'):t("body").append('<canvas id="nasa-confetti" style="display: none;"></canvas>'),t("#ns-cart-popup").length&&t("#ns-cart-popup").parents(".ns-cart-popup-wrap").prepend('<canvas id="nasa-confetti-popup" style="display: none; position: relative; z-index: 9;"></canvas>')),t("#review_form_wrapper").length&&t("#nasa-confetti-review").length<1&&t("#review_form_wrapper").prepend('<canvas id="nasa-confetti-review" style="display: none;"></canvas>'),w=document.getElementById("nasa-confetti"),t("#ns-cart-popup").parents(".ns-cart-popup-wrap").hasClass("nasa-active")&&(w=document.getElementById("nasa-confetti-popup")),t("#review_form_wrapper").hasClass("ns-show")&&(w=document.getElementById("nasa-confetti-review")),y=w.getContext("2d"),g=window.innerWidth,v=window.innerHeight,w.width=g,w.height=v,q=!0}function o(){w.style.display="block",x=[],T=!1;for(var t=0;b>t;t++){var e=C.getColor();x.push(new n(e))}l()}function a(){b=t("body").hasClass("nasa-in-mobile")?50:300,y.clearRect(0,0,g,v);for(var n=[],e=0;b>e;e++)!function(t){n.push(x[t].draw())}(e);return s(),n}function r(t,n){return Math.floor(Math.random()*(n-t+1)+t)}function s(){var t,n=0;I+=.01,A+=.1;for(var e=0;b>e;e++){if(t=x[e],T)return;!F&&t.y<-15?t.y=v+100:(d(t,e),t.y<=v&&n++,c(t,e))}0===n&&p()}function c(t,n){(t.x>g+20||t.x<-20||t.y>v)&&F&&(n%5>0||n%2==0?h(t,Math.random()*g,-10,Math.floor(10*Math.random())-10):Math.sin(I)>0?h(t,-5,Math.random()*v,Math.floor(10*Math.random())-10):h(t,g+5,Math.random()*v,Math.floor(10*Math.random())-10))}function d(t,n){t.tiltAngle+=t.tiltAngleIncremental,t.y+=(Math.cos(I+t.d)+10+t.r/2)/2,t.x+=Math.sin(I),t.tilt=10*Math.sin(t.tiltAngle-n/3)}function h(t,n,e,i){t.x=n,t.y=e,t.tilt=i}function l(){q||e(),g=window.innerWidth,v=window.innerHeight,w.width=g,w.height=v,function t(){return T?null:(_=requestAnimFrame(t),a())}()}function f(){clearTimeout(M),clearTimeout(_)}function u(){F=!1,f()}function p(){q||e(),T=!0,"undefined"!=typeof y&&(y.clearRect(0,0,g,v),w.style.display="none")}function m(){q||e(),f(),p(),M=setTimeout(function(){F=!0,T=!1,o()},100)}var w,y,g,v,M,_,b=300,x=[],I=0,A=0,F=!0,T=!0,q=!1,C={colorOptions:["#EF2964","#00C09D","#2D87B0","#48485E","#EFFF1D"],colorIndex:0,colorIncrementer:0,colorThreshold:10,getColor:function(){return this.colorIncrementer>=10&&(this.colorIncrementer=0,this.colorIndex++,this.colorIndex>=this.colorOptions.length&&(this.colorIndex=0)),this.colorIncrementer++,this.colorOptions[this.colorIndex]}};window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),this.init=e,this.start=o,this.stop=u,this.restart=m},t("body").on("nasa_confetti_init",function(){t.confetti.init()}),t("body").on("nasa_confetti_start",function(n,e){t.confetti.start(),"undefined"!=typeof e&&setTimeout(function(){t("body").trigger("nasa_confetti_stop")},e)}),t("body").on("nasa_confetti_restart",function(n,e){t.confetti.restart(),"undefined"!=typeof e&&setTimeout(function(){t("body").trigger("nasa_confetti_stop")},e)}),t("body").on("nasa_confetti_stop",function(){t.confetti.stop()})});
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)}(function(e){function n(e){return u.raw?e:encodeURIComponent(e)}function o(e){return u.raw?e:decodeURIComponent(e)}function i(e){return n(u.json?JSON.stringify(e):String(e))}function r(e){0===e.indexOf('"')&&(e=e.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return e=decodeURIComponent(e.replace(c," ")),u.json?JSON.parse(e):e}catch(n){}}function t(n,o){var i=u.raw?n:r(n);return e.isFunction(o)?o(i):i}var c=/\+/g,u=e.cookie=function(r,c,f){if(void 0!==c&&!e.isFunction(c)){if(f=e.extend({},u.defaults,f),"number"==typeof f.expires){var a=f.expires,d=f.expires=new Date;d.setTime(+d+864e5*a)}return document.cookie=[n(r),"=",i(c),f.expires?"; expires="+f.expires.toUTCString():"",f.path?"; path="+f.path:"",f.domain?"; domain="+f.domain:"",f.secure?"; secure":""].join("")}for(var p=r?void 0:{},s=document.cookie?document.cookie.split("; "):[],m=0,x=s.length;x>m;m++){var v=s[m].split("="),k=o(v.shift()),l=v.join("=");if(r&&r===k){p=t(l,c);break}r||void 0===(l=t(l))||(p[k]=l)}return p};u.defaults={},e.removeCookie=function(n,o){return void 0===e.cookie(n)?!1:(e.cookie(n,"",e.extend({},o,{expires:-1})),!e.cookie(n))}});
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+12
File diff suppressed because one or more lines are too long
Vendored
+5
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+2
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
function nasa_boot_sale_intival_countdown(n,a,s,i,e){nsfk_is_pause||(nsfk_time=0),nsfk_intival=setInterval(function(){nsfk_is_pause||(nsfk_time+=100,nsfk_time>=e/2&&(n(".ns-sale-notification").removeClass("nasa-active"),n("body").trigger("nasa_boot_sale_off")),nsfk_time>=e&&(s=s>=i-1?0:s+1,nasa_boot_sale_intival(n,a[s]),nsfk_time=0))},100)}function nasa_boot_sale_intival(n,a){if(n(".ns-sale-notification").length<=0&&n("body").append('<div class="ns-sale-notification"></div>'),"undefined"!=typeof a){var s=n("#ns-sale-notification-tml").html();s=s.replace(/{{p_name}}/g,a.p_name),s=s.replace(/{{src_img}}/g,a.src_img),s=s.replace(/{{customer}}/g,a.customer),s=s.replace(/{{p_url}}/g,a.p_url),s=s.replace(/{{time_purchase}}/g,a.time_purchase),s=s.replace(/{{p_data_prod}}/g,a.p_data_prod),n(".ns-sale-notification").html(s),0==a.p_data_prod&&n(".ns-sale-notification").find(".ns-noti-link").remove(),setTimeout(function(){n(".ns-sale-notification").addClass("nasa-active"),n("body").trigger("nasa_boot_sale_on")},100)}}var nsfk_is_pause=!1,nsfk_intival,nsfk_time=0;jQuery(document).ready(function(n){"use strict";if(n("#ns-sale-notification-tml").length&&"undefined"!=typeof ns_fkp&&ns_fkp&&"undefined"!=typeof ns_fkp_count&&ns_fkp_count&&"undefined"!=typeof time_interval&&time_interval&&!n("body").hasClass("nasa-in-mobile")){var a=0;nasa_boot_sale_intival_countdown(n,ns_fkp,a,ns_fkp_count,time_interval),n("body").on("click",".close-noti",function(){clearInterval(nsfk_intival),n(".ns-sale-notification").removeClass("nasa-active"),n("body").trigger("nasa_boot_sale_off"),a=a>=ns_fkp_count-1?0:a+1,nsfk_time=0,nsfk_is_pause=!1,nasa_boot_sale_intival_countdown(n,ns_fkp,a,ns_fkp_count,time_interval)}),n("body").on("mouseenter",".ns-sale-notification",function(){n(".ns-sale-notification").hasClass("nasa-active")&&(nsfk_is_pause=!0)}).on("mouseleave",".ns-sale-notification",function(){n(".ns-sale-notification").hasClass("nasa-active")&&(nsfk_is_pause=!1)})}});
|
||||
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(t){"use strict";t("body").on("click",".product-lightbox .adsw-attribute-option .sku-set",function(){var a=t(this);if(!t(a).hasClass("active")&&!t(a).hasClass("sku-disabled")){var i=t(a).attr("data-value"),s=t(a).parents("td.value"),e=t(s).find("select"),n=t(a).parents(".adsw-attribute-option");t(n).find(".sku-set").removeClass("active"),t(a).addClass("active"),t(e).val(i).trigger("change")}}),t("body").on("check_variations",function(){var a=t(".product-lightbox form.variations_form");t(a).length&&t(a).find(".adsw-attribute-option").each(function(){var a=t(this),i=t(a).parents("td.value"),s=t(i).find("select");t(a).find(".sku-set:not(.active)").each(function(){var a=t(this),i=t(a).attr("data-value"),e=t(s).find('option[value="'+i+'"]').attr("disabled");(t(s).find('option[value="'+i+'"]').length<=0||"undefined"!=typeof e)&&(t(a).hasClass("sku-disabled")||t(a).addClass("sku-disabled"))})})}),t("body").on("click",".reset_variations",function(){var a=t(this).parents(".product-lightbox");if(t(a).length&&t(a).find("form.variations_form").length){var i=t(a).find("form.variations_form");t(i).find(".sku-set").removeClass("active").removeClass("sku-disabled")}})});
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+2
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
+3
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(e){"use strict";if(e(".nasa-currencies-3rd .nasa-currency-switcher").length){if(e(".woocs_auto_switcher").length){var c=e(".woocs_auto_switcher"),r='<ul class="nasa-woocs-switcher crr-switcher">',a=0;e(c).find(".woocs_auto_switcher_link").each(function(){var c=e(this);if(e(c).attr("data-index",a),a++,!e(c).hasClass("woocs_curr_curr")){var n=e(c).parents("li").clone();e(n).find("a").removeClass("woocs_auto_switcher_link"),e(n).find("a").addClass("nasa-woocs-switcher-link"),r+="<li>"+e(n).html()+"</li>"}}),r+="</ul>";var n=e(c).find(".woocs_curr_curr").clone();e(n).removeClass("woocs_auto_switcher_link"),e(n).removeClass("woocs_curr_curr"),e(n).addClass("nasa-crc nasa-woocs-crc"),e(".nasa-currencies-3rd").prepend(n),e(".nasa-currency-switcher").append(r),e(".nasa-currency-switcher, .nasa-currencies-3rd").removeClass("hidden-tag")}if(e(".wmc-list-currencies").length){var s=e(".wmc-list-currencies"),r='<ul class="nasa-wmc-switcher crr-switcher">',i="";e(s).find(".wmc-currency").each(function(){var c=e(this),a=e(c).clone();if(e(c).hasClass("wmc-active")){var n=e(a).html();e(a).find(".wmc-active-title").length?(e(a).find(".wmc-active-title").prepend(e(a).find(".wmc-currency-symbol")),n=e(a).find(".wmc-active-title").html()):e(a).find("a").length&&(n=e(a).find("a").html()),i='<a href="javascript:void(0);" rel="nofollow" class="wmc-active">'+n+"</a>"}else e(a).find(".wmc-currency-symbol").length&&e(a).find("a").prepend(e(a).find(".wmc-currency-symbol")),r+="<li>"+e(a).html()+"</li>"}),r+="</ul>",e(".nasa-currencies-3rd").prepend(i),e(".nasa-currency-switcher").append(r),e(".nasa-currency-switcher, .nasa-currencies-3rd").removeClass("hidden-tag"),e(s).parents(".woocommerce-multi-currency").length&&e(s).parents(".woocommerce-multi-currency").addClass("hidden-tag")}}e("body").on("click",".nasa-woocs-switcher-link",function(){var c=e(this).attr("data-index");e('.woocs_auto_switcher_link[data-index="'+c+'"]').length&&e('.woocs_auto_switcher_link[data-index="'+c+'"]').trigger("click")}),e("body").on("nasa_after_render_currencies_switcher",function(c,r){e(r).find(".nasa-currency-switcher").length&&(e(r).addClass("menu-item-has-children root-item li_accordion"),e(r).find(".nasa-currency-switcher").addClass("nav-dropdown")),c.preventDefault()});var t="";e("body").on("nasa_before_load_ajax",function(){if(e(".nasa-currencies-3rd").length){var c=e(".nasa-currencies-3rd").clone();t=e(c).html()}}),e("body").on("nasa_after_loaded_ajax_complete",function(){e(".nasa-currencies-3rd").length&&(e(".nasa-currencies-3rd").html(t),e(".nasa-currencies-3rd").removeClass("hidden-tag")),t=""}),e("body").on("click","a[data-currency]",function(){"undefined"!=typeof _popstate_reload&&(_popstate_reload=!1)})});
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,105 @@
|
||||
var nsfk_is_pause = false,
|
||||
nsfk_intival,
|
||||
nsfk_time = 0;
|
||||
/* Document ready */
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
if (
|
||||
$('#ns-sale-notification-tml').length &&
|
||||
typeof ns_fkp !== 'undefined' &&
|
||||
ns_fkp &&
|
||||
typeof ns_fkp_count !== 'undefined' &&
|
||||
ns_fkp_count &&
|
||||
typeof time_interval !== 'undefined' &&
|
||||
time_interval
|
||||
) {
|
||||
/**
|
||||
* Boot Sale vitual
|
||||
*/
|
||||
if (!$('body').hasClass('nasa-in-mobile')) {
|
||||
var kb = 0;
|
||||
|
||||
// nasa_boot_sale_intival($, ns_fkp[kb]);
|
||||
|
||||
nasa_boot_sale_intival_countdown($, ns_fkp, kb, ns_fkp_count, time_interval);
|
||||
|
||||
$('body').on('click', '.close-noti', function () {
|
||||
clearInterval(nsfk_intival);
|
||||
|
||||
$('.ns-sale-notification').removeClass('nasa-active');
|
||||
|
||||
$('body').trigger('nasa_boot_sale_off');
|
||||
|
||||
kb = kb >= ns_fkp_count-1 ? 0 : kb + 1;
|
||||
nsfk_time = 0;
|
||||
nsfk_is_pause = false;
|
||||
nasa_boot_sale_intival_countdown($, ns_fkp, kb, ns_fkp_count, time_interval);
|
||||
});
|
||||
|
||||
$('body').on('mouseenter', '.ns-sale-notification', function() {
|
||||
if ($('.ns-sale-notification').hasClass('nasa-active')) {
|
||||
nsfk_is_pause = true;
|
||||
}
|
||||
}).on('mouseleave', '.ns-sale-notification', function() {
|
||||
if ($('.ns-sale-notification').hasClass('nasa-active')) {
|
||||
nsfk_is_pause = false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* End Document Ready */
|
||||
function nasa_boot_sale_intival_countdown($, ns_fkp, kb, ns_fkp_count, time_interval) {
|
||||
if (!nsfk_is_pause) {
|
||||
nsfk_time = 0;
|
||||
}
|
||||
|
||||
nsfk_intival = setInterval(function() {
|
||||
if (!nsfk_is_pause) {
|
||||
nsfk_time = nsfk_time + 100;
|
||||
if (nsfk_time >= time_interval/2) {
|
||||
$('.ns-sale-notification').removeClass('nasa-active');
|
||||
|
||||
$('body').trigger('nasa_boot_sale_off');
|
||||
}
|
||||
|
||||
if (nsfk_time >= time_interval) {
|
||||
kb = kb >= ns_fkp_count-1 ? 0 : kb + 1;
|
||||
nasa_boot_sale_intival($, ns_fkp[kb]);
|
||||
nsfk_time = 0;
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function nasa_boot_sale_intival($, fkb) {
|
||||
if ($('.ns-sale-notification').length <= 0) {
|
||||
$('body').append('<div class="ns-sale-notification"></div>');
|
||||
}
|
||||
|
||||
if (typeof fkb !== 'undefined') {
|
||||
var _content = $('#ns-sale-notification-tml').html();
|
||||
|
||||
_content = _content.replace(/{{p_name}}/g, fkb['p_name']);
|
||||
_content = _content.replace(/{{src_img}}/g, fkb['src_img']);
|
||||
_content = _content.replace(/{{customer}}/g, fkb['customer']);
|
||||
_content = _content.replace(/{{p_url}}/g, fkb['p_url']);
|
||||
_content = _content.replace(/{{time_purchase}}/g, fkb['time_purchase']);
|
||||
_content = _content.replace(/{{p_data_prod}}/g, fkb['p_data_prod']);
|
||||
|
||||
$('.ns-sale-notification').html(_content);
|
||||
|
||||
if (fkb['p_data_prod'] == 0) {
|
||||
$('.ns-sale-notification').find('.ns-noti-link').remove();
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
$('.ns-sale-notification').addClass('nasa-active');
|
||||
|
||||
$('body').trigger('nasa_boot_sale_on');
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
|
||||
var ns_minicart_change_html = [];
|
||||
|
||||
/* Document ready */
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
$('body').on('click', '.nasa-change_variation_mini_cart:not(.nasa-cart-variation-updating) .mini-cart-item dl.variation', function (e) {
|
||||
|
||||
nasa_quick_viewimg = true;
|
||||
/**
|
||||
* Append stylesheet Off Canvas
|
||||
*/
|
||||
$('body').trigger('nasa_append_style_off_canvas');
|
||||
|
||||
if (
|
||||
typeof nasa_params_quickview !== 'undefined' &&
|
||||
typeof nasa_params_quickview.wc_ajax_url !== 'undefined'
|
||||
) {
|
||||
var _urlAjax = nasa_params_quickview.wc_ajax_url.toString().replace('%%endpoint%%', 'nasa_quick_view');
|
||||
var _this = $(this);
|
||||
var _product_type = $(_this).attr('data-product_type');
|
||||
|
||||
if (_product_type === 'woosb' && typeof $(_this).attr('data-href') !== 'undefined') {
|
||||
window.location.href = $(_this).attr('data-href');
|
||||
}
|
||||
|
||||
else {
|
||||
var _cart = $(_this).parents('.nasa-static-sidebar'),
|
||||
_wrap = $(_this).parents('.mini-cart-item'),
|
||||
_wishlist = ($(_this).attr('data-from_wishlist') === '1') ? '1' : '0',
|
||||
product_id = $(_wrap).attr('data-id-product'),
|
||||
_data_cart_item_key = $(_wrap).find('.remove_from_cart_button ').attr('data-cart_item_key'),
|
||||
_footer_mini_cart = $(_cart).find('.nasa-minicart-footer'),
|
||||
_quantity = $(_wrap).find('.quantity-wrap .quantity .qty').attr('value'),
|
||||
_main_img = $(_wrap).find('.nasa-image-cart-item img');
|
||||
|
||||
var _data = {
|
||||
product: product_id,
|
||||
nasa_wishlist: _wishlist
|
||||
};
|
||||
|
||||
var _form_change_variation = '<div class="ext-node mini-cart-change-variation"></div>',
|
||||
_close ='<a href="javascript:void(0);" title="Close" class="nasa-close-node nasa-stclose" rel="nofollow"></a>';
|
||||
|
||||
if ((_main_img).length) {
|
||||
var _width = $(_main_img).outerWidth();
|
||||
var _height = $(_main_img).outerHeight();
|
||||
}
|
||||
|
||||
_data.quickview = 'popup';
|
||||
|
||||
if ($(_footer_mini_cart).find('.ext-nodes-wrap').length) {
|
||||
if ($(_footer_mini_cart).find('.ext-nodes-wrap .mini-cart-change-variation').length <= 0) {
|
||||
$(_footer_mini_cart).find('.ext-nodes-wrap').append(_form_change_variation);
|
||||
}
|
||||
} else {
|
||||
$(_footer_mini_cart).append('<div class="ext-nodes-wrap">' + _form_change_variation + '</div>');
|
||||
}
|
||||
|
||||
if (!$(_cart).hasClass('ext-loading')) {
|
||||
$(_cart).addClass('ext-loading');
|
||||
}
|
||||
|
||||
if ($(_cart).find('.close-nodes').length < 1) {
|
||||
$(_cart).append('<a href="javascript:void(0);" class="close-nodes"></a>');
|
||||
}
|
||||
|
||||
var _callAjax = true;
|
||||
var _change_variation = $(_footer_mini_cart).find('.ext-nodes-wrap .mini-cart-change-variation');
|
||||
var _html_mask_load = _close +
|
||||
'<div class="ns-mask-load nasa-crazy-load qv-loading padding-left-35 mobile-padding-left-20 mobile-padding-right-20 padding-right-35">' +
|
||||
'<div class="product-quickview-img-wrap nasa-flex align-start">' +
|
||||
'<div class="product-quickview-img margin-bottom-20" style="height:' + _height + 'px; width:' + _width + 'px;"></div>' +
|
||||
'<div class="nasa-quickview-fog">' +
|
||||
'<div class="qv-crazy-info">' +
|
||||
'<span class="info-1"></span>' +
|
||||
'<span class="info-2 margin-top-20"></span>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="nasa-quickview-fog">' +
|
||||
'<div class="qv-crazy-info">' +
|
||||
'<span class="info-3 margin-top-20"></span>' +
|
||||
'<span class="info-6-2 margin-top-20"></span>' +
|
||||
'<span class="info-3 margin-top-20"></span>' +
|
||||
'<span class="info-6-2 margin-top-20"></span>' +
|
||||
'<span class="info-3 margin-top-20"></span>' +
|
||||
'<span class="info-7 nasa-flex margin-top-20">' +
|
||||
'<span class="info-7-1"></span>' +
|
||||
'<span class="info-7-2"></span>' +
|
||||
'</span>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
$(_change_variation).html(_html_mask_load);
|
||||
|
||||
setTimeout(function () {
|
||||
$(_change_variation).addClass('active');
|
||||
}, 100);
|
||||
|
||||
if (typeof ns_minicart_change_html[product_id] !== 'undefined') {
|
||||
_callAjax = false;
|
||||
}
|
||||
|
||||
if (_callAjax) {
|
||||
$.ajax({
|
||||
url: _urlAjax,
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: _data,
|
||||
cache: false,
|
||||
beforeSend: function () {
|
||||
if (typeof setMaxHeightQVPU !== 'undefined') {
|
||||
clearInterval(setMaxHeightQVPU);
|
||||
}
|
||||
},
|
||||
success: function (response) {
|
||||
ns_minicart_change_html[product_id] = response;
|
||||
|
||||
$(_change_variation).html(_close + '<div class="product-lightbox">' + response.content + '</div>');
|
||||
$(_change_variation).find('.product-lightbox .nasa-product-gallery-lightbox').css({'min-height':_height});
|
||||
$('body').trigger('init-mini-cart-update-form', [_change_variation, _quantity, _data_cart_item_key, _this]);
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var quicview_obj = ns_minicart_change_html[product_id];
|
||||
|
||||
$(_change_variation).html(_close + '<div class="product-lightbox">' + quicview_obj.content + '</div>');
|
||||
$(_change_variation).find('.product-lightbox .nasa-product-gallery-lightbox').css({'min-height': _height});
|
||||
$('body').trigger('init-mini-cart-update-form', [_change_variation, _quantity, _data_cart_item_key, _this]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
$('body').on('init-mini-cart-update-form', function(e, wrap, _quantity, _data_cart_item_key, _btn) {
|
||||
/**
|
||||
* Init Gallery image
|
||||
*/
|
||||
$('body').trigger('nasa_init_product_gallery_lightbox');
|
||||
|
||||
if ($(wrap).find('.variations_form .quantity .qty').length) {
|
||||
$(wrap).find('.variations_form .quantity .qty').val(_quantity).attr({'data-old':_quantity-1});
|
||||
}
|
||||
|
||||
if ($(wrap).find('.variations_form .ns-single-add-btn').length) {
|
||||
var _text = $(wrap).parents('.nasa-static-sidebar').find('.nasa-minicart-items').attr('data-text');
|
||||
var _ns_infor_variation = $(wrap).find('.variations_form .ns-info-variants');
|
||||
|
||||
if ($(_ns_infor_variation).length) {
|
||||
$(_ns_infor_variation).replaceWith($(_ns_infor_variation).html());
|
||||
}
|
||||
|
||||
$(wrap).find('.variations_form .ns-single-add-btn').attr({'data-quantity': _quantity, 'data-cart_item_key': _data_cart_item_key}).addClass('btn-add-from-minicart').text(_text);
|
||||
}
|
||||
|
||||
var ns_objectsToAppend = [
|
||||
$(wrap).find('.product-lightbox .product-info .product_title').clone().addClass('fs-16'),
|
||||
$(wrap).find('.product-lightbox .product-info .nasa-single-product-price').clone(),
|
||||
$(wrap).find('.variations_form .woocommerce-variation').clone()
|
||||
];
|
||||
|
||||
var variation_bulk_dsct = $(wrap).find('.product-lightbox .product-info .nasa-variation-bulk-dsct');
|
||||
|
||||
$(wrap).find('.variations_form .variations').append(variation_bulk_dsct);
|
||||
|
||||
if ($(wrap).find('.product-lightbox .product-quickview-img .ns-price').length <= 0) {
|
||||
$(wrap).find('.product-lightbox .product-quickview-img').append('<div class="ns-price flex-column nasa-flex align-start"></div>');
|
||||
}
|
||||
|
||||
$(wrap).find('.product-lightbox .product-quickview-img .ns-price').append(ns_objectsToAppend);
|
||||
|
||||
$(wrap).find('.product-lightbox .product-quickview-img').removeClass('padding-left-0 padding-right-0');
|
||||
|
||||
setTimeout(function () {
|
||||
if ($('form.cart input[name="quantity"]').length && $('.product-lightbox .ev-dsc-qty').length) {
|
||||
$('form.cart input[name="quantity"]').trigger('change');
|
||||
}
|
||||
}, 10);
|
||||
|
||||
$('body').trigger('before_init_variations_form');
|
||||
|
||||
var formLightBox = $('.mini-cart-change-variation .product-lightbox').find('.variations_form');
|
||||
|
||||
if ($(formLightBox).length) {
|
||||
$(formLightBox).find('.single_variation_wrap').hide();
|
||||
|
||||
$(formLightBox).each(function () {
|
||||
var _form_var = $(this);
|
||||
$('body').trigger('init_quickview_variations_form', [_form_var]);
|
||||
|
||||
$(_form_var).find('select').trigger('change');
|
||||
|
||||
if ($(_form_var).find('.variations select option[selected="selected"]').length) {
|
||||
$(_form_var).find('.variations .reset_variations').css({'visibility': 'visible'}).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var infor_cart_item = $(_btn).parents('.nasa-info-cart-item');
|
||||
var data_variations_selected = jQuery.parseJSON($(infor_cart_item).attr('data-variations-selected'));
|
||||
|
||||
for (var key in data_variations_selected) {
|
||||
var _value = data_variations_selected[key];
|
||||
|
||||
if ($(wrap).find('.variations_form .variations').length) {
|
||||
var _pa = $(wrap).find('.variations_form .variations');
|
||||
|
||||
var _ux = $(_pa).find('td.value .nasa-attr-ux_wrap[data-attribute_name="' + key + '"] a[data-value="' + _value + '"]');
|
||||
// console.log(_ux);
|
||||
|
||||
if ($(_ux).length) {
|
||||
if (!$(_ux).hasClass('selected')) {
|
||||
$(_ux).trigger('click');
|
||||
}
|
||||
} else {
|
||||
_ux = $(_pa).find('td.value select[data-attribute_name="' + key + '"]');
|
||||
$(_ux).val(_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('body').trigger('nasa_changed_gallery_variable_quickview');
|
||||
$('body').trigger('nasa_after_quickview');
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
* Change gallery for variation - Quick view
|
||||
*/
|
||||
$('body').on('nasa_changed_gallery_variable_quickview', function () {
|
||||
var wrap = $('#cart-sidebar .ext-nodes-wrap .mini-cart-change-variation');
|
||||
|
||||
if ($(wrap).find('.product-quickview-img .nasa-slick-slider').length) {
|
||||
var img = $(wrap).find('.product-quickview-img .nasa-slick-slider img:first-child').clone().attr({'class': 'main-img', 'style': 'width:100%;'});
|
||||
|
||||
if ($(wrap).find('.product-quickview-img .product-img .main-img').length <= 0) {
|
||||
$(wrap).find('.product-quickview-img .product-img').prepend(img);
|
||||
}else {
|
||||
$(wrap).find('.product-quickview-img .product-img .main-img').replaceWith(img);
|
||||
}
|
||||
}
|
||||
|
||||
// /loading_slick_element($, true, '.mini-cart-change-variation .product-lightbox');
|
||||
});
|
||||
|
||||
/**
|
||||
* Update Quantity mini cart change
|
||||
*/
|
||||
$('body').on('ns_bulk_discount_changed', function () {
|
||||
var wrap = $('#cart-sidebar .ext-nodes-wrap .mini-cart-change-variation');
|
||||
if ($(wrap).length) {
|
||||
$('body').trigger('update-price-stock-pos',[wrap]);
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('update-price-stock-pos',function(e,wrap) {
|
||||
setTimeout(function () {
|
||||
var _price_stock = $(wrap).find('.variations_form .woocommerce-variation').clone();
|
||||
if ($(wrap).find('.product-info .price.nasa-bulk-price').length) {
|
||||
_price_stock = $(wrap).find('.product-info .price.nasa-bulk-price').html();
|
||||
$(wrap).find('.product-lightbox .product-quickview-img .ns-price .woocommerce-variation .woocommerce-variation-price').html('<span class="price">' + _price_stock + '</span>');
|
||||
$(wrap).find('.product-lightbox .product-quickview-img .ns-price .woocommerce-variation').removeAttr('style');
|
||||
} else {
|
||||
$(wrap).find('.product-lightbox .product-quickview-img .ns-price .woocommerce-variation').replaceWith(_price_stock);
|
||||
}
|
||||
|
||||
var _org_price = $(wrap).find('.product-lightbox .product-quickview-img .ns-price .nasa-single-product-price');
|
||||
if ($(_price_stock).find('.woocommerce-variation-price').html() != '' && !$(wrap).find('.variations_form .btn-add-from-minicart').hasClass('disabled')) {
|
||||
$(_org_price).hide();
|
||||
}else {
|
||||
$(_org_price).show();
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
});
|
||||
/* End Document Ready */
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Document Ready !!!
|
||||
*/
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
$('body').on('click', '.product-lightbox .adsw-attribute-option .sku-set', function() {
|
||||
var _this = $(this);
|
||||
|
||||
if (!$(_this).hasClass('active') && !$(_this).hasClass('sku-disabled')) {
|
||||
var _val = $(_this).attr('data-value');
|
||||
var _wrap = $(_this).parents('td.value');
|
||||
var _select = $(_wrap).find('select');
|
||||
var _ops = $(_this).parents('.adsw-attribute-option');
|
||||
|
||||
$(_ops).find('.sku-set').removeClass('active');
|
||||
$(_this).addClass('active');
|
||||
$(_select).val(_val).trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on("check_variations", function () {
|
||||
var _form = $('.product-lightbox form.variations_form');
|
||||
|
||||
if ($(_form).length) {
|
||||
$(_form).find(".adsw-attribute-option").each(function () {
|
||||
var _adsw = $(this);
|
||||
var _wrap = $(_adsw).parents('td.value');
|
||||
var _select = $(_wrap).find('select');
|
||||
|
||||
$(_adsw).find('.sku-set:not(.active)').each(function() {
|
||||
var _item = $(this);
|
||||
var _value = $(_item).attr('data-value');
|
||||
var _option = $(_select).find('option[value="' + _value + '"]').attr('disabled');
|
||||
|
||||
if (
|
||||
$(_select).find('option[value="' + _value + '"]').length <= 0 ||
|
||||
typeof _option !== 'undefined'
|
||||
) {
|
||||
if (!$(_item).hasClass('sku-disabled')) {
|
||||
$(_item).addClass('sku-disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('click', '.reset_variations', function () {
|
||||
var _wrap = $(this).parents('.product-lightbox');
|
||||
if ($(_wrap).length && $(_wrap).find('form.variations_form').length) {
|
||||
var _form = $(_wrap).find('form.variations_form');
|
||||
$(_form).find(".sku-set").removeClass("active").removeClass("sku-disabled");
|
||||
}
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,945 @@
|
||||
/* Document ready */
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Images exists be checked
|
||||
* @type Array
|
||||
*/
|
||||
var _ns_img_checked = [];
|
||||
var Timeout_bc =null
|
||||
var Timeout_bc_remoc_class = null;
|
||||
var Timeout_bc_click = null;
|
||||
var tab_bc = [];
|
||||
|
||||
$('body').on('ns_btns_fixed', function() {
|
||||
if ($('.ns_btn-fixed').length <= 0) {
|
||||
$('body').append('<div class="ns_btn-fixed nasa-flex"></div>');
|
||||
}
|
||||
|
||||
var has_padding_bottom = false;
|
||||
|
||||
if ($('.nasa-single-product-in-mobile .single_add_to_cart_button').length) {
|
||||
if ($('.ns_btn-fixed').find('.single_add_to_cart_button').length <= 0) {
|
||||
var _text = $('.nasa-single-product-in-mobile .single_add_to_cart_button.ns-single-add-btn').text();
|
||||
$('.ns_btn-fixed').append('<a href="javascript:void(0);" class="single_add_to_cart_button button">' + _text + '</a>');
|
||||
}
|
||||
|
||||
has_padding_bottom = true;
|
||||
}
|
||||
|
||||
if ($('.nasa-single-product-in-mobile .nasa-buy-now').length) {
|
||||
if ($('.ns_btn-fixed').find('.nasa-buy-now').length <= 0) {
|
||||
var _text = $('.nasa-single-product-in-mobile .nasa-buy-now').text();
|
||||
$('.ns_btn-fixed').append('<a href="javascript:void(0);" class="nasa-buy-now button">' + _text + '</a>');
|
||||
}
|
||||
|
||||
has_padding_bottom = true;
|
||||
}
|
||||
|
||||
if (has_padding_bottom) {
|
||||
var _padding_bottom = $('.ns_btn-fixed').outerHeight();
|
||||
$('body').css({'padding-bottom': _padding_bottom});
|
||||
}
|
||||
|
||||
}).trigger('ns_btns_fixed');
|
||||
|
||||
/**
|
||||
* ADD TO CART - show in variations form
|
||||
*/
|
||||
$('body').on('click', '.ns_btn-fixed .single_add_to_cart_button, .ns-open-var-form', function() {
|
||||
if ($('.nasa-single-product-in-mobile form.cart').length) {
|
||||
var _form = $('.nasa-single-product-in-mobile form.cart');
|
||||
var _btn = $(_form).find('button[type="submit"].single_add_to_cart_button');
|
||||
|
||||
$('body').trigger('slick_go_to_0',[$('.main-images')]);
|
||||
|
||||
if ($(_form).hasClass('variations_form')) {
|
||||
if (!$(_form).hasClass('ns-show')) {
|
||||
$(_form).addClass('ns-show ns_add_to_cart_button_show');
|
||||
|
||||
$('.black-window').fadeIn(200).addClass('desk-window');
|
||||
|
||||
if (!$('body').hasClass('ovhd')) {
|
||||
$('body').addClass('ovhd');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($(_btn).length) {
|
||||
$(_btn).trigger('click');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* BUY NOW - show in variations form
|
||||
*/
|
||||
$('body').on('click', '.ns_btn-fixed .nasa-buy-now', function() {
|
||||
if ($('.nasa-single-product-in-mobile form.cart').length) {
|
||||
var _this = $(this);
|
||||
|
||||
var _form = $('.nasa-single-product-in-mobile form.cart');
|
||||
var _btn = $(_form).find('.nasa-buy-now');
|
||||
|
||||
$('body').trigger('slick_go_to_0',[$('.main-images')]);
|
||||
|
||||
if ($(_form).hasClass('variations_form')) {
|
||||
if (!$(_form).hasClass('ns-show')) {
|
||||
$(_form).addClass('ns-show ns_buy_now_button_show');
|
||||
|
||||
$(_this).removeClass('loading');
|
||||
|
||||
$('.black-window').fadeIn(200).addClass('desk-window');
|
||||
|
||||
if (!$('body').hasClass('ovhd')) {
|
||||
$('body').addClass('ovhd');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($(_btn).length) {
|
||||
$(_btn).trigger('click');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Hide simple product - cart form
|
||||
*/
|
||||
$('body').on('ns_hide_simple_cart_form', function() {
|
||||
if (
|
||||
$('.nasa-single-product-in-mobile form.cart').length &&
|
||||
$('.nasa-single-product-in-mobile form.cart').find('input[name="data-type"]').length
|
||||
) {
|
||||
if ($('.nasa-single-product-in-mobile form.cart').find('input[name="data-type"]').val() === 'simple') {
|
||||
/**
|
||||
* Compatible WCPA
|
||||
*/
|
||||
if ($('.nasa-single-product-in-mobile form.cart').find('.wcpa_form_outer').length) {
|
||||
$('.nasa-single-product-in-mobile form.cart').find('>*').each(function() {
|
||||
if (!$(this).hasClass('wcpa_form_outer')) {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('.nasa-single-product-in-mobile form.cart').hide();
|
||||
if ($('.nasa-single-product-in-mobile form.cart').find('.nasa-dsc-wrap').length) {
|
||||
var _nasa_dsc_wrap = $('.nasa-single-product-in-mobile form.cart').find('.nasa-dsc-wrap');
|
||||
if (!$(_nasa_dsc_wrap).hasClass('nasa-dsc-type-2')) {
|
||||
$(_nasa_dsc_wrap).addClass('nasa-dsc-mobile-quick-add');
|
||||
}
|
||||
$('.nasa-single-product-in-mobile form.cart').after($(_nasa_dsc_wrap));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).trigger('ns_hide_simple_cart_form');
|
||||
|
||||
/**
|
||||
* Checkout Plugins - Stripe for WooCommerce
|
||||
*/
|
||||
$('body').on('ns_ppc_woo', function() {
|
||||
var _form = $('.nasa-single-product-in-mobile form.cart');
|
||||
|
||||
if ($(_form).length && ($('#ppcp-messages').length || $('.ppc-button-wrapper').length)) {
|
||||
|
||||
if ($('.ns-ppc-wrap').length <= 0) {
|
||||
$(_form).after('<div class="ns-ppc-wrap ns-begin-wrap nasa-crazy-box"></div>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout Plugins - Stripe for WooCommerce - Mess
|
||||
*/
|
||||
if ($('#ppcp-messages').length) {
|
||||
var _ppcp_mess = $('#ppcp-messages');
|
||||
$('.ns-ppc-wrap').append(_ppcp_mess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout Plugins - Stripe for WooCommerce - Button
|
||||
*/
|
||||
if ($('.ppc-button-wrapper').length) {
|
||||
var _ppc_btns = $('.ppc-button-wrapper');
|
||||
$('.ns-ppc-wrap').append(_ppc_btns);
|
||||
}
|
||||
}
|
||||
}).trigger('ns_ppc_woo');
|
||||
|
||||
/**
|
||||
* triger price load
|
||||
*/
|
||||
$('body').on('ns_add_nasa_price_loading', function(e, _form) {
|
||||
var _org_price = null,
|
||||
_sub_price = null,
|
||||
_sub_price_1st = null,
|
||||
_sub_price_2nd = null;
|
||||
|
||||
if ($(_form).find('.ns-form-info .ns-info-wrap').length <= 0) {
|
||||
$(_form).find('.ns-form-info').append('<div class="ns-info-wrap"></div>');
|
||||
}
|
||||
|
||||
$(_form).find('.ns-form-info .ns-info-wrap').html('');
|
||||
|
||||
if ($(_form).find('.ns-form-info .ns-info-wrap .ns-price-wrap').length <= 0) {
|
||||
$(_form).find('.ns-form-info .ns-info-wrap').append('<div class="ns-price-wrap"></div>');
|
||||
}
|
||||
|
||||
/**
|
||||
* nasa-single-product-price - Orgirin
|
||||
*/
|
||||
if ($('.nasa-single-product-in-mobile .price.nasa-single-product-price').length) {
|
||||
if (!$('.nasa-single-product-in-mobile .price.nasa-single-product-price').hasClass('org-price')) {
|
||||
$('.nasa-single-product-in-mobile .price.nasa-single-product-price').addClass('org-price');
|
||||
}
|
||||
|
||||
_org_price = $('.nasa-single-product-in-mobile .price.nasa-single-product-price').clone();
|
||||
|
||||
$(_org_price).removeClass('nasa-single-product-price');
|
||||
}
|
||||
|
||||
if (_org_price) {
|
||||
$(_form).find('.ns-form-info .ns-price-wrap').append(_org_price);
|
||||
}
|
||||
|
||||
if ($(_form).find('.ns-info-variants .single_variation_wrap .woocommerce-variation-price .price').length) {
|
||||
_sub_price = $(_form).find('.ns-info-variants .single_variation_wrap .woocommerce-variation-price .price').html();
|
||||
} else if ($('.nasa-single-product-in-mobile .nasa-bulk-price').length) {
|
||||
_sub_price = $('.nasa-single-product-in-mobile .nasa-bulk-price').html();
|
||||
}
|
||||
|
||||
if (_sub_price) {
|
||||
/**
|
||||
* For Bulk Price OUT Form
|
||||
*/
|
||||
_sub_price_1st = '<p class="price nasa-bulk-price">' + _sub_price + '</p>';
|
||||
|
||||
if ($('.nasa-single-product-in-mobile .nasa-bulk-price').length <= 0) {
|
||||
$('.nasa-single-product-in-mobile .nasa-single-product-price').after(_sub_price_1st);
|
||||
} else {
|
||||
$('.nasa-single-product-in-mobile .nasa-bulk-price').replaceWith(_sub_price_1st);
|
||||
}
|
||||
|
||||
/**
|
||||
* For Bulk Price IN Form
|
||||
*/
|
||||
_sub_price_2nd = '<p class="price sub-price sub-price-2nd">' + _sub_price + '</p>';
|
||||
|
||||
if ($(_form).find('.ns-form-info .sub-price.sub-price-2nd').length <= 0) {
|
||||
$(_form).find('.ns-form-info .ns-price-wrap').append(_sub_price_2nd);
|
||||
} else {
|
||||
$(_form).find('.ns-form-info .sub-price.sub-price-2nd').replaceWith(_sub_price_2nd);
|
||||
}
|
||||
|
||||
$('.price.org-price').hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* availability
|
||||
*/
|
||||
if ($(_form).find('.ns-info-variants .single_variation_wrap .woocommerce-variation-availability').length) {
|
||||
var _availability = $(_form).find('.ns-info-variants .single_variation_wrap .woocommerce-variation-availability').html();
|
||||
|
||||
if (_availability && $(_form).find('.ns-form-info .ns-info-wrap .stock').length <= 0) {
|
||||
$(_form).find('.ns-form-info .ns-info-wrap').append(_availability);
|
||||
// $(_form).find('.ns-form-info .price').append(_availability);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* trigger img load
|
||||
*/
|
||||
$('body').on('ns_add_nasa_img_loading', function(e,_form) {
|
||||
|
||||
var _img = null;
|
||||
|
||||
if ($('.nasa-single-product-in-mobile .main-images .nasa-item-main-image-wrap[data-key="0"] img').length) {
|
||||
_img = $('.nasa-single-product-in-mobile .main-images .item-wrap:not(.slick-cloned) .nasa-item-main-image-wrap[data-key="0"] img').clone();
|
||||
}
|
||||
|
||||
if (_img) {
|
||||
|
||||
if ($(_form).find('.ns-form-info').length <= 0) {
|
||||
$(_form).prepend('<div class="ns-form-info nasa-flex align-start margin-bottom-20"></div>');
|
||||
}
|
||||
|
||||
var _img_src = $(_img).attr('src');
|
||||
|
||||
if ($(_form).find('.ns-form-info .main_min_img').length <= 0) {
|
||||
$(_form).find('.ns-form-info').prepend('<div class="main_min_img"></div>');
|
||||
}
|
||||
|
||||
if ($.inArray(_img_src, _ns_img_checked) !== -1) {
|
||||
$(_form).find('.ns-form-info .main_min_img').html('');
|
||||
|
||||
if ($('body').hasClass('product-zoom')) {
|
||||
$(_form).find('.ns-form-info .main_min_img').html('<a class="ns-popup-img" href="javascript:void(0);"><svg fill="currentColor" viewBox="0 0 24 24" width="20" height="20"><path d="M3,20V12a1,1,0,0,1,2,0v5.585L17.586,5H12a1,1,0,0,1,0-2h8a1,1,0,0,1,1,1v8a1,1,0,0,1-2,0V6.414L6.414,19H12a1,1,0,0,1,0,2H4A1,1,0,0,1,3,20Z"/></svg></a>');
|
||||
}
|
||||
|
||||
$(_form).find('.ns-form-info .main_min_img').append(_img);
|
||||
|
||||
$(_form).find('.ns-form-info .main_min_img').removeClass('nasa-img-loading');
|
||||
|
||||
} else {
|
||||
if (!$(_form).find('.ns-form-info .main_min_img').hasClass('nasa-img-loading')) {
|
||||
$(_form).find('.ns-form-info .main_min_img').addClass('nasa-img-loading');
|
||||
}
|
||||
|
||||
var _interval = setInterval(function() {
|
||||
var _main_src = _img.attr('src');
|
||||
var _img_main = new Image();
|
||||
_img_main.src = _main_src;
|
||||
_img_main.onload = function() {
|
||||
$(_form).find('.ns-form-info .main_min_img').removeClass('nasa-img-loading');
|
||||
|
||||
$(_form).find('.ns-form-info .main_min_img').html('');
|
||||
|
||||
if ($('body').hasClass('product-zoom')) {
|
||||
$(_form).find('.ns-form-info .main_min_img').html('<a class="ns-popup-img" href="javascript:void(0);"><svg fill="currentColor" viewBox="0 0 24 24" width="20" height="20"><path d="M3,20V12a1,1,0,0,1,2,0v5.585L17.586,5H12a1,1,0,0,1,0-2h8a1,1,0,0,1,1,1v8a1,1,0,0,1-2,0V6.414L6.414,19H12a1,1,0,0,1,0,2H4A1,1,0,0,1,3,20Z"/></svg></a>');
|
||||
}
|
||||
|
||||
$(_form).find('.ns-form-info .main_min_img').append(_img);
|
||||
|
||||
_ns_img_checked.push(_img_src);
|
||||
|
||||
clearInterval(_interval);
|
||||
};
|
||||
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Fixed Variation Form
|
||||
*/
|
||||
$('body').on('ns_variation_form_fixed', function() {
|
||||
if ($('.nasa-single-product-in-mobile form.cart.variations_form').length) {
|
||||
|
||||
$('body').trigger('ns_before_variation_form_fixed');
|
||||
|
||||
var _form = $('.nasa-single-product-in-mobile form.cart.variations_form');
|
||||
|
||||
if ($(_form).find('.ns-form-close').length <= 0) {
|
||||
$(_form).append('<a class="ns-form-close nasa-stclose" href="javascript:void(0);" rel="nofollow"></a>');
|
||||
}
|
||||
|
||||
if ($(_form).find('.ns-form-info').length <= 0) {
|
||||
$(_form).prepend('<div class="ns-form-info nasa-flex align-start margin-bottom-20"></div>');
|
||||
}
|
||||
|
||||
if ($(_form).find('.ns-form-info .ns-info-wrap').length <= 0) {
|
||||
$(_form).find('.ns-form-info').append('<div class="ns-info-wrap"></div>');
|
||||
}
|
||||
|
||||
if ($(_form).find('.ns-form-info .ns-info-wrap .ns-price-wrap').length <= 0) {
|
||||
$(_form).find('.ns-form-info .ns-info-wrap').append('<div class="ns-price-wrap"></div>');
|
||||
}
|
||||
|
||||
/**
|
||||
* img change
|
||||
*/
|
||||
$('body').trigger('ns_add_nasa_img_loading', [_form]);
|
||||
|
||||
/**
|
||||
* price change
|
||||
*/
|
||||
$('body').trigger('ns_add_nasa_price_loading', [_form]);
|
||||
|
||||
/**
|
||||
* Size Guide
|
||||
*/
|
||||
if ($('.nasa-single-product-in-mobile .nasa-wrap-popup-nodes .nasa-size-guide').length) {
|
||||
var _side_guide = $('.nasa-single-product-in-mobile .nasa-wrap-popup-nodes .nasa-size-guide .nasa-node-popup').clone();
|
||||
|
||||
if (_side_guide && $(_form).find('.ns-info-variants .nasa-node-popup').length <= 0) {
|
||||
_side_guide.text(_side_guide.text().trim());
|
||||
$(_form).find('table.variations tbody tr:last-child .label').append(_side_guide);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move Btns
|
||||
*/
|
||||
if ($(_form).find('.ns-info-btns .variations_button').length <= 0) {
|
||||
if ($(_form).find('.ns-info-btns').length <= 0) {
|
||||
$(_form).append('<div class="ns-info-btns"></div>');
|
||||
}
|
||||
|
||||
var _btn = $(_form).find('.variations_button');
|
||||
|
||||
if ($(_btn).length) {
|
||||
$(_form).find('.ns-info-btns').append(_btn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatible Woocommerce Custom Product Addons
|
||||
*/
|
||||
if ($(_form).find('.ns-info-btns .wcpa_form_outer').length) {
|
||||
var _wcpa_form_outer = $(_form).find('.ns-info-btns .wcpa_form_outer');
|
||||
|
||||
if ($(_form).find('.ns-info-variants').length) {
|
||||
$(_form).find('.ns-info-variants').append(_wcpa_form_outer);
|
||||
} else {
|
||||
$(_form).find('.ns-info-btns').before(_wcpa_form_outer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout Plugins - Stripe for WooCommerce
|
||||
*/
|
||||
if ($('.ns-ppc-wrap').length) {
|
||||
var _ppc = $('.ns-ppc-wrap');
|
||||
if ($(_form).find('.ns-info-variants').length) {
|
||||
$(_form).find('.ns-info-variants').append(_ppc);
|
||||
} else {
|
||||
$(_form).find('.ns-info-btns').before(_ppc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose Variations
|
||||
*/
|
||||
$('body').trigger('ns_variants_clone_render', [_form]);
|
||||
|
||||
$('body').trigger('ns_after_variation_form_fixed');
|
||||
}
|
||||
}).trigger('ns_variation_form_fixed');
|
||||
|
||||
/**
|
||||
* Variants Clone render
|
||||
*/
|
||||
$('body').on('ns_variants_clone_render', function(e, _form) {
|
||||
if ($('.ns-variants-first').length <= 0) {
|
||||
$(_form).before('<div class="ns-begin-wrap ns-variants-first"></div>');
|
||||
}
|
||||
|
||||
var _choose = '';
|
||||
|
||||
var _tr_attrs = $('body').hasClass('app-attrs-full') ? '.variations tr' : '.variations tr:first-child';
|
||||
$(_form).find(_tr_attrs).each(function() {
|
||||
var _this = $(this);
|
||||
|
||||
var _label = $(_this).find('th.label').length ? $(_this).find('th.label').clone() : null;
|
||||
|
||||
if ($(_label).find('.nasa-node-popup').length) {
|
||||
$(_label).find('.nasa-node-popup').remove();
|
||||
}
|
||||
|
||||
_choose += _label !== null ? '<div class="ns-variant-lbl">' + $(_label).html() + '</div>' : '';
|
||||
|
||||
var _value = $(_this).find('td.value').length ? $(_this).find('td.value').clone() : null;
|
||||
|
||||
if (_value !== null) {
|
||||
if ($(_value).find('.reset_variations').length) {
|
||||
$(_value).find('.reset_variations').remove();
|
||||
}
|
||||
|
||||
if ($(_value).find('[id]').length) {
|
||||
$(_value).find('[id]').removeAttr('id');
|
||||
}
|
||||
|
||||
if ($(_value).find('>select').length){
|
||||
$('.ns-variants-first').addClass('nasa-attribute-select');
|
||||
}
|
||||
|
||||
_choose += '<div class="ns-variant-val">' + $(_value).html() + '</div>';
|
||||
}
|
||||
});
|
||||
|
||||
if (_choose !== '') {
|
||||
$('.ns-variants-first').html('<div class="ns-variants-clone"><a href="javascript:void(0);" class="ns-open-var-form" rel="nofollow"><svg width="11" height="11" viewBox="0 0 512 512" fill="currentColor"><path d="M135 512c3 0 4 0 6 0 15-4 26-21 40-33 62-61 122-122 187-183 9-9 27-24 29-33 3-14-8-23-17-32-67-66-135-131-202-198-11-9-24-27-33-29-18-4-28 8-31 21 0 0 0 2 0 2 1 1 1 6 3 10 3 8 18 20 27 28 47 47 95 93 141 139 19 18 39 36 55 55-62 64-134 129-199 193-8 9-24 21-26 32-3 18 8 24 20 28z"/></svg></a>' + _choose + '</div>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatible - WooCommerce Dynamic Pricing & Discounts
|
||||
*/
|
||||
if ($('#rp_wcdpd_pricing_table_variation_container').length && $(_form).find('.ns-info-variants #rp_wcdpd_pricing_table_variation_container').length <= 0) {
|
||||
$(_form).find('.ns-info-variants').prepend($('#rp_wcdpd_pricing_table_variation_container'));
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Image Variation Changed
|
||||
*/
|
||||
$('body').on('nasa_changed_gallery_variable_single nasa_after_changed_src_main_img', function() {
|
||||
var _form = $('.nasa-single-product-in-mobile form.cart.variations_form');
|
||||
|
||||
/**
|
||||
* img change
|
||||
*/
|
||||
$('body').trigger('ns_add_nasa_img_loading', [_form]);
|
||||
$('body').trigger('load_mini_popup');
|
||||
|
||||
/**
|
||||
* Count items Slides
|
||||
* @type type
|
||||
*/
|
||||
var _wrap = $('.nasa-main-image-default-wrap').parents('.product-images-slider');
|
||||
var _total_gallery = $('.main-images .item-wrap:not(.slick-cloned)').length;
|
||||
var _count = $(_wrap).find('.ns-img-count .ns-img-now');
|
||||
var _total = $(_wrap).find('.ns-img-count .ns-img-total');
|
||||
$(_count).text('1');
|
||||
$(_total).text(_total_gallery);
|
||||
|
||||
if ($(_wrap).find('.nasa-single-arrow').length) {
|
||||
$(_wrap).find('.nasa-single-arrow[data-action="prev"]').addClass('nasa-disabled');
|
||||
|
||||
if (_total_gallery > 1) {
|
||||
$(_wrap).find('.nasa-single-arrow[data-action="next"]').removeClass('nasa-disabled');
|
||||
} else {
|
||||
$(_wrap).find('.nasa-single-arrow[data-action="next"]').addClass('nasa-disabled');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Form Close event
|
||||
*/
|
||||
$('body').on('click', '.ns-form-close', function() {
|
||||
var _form = $(this).parents('form');
|
||||
$(_form).removeClass('ns-show');
|
||||
|
||||
if ($(_form).hasClass('ns_add_to_cart_button_show')) {
|
||||
setTimeout(function() {
|
||||
$(_form).removeClass('ns_add_to_cart_button_show');
|
||||
}, 400);
|
||||
}
|
||||
|
||||
if ($(_form).hasClass('ns_buy_now_button_show')) {
|
||||
setTimeout(function() {
|
||||
$(_form).removeClass('ns_buy_now_button_show');
|
||||
}, 400);
|
||||
}
|
||||
|
||||
$('.black-window').fadeOut(400).removeClass('desk-window');
|
||||
|
||||
$('body').removeClass('ovhd');
|
||||
});
|
||||
|
||||
/**
|
||||
* Added To Cart - Then Close form
|
||||
*/
|
||||
$('body').on('added_to_cart', function() {
|
||||
if ($('form.cart .ns-form-close').length) {
|
||||
$('form.cart .ns-form-close').trigger('click');
|
||||
}
|
||||
|
||||
$('.ns_btn-fixed .single_add_to_cart_button').removeClass('loading');
|
||||
});
|
||||
|
||||
/**
|
||||
* Change Count slide items
|
||||
*/
|
||||
$('body').on('nasa_single_gallery_after_change', function(_ev, _main) {
|
||||
var _wrap = $(_main).parents('.product-images-slider');
|
||||
|
||||
if ($(_wrap).find('.ns-img-count .ns-img-now').length) {
|
||||
var _slides = $(_wrap).find('.nasa-single-product-main-image');
|
||||
var _count = $(_wrap).find('.ns-img-count .ns-img-now');
|
||||
var _imgnow = $(_slides).find('.slick-track .item-wrap.slick-slide.slick-active');
|
||||
$(_count).text(parseInt(_imgnow.attr('data-slick-index')) + 1);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Zoom mini image - magnificPopup
|
||||
*/
|
||||
$('body').on('load_mini_popup', function() {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Show variation
|
||||
*/
|
||||
$('body').on('show_variation', function() {
|
||||
var _form = $('.nasa-single-product-in-mobile form.cart.variations_form');
|
||||
|
||||
/**
|
||||
* Price change
|
||||
*/
|
||||
$('body').trigger('ns_add_nasa_price_loading', [_form]);
|
||||
|
||||
/**
|
||||
* Choose Variations
|
||||
*/
|
||||
$('body').trigger('ns_variants_clone_render', [_form]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Reset Variation
|
||||
*/
|
||||
$('body').on('reset_data', function() {
|
||||
var _form = $('.nasa-single-product-in-mobile form.cart.variations_form');
|
||||
|
||||
/**
|
||||
* Reset Stock
|
||||
*/
|
||||
if ($(_form).find('.ns-form-info .ns-info-wrap .stock').length) {
|
||||
$(_form).find('.ns-form-info .ns-info-wrap .stock').remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset Price
|
||||
*/
|
||||
$('.price.org-price').show();
|
||||
$('.price.sub-price').remove();
|
||||
|
||||
/**
|
||||
* Choose Variations
|
||||
*/
|
||||
$('body').trigger('ns_variants_clone_render', [_form]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Bulk Discount price changed
|
||||
*/
|
||||
$('body').on('ns_bulk_discount_changed', function() {
|
||||
var _form = $('.nasa-single-product-in-mobile form.cart.variations_form');
|
||||
|
||||
if ($(_form).find('.nasa-variation-bulk-dsct').length <= 0 && $('.nasa-single-product-in-mobile .nasa-variation-bulk-dsct').length) {
|
||||
var _bulk = $('.nasa-single-product-in-mobile .nasa-variation-bulk-dsct');
|
||||
$(_form).find('.ns-info-variants').append(_bulk);
|
||||
}
|
||||
|
||||
$('body').trigger('ns_variation_form_fixed');
|
||||
$('body').trigger('ns_add_nasa_price_loading', [_form]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Even Click Read more Tab content
|
||||
*/
|
||||
$('body').on('click', '.ns-btn-read-more', function() {
|
||||
var _this = $(this);
|
||||
//var _row = $(_this).parents('.row:not(.nasa-product-details-page)');
|
||||
var _row = $(_this).parents('.ns-tab-item');
|
||||
// var _read =$(_row).find('.ns-read-more');
|
||||
if (!$(_row).hasClass('ns-row-active')) {
|
||||
$(_row).addClass('ns-row-active');
|
||||
$(_this).find('.ns-btn-read-more-text').html($(_this).attr('data-show-less'));
|
||||
if ($(_row).hasClass('ns-tab-reviews') && $(_row).find('.commentlist').hasClass('masonry')) {
|
||||
$('body').trigger('nasa_masonry_comments', [false, true]);
|
||||
}
|
||||
} else {
|
||||
$(_row).removeClass('ns-row-active');
|
||||
$('body').trigger('nasa_animate_scroll_to_top', [$, _row, 500]);
|
||||
$(_this).find('.ns-btn-read-more-text').html($(_this).attr('data-show-more'));
|
||||
}
|
||||
|
||||
$('body').trigger('nasa_get_tab_mobile_bc');
|
||||
});
|
||||
|
||||
/**
|
||||
* Add Read more for WooCommerce Tab content
|
||||
*/
|
||||
$('body').on('ns_add_read_more', function() {
|
||||
// if ($('#review_form_wrapper').length && $('.btn-add-new-review').length <= 0) {
|
||||
// var _text = $('[name="ns-add-review"]').length ? $('[name="ns-add-review"]').val() : 'Write a review';
|
||||
// $('#review_form_wrapper').after('<a class="button btn-add-new-review" href="javascript:void(0);" rel="nofollow">' + _text + '</a>');
|
||||
// }
|
||||
|
||||
if ($('.woocommerce-tabs .ns-tab-item').length && $('#tmp-read-more-tab').length) {
|
||||
var _ns_readmore = $('#tmp-read-more-tab').html();
|
||||
|
||||
$('.woocommerce-tabs .ns-tab-item').each(function() {
|
||||
var _this = $(this);
|
||||
|
||||
if ($(_this).find('.ns-read-more').length <= 0) {
|
||||
$(_this).append(_ns_readmore);
|
||||
}
|
||||
|
||||
if ($(_this).find('.nasa-content-accessories_content, .cr-reviews-ajax-reviews, .nasa-content-no-read-more').length) {
|
||||
$(_this).removeClass('ns-tab-item');
|
||||
$(_this).addClass('ns-tab-no-read-more');
|
||||
}
|
||||
|
||||
if ($(_this).find('.nasa-content-additional_information').length && $(_this).find('.nasa-content-additional_information').outerHeight() <= 300) {
|
||||
|
||||
console.log($(_this).find('.nasa-content-additional_information').outerHeight());
|
||||
$(_this).removeClass('ns-tab-item');
|
||||
$(_this).addClass('ns-tab-no-read-more');
|
||||
}
|
||||
|
||||
if ($(_this).find('.nasa-content-reviews').length) {
|
||||
$(_this).addClass('ns-tab-reviews');
|
||||
}
|
||||
});
|
||||
}
|
||||
}).trigger('ns_add_read_more');
|
||||
|
||||
/**
|
||||
* After Loaded Ajax complete
|
||||
*/
|
||||
$('body').on('nasa_after_loaded_ajax_complete', function() {
|
||||
if ($('body').find('.ns_btn-fixed').length) {
|
||||
$('body').find('.ns_btn-fixed').remove();
|
||||
}
|
||||
|
||||
$('body').trigger('ns_btns_fixed');
|
||||
$('body').trigger('ns_hide_simple_cart_form');
|
||||
$('body').trigger('ns_variation_form_fixed');
|
||||
$('body').trigger('ns_add_read_more');
|
||||
});
|
||||
|
||||
//swipe down to close variations_form, size-guide, delivery-return, ask-a-quetion.
|
||||
$('body').on('touchstart', '.variations_form, #nasa-content-size-guide, #nasa-content-delivery-return, #nasa-content-ask-a-quetion, #review_form_wrapper, #nasa-content-request-a-callback', function(e) {
|
||||
var scrollTop = $(this).find('.ns-inct').scrollTop();
|
||||
touchstart = 0;
|
||||
if ($(e.target).parents('.nasa-popup-content-contact').length) {
|
||||
scrollTop = $(this).find('.nasa-wrap').scrollTop();
|
||||
if ($(e.target).attr('name') == 'your-message') {
|
||||
var st = $(e.target).scrollTop();
|
||||
if(st > 0) {
|
||||
scrollTop = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($(e.target).parents('.variations_form').length) {
|
||||
scrollTop = $(this).find('.ns-info-variants').scrollTop();
|
||||
}
|
||||
|
||||
if ($(e.target).parents('#review_form_wrapper').length) {
|
||||
scrollTop = $(this).scrollTop();
|
||||
|
||||
if ($(e.target).attr('id') == 'comment') {
|
||||
var st = $(e.target).scrollTop();
|
||||
if (st > 0) {
|
||||
scrollTop = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($(e.target).hasClass('nasa-product') || $(e.target).attr('id') == 'nasa-content-size-guide' || $(e.target).attr('id') == 'nasa-content-delivery-return') {
|
||||
scrollTop = 0;
|
||||
}
|
||||
|
||||
if (scrollTop <= 0) {
|
||||
touchstart = e.touches[0].clientY;
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('touchmove', '.variations_form, #nasa-content-size-guide, #nasa-content-delivery-return, #nasa-content-ask-a-quetion, #review_form_wrapper, #nasa-content-request-a-callback', function(e) {
|
||||
touchend = e.changedTouches[0].clientY;
|
||||
|
||||
if (touchstart != touchend && touchstart != 0 && Math.abs(touchstart - touchend) > distance) {
|
||||
if (touchstart < touchend) {
|
||||
$(this).find('a.nasa-stclose').trigger('click');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if ($('.related-product .nasa-title-relate').length) {
|
||||
$('.related-product .nasa-title-relate').removeClass('text-center');
|
||||
}
|
||||
|
||||
//swipe photoswipe X
|
||||
// $('body').on('touchstart', '.pswp .comment-text',function(e) {
|
||||
// touchstart = e.touches[0].clientX;
|
||||
// });
|
||||
|
||||
// $('body').on('touchend', '.pswp .comment-text',function(e) {
|
||||
// touchend = e.changedTouches[0].clientX;
|
||||
|
||||
// if (touchstart != touchend && touchstart != 0 && Math.abs(touchstart - touchend) > distance) {
|
||||
// if (touchstart > touchend) {
|
||||
// $('.pswp__button--arrow--right').trigger('click');
|
||||
// } else {
|
||||
// $('.pswp__button--arrow--left').trigger('click');
|
||||
// }
|
||||
// }
|
||||
|
||||
// touchend = 0;
|
||||
// touchstart = 0;
|
||||
// });
|
||||
|
||||
$('body').on('mini_cart_mobile_layout_change_single_page',function() {
|
||||
var _nasa_product_details_page = $('.nasa-product-details-page.nasa-top-navigaton');
|
||||
|
||||
setTimeout(function() {
|
||||
if ($(_nasa_product_details_page).length && $('body').hasClass('nasa-mobile-app')) {
|
||||
var _woocommerce_tabs = $(_nasa_product_details_page).find('.woocommerce-tabs');
|
||||
var _ns_tab_item = $(_woocommerce_tabs).find('>.row');
|
||||
var _product_header = $('body').find('.nasa-header-mobile-layout .sticky-wrapper');
|
||||
var _related_product = $('body').find('.related-product:first');
|
||||
var _focus_info = $(_nasa_product_details_page).find('.focus-info');
|
||||
|
||||
var _title = '';
|
||||
var _target = '';
|
||||
|
||||
var html = '<div class="nasa-bc-details-page-wrap"><div class="nasa-iflex flex-nowrap">';
|
||||
|
||||
if ($(_focus_info).length) {
|
||||
_title = $('body').find('input[name="nasa-title-bc-general"]').val();
|
||||
_target = '.focus-info';
|
||||
|
||||
html += '<a href="javascript:void(0);" title="' + _title + '" rel="nofollow" class="nasa-bold-500 nasa-bc-details-step" data-target="' + _target + '">' + _title + '</a>';
|
||||
}
|
||||
|
||||
$(_ns_tab_item).each(function() {
|
||||
var _this = $(this);
|
||||
var _nasa_content = $(_this).find('.nasa-content');
|
||||
_title = $(_nasa_content).find('.ns-woo-tab-title').length ? $(_nasa_content).find('.ns-woo-tab-title').text().trim() : '';
|
||||
var _id = $(_nasa_content).attr('id');
|
||||
|
||||
if (_id == 'nasa-scroll-reviews') {
|
||||
_title = $('body').find('input[name="nasa-title-bc-review"]').val();
|
||||
}
|
||||
|
||||
if (_id == 'nasa-scroll-reviews' | _id == 'nasa-scroll-description') {
|
||||
html += '<a href="javascript:void(0);" title="'+_title+'" rel="nofollow" class="nasa-bold-500 nasa-bc-details-step" data-target="#' + _id + '">' + _title + '</a>';
|
||||
}
|
||||
else if ($(_nasa_product_details_page).hasClass('nasa-top-navigaton-ctab') && _id !== 'nasa-scroll-accessories_content') {
|
||||
html += '<a href="javascript:void(0);" title="'+_title+'" rel="nofollow" class="nasa-bold-500 nasa-bc-details-step" data-target="#' + _id + '">' + _title + '</a>';
|
||||
}
|
||||
});
|
||||
|
||||
if ($(_related_product).length) {
|
||||
_title = $('body').find('input[name="nasa-title-bc-recommendation"]').val();
|
||||
_target = '.related-product:first';
|
||||
|
||||
html += '<a href="javascript:void(0);" title="' + _title + '" rel="nofollow" class="nasa-bold-500 nasa-bc-details-step" data-target="' + _target + '">' + _title + '</a>';
|
||||
}
|
||||
|
||||
html += '</div></div>';
|
||||
|
||||
if ($(_product_header).length) {
|
||||
$(_product_header).append(html);
|
||||
$(_product_header).find('.nasa-bc-details-step:first-child').addClass('nasa-active');
|
||||
}
|
||||
}
|
||||
|
||||
$('body').trigger('nasa_get_tab_mobile_bc');
|
||||
|
||||
}, 1000);
|
||||
|
||||
}).trigger('mini_cart_mobile_layout_change_single_page');
|
||||
|
||||
$('body').on('click', '.nasa-bc-details-step', function(){
|
||||
var _this = $(this);
|
||||
var index = $(_this).index();
|
||||
var tab_active = tab_bc[index];
|
||||
|
||||
$('.nasa-bc-details-page-wrap').addClass('on-scrolling');
|
||||
$(_this).addClass('nasa-active').siblings().removeClass('nasa-active');
|
||||
|
||||
|
||||
$('html').animate({scrollTop: tab_active.offsetTop + 10}, 10, function() {
|
||||
if (Timeout_bc_remoc_class != null) {
|
||||
clearTimeout(Timeout_bc_remoc_class);
|
||||
}
|
||||
|
||||
Timeout_bc_remoc_class = setTimeout(function() {
|
||||
$('.nasa-bc-details-page-wrap').removeClass('on-scrolling');
|
||||
},1000);
|
||||
});
|
||||
|
||||
var _first = $('.nasa-bc-details-page-wrap').find('.nasa-bc-details-step:first');
|
||||
var p_w = $('.nasa-bc-details-page-wrap').outerWidth();
|
||||
var c_w = $(_this).outerWidth();
|
||||
var _pos_left = $(_this).offset().left;
|
||||
var _f_pos = $(_first).offset().left;
|
||||
|
||||
if (Timeout_bc_click != null) {
|
||||
clearTimeout(Timeout_bc_click);
|
||||
}
|
||||
|
||||
Timeout_bc_click = setTimeout(function() {
|
||||
$('.nasa-bc-details-page-wrap').animate({scrollLeft: _pos_left - _f_pos -(p_w - c_w)/2}, 200);
|
||||
}, 10);
|
||||
});
|
||||
|
||||
$('body').on('nasa_after_loaded_ajax_complete', function() {
|
||||
$('body').trigger('mini_cart_mobile_layout_change_single_page');
|
||||
});
|
||||
|
||||
$('body').on('nasa_get_tab_mobile_bc', function() {
|
||||
var _step = $('.nasa-bc-details-page-wrap .nasa-bc-details-step');
|
||||
var _nasa_ajax_store = $('#nasa-ajax-store');
|
||||
|
||||
$(_step).each(function() {
|
||||
var _this = $(this);
|
||||
var _target = $(_this).attr('data-target');
|
||||
var _row = $(_nasa_ajax_store).find(_target);
|
||||
var _pos_top = $(_row).length ? $(_row).offset().top : 0;
|
||||
|
||||
|
||||
if ($('body').find('.nasa-header-sticky').length && $('.sticky-wrapper').length) {
|
||||
_pos_top -= $('.sticky-wrapper').outerHeight();
|
||||
}
|
||||
|
||||
if ($('#wpadminbar').length) {
|
||||
_pos_top -= $('#wpadminbar').outerHeight();
|
||||
}
|
||||
|
||||
_pos_top -= 10;
|
||||
|
||||
tab_bc.push({ name: _target, offsetTop: _pos_top });
|
||||
});
|
||||
});
|
||||
|
||||
var headerHeight = $('#header-content').length ? $('#header-content').outerHeight() : 0;
|
||||
|
||||
$(window).on('scroll', function () {
|
||||
var scrollTop = $(this).scrollTop();
|
||||
if ($('body').find('.nasa-header-sticky').length && $('.sticky-wrapper').length) {
|
||||
if (Math.round(scrollTop) > 0) {
|
||||
if (!$('.sticky-wrapper').hasClass('fixed-already')) {
|
||||
$('.sticky-wrapper').addClass('fixed-already');
|
||||
}
|
||||
} else {
|
||||
$('.sticky-wrapper').removeClass('fixed-already');
|
||||
}
|
||||
}
|
||||
|
||||
if ($('.nasa-bc-details-page-wrap .nasa-bc-details-step').length && !$('.nasa-bc-details-page-wrap').hasClass('on-scrolling')) {
|
||||
var currentTab = $('.nasa-bc-details-step.nasa-active').attr('data-target');
|
||||
var activeTab = null;
|
||||
|
||||
tab_bc.forEach(function(element, index) {
|
||||
var nextElement = tab_bc[index + 1];
|
||||
|
||||
if (!nextElement) {
|
||||
if (scrollTop >= element.offsetTop) {
|
||||
activeTab = element.name;
|
||||
}
|
||||
} else if (scrollTop >= element.offsetTop && scrollTop < nextElement.offsetTop) {
|
||||
activeTab = element.name;
|
||||
}
|
||||
});
|
||||
|
||||
if (activeTab !== currentTab) {
|
||||
currentTab = activeTab;
|
||||
var _just_active = $('.nasa-bc-details-step[data-target="'+currentTab+'"]');
|
||||
var _first = $('.nasa-bc-details-page-wrap').find('.nasa-bc-details-step:first');
|
||||
var p_w = $('.nasa-bc-details-page-wrap').outerWidth();
|
||||
|
||||
if (_just_active) {
|
||||
var c_w = $(_just_active).outerWidth();
|
||||
var _pos_left = $(_just_active).offset().left;
|
||||
var _f_pos = $(_first).offset().left;
|
||||
|
||||
$('.nasa-bc-details-step').removeClass('nasa-active');
|
||||
$(_just_active).addClass('nasa-active');
|
||||
|
||||
if (Timeout_bc != null) {
|
||||
clearTimeout(Timeout_bc);
|
||||
}
|
||||
|
||||
Timeout_bc = setTimeout(function() {
|
||||
$('.nasa-bc-details-page-wrap').stop().animate({scrollLeft: _pos_left - _f_pos -(p_w - c_w)/2}, 200);
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
/* End Document Ready */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Document Ready !!!
|
||||
*/
|
||||
jQuery(document).ready(function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Multi Currencies
|
||||
*/
|
||||
if ($('.nasa-currencies-3rd .nasa-currency-switcher').length) {
|
||||
/**
|
||||
* For FOX - Currency Switcher Professional for WooCommerce
|
||||
*/
|
||||
if ($('.woocs_auto_switcher').length) {
|
||||
var _woocs = $('.woocs_auto_switcher');
|
||||
var _clone = '<ul class="nasa-woocs-switcher crr-switcher">';
|
||||
|
||||
var _i = 0;
|
||||
$(_woocs).find('.woocs_auto_switcher_link').each(function() {
|
||||
var _this = $(this);
|
||||
$(_this).attr('data-index', _i);
|
||||
_i++;
|
||||
|
||||
if (!$(_this).hasClass('woocs_curr_curr')) {
|
||||
var _item = $(_this).parents('li').clone();
|
||||
$(_item).find('a').removeClass('woocs_auto_switcher_link');
|
||||
$(_item).find('a').addClass('nasa-woocs-switcher-link');
|
||||
_clone += '<li>' + $(_item).html() + '</li>';
|
||||
}
|
||||
});
|
||||
|
||||
_clone += '</ul>';
|
||||
|
||||
var _cur_woocs = $(_woocs).find('.woocs_curr_curr').clone();
|
||||
$(_cur_woocs).removeClass('woocs_auto_switcher_link');
|
||||
$(_cur_woocs).removeClass('woocs_curr_curr');
|
||||
$(_cur_woocs).addClass('nasa-crc nasa-woocs-crc');
|
||||
$('.nasa-currencies-3rd').prepend(_cur_woocs);
|
||||
$('.nasa-currency-switcher').append(_clone);
|
||||
$('.nasa-currency-switcher, .nasa-currencies-3rd').removeClass('hidden-tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* For CURCY - Multi Currency for WooCommerce
|
||||
*/
|
||||
if ($('.wmc-list-currencies').length) {
|
||||
var _wmc = $('.wmc-list-currencies');
|
||||
var _clone = '<ul class="nasa-wmc-switcher crr-switcher">';
|
||||
var _active = '';
|
||||
|
||||
$(_wmc).find('.wmc-currency').each(function() {
|
||||
var _this = $(this);
|
||||
var _item = $(_this).clone();
|
||||
|
||||
if (!$(_this).hasClass('wmc-active')) {
|
||||
if ($(_item).find('.wmc-currency-symbol').length) {
|
||||
$(_item).find('a').prepend($(_item).find('.wmc-currency-symbol'));
|
||||
}
|
||||
|
||||
_clone += '<li>' + $(_item).html() + '</li>';
|
||||
} else {
|
||||
var _html_act = $(_item).html();
|
||||
|
||||
if ($(_item).find('.wmc-active-title').length) {
|
||||
$(_item).find('.wmc-active-title').prepend($(_item).find('.wmc-currency-symbol'));
|
||||
|
||||
_html_act = $(_item).find('.wmc-active-title').html();
|
||||
} else {
|
||||
if ($(_item).find('a').length) {
|
||||
_html_act = $(_item).find('a').html();
|
||||
}
|
||||
}
|
||||
|
||||
_active = '<a href="javascript:void(0);" rel="nofollow" class="wmc-active">' + _html_act + '</a>';
|
||||
}
|
||||
});
|
||||
|
||||
_clone += '</ul>';
|
||||
|
||||
$('.nasa-currencies-3rd').prepend(_active);
|
||||
$('.nasa-currency-switcher').append(_clone);
|
||||
$('.nasa-currency-switcher, .nasa-currencies-3rd').removeClass('hidden-tag');
|
||||
|
||||
if ($(_wmc).parents('.woocommerce-multi-currency').length) {
|
||||
$(_wmc).parents('.woocommerce-multi-currency').addClass('hidden-tag');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger For FOX - Currency Switcher Professional for WooCommerce
|
||||
*/
|
||||
$('body').on('click', '.nasa-woocs-switcher-link', function(e) {
|
||||
var _index = $(this).attr('data-index');
|
||||
if ($('.woocs_auto_switcher_link[data-index="' + _index + '"]').length) {
|
||||
$('.woocs_auto_switcher_link[data-index="' + _index + '"]').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Render for Mobile menu
|
||||
*/
|
||||
$('body').on('nasa_after_render_currencies_switcher', function(e, _currency) {
|
||||
if ($(_currency).find('.nasa-currency-switcher').length) {
|
||||
$(_currency).addClass('menu-item-has-children root-item li_accordion');
|
||||
$(_currency).find('.nasa-currency-switcher').addClass('nav-dropdown');
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
/**
|
||||
* After loaded ajax .nasa-currency-switcher
|
||||
*/
|
||||
var _ns_spmtcrc = '';
|
||||
|
||||
$('body').on('nasa_before_load_ajax', function() {
|
||||
if ($('.nasa-currencies-3rd').length) {
|
||||
var _crc = $('.nasa-currencies-3rd').clone();
|
||||
_ns_spmtcrc = $(_crc).html();
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('nasa_after_loaded_ajax_complete', function() {
|
||||
if ($('.nasa-currencies-3rd').length) {
|
||||
$('.nasa-currencies-3rd').html(_ns_spmtcrc);
|
||||
$('.nasa-currencies-3rd').removeClass('hidden-tag');
|
||||
}
|
||||
|
||||
_ns_spmtcrc = '';
|
||||
});
|
||||
|
||||
$('body').on('click', 'a[data-currency]', function() {
|
||||
if (typeof _popstate_reload !== 'undefined') {
|
||||
_popstate_reload = false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user