Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/game.picotech.app/public_html/assets/front/js/ drwxr-xr-x | |
| Viewing file: Select action/file-type: $(function ($) {
"use strict";
function lazy() {
$(".lazy").Lazy({
scrollDirection: 'vertical',
effect: "fadeIn",
effectTime: 1000,
threshold: 0,
visibleOnly: false,
onError: function (element) {
console.log('error loading ' + element.data('src'));
}
});
}
$(document).ready(function () {
lazy();
function number_format (number, decimals =2, dec_point, thousands_sep) {
// Strip all characters but numerical ones.
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
s = '',
toFixedFix = function (n, prec) {
var k = Math.pow(10, prec);
return '' + Math.round(n * k) / k;
};
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0');
}
return s.join(dec);
}
// announcement banner magnific popup
if (mainbs.is_announcement == 1) {
$('.announcement-banner').magnificPopup({
type: 'inline',
midClick: true,
mainClass: 'mfp-fade',
callbacks: {
open: function () {
$.magnificPopup.instance.close = function () {
// Do whatever else you need to do here
sessionStorage.setItem("announcement", "closed");
// console.log(sessionStorage.getItem('announcement'));
// Call the original close method to close the announcement
$.magnificPopup.proto.close.call(this);
};
}
}
});
}
// Mobile Category
$('#category_list .has-children .category_search span').on('click', function (e) {
e.preventDefault();
});
// Toggle mobile serch
$('.close-m-serch').on('click', function () {
$('.topbar .search-box-wrap').toggleClass('d-none');
});
// Flash Deal Area Start
var $hero_slider_main = $(".hero-slider-main");
$hero_slider_main.owlCarousel({
navText: [],
nav: true,
dots: false,
loop: true,
autoplay: true,
autoplayTimeout: 5000,
smartSpeed: 1200,
items: 1,
thumbs: false,
});
// heroarea-slider
var $testimonialSlider = $('.heroarea-slider');
$testimonialSlider.owlCarousel({
loop: true,
navText: [],
nav: true,
nav: true,
dots: false,
autoplay: true,
thumbs: false,
autoplayTimeout: 5000,
smartSpeed: 1200,
responsive: {
0: {
items: 1,
nav: false,
},
576: {
items: 1
},
950: {
items: 1
},
960: {
items: 1
},
1200: {
items: 1
}
}
});
// popular_category_slider
var $popular_category_slider = $(".popular-category-slider");
$popular_category_slider.owlCarousel({
navText: [],
nav: true,
dots: false,
loop: false,
autoplayTimeout: 6000,
smartSpeed: 1200,
margin: 15,
thumbs: false,
responsive: {
0: {
items: 2,
},
576: {
items: 2,
},
768: {
items: 3,
},
992: {
items: 4,
},
1200: {
items: 4,
},
1400: {
items: 5
}
},
});
// Flash Deal Area Start
var $flash_deal_slider = $(".flash-deal-slider");
$flash_deal_slider.owlCarousel({
navText: [],
nav: true,
dots: false,
autoplayTimeout: 6000,
smartSpeed: 1200,
margin: 15,
thumbs: false,
responsive: {
0: {
items: 1,
margin: 0,
},
576: {
items: 1,
margin: 0,
},
768: {
items: 1,
margin: 0,
},
992: {
items: 2,
},
1200: {
items: 2,
},
1400: {
items: 2,
},
},
});
// col slider
var $col_slider = $(".newproduct-slider");
$col_slider.owlCarousel({
navText: [],
nav: true,
dots: false,
loop: false,
autoplayTimeout: 6000,
smartSpeed: 1200,
margin: 15,
thumbs: false,
responsive: {
0: {
items: 1,
},
530: {
items: 1,
},
},
});
// col slider 2
var $col_slider2 = $(".toprated-slider");
$col_slider2.owlCarousel({
navText: [],
nav: true,
dots: false,
loop: true,
autoplayTimeout: 6000,
smartSpeed: 1200,
margin: 15,
thumbs: false,
responsive: {
0: {
items: 1,
},
530: {
items: 1,
},
},
});
// newproduct-slider Area Start
var $newproduct_slider = $(".features-slider");
$newproduct_slider.owlCarousel({
navText: [],
nav: true,
dots: false,
autoplayTimeout: 6000,
smartSpeed: 1200,
loop: false,
margin: 15,
thumbs: false,
responsive: {
0: {
items: 2,
},
576: {
items: 2,
},
768: {
items: 3,
},
992: {
items: 4,
},
1200: {
items: 4,
},
1400: {
items: 5
}
},
});
// home-blog-slider
var $home_blog_slider = $(".home-blog-slider");
$home_blog_slider.owlCarousel({
navText: [],
nav: true,
dots: false,
autoplayTimeout: 6000,
smartSpeed: 1200,
loop: false,
thumbs: false,
margin: 15,
responsive: {
0: {
items: 1,
},
576: {
items: 2,
},
768: {
items: 3,
},
992: {
items: 3,
},
1200: {
items: 3,
},
1400: {
items: 4,
}
},
});
// brand-slider
var $brand_slider = $(".brand-slider");
$brand_slider.owlCarousel({
navText: [],
nav: true,
dots: false,
autoplayTimeout: 6000,
smartSpeed: 1200,
loop: true,
thumbs: false,
margin: 15,
responsive: {
0: {
items: 2,
},
575: {
items: 3,
},
790: {
items: 4,
},
1100: {
items: 4,
},
1200: {
items: 4,
},
1400: {
items: 5,
}
},
});
// toprated-slider Area Start
var $relatedproductsliderv = $(".relatedproductslider");
$relatedproductsliderv.owlCarousel({
nav: false,
dots: true,
autoplayTimeout: 6000,
smartSpeed: 1200,
margin: 15,
thumbs: false,
responsive: {
0: {
items: 2,
},
576: {
items: 2,
},
768: {
items: 3,
},
992: {
items: 4,
},
1200: {
items: 4,
},
1400: {
items: 5
}
},
});
// Blog Details Slider Area Start
var $hero_slider_main = $(".blog-details-slider");
$hero_slider_main.owlCarousel({
navText: [],
nav: true,
dots: true,
loop: true,
autoplay: true,
autoplayTimeout: 5000,
smartSpeed: 1200,
items: 1,
thumbs: false,
});
// Recent Blog Slider Area Start
var $popular_category_slider = $(".resent-blog-slider");
$popular_category_slider.owlCarousel({
navText: [],
nav: false,
dots: true,
loop: false,
autoplayTimeout: 5000,
smartSpeed: 1200,
margin: 30,
thumbs: false,
responsive: {
0: {
items: 1,
},
576: {
items: 2,
},
768: {
items: 2,
},
992: {
items: 3,
},
1200: {
items: 3,
}
},
});
// Product details main slider
$('.product-details-slider').owlCarousel({
loop: true,
items: 1,
autoplayTimeout: 5000,
smartSpeed: 1200,
autoplay: false,
thumbs: true,
dots: false,
thumbImage: true,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
thumbContainerClass: 'owl-thumbs',
thumbItemClass: 'owl-thumb-item',
});
// Product details image zoom
$('.product-details-slider .item').zoom();
// Video popup
$('.video-btn a').magnificPopup({
type: 'iframe',
mainClass: 'mfp-fade'
});
$('.left-category-area .category-header').on('click', function () {
$('.left-category-area .category-list').toggleClass("active")
});
$("[data-date-time]").each(function () {
var $this = $(this),
finalDate = $(this).attr("data-date-time");
$this.countdown(finalDate, function (event) {
$this.html(
event.strftime(
`<span>%D<small>${language.Days}</small></span></small> <span>%H<small>${language.Hrs}</small></span> <span>%M<small>${language.Min}</small></span> <span>%S<small>${language.Sec}</small></span>`
)
);
});
});
$(document).on("click", ".subscribe-btn", function (e) {
e.preventDefault();
const subscribe_url = $(this).attr('data-subscribe-url');
const subscribe_token = $(this).attr('data-subscribe-token');
let subscriber_email_address = $("#subscriber-email-address").val();
if (subscriber_email_address) {
$.ajax({
type: "POST",
url: subscribe_url,
data: {
email: subscriber_email_address,
"_token": subscribe_token,
},
success: function (response) {
if (response.status == 'success') {
successNotification(response.message);
} else {
dangerNotification(response.message);
}
},
});
}
})
$(document).on("click", ".subscribe-btn1", function (e) {
e.preventDefault();
const subscriber_url = $(this).attr('data-subscriber-url');
const subscriber_token = $(this).attr('data-subscriber-token');
let subscribe_email_address = $("#subscriber-email").val();
if (subscribe_email_address) {
$.ajax({
type: "POST",
url: subscriber_url,
data: {
email: subscribe_email_address,
"_token": subscriber_token,
},
success: function (response) {
if (response.status == 'success') {
successNotification(response.message);
} else {
dangerNotification(response.message);
}
},
});
}
})
let selectedRating = $("#rating_point").val() || 0;
$(".star").on("mouseover", function() {
const ratingValue = $(this).data("value");
highlightStars(ratingValue);
});
$(".star").on("mouseout", function() {
highlightStars(selectedRating);
});
$(".star").on("click", function() {
selectedRating = $(this).data("value");
highlightStars(selectedRating);
$("#rating-value").text("You rated this " + selectedRating + " stars.");
$("#rating_point").val(selectedRating);
});
function highlightStars(ratingValue) {
$(".star").each(function() {
if ($(this).data("value") <= ratingValue) {
$(this).addClass("selected");
$(this).removeClass("star-inactive");
} else {
$(this).removeClass("selected");
$(this).addClass("star-inactive");
}
});
}
$(document).on("click", ".user-btn-review", function(e) {
const review_url = $(this).attr('data-review-url');
const review_token = $(this).attr('data-review-token');
let review = $("#user_review").val();
let item_id = $("#item_id").val();
let selectedRating = $("#rating_point").val();
if (review && selectedRating) {
$.ajax({
type: "POST",
url: review_url,
data: {
rating: selectedRating,
review: review,
item_id: item_id,
"_token": review_token,
},
success: function(response) {
if (response.status == 'success') {
successNotification(response.message);
const newRating = response.rating;
$('.star').each(function() {
if ($(this).data('value') <= newRating) {
$(this).addClass('active');
}
});
$('#rating_point').val(newRating);
selectedRating = newRating;
highlightStars(newRating);
} else {
dangerNotification(response.message);
}
},
});
}
});
highlightStars(selectedRating);
// $(document).on("click", ".user-btn-review", function (e) {
// e.preventDefault();
// const review_url = $(this).attr('data-review-url');
// const review_token = $(this).attr('data-review-token');
// let review = $("#user_review").val();
// let item_id = $("#item_id").val();
// let selectedRating = $("#rating_point").val();
// console.log(review,selectedRating);
// if(review && selectedRating){
// $.ajax({
// type: "POST",
// url: review_url,
// data: {
// rating: selectedRating,
// review: review,
// item_id: item_id,
// "_token": review_token,
// },
// success: function (response) {
// if (response.status == 'success') {
// successNotification(response.message);
// } else {
// dangerNotification(response.message);
// }
// },
// });
// }
// });
$(document).on('click', '.whish-list-add', function (e) {
e.preventDefault();
let product_id = '';
let wish_list_count = 0;
let wishlist_url = $(this).attr('data-url');
const token = $(this).attr('data-token');
product_id = $(this).attr('data-product-id');
wish_list_count = $('#wish-list-total-count').html();
$.ajax({
type: "POST",
url: wishlist_url,
data: {
product_id: product_id,
"_token": token,
},
success: function (response) {
if (response.status == 0) {
location.href = response.link;
} else if (response.status == 2) {
dangerNotification(response.message);
} else {
$('#wish-list-total-count').text(response.count);
$('#wish-list-total-count-sm').text(response.count);
successNotification(response.message);
}
},
error: function (xhr, status, error) {
dangerNotification(error);
}
});
});
// Subscriber Form Submit
// $(document).on("submit", ".subscriber-form", function (e) {
// e.preventDefault();
// var $this = $(this);
// var submit_btn = $this.find("button");
// submit_btn.find(".fa-spin").removeClass("d-none");
// $this.find("input[name=email]").prop("readonly", true);
// submit_btn.prop("disabled", true);
// $.ajax({
// method: "POST",
// url: $(this).prop("action"),
// data: new FormData(this),
// contentType: false,
// cache: false,
// processData: false,
// success: function (data) {
// if (data.errors) {
// for (var error in data.errors) {
// dangerNotification(data.errors[error]);
// }
// } else {
// if ($this.hasClass("subscription-form")) {
// $(".close-popup").click();
// }
// successNotification(data);
// $this.find("input[name=email]").val("");
// }
// submit_btn.find(".fa-spin").addClass("d-none");
// $this.find("input[name=email]").prop("readonly", false);
// submit_btn.prop("disabled", false);
// },
// });
// });
$(document).on("submit", ".subscribe-btn", function (e) {
e.preventDefault();
console.log('pepepepep');
var $this = $(this);
var submit_btn = $this.find("button");
submit_btn.find(".fa-spin").removeClass("d-none");
$this.find("input[name=email]").prop("readonly", true);
submit_btn.prop("disabled", true);
$.ajax({
method: "POST",
url: $(this).prop("action"),
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function (data) {
if (data.errors) {
for (var error in data.errors) {
dangerNotification(data.errors[error]);
}
} else {
if ($this.hasClass("subscription-form")) {
$(".close-popup").click();
}
successNotification(data);
$this.find("input[name=email]").val("");
}
submit_btn.find(".fa-spin").addClass("d-none");
$this.find("input[name=email]").prop("readonly", false);
submit_btn.prop("disabled", false);
},
});
});
// Subscriber Form Submit ENDS
// Notifications
function successNotification(title) {
$.notify(
{
title: ` <strong>${title}</strong>`,
message: "",
icon: "fas fa-check-circle",
},
{
// settings
element: "body",
position: null,
type: "success",
allow_dismiss: true,
newest_on_top: false,
showProgressbar: false,
placement: {
from: "top",
align: "right",
},
offset: 20,
spacing: 10,
z_index: 99999,
delay: 5000,
timer: 1000,
url_target: "_blank",
mouse_over: null,
animate: {
enter: "animated fadeInDown",
exit: "animated fadeOutUp",
},
onShow: null,
onShown: null,
onClose: null,
onClosed: null,
icon_type: "class",
}
);
}
function dangerNotification(title) {
$.notify(
{
// options
title: ` <strong>${title}</strong>`,
message: "",
icon: "fas fa-exclamation-triangle",
},
{
// settings
element: "body",
position: null,
type: "danger",
allow_dismiss: true,
newest_on_top: false,
showProgressbar: false,
placement: {
from: "top",
align: "right",
},
offset: 20,
spacing: 10,
z_index: 99999,
delay: 5000,
timer: 1000,
url_target: "_blank",
mouse_over: null,
animate: {
enter: "animated fadeInDown",
exit: "animated fadeOutUp",
},
onShow: null,
onShown: null,
onClose: null,
onClosed: null,
icon_type: "class",
}
);
}
// Notifications Ends
$(document).on('click', '.list-view', function () {
let viewCheck = $(this).attr('data-step');
let check = $(this);
$('.list-view').removeClass('active');
$('#search_form #view_check').val(viewCheck);
$("#search_button").click();
check.addClass('active');
})
// category wise product
$(document).on('click', '.category_get,.product_get', function () {
$('.' + this.className).removeClass('active');
$(this).addClass('active');
let geturl = $(this).attr('data-href');
let view = $(this).attr('data-target');
$('.' + view).removeClass('d-none');
$.get(geturl, function (response) {
$('#' + view).html(response);
$('.' + view).addClass('d-none');
if (response.data === undefined) {
$('.' + view + '_not_found').removeClass('d-none');
} else {
$('.' + view + '_not_found').addClass('d-none');
}
});
})
function check_product_stock(){
let item_current_stock = parseInt($('#current_stock').val());
let item_current_qty = parseInt($('.cart-amount').val());
if (item_current_stock == 0) {
dangerNotification('Product is out of stock.');
return false;
}
if (item_current_qty > item_current_stock) {
const maximum_product_quantity = 'Low Stock, Current Stock is: ' + item_current_stock;
dangerNotification(maximum_product_quantity);
return false;
}
return true;
}
// product quintity select js Start
$(document).on('click', '.subclick', function () {
let current_qty = parseInt($('.cart-amount').val());
if (current_qty > 1) {
$('.cart-amount').val(current_qty - 1);
} else {
const minimum_product_quantity = 'Minumum Quantity Must Be 1';
dangerNotification(minimum_product_quantity);
}
})
// product quintity select js Start
$(document).on('click', '.addclick', function () {
let current_stock = parseInt($('#current_stock').val());
let current_qty = parseInt($('.cart-amount').val());
if (current_qty < current_stock) {
$('.cart-amount').val(current_qty + 1);
} else {
const maximum_product_quantity = 'Low Stock, Current Stock is : ' + current_stock;
dangerNotification(maximum_product_quantity);
}
})
$(document).on('keyup', '.cart-amount', function () {
let current_stock = parseInt($('#current_stock').val());
let key_val = parseInt($(this).val());
if (key_val > current_stock) {
error('Product Maximum Quantity ' + current_stock);
$('.cart-amount').val(current_stock);
}
if (key_val <= 0) {
$('.cart-amount').val(1);
error('Product Minimum Quantity' + 1);
}
if (key_val > 0 && key_val < current_stock) {
$('.cart-amount').val(key_val);
}
})
$(document).on('click', '.wishlist_store', function (e) {
e.preventDefault();
let wishlist_url = $(this).attr('href');
$.get(wishlist_url, function (response) {
if (response.status == 0) {
location.href = response.link;
} else if (response.status == 2) {
dangerNotification(response.message);
} else {
$('.wishlist1').addClass('d-none');
$('.wishlist2').removeClass('d-none');
$('.wishlist_count').text(response.count)
successNotification(response.message);
}
})
})
// catalog js start
$(document).on("click", ".brand-select", function () {
$('.brand-select').prop('checked', false);
let brand = $(this).val();
$(this).prop('checked', true);
$("#search_form #brand").val(brand);
removePage();
$("#search_button").click();
});
$(document).on("click", "#price_filter", function () {
let min_price = parseInt($(".min_price").html());
let max_price = parseInt($(".max_price").html());
$("#search_form #minPrice").val(min_price);
$("#search_form #maxPrice").val(max_price);
removePage();
$("#search_button").click();
});
$(document).on("change", "#sorting", function () {
let sorting = $(this).val();
$("#search_form #sorting").val(sorting);
removePage();
$("#search_button").click();
});
$(document).on("click", ".widget_price_filter", function () {
let filter_prices = $(this).val();
if (filter_prices) {
filter_prices = filter_prices.split(",");
$("#search_form #minPrice").val(filter_prices[0]);
$("#search_form #maxPrice").val(filter_prices[1]);
} else {
$("#search_form #minPrice").val('');
$("#search_form #maxPrice").val('');
}
removePage();
$("#search_button").click();
});
$(document).on('change', '#category_select', function () {
let category = $(this).val();
$('#search__category').val(category);
})
$(document).on('click', '#quick_filter li a', function () {
$('#quick_filter li').removeClass('active');
let filter = '';
$(this).parent().addClass('active');
if ($(this).attr('data-href')) {
filter = $(this).attr('data-href');
} else {
filter = $(this).attr('data-href');
}
$("#search_form #quick_filter").val(filter);
removePage();
$("#search_button").click();
});
function removePage() {
$("#search_form #page").val('');
}
$(document).on('keyup', '#__product__search', function () {
let search = $(this).val();
let category = '';
category = $('#search__category').val();
if (search) {
let url = $(this).attr('data-target');
$.get(url + '?search=' + search + '&category=' + category, function (response) {
$('.serch-result').removeClass('d-none');
$('.serch-result').html(response);
})
} else {
$('.serch-result').addClass('d-none');
}
})
$(document).on('click', '#view_all_search_', function () {
$('#header_search_form').submit();
})
$(document).on('click', '#category_list li a.category_search', function () {
$('#category_list li').removeClass('active');
let category = '';
$(this).parent().addClass('active');
if ($(this).attr('data-href')) {
category = $(this).attr('data-href');
} else {
category = $(this).attr('data-href');
}
removePage();
$("#search_form #childcategory").val('');
$("#search_form #subcategory").val('');
$("#search_form #category").val(category);
$("#search_button").click();
});
$(document).on('click', '#subcategory_list li a.subcategory', function () {
$('#subcategory_list li').removeClass('active');
let category = '';
$(this).parent().addClass('active');
if ($(this).attr('data-href')) {
category = $(this).attr('data-href');
} else {
category = $(this).attr('data-href');
}
$("#search_form #childcategory").val('');
$("#search_form #subcategory").val(category);
$("#search_button").click();
});
$(document).on('click', '#childcategory_list li a.childcategory', function () {
$('#childcategory_list li').removeClass('active');
let childcategory = '';
$(this).parent().addClass('active');
if ($(this).attr('data-href')) {
childcategory = $(this).attr('data-href');
} else {
childcategory = $(this).attr('data-href');
}
removePage();
$("#search_form #childcategory").val(childcategory);
$("#search_button").click();
});
$(document).on('click', '#item_pagination .page-item .page-link', function (e) {
e.preventDefault();
let pagination = $(this).text();
let lastActive = parseInt($('#item_pagination .page-item.active .page-link').text());
if(pagination == '›'){
pagination = lastActive+1;
}else if(pagination == '‹'){
pagination = lastActive -1;
}
$("#search_form #page").val(pagination);
$("#search_button").click();
})
$(document).on('click', '.option', function () {
let option = [];
$(this).parent().addClass('active');
$("input.option").each(function (index) {
if ($(this).is(':checked')) {
option.push($(this).val());
}
});
removePage();
$("#search_form #option").val(option);
$("#search_button").click();
});
$(document).on('submit', '#search_form', function (e) {
e.preventDefault();
let loader = `
<div id="view_loader_div" class="">
<div class="product-not-found">
<img class="loader_image" src="${mainurl + '/assets/images/ajax_loader.gif'}" alt="">
</div>
</div>
`;
$('#list_view_ajax').html(loader);
let form_url = $(this).attr('action');
let method = $(this).attr('method');
$.ajax({
type: method,
url: form_url,
data: $(this).serialize(),
success: function (data) {
window.scrollTo(0, 0);
$('#list_view_ajax').html(data);
}
});
})
// catalog script end
// rating from submit
$(".ratingForm").on("submit", function (e) {
e.preventDefault();
var $this = $(this);
var submit_btn = $this.find("button");
submit_btn.find(".fa-spin").removeClass("d-none");
$this.find("textarea").prop("readonly", true);
submit_btn.prop("disabled", true);
$.ajax({
method: "POST",
url: $(this).prop("action"),
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function (data) {
if (data.errors) {
for (var error in data.errors) {
dangerNotification(data.errors[error]);
}
} else {
successNotification(data);
$this.find("textarea").val("");
}
$this.find("textarea").prop("readonly", false);
submit_btn.prop("disabled", false);
$(".modal_close").click();
},
});
});
// compare script start
$(document).on("click", ".product_compare", function () {
let compare_url = $(this).attr("data-target");
$.get(compare_url, function (data) {
if (data.status == 1) {
successNotification(data.message);
} else {
dangerNotification(data.message);
}
$(".compare_count").text(data.compare_count);
});
});
$(document).on("click", ".compare_remove", function () {
let removeUrl = $(this).attr("data-href");
$.get(removeUrl, function () {
location.reload();
});
});
// compare script end
// cart script start
// $(document).on("change", ".attribute_option", function () {
// getData();
// });
// $(document).on("click", ".attribute_option", function () {
// getData();
// });
// $(document).on('click', '.attribute_option', function () {
// getData();
// });
$(document).on("keyup", ".cart-amount", function () {
getData();
});
$(document).on("click", ".decreaseQty", function () {
getData();
});
$(document).on("click", ".increaseQty", function () {
getData();
});
$(document).on("click", ".increaseQtycart", function () {
let item_key = $(this).attr('data-target');
let item_id = $(this).attr('data-id');
const data_action = $(this).attr('data-action');
let item = $(this).attr('data-item');
let newOptionArray = item.split(',');
let qty = parseInt($(this).parent().find('input').val());
// $(`input[data-id="${item_id}"]`).val(qty)
get_product_quantity(item_key,item_id,item,newOptionArray,qty,data_action);
});
$(document).on("click", ".decreaseQtycart", function () {
let item_d_key = $(this).attr('data-target');
let item_d_id = $(this).attr('data-id');
let item_d = $(this).attr('data-item');
let item_stock_quanitity = $(this).attr('data-item');
const data_dec_action = $(this).attr('data-action');
let newOptiondecArray = '';
let d_item = '';
let d_qty = $(`input[data-id="${item_d_id}"]`).val();
if (d_qty > 1) {
d_qty--;
} else {
d_qty = 1;
}
$(`input[data-id="${item_d_id}"]`).val(d_qty)
get_product_quantity(item_d_key,item_d_id,d_item,newOptiondecArray,d_qty,data_dec_action);
});
// $(document).on("click", ".decreaseQtycart", function () {
// let item_key = $(this).attr('data-target');
// let item_id = $(this).attr('data-id');
// let qty = parseInt($(this).parent().find('input').val()) -1;
// if(qty>0){
// cartSubmit(item_key,item_id,qty);
// getData();
// }
// });
$(document).on("click", "#but_to_cart", function () {
getData(1, 0, 0, 0, 1);
});
// $(document).on("click", ".add_to_single_cart", function () {
// getData(1, $(this).attr("data-target"));
// });
$(document).on("click", ".get_size_attribute", function () {
getData();
});
$(document).on("click", ".get_color_attribute", function () {
getData();
});
$(document).on("click", "#add_to_cart", function () {
const checking_item = check_product_stock();
if (!checking_item) {
return;
}
const product_has_attr = $(this).attr('data-p-item-type');
const item_weight_ck = $(".get_weight_attribute.weightKey.active").attr("data-weight");
if(product_has_attr != "yes"){
getData(1);
} else {
if(item_weight_ck){
handleProductWeight(item_weight_ck);
}else{
const size = $(".get_size_attribute.active").text();
const color = $(".get_color_attribute.active").attr("data-color");
if (!size) {
return dangerNotification("Select Any Size");
}
if (!color) {
return dangerNotification("Select Any Color");
}
handleProductSelection(size, color);
}
}
});
$(document).on("click", ".get_size_attribute", function () {
$(".get_size_attribute").removeClass("active");
$(this).addClass("active");
});
$(document).on("click", ".get_weight_attribute", function () {
$(".get_weight_attribute").removeClass("active");
$(this).addClass("active");
getData();
});
$(document).on("click", ".get_color_attribute", function () {
$(".get_color_attribute").removeClass("active");
$(this).addClass("active");
});
function handleProductSelection(size, color) {
if(size && color){
$('#showed-product-des').modal('hide');
getData(1);
}
}
function handleProductWeight(item_weight_measure){
if(item_weight_measure){
$('#showed-product-des').modal('hide');
getData(1);
}
}
function cartSubmit(item_key,item_id,cartQty,newOptionArray) {
let check_type = 'qty';
getData(1, item_key,item_id, cartQty, 0 ,newOptionArray,check_type);
};
$(document).on("click", "#add-cart-destroy", function (e) {
e.preventDefault();
var cartKey = $(this).data('id');
$.ajax({
url: '/cart/destroy/' + cartKey,
type: 'GET',
data: {
_token: '{{ csrf_token() }}',
_method: 'DELETE'
},
success: function (response) {
if (response.status === 'success') {
$(".cart_view_header").load(
$("#header_cart_load").attr("data-target")
);
// $("#view_cart_load").load(
// $("#cart_view_load").attr("data-target")
// );
successNotification(response.message);
$(".cart_count").text(response.total_cart);
}
},
error: function (xhr, status, error) {
dangerNotification(error);
$(".cart_view_header").load(
$("#header_cart_load").attr("data-target")
);
// $("#view_cart_load").load(
// $("#cart_view_load").attr("data-target")
// );
$(".cart_count").text(response.total_cart);
}
});
});
$(document).on("click", "#add-viewcart-destroy", function (e) {
e.preventDefault();
var cartKey = $(this).data('id');
$.ajax({
url: '/cart/destroy/' + cartKey,
type: 'GET',
data: {
_token: '{{ csrf_token() }}',
_method: 'DELETE'
},
success: function (response) {
if (response.status === 'success') {
$(".cart_view_header").load(
$("#header_cart_load").attr("data-target")
);
$("#view_cart_load").load(
$("#cart_view_load").attr("data-target")
);
successNotification(response.message);
$(".cart_count").text(response.total_cart);
}
},
error: function (xhr, status, error) {
dangerNotification(error);
$(".cart_view_header").load(
$("#header_cart_load").attr("data-target")
);
$("#view_cart_load").load(
$("#cart_view_load").attr("data-target")
);
$(".cart_count").text(response.total_cart);
}
});
});
function get_product_quantity(item_key,item_id,item,newOptionArray,qty,data_action){
let current_item_qty = 0;
let qtyUpdateUrl = `${mainurl}/cart/qty/update`;
$.ajax({
type: "GET",
url: qtyUpdateUrl,
data: {
item_key: item_key,
item_id: item_id,
qty: qty,
data_action: data_action,
},
success: function (data) {
if(data.status=='failed'){
dangerNotification(data.message)
}
if(data.stock >= data.item_qty){
current_item_qty = data.item_qty;
$(`input[data-id="${item_id}"]`).val(current_item_qty);
}
let item_grand_total_price = 0;
item_grand_total_price = data.grand_total;
let itemSetCurrency = $("#set_currency").val();
let itemCurrencyDirection = $("#currency_direction").val();
item_grand_total_price = number_format(item_grand_total_price, 2, decimal_separator, thousand_separator);
if (itemCurrencyDirection == 0) {
$('.sub-total').html(item_grand_total_price + itemSetCurrency);
// $('.main_price').html(mainPrice + setCurrency);
} else {
$('.sub-total').html(itemSetCurrency + item_grand_total_price);
}
},
});
}
function getData(status = 0, check = 0, item_key = 0, qty = 0, add_type = 0 , optionIds = null,check_type) {
let itemId;
let type;
if (check != 0) {
itemId = check;
type = 1;
} else {
itemId = $("#item_id").val();
type = 0;
}
if(check_type){
type = 3;
}
let options_prices = optionPrice();
let totalOptionPrice = parseFloat(optionPriceSum(options_prices));
let attribute_ids = $(".gt_attr_item.active")
.map(function () {
return $(this).attr("data-type");
}).get();
if(optionIds != null){
var options_ids = optionIds;
}else{
var options_ids = $(".gt_attr_item.active")
.map(function (i, el) {
return $(el).attr("data-href");
})
.get();
}
let quantity;
quantity = parseInt(getQuantity());
if (isNaN(quantity)) {
quantity = 1;
}
if (qty != 0) {
quantity = qty;
}
let setCurrency = $("#set_currency").val();
let currency_direction = $("#currency_direction").val();
let demoPrice = parseFloat($("#demo_price").val());
totalOptionPrice = isNaN(totalOptionPrice) ? 0 : totalOptionPrice;
let subPrice = parseFloat(totalOptionPrice);
let mainPrice = subPrice * quantity;
mainPrice = number_format(mainPrice,2,decimal_separator,thousand_separator);
if (currency_direction == 0) {
$('#main_price').html(mainPrice + setCurrency);
// $('.main_price').html(mainPrice + setCurrency);
} else {
$('#main_price').html(setCurrency + mainPrice);
}
let attr_color = $(".get_color_attribute.active").attr("data-color");
let attr_size = $(".get_size_attribute.active").text();
// dd(quantity,'qty');
if (status == 1) {
let addToCartUrl = `${mainurl}/product/add/cart?`;
$.ajax({
type: "GET",
url: addToCartUrl,
data: {
item_id: itemId,
options_ids: options_ids,
attribute_ids: attribute_ids,
quantity: quantity,
type: type,
item_key: item_key,
add_type: add_type,
// item_color: itemColor,
// item_size: itemSize
},
success: function (data) {
if(data.status == 'outStock'){
dangerNotification(data.message);
}
else if(data.status == 'alreadyInCart'){
dangerNotification(data.message);
}
else{
$(".cart_count").text(data.qty);
$(".cart_view_header").load(
$("#header_cart_load").attr("data-target")
);
if (qty) {
$("#view_cart_load").load(
$("#cart_view_load").attr("data-target")
);
}
if (add_type == 1) {
location.href = mainurl + '/cart';
} else {
successNotification(data.message);
}
}
},
});
}
}
function attribute_item_price() {
let option_prices = itemPriceAttr;
return option_prices;
}
// function optionPrice() {
// const option_item_price = $("")
// let option_prices = $(".attribute_option :selected")
// .map(function (i, el) {
// return $(el).attr("data-target");
// })
// .get();
// console.log(option_prices);
// return option_prices;
// }
// function optionPrice() {
// let option_prices
// = $(".get_size_attribute.active").attr('data-item-price')
// let option_prices = $(".get_color_attribute.active").attr('data-item-price')
// return option_prices;
// }
// function optionPrice() {
// let discountPrice = 0;
// let sizePrice = $(".get_size_attribute.active").attr('data-item-price') || 0;
// let weightPrice = $(".weightKey").attr('data-item-weight-price');
// console.log(weightPrice,'okkksksksk');
// let totalPrice = 0;
// let colorPrice = $(".get_color_attribute.active").attr('data-item-price') || 0;
// discountPrice = $(".totalprice_solo").attr('data-price') || 0;
// totalPrice = parseFloat(sizePrice) + parseFloat(colorPrice) + parseFloat(discountPrice);
// if(weightPrice){
// totalPrice = parseFloat(weightPrice) + parseFloat(discountPrice);
// }
// return totalPrice.toFixed(2);
// }
function optionPrice() {
let discountPrice = 0;
let sizePrice = $(".get_size_attribute.active").attr('data-item-price') || 0;
let weightPrice = $(".get_weight_attribute.weightKey.active").attr('data-item-weight-price') || 0;
let totalPrice = 0;
let colorPrice = $(".get_color_attribute.active").attr('data-item-price') || 0;
discountPrice = $(".totalprice_solo").attr('data-price') || 0;
totalPrice = parseFloat(sizePrice) + parseFloat(colorPrice) + parseFloat(discountPrice);
if (weightPrice) {
totalPrice = parseFloat(weightPrice) + parseFloat(discountPrice);
}
return totalPrice.toFixed(2);
}
function getQuantity() {
let quantity = $("#qtyValue_1").val();
// console.log(quantity);
return parseInt(quantity);
}
function optionPriceSum(options_prices) {
var price = 0;
price += parseFloat(options_prices);
// $.each(options_prices, function (i, v) {
// price += parseFloat(v);
// });
return price;
}
// function optionPriceSum(options_prices) {
// var price = 0;
// $.each(options_prices, function (i, v) {
// price += parseFloat(v);
// });
// return price;
// }
// cart script end
$(document).on("submit", "#coupon_form", function (e) {
e.preventDefault();
var form = $(this);
var url = form.attr("action");
$.ajax({
type: "POST",
url: url,
data: form.serialize(),
success: function (data) {
if (data.status == true) {
successNotification(data.message);
$("#view_cart_load").load(
$("#cart_view_load").attr("data-target")
);
} else {
dangerNotification(data.message);
}
},
});
});
// user panel script start
$(document).on("change", "#avater", function () {
var file = event.target.files[0];
var reader = new FileReader();
reader.onload = function (e) {
$("#avater_photo_view").attr("src", e.target.result);
};
reader.readAsDataURL(file);
});
$('#submit_number').on('click', function (e) {
var link = $(this).data('href') + '?order_number=' + $('#order_number').val();
$('#track-order').load(link);
return false;
});
});
});
// state price set up
// $(document).on('change','#state_id_select',function(){
// var url = $('option:selected', this).attr('data-href');
// var state_id = $(this).val();
// var shipping_id = $('#shipping_id_select option:selected').val();
// url = url + '?state_id=' + state_id+'&shipping_id='+shipping_id;
// $.get(url,function(response){
// $('.set__state_price_tr').removeClass('d-none');
// $('.set__state_price').text(response.state_price);
// $('.grand_total_set').text(response.grand_total);
// $('.state_id_setup').val(state_id);
// $(".state_message").addClass('d-none');
// })
// })
$(document).on('change','#shipping_id_select',function(){
var url = $('option:selected', this).attr('data-href');
var state_id = $('#state_id_select option:selected').val();
var shipping_id = $(this).val();
url = url + '?state_id=' + state_id+'&shipping_id='+shipping_id;
$.get(url,function(response){
$('.set__shipping_price_tr').removeClass('d-none');
$('.set__shipping_price').text(response.shipping_price);
$('.grand_total_set').text(response.grand_total);
$('.shipping_id_setup').val(shipping_id);
$(".shipping_message").addClass('d-none');
})
})
$(document).on('click', '#trams__condition', function () {
if ($(this).is(':checked')) {
$('#continue__button').attr('type', 'submit');
$('#continue__button').prop('disabled', false);
} else {
$('#continue__button').attr('type', 'button');
$('#continue__button').prop('disabled', true);
}
})
$(window).on('load', function (event) {
// Preloader
$('#preloader').fadeOut(500);
// announcement
if (mainbs.is_announcement == 1) {
// trigger announcement banner base on sessionStorage
let announcement = sessionStorage.getItem('announcement') != null ? false : true;
if (announcement) {
setTimeout(function () {
$('.announcement-banner').trigger('click');
}, mainbs.announcement_delay * 1000);
}
}
});
// $(document).on('click', '.whish-list-add', function (e) {
// e.preventDefault();
// let product_id = '';
// let wish_list_count = 0;
// let wishlist_url = $(this).attr('data-url');
// const token = $(this).attr('data-token');
// product_id = $(this).attr('data-product-id');
// wish_list_count = $('#wish-list-total-count').html();
// $.ajax({
// type: "POST",
// url: wishlist_url,
// data: {
// product_id: product_id,
// "_token": token,
// },
// success: function (response) {
// console.log(response);
// if (response.status == 0) {
// location.href = response.link;
// } else if (response.status == 2) {
// dangerNotification(response.message);
// } else {
// $('#wish-list-total-count').text(response.count);
// successNotification(response.message);
// }
// },
// error: function (xhr, status, error) {
// dangerNotification(error);
// }
// });
// });
$(document).on("click", "#add-whish-destroy", function (e) {
e.preventDefault();
let id = $(this).data('id');
let token = $(this).attr('data-token');
$.ajax({
url: 'wishlist/delete',
type: 'GET',
data: {
"_token": token,
id:id
},
success: function (response) {
if (response.status === 'success') {
// successNotification(response.message);
$('#deleet_table_row_' + id).remove();
$('.wish-list-total-count').text(response.total_cart);
}
},
error: function (xhr, status, error) {
// dangerNotification(error);
$('.wish-list-total-count').text(response.total_cart);
}
});
});
$(document).on('click', '.get_category_modal', function (e) {
e.preventDefault();
let get_category_url = $(this).attr('data-get-category-url');
$.ajax({
type: "GET",
url: get_category_url,
success: function (response) {
if (response.status == 'success') {
$('#for-category-navs').html(response.navTabsHtml);
$('#for-sub-category-content').html(response.tabContentHtml);
} else {
// $('#wish-list-total-count').text(response.count);
// successNotification(response.message);
}
},
error: function (xhr, status, error) {
// dangerNotification(error);
}
});
});
$(document).on('click', '.category-nav-link', function (e) {
e.preventDefault();
const target = $(this).attr('href');
$('.nav-link-rline').removeClass('active');
$(this).addClass('active');
const id = $(this).attr('data-id');
$('.category-tab-link').removeClass('show').removeClass('active');
// $('#v-pills_'+id).addClass('show').addClass('active');
$(target).addClass('show active');
});
// $(document).on('click', '.nav-link-rline', function (e) {
// e.preventDefault();
// const target = $(this).attr('href');
// $('.nav-link-rline').removeClass('active');
// $(this).addClass('active');
// $(target).addClass('show active');
// });
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0045 ]-- |