first commit
This commit is contained in:
308
layout/js/custom.js
Normal file
308
layout/js/custom.js
Normal file
@@ -0,0 +1,308 @@
|
||||
$('img').on('contextmenu', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
$('canvas').on('contextmenu', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$(function () {
|
||||
if($( window ).width() <= 991){
|
||||
$("#advance_menu ul.lvl_1 > li.parent > a").click(function(e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
$("#advance_menu ul.lvl_3 > li > a").click(function(e) {
|
||||
location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
if($("#product-preview-box").length && $("#nav_tabs").length){
|
||||
$("#advance_menu ul.lvl_3 > li > a").on("click", function() {
|
||||
if($(`#nav_tabs li a[href='#${$(this).attr("href").split("#")[1]}']`).length){
|
||||
$(`#nav_tabs li a[href='#${$(this).attr("href").split("#")[1]}']`).click()
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: parseInt($('.box-01').offset().top - 150 )
|
||||
}, 1);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
$(function () {
|
||||
if ($(".illustration_product_slider").length) {
|
||||
var swiperProductSlider = new Swiper(".illustration_product_slider", {
|
||||
navigation: {
|
||||
nextEl: ".swiper-slide-next",
|
||||
prevEl: ".swiper-slide-prev",
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
$(function () {
|
||||
let windowWidth = $(window).width()
|
||||
function alignmentBlocks() {
|
||||
if (windowWidth >= 992) {
|
||||
let productImgHeight = $(
|
||||
"#product-preview-box .product-preview.active .product_info_img .illustration_product_slider"
|
||||
).height()
|
||||
|
||||
let productTextHeight = $(
|
||||
"#product-preview-box .product-preview.active .product_info_text"
|
||||
).height()
|
||||
|
||||
if (productTextHeight > productImgHeight) {
|
||||
let productHeightDifference = productTextHeight - productImgHeight
|
||||
let productTilesHeight = $(
|
||||
"#product-preview-box .product-preview.active .product_info_text ul"
|
||||
).height()
|
||||
|
||||
let productTilesFooterHeight = $(
|
||||
"#product-preview-box .product-preview.active .product_info_text .product_info_text__footer"
|
||||
).outerHeight()
|
||||
|
||||
$(
|
||||
"#product-preview-box .product-preview .product_info_text ul"
|
||||
).removeAttr("style")
|
||||
|
||||
$(
|
||||
"#product-preview-box .product-preview.active .product_info_text ul"
|
||||
).css({
|
||||
"max-height": productImgHeight - productTilesFooterHeight,
|
||||
overflow: "auto",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function activateProductBox(boxHref) {
|
||||
$(".product-preview", productList).removeClass("active")
|
||||
$(productList).find(`#${boxHref}`).addClass("active")
|
||||
}
|
||||
|
||||
function activateCharacteristicsBox(boxHref) {
|
||||
$("#characteristics-box .scontainer-content .row").removeClass("active")
|
||||
$(
|
||||
`#characteristics-box .scontainer-content .row[group="${boxHref}"]`
|
||||
).addClass("active")
|
||||
}
|
||||
|
||||
function activateProductColors(boxHref = "") {
|
||||
if (boxHref === "") {
|
||||
$("#product-colors .col-12").first().addClass("active")
|
||||
} else if ($("#product-colors .col-12").length > 1) {
|
||||
$("#product-colors .col-12").removeClass("active")
|
||||
$("#product-colors .col-12").each(function () {
|
||||
if ($(this).hasClass(boxHref)) {
|
||||
$(this).addClass("active")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function activateTurenPopup(boxHref = "") {
|
||||
if (boxHref === "") {
|
||||
$("#turen-popup .row").first().addClass("active")
|
||||
} else if ($("#turen-popup .row").length > 1) {
|
||||
$("#turen-popup .row").removeClass("active")
|
||||
$("#turen-popup .row").each(function () {
|
||||
if ($(this).hasClass(boxHref)) {
|
||||
$(this).addClass("active")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function activateOurCatalog(boxHref = "") {
|
||||
|
||||
if (boxHref === "") {
|
||||
$("#our-catalog .row").first().addClass("active")
|
||||
} else if ($("#our-catalog .row").length > 1) {
|
||||
$("#our-catalog .row").removeClass("active")
|
||||
$("#our-catalog .row").each(function () {
|
||||
if ($(this).hasClass(boxHref)) {
|
||||
$(this).addClass("active")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function activateProductPopup(boxHref = "") {
|
||||
if (boxHref === "") {
|
||||
$("#product-popup-box .product-popup-box-list").first().addClass("active")
|
||||
} else if ($("#product-popup-box .product-popup-box-list").length > 1) {
|
||||
$("#product-popup-box .product-popup-box-list").removeClass("active")
|
||||
$("#product-popup-box .product-popup-box-list").each(function () {
|
||||
if ($(this).hasClass(boxHref)) {
|
||||
$(this).addClass("active")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var productList = $("#product-preview-box .scontainer-content")
|
||||
$(".product-preview", productList).first().addClass("active")
|
||||
|
||||
$("#nav_tabs li a").on("click", function () {
|
||||
event.preventDefault()
|
||||
var boxHref = $(this).attr("href").substring(1)
|
||||
$(this).parent().parent().find("li").removeClass("active")
|
||||
$(this).parent().addClass("active")
|
||||
|
||||
activateProductBox(boxHref)
|
||||
activateCharacteristicsBox(boxHref)
|
||||
$('.product-preview.active .product_info_img .swiper-slide img').load(function() {
|
||||
alignmentBlocks()
|
||||
})
|
||||
alignmentBlocks()
|
||||
if($("#product-colors").length) { activateProductColors(boxHref) }
|
||||
if($("#turen-popup").length){ activateTurenPopup(boxHref) }
|
||||
if($("#our-catalog .scontainer-content >.row").length > 1){ activateOurCatalog(boxHref) }
|
||||
if($("#product-popup-box .product-popup-box-list").length > 1){ activateProductPopup(boxHref) }
|
||||
|
||||
activateProductPopup()
|
||||
})
|
||||
|
||||
$("#nav_tabs li").first().addClass("active")
|
||||
$("#characteristics-box .scontainer-content .row").first().addClass("active")
|
||||
if($("#product-colors").length) { activateProductColors() }
|
||||
if($("#turen-popup").length){ activateTurenPopup() }
|
||||
if($("#our-catalog .scontainer-content >.row").length > 1){ activateOurCatalog() }
|
||||
if($("#product-popup-box .product-popup-box-list").length > 1){ activateProductPopup() }
|
||||
// setTimeout(() => {
|
||||
// alignmentBlocks()
|
||||
// },1000)
|
||||
|
||||
$('.product-preview.active .product_info_img .swiper-slide img').load(function() {
|
||||
alignmentBlocks()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
//* Image 360
|
||||
$(document).ready(function () {
|
||||
const GURKHA_SUV_HOTSPOTS_CONFIG = [
|
||||
{
|
||||
variant: {
|
||||
images: [
|
||||
{
|
||||
src: "/images/images360/VD82/1.jpg",
|
||||
alt: "air snorkel",
|
||||
},
|
||||
],
|
||||
title: "Air Intake Snorkel",
|
||||
description:
|
||||
"The snorkel gives the Gurkha an unmatched water-wading ability and ensures ample supply of fresh air for combustion.",
|
||||
moreDetailsUrl: "https://forcegurkha.co.in",
|
||||
},
|
||||
popupProps: {
|
||||
popupSelector: "air-intake-popup",
|
||||
},
|
||||
initialDimensions: [600, 600],
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
$(function () {
|
||||
$(".anchor").on("click", function () {
|
||||
let menuHeight = $("header").height()
|
||||
|
||||
$("html, body").animate(
|
||||
{
|
||||
scrollTop: $("#colors-anchor").offset().top - menuHeight,
|
||||
},
|
||||
1000
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
$(function () {
|
||||
$("#product-popup-box .box-data ul li").on('click', function(){
|
||||
$("#product-popup-box .box-data ul li").not($(this)).find('p').removeClass('active')
|
||||
$(this).find('p').toggleClass("active")
|
||||
})
|
||||
})
|
||||
|
||||
//* product colors changer (show more...)
|
||||
$(function () {
|
||||
if($("#product-colors").length) {
|
||||
var litesList = $("#product-colors .color-tiles").find("button").parent()
|
||||
litesList.attr("status", false)
|
||||
|
||||
var closeUl = 0
|
||||
|
||||
if($( document ).width() >= 992) {
|
||||
closeUl = 17 * 2 + 50
|
||||
} else {
|
||||
closeUl = 17 * 2 + 30
|
||||
}
|
||||
$(litesList.find("ul").children('li:lt(3)')).each(function() {
|
||||
closeUl += $(this).height();
|
||||
});
|
||||
|
||||
litesList.find("ul").addClass("closed")
|
||||
litesList.find("ul").css({
|
||||
"max-height" : closeUl
|
||||
})
|
||||
|
||||
litesList.find("button").on("click", function () {
|
||||
var thisParent = $(this).parent()
|
||||
thisParent.find("ul").toggleClass('closed')
|
||||
|
||||
if (thisParent.attr('status') === "false") {
|
||||
thisParent.attr('status', "true");
|
||||
} else {
|
||||
thisParent.attr('status', "false");
|
||||
}
|
||||
|
||||
if(thisParent.find("ul").hasClass("closed")){
|
||||
thisParent.find("ul").css({
|
||||
"max-height" : closeUl
|
||||
})
|
||||
} else {
|
||||
thisParent.find("ul").css({
|
||||
"max-height" : "unset"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
//* Page scroll anchor
|
||||
$(function () {
|
||||
if($("#box-scrolling-page").length) {
|
||||
$("#scroll-anchor", this).on("click", function () {
|
||||
$("html, body").animate({ scrollTop: 0 }, "slow");
|
||||
})
|
||||
}
|
||||
|
||||
var scroll = $(window).scrollTop();
|
||||
|
||||
|
||||
$(window).scroll(function (e) {
|
||||
scroll = $(window).scrollTop();
|
||||
|
||||
if(scroll != 0) {
|
||||
$("#scroll-anchor").slideDown({
|
||||
start: function () {
|
||||
$(this).css({
|
||||
display: "flex"
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#scroll-anchor").slideUp()
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
//* Turen - popup
|
||||
// $(function () {
|
||||
// if($("#box-scrolling-page").length) {
|
||||
// $("#scroll-anchor", this).on("click", function () {
|
||||
// $("html, body").animate({ scrollTop: 0 }, "slow");
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
Reference in New Issue
Block a user