jQuery(document).ready(function($) {
jQuery(".wpcf7-phonetext-country-code").val("+39");
jQuery("#signature_filed").html(`
`);
var SignaturePad = (function(document) {
"use strict";
var log = console.log.bind(console);
var SignaturePad = function(canvas, options) {
var self = this,
opts = options || {};
this.velocityFilterWeight = opts.velocityFilterWeight || 0.7;
this.minWidth = opts.minWidth || 0.5;
this.maxWidth = opts.maxWidth || 2.5;
this.dotSize = opts.dotSize || function() {
return (self.minWidth + self.maxWidth) / 2;
};
this.penColor = opts.penColor || "black";
this.backgroundColor = opts.backgroundColor || "rgba(0,0,0,0)";
this.throttle = opts.throttle || 0;
this.throttleOptions = {
leading: true,
trailing: true
};
this.minPointDistance = opts.minPointDistance || 0;
this.onEnd = opts.onEnd;
this.onBegin = opts.onBegin;
this._canvas = canvas;
this._ctx = canvas.getContext("2d");
this._ctx.lineCap = 'round';
this.clear();
// we need add these inline so they are available to unbind while still having
// access to 'self' we could use _.bind but it's not worth adding a dependency
this._handleMouseDown = function(event) {
if (event.which === 1) {
self._mouseButtonDown = true;
self._strokeBegin(event);
}
};
var _handleMouseMove = function(event) {
event.preventDefault();
if (self._mouseButtonDown) {
self._strokeUpdate(event);
if (self.arePointsDisplayed) {
var point = self._createPoint(event);
self._drawMark(point.x, point.y, 5);
}
}
};
this._handleMouseMove = _.throttle(_handleMouseMove, self.throttle, self.throttleOptions);
//this._handleMouseMove = _handleMouseMove;
this._handleMouseUp = function(event) {
if (event.which === 1 && self._mouseButtonDown) {
self._mouseButtonDown = false;
self._strokeEnd(event);
}
};
this._handleTouchStart = function(event) {
if (event.targetTouches.length == 1) {
var touch = event.changedTouches[0];
self._strokeBegin(touch);
}
};
var _handleTouchMove = function(event) {
// Prevent scrolling.
event.preventDefault();
var touch = event.targetTouches[0];
self._strokeUpdate(touch);
if (self.arePointsDisplayed) {
var point = self._createPoint(touch);
self._drawMark(point.x, point.y, 5);
}
};
this._handleTouchMove = _.throttle(_handleTouchMove, self.throttle, self.throttleOptions);
//this._handleTouchMove = _handleTouchMove;
this._handleTouchEnd = function(event) {
var wasCanvasTouched = event.target === self._canvas;
if (wasCanvasTouched) {
event.preventDefault();
self._strokeEnd(event);
}
};
this._handleMouseEvents();
this._handleTouchEvents();
};
SignaturePad.prototype.clear = function() {
var ctx = this._ctx,
canvas = this._canvas;
ctx.fillStyle = this.backgroundColor;
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillRect(0, 0, canvas.width, canvas.height);
this._reset();
};
SignaturePad.prototype.toDataURL = function(imageType, quality) {
var canvas = this._canvas;
return canvas.toDataURL.apply(canvas, arguments);
};
SignaturePad.prototype.fromDataURL = function(dataUrl) {
var self = this,
image = new Image(),
ratio = window.devicePixelRatio || 1,
width = this._canvas.width / ratio,
height = this._canvas.height / ratio;
this._reset();
image.src = dataUrl;
image.onload = function() {
self._ctx.drawImage(image, 0, 0, width, height);
};
this._isEmpty = false;
};
SignaturePad.prototype._strokeUpdate = function(event) {
var point = this._createPoint(event);
if(this._isPointToBeUsed(point)){
this._addPoint(point);
}
};
var pointsSkippedFromBeingAdded = 0;
SignaturePad.prototype._isPointToBeUsed = function(point) {
// Simplifying, De-noise
if(!this.minPointDistance)
return true;
var points = this.points;
if(points && points.length){
var lastPoint = points[points.length-1];
if(point.distanceTo(lastPoint) < this.minPointDistance){
// log(++pointsSkippedFromBeingAdded);
return false;
}
}
return true;
};
SignaturePad.prototype._strokeBegin = function(event) {
this._reset();
this._strokeUpdate(event);
if (typeof this.onBegin === 'function') {
this.onBegin(event);
}
};
SignaturePad.prototype._strokeDraw = function(point) {
var ctx = this._ctx,
dotSize = typeof(this.dotSize) === 'function' ? this.dotSize() : this.dotSize;
ctx.beginPath();
this._drawPoint(point.x, point.y, dotSize);
ctx.closePath();
ctx.fill();
};
SignaturePad.prototype._strokeEnd = function(event) {
var canDrawCurve = this.points.length > 2,
point = this.points[0];
if (!canDrawCurve && point) {
this._strokeDraw(point);
}
if (typeof this.onEnd === 'function') {
this.onEnd(event);
}
};
SignaturePad.prototype._handleMouseEvents = function() {
this._mouseButtonDown = false;
this._canvas.addEventListener("mousedown", this._handleMouseDown);
this._canvas.addEventListener("mousemove", this._handleMouseMove);
document.addEventListener("mouseup", this._handleMouseUp);
};
SignaturePad.prototype._handleTouchEvents = function() {
// Pass touch events to canvas element on mobile IE11 and Edge.
this._canvas.style.msTouchAction = 'none';
this._canvas.style.touchAction = 'none';
this._canvas.addEventListener("touchstart", this._handleTouchStart);
this._canvas.addEventListener("touchmove", this._handleTouchMove);
this._canvas.addEventListener("touchend", this._handleTouchEnd);
};
SignaturePad.prototype.on = function() {
this._handleMouseEvents();
this._handleTouchEvents();
};
SignaturePad.prototype.off = function() {
this._canvas.removeEventListener("mousedown", this._handleMouseDown);
this._canvas.removeEventListener("mousemove", this._handleMouseMove);
document.removeEventListener("mouseup", this._handleMouseUp);
this._canvas.removeEventListener("touchstart", this._handleTouchStart);
this._canvas.removeEventListener("touchmove", this._handleTouchMove);
this._canvas.removeEventListener("touchend", this._handleTouchEnd);
};
SignaturePad.prototype.isEmpty = function() {
return this._isEmpty;
};
SignaturePad.prototype._reset = function() {
this.points = [];
this._lastVelocity = 0;
this._lastWidth = (this.minWidth + this.maxWidth) / 2;
this._isEmpty = true;
this._ctx.fillStyle = this.penColor;
};
SignaturePad.prototype._createPoint = function(event) {
var rect = this._canvas.getBoundingClientRect();
return new Point(
event.clientX - rect.left,
event.clientY - rect.top
);
};
SignaturePad.prototype._addPoint = function(point) {
var points = this.points,
c2, c3,
curve, tmp;
points.push(point);
if (points.length > 2) {
// To reduce the initial lag make it work with 3 points
// by copying the first point to the beginning.
if (points.length === 3) points.unshift(points[0]);
tmp = this._calculateCurveControlPoints(points[0], points[1], points[2]);
c2 = tmp.c2;
tmp = this._calculateCurveControlPoints(points[1], points[2], points[3]);
c3 = tmp.c1;
curve = new Bezier(points[1], c2, c3, points[2]);
this._addCurve(curve);
// Remove the first element from the list,
// so that we always have no more than 4 points in points array.
points.shift();
}
};
SignaturePad.prototype._calculateCurveControlPoints = function(s1, s2, s3) {
var dx1 = s1.x - s2.x,
dy1 = s1.y - s2.y,
dx2 = s2.x - s3.x,
dy2 = s2.y - s3.y,
m1 = {
x: (s1.x + s2.x) / 2.0,
y: (s1.y + s2.y) / 2.0
},
m2 = {
x: (s2.x + s3.x) / 2.0,
y: (s2.y + s3.y) / 2.0
},
l1 = Math.sqrt(1.0 * dx1 * dx1 + dy1 * dy1),
l2 = Math.sqrt(1.0 * dx2 * dx2 + dy2 * dy2),
dxm = (m1.x - m2.x),
dym = (m1.y - m2.y),
k = l2 / (l1 + l2),
cm = {
x: m2.x + dxm * k,
y: m2.y + dym * k
},
tx = s2.x - cm.x,
ty = s2.y - cm.y;
return {
c1: new Point(m1.x + tx, m1.y + ty),
c2: new Point(m2.x + tx, m2.y + ty)
};
};
SignaturePad.prototype._addCurve = function(curve) {
var startPoint = curve.startPoint,
endPoint = curve.endPoint,
velocity, newWidth;
velocity = endPoint.velocityFrom(startPoint);
velocity = this.velocityFilterWeight * velocity +
(1 - this.velocityFilterWeight) * this._lastVelocity;
newWidth = this._strokeWidth(velocity);
this._drawCurve(curve, this._lastWidth, newWidth);
this._lastVelocity = velocity;
this._lastWidth = newWidth;
};
SignaturePad.prototype._drawPoint = function(x, y, size) {
var ctx = this._ctx;
ctx.moveTo(x, y);
ctx.arc(x, y, size, 0, 2 * Math.PI, false);
this._isEmpty = false;
};
SignaturePad.prototype._drawMark = function(x, y, size) {
var ctx = this._ctx;
ctx.save();
ctx.moveTo(x, y);
ctx.arc(x, y, size, 0, 2 * Math.PI, false);
ctx.fillStyle = 'rgba(255, 0, 0, 0.2)';
ctx.fill();
ctx.restore();
};
SignaturePad.prototype._drawCurve = function(curve, startWidth, endWidth) {
var ctx = this._ctx,
widthDelta = endWidth - startWidth,
drawSteps, width, i, t, tt, ttt, u, uu, uuu, x, y;
drawSteps = Math.floor(curve.length());
ctx.beginPath();
for (i = 0; i < drawSteps; i++) {
// Calculate the Bezier (x, y) coordinate for this step.
t = i / drawSteps;
tt = t * t;
ttt = tt * t;
u = 1 - t;
uu = u * u;
uuu = uu * u;
x = uuu * curve.startPoint.x;
x += 3 * uu * t * curve.control1.x;
x += 3 * u * tt * curve.control2.x;
x += ttt * curve.endPoint.x;
y = uuu * curve.startPoint.y;
y += 3 * uu * t * curve.control1.y;
y += 3 * u * tt * curve.control2.y;
y += ttt * curve.endPoint.y;
width = startWidth + ttt * widthDelta;
this._drawPoint(x, y, width);
}
ctx.closePath();
ctx.fill();
};
SignaturePad.prototype._strokeWidth = function(velocity) {
return Math.max(this.maxWidth / (velocity + 1), this.minWidth);
};
var Point = function(x, y, time) {
this.x = x;
this.y = y;
this.time = time || new Date().getTime();
};
Point.prototype.velocityFrom = function(start) {
return (this.time !== start.time) ? this.distanceTo(start) / (this.time - start.time) : 1;
};
Point.prototype.distanceTo = function(start) {
return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
};
var Bezier = function(startPoint, control1, control2, endPoint) {
this.startPoint = startPoint;
this.control1 = control1;
this.control2 = control2;
this.endPoint = endPoint;
};
// Returns approximated length.
Bezier.prototype.length = function() {
var steps = 10,
length = 0,
i, t, cx, cy, px, py, xdiff, ydiff;
for (i = 0; i <= steps; i++) {
t = i / steps;
cx = this._point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
cy = this._point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
if (i > 0) {
xdiff = cx - px;
ydiff = cy - py;
length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
}
px = cx;
py = cy;
}
return length;
};
Bezier.prototype._point = function(t, start, c1, c2, end) {
return start * (1.0 - t) * (1.0 - t) * (1.0 - t) +
3.0 * c1 * (1.0 - t) * (1.0 - t) * t +
3.0 * c2 * (1.0 - t) * t * t +
end * t * t * t;
};
return SignaturePad;
})(document);
var signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
backgroundColor: 'rgba(255, 255, 255, 0)',
penColor: 'rgb(0, 0, 0)',
velocityFilterWeight: .7,
minWidth: 0.5,
maxWidth: 2.5,
throttle: 16, // max x milli seconds on event update, OBS! this introduces lag for event update
minPointDistance: 3,
});
var saveButton = document.getElementById('save'),
clearButton = document.getElementById('clear');
saveButton.addEventListener('click', function(event) {
var data = signaturePad.toDataURL('image/png');
jQuery(".sign_tik").show();
jQuery('#sign_image_url').val(data);
});
clearButton.addEventListener('click', function(event) {
signaturePad.clear();
jQuery(".sign_tik").hide();
jQuery('#sign_image_url').val("");
});
jQuery(".concessione").click(function(){
var ths = jQuery(this).val();
jQuery("#vat_text").val(ths);
});
jQuery(".disposal_included").click(function(){
var ths = jQuery(this).val();
jQuery("#disposal_included").val(ths);
});
});
jQuery(document).ready(function () {
jQuery(".iti-arrow").hide();
jQuery(".flag-container").click(function (e) {
jQuery(".country-list").addClass("hide");
jQuery(".country-list").hide();
});
jQuery('.price_Box_mobile_view').hide();
if (screen.width < 1000) {
jQuery(window).scroll(function () {
if (jQuery(this).scrollTop() > 400) {
jQuery('.price_Box_mobile_view').show();
jQuery('.price_Box_mobile_view').addClass("price_Box_mobile");
} else {
jQuery('.price_Box_mobile_view').hide();
jQuery('.price_Box_mobile_view').removeClass("price_Box_mobile");
}
});
}
var view_check = jQuery(".view_check").val();
if (view_check == 'active') {
var pano = new pano2vrPlayer("interior_360");
pano.readConfigUrlAsync("../wp-content/plugins/garage-wordpress-plugin/360/tiggo8pro.xml");
if (jQuery(".model_wrap").hasClass("sirio_main")) {
jQuery(".pop_360_rcon").ThreeSixty({
totalFrames: 36,
endFrame: 1,
currentFrame: 36,
imgList: ".threesixty_images",
progress: ".loading-360",
imagePath: "../wp-content/plugins/garage-wordpress-plugin/images/360_view/tiggo8pro/sirio/",
filePrefix: "",
ext: ".png",
width: jQuery(window).outerWidth(),
height: "100%",
navigation: !1,
disableSpin: !1,
responsive: !0,
zeroPadding: true,
speed: 100, // Rotation speed during 'play' mode. Default: 10
inverted: false // Inverts rotation direction
});
}
else if (jQuery(".model_wrap").hasClass("cupis_main")) {
jQuery(".pop_360_rcon").ThreeSixty({
totalFrames: 36,
endFrame: 1,
currentFrame: 36,
imgList: ".threesixty_images",
progress: ".loading-360",
imagePath: "../wp-content/plugins/garage-wordpress-plugin/images/360_view/tiggo8pro/cupis/",
filePrefix: "",
ext: ".png",
width: jQuery(window).outerWidth(),
height: "100%",
navigation: !1,
disableSpin: !1,
responsive: !0,
zeroPadding: true,
});
}
else if (jQuery(".model_wrap").hasClass("iris_main")) {
jQuery(".pop_360_rcon").ThreeSixty({
totalFrames: 36,
endFrame: 1,
currentFrame: 36,
imgList: ".threesixty_images",
progress: ".loading-360",
imagePath: "../wp-content/plugins/garage-wordpress-plugin/images/360_view/tiggo8pro/iris/",
filePrefix: "",
ext: ".png",
width: jQuery(window).outerWidth(),
height: "100%",
navigation: !1,
disableSpin: !1,
responsive: !0,
zeroPadding: true,
});
}
else if (jQuery(".model_wrap").hasClass("venus_main")) {
jQuery(".pop_360_rcon").ThreeSixty({
totalFrames: 36,
endFrame: 1,
currentFrame: 36,
imgList: ".threesixty_images",
progress: ".loading-360",
imagePath: "../wp-content/plugins/garage-wordpress-plugin/images/360_view/tiggo8pro/venus/",
filePrefix: "",
ext: ".png",
width: jQuery(window).outerWidth(),
height: "100%",
navigation: !1,
disableSpin: !1,
responsive: !0,
zeroPadding: true,
});
}
jQuery(".change_E_I span").on("click", function () {
jQuery(".change_E_I span").removeClass("on");
jQuery(this).addClass("on");
switch (jQuery(this).index()) {
case 0:
jQuery("#interior_360").css({ "z-index": -10, opacity: 0 });
jQuery(".color_cut .color").removeClass("off");
jQuery(".color_cut .interior_color").addClass("off");
break;
case 1:
jQuery(".color_cut .color").removeClass("off");
jQuery(".color_cut .exterior_color").addClass("off");
jQuery("#interior_360").css({ "z-index": 10, opacity: 1 });
break;
}
});
}
});
var container = document.getElementById("image_zoom");
var img = container.getElementsByTagName("img")[0];
container.addEventListener("mousemove", onZoom);
container.addEventListener("mouseover", onZoom);
container.addEventListener("mouseleave", offZoom);
function onZoom(e) {
var x = e.clientX - e.target.offsetLeft;
var y = e.clientY - e.target.offsetTop;
img.style.transformOrigin = `${x}px ${y}px`;
img.style.transform = "scale(1.8)";
}
function offZoom(e) {
img.style.transformOrigin = `center center`;
img.style.transform = "scale(1)";
}
jQuery(document).ready(function () {
jQuery('.all2').owlCarousel({
// loop: true,
navigation: true,
autoplay: false,
autoplayTimeout: 5000,
autoplayHoverPause: true,
items: 1,
mousewheel: false,
dots: true,
slideBy: 1,
});
});
jQuery(".btn__right").click(function () {
var owl = jQuery(".all2");
owl.trigger('next.owl.carousel');
});
jQuery(".btn__left").click(function () {
var owl = jQuery(".all2");
owl.trigger('prev.owl.carousel');
});
jQuery(".tab .tab__head li").click(function () {
jQuery(".tab__head li").removeClass("active");
jQuery(this).addClass("active");
var className = jQuery(this).attr('data-class');
jQuery(".tab__body--box").hide();
jQuery("#" + className).slideDown();
});
jQuery(document).ready(function () {
jQuery(".paintBox li").click(function () {
var dataKey = jQuery(this).attr("data-key");
var colorName = jQuery(this).attr("data-name");
var otherColorPrice = parseFloat(jQuery("#other_color_price").val());
var after_change = parseFloat(jQuery("#after_change").val());
var totalValue = parseFloat(jQuery(".pr2").text());
jQuery(".ProductSlider").show();
jQuery(".model_wrap").hide();
if (dataKey == "0") {
var width = jQuery("#width");
var height = jQuery("#height");
if (otherColorPrice == "0" && after_change == "0") {
jQuery(".colorNameDiv").children("b").html(colorName + ":
");
}
if (otherColorPrice != "0" && after_change == "0") {
var total = totalValue + otherColorPrice;
var color_code = jQuery("#chose_color").val();
jQuery(".colorNameDiv").children("b").html(colorName + ": " + color_code + "");
jQuery('#door_color').val(color_code);
// jQuery(".other_color_selct").show();
// jQuery(".other_color_selct").css('background-color',colorCode);
jQuery(".coloreleft").html("" + color_code + ": ");
jQuery(".coloreright").html("€" + otherColorPrice);
jQuery("#after_change").val(otherColorPrice);
jQuery("#other_color_price").val("0");
if (total % 1 !== 0) {
//if number is integer
total = total.toFixed(2);
}
jQuery(".pr").text(total);
jQuery(".pr_mobile").text(total);
jQuery(".totalPrice").val(total);
jQuery(".pr2").text(total);
jQuery('.concessione').each(function () {
if (this.checked) {
var percent = parseInt(jQuery(this).attr("data-percent"));
var totalValue = parseFloat(jQuery(".pr2").text());
var percentValue = totalValue * percent / 100;
var total;
jQuery("#vat_price").val(percentValue);
jQuery(".included_vat").find("span").html("€" + percentValue.toFixed(2));
total = totalValue + percentValue;
if (total % 1 !== 0) {
//if number is integer
total = total.toFixed(2);
}
jQuery(".pr").text(total);
jQuery(".pr_mobile").text(total);
jQuery(".totalPrice").val(total);
}
});
}
if (height.val() != "" && width.val() != "") {
jQuery(".ProductSlider").empty();
jQuery(".garage_doors_images").empty();
var colorName = jQuery(this).attr("data-name");
var color_price = jQuery(this).attr("data-price");
// jQuery(".colorNameDiv").children("span").html("€"+color_price+" per metro quadrato");
jQuery(".paintBox li").removeClass("active");
jQuery(this).addClass("active");
// jQuery(".customColor").slideDown();
jQuery(".ProductSlider").append(
` `
);
jQuery.map(scriptMain, function (val, i) {
if ('multiple' in scriptMain[i]) {
// console.log(scriptMain[i]['multiple']);
jQuery.map(scriptMain[i]['multiple'], function (image, key) {
jQuery(".garage_doors_images").append(
` `
);
});
}
});
jQuery("#my-color")[0].click();
}
else {
swal("AVVISO!", "Compila Prima i Campi Di Larghezza e Altezza!");
}
}
else {
jQuery(".ProductSlider ").empty();
jQuery(".garage_doors_images ").empty();
var colorName = jQuery(this).attr("data-name");
jQuery(".colorNameDiv").children("b").text(colorName);
// jQuery(".colorNameDiv").children("span").text(" Included");
jQuery(".coloreleft").html(colorName + " ");
jQuery(".coloreright").html(" €0");
jQuery('#door_color').val(colorName);
jQuery(".paintBox li").removeClass("active");
jQuery(".customColor").slideUp();
jQuery(this).addClass("active");
var counter = 0;
if ('multiple' in scriptMain[dataKey]) {
jQuery.map(scriptMain[dataKey]['multiple'], function (val, i) {
// console.log(i);
jQuery(".garage_doors_images").append(
` `
);
counter++;
});
}
var pandonal_image = scriptMain[dataKey]['ribassata'];
var lucernari_image = scriptMain[dataKey]['window_one_image'];
var rinforzata_image = scriptMain[dataKey]['rinforzata'];
jQuery(".ProductSlider").append(
` `
);
jQuery(".pandonal_image").find("img").attr("src", pandonal_image);
jQuery(".lucernari_image").find("img").attr("src", lucernari_image);
jQuery(".ribassata_image").find("img").attr("src", pandonal_image);
jQuery(".rinforzata_image").find("img").attr("src", rinforzata_image);
jQuery(".lucernari_input").attr("data-key", dataKey);
if (after_change != "0" && otherColorPrice == "0") {
var total = totalValue - after_change;
jQuery("#other_color_price").val(after_change);
jQuery("#after_change").val("0");
jQuery(".pr").text(total);
jQuery(".pr_mobile").text(total);
jQuery(".totalPrice").val(total);
jQuery(".pr2").text(total);
jQuery('.concessione').each(function () {
if (this.checked) {
var percent = parseInt(jQuery(this).attr("data-percent"));
var totalValue = parseFloat(jQuery(".pr2").text());
var percentValue = totalValue * percent / 100;
var total;
jQuery("#vat_price").val(percentValue);
jQuery(".included_vat").find("span").html("€" + percentValue.toFixed(2));
total = totalValue + percentValue;
if (total % 1 !== 0) {
//if number is integer
total = total.toFixed(2);
}
jQuery(".pr").text(total);
jQuery(".pr_mobile").text(total);
jQuery(".totalPrice").val(total);
}
});
}
}
jQuery(".ProductSlider").append(`
`);
var swiper = new Swiper(".loopswiper", {
slidesPerView: 6,
spaceBetween: 10,
loop: false,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
});
jQuery('#my-color').change(function () { // <-- use change event
var colorCode = jQuery(this).val();
jQuery(".colorNameDiv").find("span").text(colorCode);
jQuery(".colorNameDiv").find(".other_color_selct").show();
jQuery(".colorNameDiv").find(".other_color_selct").css('background-color', colorCode);
// let result = ntc.name(colorCode);
// let specific_name = result[1];
jQuery("#chose_color").val(colorCode);
jQuery('#door_color').val(colorCode);
var ColorPrice = jQuery("#other_price").val();
jQuery(".coloreleft").html("" + colorCode + ": ");
var otherColorPrice = jQuery("#other_color_price").val();
var after_change = jQuery("#after_change").val();
if (otherColorPrice == "0" && after_change == "0") {
var squarValue = jQuery("#square").val();
if (squarValue != 0) {
var squareVal = parseFloat(squarValue) * parseFloat(ColorPrice);
var totalValue = parseFloat(jQuery(".pr2").text());
if (squareVal % 1 !== 0) {
//if number is integer
squareVal = squareVal.toFixed(2);
}
var total = parseFloat(totalValue) + parseFloat(squareVal);
jQuery("#after_change").val(squareVal);
jQuery(".coloreright").html("€" + squareVal);
if (total % 1 !== 0) {
//if number is integer
total = total.toFixed(2);
}
jQuery(".pr").text(total);
jQuery(".pr_mobile").text(total);
jQuery(".totalPrice").val(total);
jQuery(".pr2").text(total);
jQuery('.concessione').each(function () {
if (this.checked) {
var percent = parseInt(jQuery(this).attr("data-percent"));
var totalValue = parseFloat(jQuery(".pr").text());
var percentValue = totalValue * percent / 100;
var total;
jQuery("#vat_price").val(percentValue);
jQuery(".included_vat").find("span").html("€" + percentValue.toFixed(2));
total = totalValue + percentValue;
if (total % 1 !== 0) {
//if number is integer
total = total.toFixed(2);
}
jQuery(".pr").text(total);
jQuery(".pr_mobile").text(total);
jQuery(".totalPrice").val(total);
}
});
}
}
});
// var oldpric = jQuery(".pr").text();
// var oldprice = parseInt(oldpric);
// jQuery(".btn-advan1").click(function(){
// jQuery(this).toggleClass("active");
// var advan1 = jQuery(this).attr("data-price");
// var newprice = oldprice+parseInt(advan1);
// if(jQuery(this).hasClass("active")){
// jQuery(".pr").text(newprice)
// jQuery(".pr2").text(newprice)
// }
// else {
// jQuery(".pr").text(newprice - parseInt(advan1))
// jQuery(".pr2").text(newprice - parseInt(advan1))
// }
// })
// jQuery(".btn-advan2").click(function(){
// jQuery(this).toggleClass("active");
// var advan2 = jQuery(this).attr("data-price");
// var newprice = oldprice+parseInt(advan2);
// if(jQuery(this).hasClass("active")){
// jQuery(".pr").text(newprice)
// }
// else {
// jQuery(".pr").text(newprice - parseInt(advan2))
// }
// })
jQuery(".remotecontrollers img").click(function () {
jQuery(".ProductSlider").show();
jQuery(".model_wrap").hide();
var img = jQuery(this).attr("src");
jQuery(".ProductSlider").html(
` `
);
})
jQuery(".btn-form-next").click(function (e) {
e.preventDefault();
if (jQuery("#disposal_included").val() == ""){
swal("AVVISO!", "Smontaggio e smaltimento inclusi?");
return false;
}
if (jQuery("#square").val() != 0 && jQuery(".totalP").val() != 0 && jQuery(".totalP").val() != "") {
scroll({
top: 100
}, "slow")
jQuery(".tab__head li:nth-child(2)").removeClass("active");
jQuery(".tab__head li:nth-child(3)").addClass("active");
jQuery(".tab__body--box:nth-child(2)").hide();
jQuery(".tab__body--box:nth-child(3)").slideDown();
}else if (jQuery(".totalP").val() == 0 && jQuery(".totalP").val() == "") {
swal("AVVISO!", "Compila prima tutti i campi del configuratore!");
}else {
swal("AVVISO!", "Compila prima tutti i campi del configuratore!");
}
});
jQuery(".btn-form-continue").click(function (e) {
e.preventDefault();
if (jQuery("#square").val() != 0) {
jQuery("html, body").animate({ scrollTop: 200 }, "slow");
var totalPrice = jQuery(".totalPrice").val();
var per_month_price = parseFloat(totalPrice)/24;
per_month_price = parseFloat(per_month_price.toFixed(2));
jQuery("#per_month").html(per_month_price+"€" );
jQuery(".totalP").val(totalPrice);
var vat_price = parseFloat(jQuery("#vat_price").val());
var exl_vat_price = totalPrice - vat_price;
if (exl_vat_price % 1 !== 0) {
//if number is integer
exl_vat_price = parseFloat(exl_vat_price.toFixed(2));
}
jQuery(".quadri").find("span").html("€" + exl_vat_price);
jQuery(".tab__head li:nth-child(1)").removeClass("active");
jQuery(".tab__head li:nth-child(2)").addClass("active");
jQuery(".tab__body--box:nth-child(1)").hide();
jQuery(".tab__body--box:nth-child(2)").slideDown();
if (jQuery(".accessoriUl").has("li").length == 0) {
jQuery(".accessoriUl").hide();
} else {
jQuery(".accessoriUl").show();
}
if (!jQuery(".paintBox").find("li").hasClass("active")) {
scroll({
top: 200
}, "slow");
jQuery(".tab__head li:nth-child(2)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(2)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
swal("AVVISO!", "Scegli La Colorazione");
}
if (jQuery(".remoteClick").val() == 0) {
jQuery(".tab__head li:nth-child(2)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(2)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
swal("AVVISO!", "Scegli la quantità del telecomando!");
jQuery(".remoteUl").hide();
} else {
jQuery(".remoteUl").show();
}
if (jQuery("#iva4").text() == "") {
// jQuery(".tab__head li:nth-child(2)").removeClass("active");
// jQuery(".tab__head li:nth-child(1)").addClass("active");
// jQuery(".tab__body--box:nth-child(2)").hide();
// jQuery(".tab__body--box:nth-child(1)").slideDown();
// swal("AVVISO!", "Scegli prima un'aliquota IVA!");
jQuery(".included_vat").hide();
} else {
jQuery(".included_vat").show();
}
} else {
swal("AVVISO!", "Compila prima tutti i campi del configuratore!");
}
});
jQuery(document).on("click", ".editConfigurator,.sideditbutton", function (e) {
e.preventDefault();
if (jQuery("#square").val() != 0) {
scroll({
top: 200
}, "slow")
jQuery(".tab__head li:nth-child(2)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(2)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
} else {
swal("AVVISO!", "Compila prima tutti i campi del configuratore!");
}
});
jQuery(".goback").click(function (e) {
e.preventDefault();
if (jQuery("#square").val() != 0) {
scroll({
top: 200
}, "slow")
jQuery(".tab__head li:nth-child(3)").removeClass("active");
jQuery(".tab__head li:nth-child(2)").addClass("active");
jQuery(".tab__body--box:nth-child(3)").hide();
jQuery(".tab__body--box:nth-child(2)").slideDown();
} else {
swal("AVVISO!", "Compila prima tutti i campi del configuratore!");
}
});
jQuery(".PotentialSavings").click(function (e) {
e.preventDefault();
if (jQuery("#square").val() == 0) {
jQuery(".tab__head li:nth-child(3)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(3)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
swal("AVVISO!", "Compila prima tutti i campi del configuratore!");
}
if (jQuery(".remoteClick").val() == 0) {
jQuery(".tab__head li:nth-child(3)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(3)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
swal("AVVISO!", "Scegli la quantità del telecomando!");
}
});
jQuery(".contactForm").click(function (e) {
e.preventDefault();
if (jQuery("#square").val() == 0) {
jQuery(".tab__head li:nth-child(3)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(3)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
swal("AVVISO!", "Compila prima tutti i campi del configuratore!");
}
// if(jQuery(".remoteClick").val() == 0) {
// jQuery(".tab__head li:nth-child(3)").removeClass("active");
// jQuery(".tab__head li:nth-child(1)").addClass("active");
// jQuery(".tab__body--box:nth-child(3)").hide();
// jQuery(".tab__body--box:nth-child(1)").slideDown();
// swal("AVVISO!", "Scegli la quantità del telecomando!")");
// }
});
jQuery(".detailsSection").click(function (e) {
e.preventDefault();
if (jQuery("#square").val() == 0) {
jQuery(".tab__head li:nth-child(2)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(2)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
swal("AVVISO!", "Compila prima tutti i campi del configuratore!");
} else {
var totalPrice = jQuery(".totalPrice").val();
jQuery(".totalP").val(totalPrice);
var vat_price = parseFloat(jQuery("#vat_price").val());
var exl_vat_price = totalPrice - vat_price;
if (exl_vat_price % 1 !== 0) {
//if number is integer
exl_vat_price = parseFloat(exl_vat_price.toFixed(2));
}
jQuery(".quadri").find("span").html("€" + exl_vat_price);
if (jQuery(".accessoriUl").has("li").length == 0) {
jQuery(".accessoriUl").hide();
} else {
jQuery(".accessoriUl").show();
}
if (!jQuery(".paintBox_").hasClass("active")) {
jQuery(".tab__head li:nth-child(2)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(2)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
swal("AVVISO!", "Scegli La Colorazione");
}
if (jQuery(".remoteClick").val() == 0) {
jQuery(".tab__head li:nth-child(2)").removeClass("active");
jQuery(".tab__head li:nth-child(1)").addClass("active");
jQuery(".tab__body--box:nth-child(2)").hide();
jQuery(".tab__body--box:nth-child(1)").slideDown();
swal("AVVISO!", "Scegli la quantità del telecomando!");
jQuery(".remoteUl").hide();
} else {
jQuery(".remoteUl").show();
}
if (jQuery("#iva4").text() == "") {
// jQuery(".tab__head li:nth-child(2)").removeClass("active");
// jQuery(".tab__head li:nth-child(1)").addClass("active");
// jQuery(".tab__body--box:nth-child(2)").hide();
// jQuery(".tab__body--box:nth-child(1)").slideDown();
// swal("AVVISO!", "Scegli prima un'aliquota IVA!");
jQuery(".included_vat").hide();
} else {
jQuery(".included_vat").show();
}
}
})
// jQuery(".ProductSlider-next,.ProductSlider-prev").click(function() {
// var ProductSlider = jQuery(".ProductSlider .swiper-slide img");
// for (let index = 0; index < ProductSlider.length -1; index++) {
// jQuery(ProductSlider[index]).attr("src", `../../wp-content/plugins/garage-doors/webImages/Products/${jQuery(".paintBox li.active").attr("data-color")}/${index}.jpg`)
// }
// })
jQuery(".Accessories img").click(function () {
jQuery(".ProductSlider").show();
jQuery(".model_wrap").hide();
var img = jQuery(this).attr("src");
jQuery(".ProductSlider").html(
`
`
);
jQuery(".ProductSlider").append(`
`);
})
})
var swiperS = new Swiper(".remotecontrollersSwiper", {
watchSlidesProgress: true,
slidesPerView: 3,
spaceBetween: 10,
// navigation: {
// nextEl: ".swiper-button-next",
// prevEl: ".swiper-button-prev",
// },
});
var swiper = new Swiper(".Accessories__mainSwiper", {
slidesPerView: 3,
spaceBetween: 10,
// navigation: {
// nextEl: ".swiper-button-next",
// prevEl: ".swiper-button-prev",
// },
});
// jQuery(function () {
// jQuery('[data-toggle="tooltip"]').tooltip({
// trigger: 'hover',
// })
// });
jQuery(document).ready(function () {
{ jQuery(".paintBox li").length > 3 ? jQuery(".paintBox li").addClass("paintBox_") : jQuery(".paintBox li").removeClass("paintBox_") }
{ jQuery(".paintBox li").length > 10 ? jQuery(".paintBox li").addClass("paintBox_2") : jQuery(".paintBox li").removeClass("paintBox_2") }
jQuery(".Accessories__box--Body input").click(function () {
jQuery(".ProductSlider").show();
jQuery(".model_wrap").hide();
var img_ = jQuery(this).closest(".Accessories__box--Body").siblings(".Accessories__box--img").find("img").attr("src");
jQuery(".ProductSlider").html(
` `
);
jQuery(".ProductSlider").append(`
`);
})
// jQuery(".remotecontrollersBox").click(function() {
// jQuery(".ProductSlider").show();
// jQuery(".model_wrap").hide();
// var img_ = jQuery(this).find("img").attr("src");
// jQuery(".ProductSlider").html(
// `
//

//
`
// );
// })
})
jQuery("#close").click(function () {
jQuery(".alertMessage").hide();
});
jQuery(document).on("click", ".spalletta_image,.spalletta_image_old", function (e) {
e.preventDefault();
if (jQuery("#square").val() != 0) {
var default_image = jQuery("#other_image").val();
var default_value = jQuery("#other_image").attr("data-value");
var spelettaImg = jQuery(this).closest(".Accessories__box--Body").siblings(".Accessories__box--img").find("img").attr("src");
var hasClassImage = jQuery(this).parents(".multipleAccessories").find("a").hasClass("spalletta_image");
if (default_image != "" && default_value == 0 && hasClassImage == true) {
jQuery("#other_image").val(spelettaImg);
jQuery("#other_image").attr("data-value", "1");
jQuery(".color_image").find("img").attr("src", default_image);
jQuery(this).parents(".multipleAccessories").find("input").addClass("spalletta_image_old");
jQuery(this).removeClass("spalletta_image");
jQuery(this).closest(".Accessories__box--Body").siblings(".Accessories__box--img").find("img").attr("src", default_image);
} else if (default_image != "" && default_value == 1 && hasClassImage == false) {
jQuery("#other_image").val(spelettaImg);
jQuery("#other_image").attr("data-value", "0");
jQuery(".color_image").find("img").attr("src", default_image);
jQuery(this).parents(".multipleAccessories").find("a").addClass("spalletta_image");
jQuery(this).removeClass("spalletta_image_old");
jQuery(this).closest(".Accessories__box--Body").siblings(".Accessories__box--img").find("img").attr("src", default_image);
}
}
else {
swal("AVVISO!", "Compila Prima i Campi Di Larghezza e Altezza!");
jQuery(this).prop("checked", false);
jQuery(this).removeAttr("checked");
}
});
jQuery(document).ready(function () {
jQuery(".in_boxNo").click(function (e) {
e.preventDefault();
if (jQuery("#square").val() != 0) {
jQuery(this).addClass("active");
if (jQuery(this).siblings(".in_box").find("input").hasClass("pedestrian")) {
// jQuery(this).siblings(".in_box").find("input").prop("checked", false);
jQuery(".pedestrian_inner").slideUp();
}
if (jQuery(this).siblings(".in_box").find("input").hasClass("lucernari")) {
jQuery(".lucernari_main").slideUp();
}
jQuery(this).siblings(".in_box").removeClass("active");
// jQuery(this).siblings(".in_box").find("input").prop("checked", false);
jQuery(this).closest(".Accessories__b").removeClass("active");
}
else {
swal("AVVISO!", "Compila Prima i Campi Di Larghezza e Altezza!");
// jQuery(this).prop("checked", false);
jQuery(this).removeAttr("checked");
}
})
// close
jQuery(".Accessories__mm .pedestrianRadio").click(function (e) {
jQuery(".Accessories__mm .Accessories__b").removeClass("active");
jQuery(".Accessories__mm .in_box").removeClass("active");
jQuery(this).closest(".in_box").addClass("active");
jQuery(this).closest(".Accessories__b").addClass("active");
})
})
jQuery(".pedestrian").closest(".Accessories__b").addClass("Accessoriespedestrian");
jQuery(".pedestrian").closest(".lucernari").addClass("Accessoriespedestrian2");
jQuery(".remotecontrollers_top").click(function (e) {
e.stopPropagation();
if (jQuery("#square").val() != 0) {
jQuery(".remotecontrollers_Body").slideToggle();
}
else {
swal("AVVISO!", "Compila Prima i Campi Di Larghezza e Altezza!");
jQuery(this).prop("checked", false);
jQuery(this).removeAttr("checked");
}
})
var defimg = jQuery(this).siblings("img").attr("src");
var defspan = jQuery(this).siblings("span").html();
jQuery(document).click(function (e) {
if (jQuery(e.target).hasClass('remoteClick')) {
}
else {
jQuery(".remotecontrollers_Body").hide();
}
})
if (screen.width > 1000) {
jQuery(window).ready(function () {
if (jQuery('.product__left').length) {
var windowh = jQuery(window).height();
var filter = jQuery('.product__left').height();
var coord = windowh - filter;
var sidebar = new StickySidebar('.product__left', {
containerSelector: '.productBlock',
innerWrapperSelector: '.product__left-in',
topSpacing: 60,
// bottomSpacing: 20
});
};
// jQuery(".product__left-in").sticky({topSpacing:20});
});
}
jQuery(".lucernari").click(function () {
if (jQuery("#square").val() != 0) {
jQuery(".lucernari_main").slideDown();
jQuery(".pedestrian_inner").hide();
}
})
jQuery(document).on("click", ".sidmedia", function () {
var img = jQuery(this).find("img").attr("src")
jQuery(".color_image img").attr("src", img);
})
var swiper = new Swiper(".loopswiper", {
slidesPerView: 6,
spaceBetween: 10,
loop: false,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
jQuery(".swiper-button-next").click(function () {
if (jQuery("[name=othercolor]").parent(".paintBox_").hasClass("active")) {
const myTimeout = setTimeout(myGreeting, 20);
}
function myGreeting() {
jQuery(".swiper-button-disabled").removeClass("swiper-button-disabled");
}
})
jQuery(function () {
jQuery("#datepicker").datepicker({
monthNames: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno",
"Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"],
dayNamesMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"],
dateFormat: "dd MM yy",
firstDay: 1,
minDate: 1,
beforeShowDay: jQuery.datepicker.noWeekends,
isRTL: false
});
});
jQuery("#chose_amount").on("input", function () {
var inputValue = jQuery(this).val();
if(inputValue != "" && inputValue != 0){
jQuery("#bank_amount").text(inputValue);
}else{
jQuery("#bank_amount").text('500');
}
});
jQuery("#personale_payment").on("input", function () {
var inputValue = jQuery(this).val();
if(inputValue != ""){
jQuery("select[name=menu-120] option[value=\'Seleziona\']").prop("selected",true);
jQuery("#main_select_payment").val("");
jQuery("#main_personal_payment").val(inputValue);
}
});
jQuery(".totalP").on("input", function () {
var inputValue = jQuery(this).val();
if(inputValue == ""){
inputValue = 0;
}
jQuery(".totalPrice").val(inputValue);
jQuery(".pr").text(inputValue);
jQuery(".pr_mobile").text(inputValue);
var per_month_price = parseFloat(inputValue)/24;
per_month_price = parseFloat(per_month_price.toFixed(2));
jQuery("#per_month").html(per_month_price+"€" );
});
jQuery(".bank_transfer_btn").click(function (e) {
e.preventDefault();
jQuery("#main_select_payment").val("");
jQuery("#main_personal_payment").val("");
jQuery("select[name=menu-120] option[value=\'Seleziona\']").prop("selected",true);
jQuery("#personale_payment").val("");
jQuery("#bank_transfer").slideDown();
});
jQuery(".user_email").on("input", function () {
var inputValue = jQuery(this).val();
jQuery("#user_mail").val(inputValue);
});
jQuery("#iva_number").on("input", function () {
var inputValue = jQuery(this).val();
jQuery("#main_iva_number").val(inputValue);
});
jQuery("#sdi_pec").on("input", function () {
var inputValue = jQuery(this).val();
jQuery("#main_sdi_pec").val(inputValue);
});
jQuery("#indirizzo").on("input", function () {
var inputValue = jQuery(this).val();
jQuery("#main_indirizzo").val(inputValue);
});
jQuery('.wpcf7-select').change(function () {
var main_select_payment = jQuery(this).val();
if(main_select_payment != "Seleziona"){
jQuery("#main_personal_payment").val("");
jQuery("#personale_payment").val("");
jQuery("#main_select_payment").val(main_select_payment);
}
});
jQuery(".accessoriesClick").click(function (e) {
var ths = jQuery(this);
var fieldName = ths.attr("name");
var attaributeName = ths.attr("data-name");
if(fieldName == "accessories"){
var fieldValue = ths.val();
jQuery("#veletta_text").val(fieldValue);
}else if(attaributeName != "" && attaributeName == "no_accessories"){
jQuery("#veletta_text").val("");
}else if(attaributeName != "" && attaributeName == "no_pedestrian"){
jQuery("#pedestrian_text").val("");
}
});
jQuery(".pedestrianRadio").click(function (e) {
var ths = jQuery(this);
var fieldValue = ths.val();
jQuery("#pedestrian_text").val(fieldValue);
});
jQuery(".mail_btn").click(function (e) {
var phone_code = jQuery(".selected-flag").attr("title");
var arr = phone_code.split("+");
jQuery(".wpcf7-phonetext-country-code").val(arr[1]);
var btnClickValue = jQuery(this).attr("data-click");
var user_name = jQuery(".user_name").val();
var user_phone = jQuery(".user_phone").val();
var user_email = jQuery(".user_email").val();
if (user_name != "" && user_phone != "" && user_email != "" && btnClickValue == '1') {
jQuery(this).attr("data-click", "0");
jQuery(".mail-spinner").show();
}
if (user_name != "" && user_phone != "" && user_email != "" && btnClickValue == '0') {
e.preventDefault();
}
});
jQuery(".flag-container").click(function (e) {
alert("OK");
jQuery(".country-list").addClass("hide");
jQuery(".country-list").hide();
jQuery(".iti-arrow").hide();
});