// Unobtrusive Ajax support library for jQuery // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // @version // // Microsoft grants you the right to use these script files for the sole // purpose of either: (i) interacting through your browser with the Microsoft // website or online service, subject to the applicable licensing or use // terms; or (ii) using the files as included with a Microsoft product subject // to that product's license terms. Microsoft reserves all other rights to the // files not expressly granted by Microsoft, whether by implication, estoppel // or otherwise. Insofar as a script file is dual licensed under GPL, // Microsoft neither took the code under GPL nor distributes it thereunder but // under the terms set out in this paragraph. All notices and licenses // below are for informational purposes only. /*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ /*global window: false, jQuery: false */ (function ($) { var data_click = "unobtrusiveAjaxClick", data_target = "unobtrusiveAjaxClickTarget", data_validation = "unobtrusiveValidation"; function getFunction(code, argNames) { var fn = window, parts = (code || "").split("."); while (fn && parts.length) { fn = fn[parts.shift()]; } if (typeof (fn) === "function") { return fn; } argNames.push(code); return Function.constructor.apply(null, argNames); } function isMethodProxySafe(method) { return method === "GET" || method === "POST"; } function asyncOnBeforeSend(xhr, method) { if (!isMethodProxySafe(method)) { xhr.setRequestHeader("X-HTTP-Method-Override", method); } } function asyncOnSuccess(element, data, contentType) { var mode; if (contentType.indexOf("application/x-javascript") !== -1) { // jQuery already executes JavaScript for us return; } mode = (element.getAttribute("data-ajax-mode") || "").toUpperCase(); $(element.getAttribute("data-ajax-update")).each(function (i, update) { var top; switch (mode) { case "BEFORE": $(update).prepend(data); break; case "AFTER": $(update).append(data); break; case "REPLACE-WITH": $(update).replaceWith(data); break; default: $(update).html(data); break; } }); } function asyncRequest(element, options) { var confirm, loading, method, duration; confirm = element.getAttribute("data-ajax-confirm"); if (confirm && !window.confirm(confirm)) { return; } loading = $(element.getAttribute("data-ajax-loading")); duration = parseInt(element.getAttribute("data-ajax-loading-duration"), 10) || 0; $.extend(options, { type: element.getAttribute("data-ajax-method") || undefined, url: element.getAttribute("data-ajax-url") || undefined, cache: (element.getAttribute("data-ajax-cache") || "").toLowerCase() === "true", beforeSend: function (xhr) { var result; asyncOnBeforeSend(xhr, method); result = getFunction(element.getAttribute("data-ajax-begin"), ["xhr"]).apply(element, arguments); if (result !== false) { loading.show(duration); } return result; }, complete: function () { loading.hide(duration); getFunction(element.getAttribute("data-ajax-complete"), ["xhr", "status"]).apply(element, arguments); }, success: function (data, status, xhr) { asyncOnSuccess(element, data, xhr.getResponseHeader("Content-Type") || "text/html"); getFunction(element.getAttribute("data-ajax-success"), ["data", "status", "xhr"]).apply(element, arguments); }, error: function () { getFunction(element.getAttribute("data-ajax-failure"), ["xhr", "status", "error"]).apply(element, arguments); } }); options.data.push({ name: "X-Requested-With", value: "XMLHttpRequest" }); method = options.type.toUpperCase(); if (!isMethodProxySafe(method)) { options.type = "POST"; options.data.push({ name: "X-HTTP-Method-Override", value: method }); } // change here: // Check for a Form POST with enctype=multipart/form-data // add the input file that were not previously included in the serializeArray() // set processData and contentType to false var $element = $(element); if ($element.is("form") && $element.attr("enctype") == "multipart/form-data") { var formdata = new FormData(); $.each(options.data, function (i, v) { formdata.append(v.name, v.value); }); $("input[type=file]", $element).each(function () { var file = this; $.each(file.files, function (n, v) { formdata.append(file.name, v); }); }); $.extend(options, { processData: false, contentType: false, data: formdata }); } // end change $.ajax(options); } function validate(form) { var validationInfo = $(form).data(data_validation); return !validationInfo || !validationInfo.validate || validationInfo.validate(); } $(document).on("click", "a[data-ajax=true]", function (evt) { evt.preventDefault(); asyncRequest(this, { url: this.href, type: "GET", data: [] }); }); $(document).on("click", "form[data-ajax=true] input[type=image]", function (evt) { var name = evt.target.name, target = $(evt.target), form = $(target.parents("form")[0]), offset = target.offset(); form.data(data_click, [ { name: name + ".x", value: Math.round(evt.pageX - offset.left) }, { name: name + ".y", value: Math.round(evt.pageY - offset.top) } ]); setTimeout(function () { form.removeData(data_click); }, 0); }); $(document).on("click", "form[data-ajax=true] :submit", function (evt) { var name = evt.currentTarget.name, target = $(evt.target), form = $(target.parents("form")[0]); form.data(data_click, name ? [{ name: name, value: evt.currentTarget.value }] : []); form.data(data_target, target); setTimeout(function () { form.removeData(data_click); form.removeData(data_target); }, 0); }); $(document).on("submit", "form[data-ajax=true]", function (evt) { var clickInfo = $(this).data(data_click) || [], clickTarget = $(this).data(data_target), isCancel = clickTarget && (clickTarget.hasClass("cancel") || clickTarget.attr('formnovalidate') !== undefined); evt.preventDefault(); if (!isCancel && !validate(this)) { return; } asyncRequest(this, { url: this.action, type: this.method || "GET", data: clickInfo.concat($(this).serializeArray()) }); }); }(jQuery)); //function getCookie(name) { // var nameEQ = name + "="; // var ca = document.cookie.split(';'); // for (var i = 0; i < ca.length; i++) { // var c = ca[i]; // while (c.charAt(0) == ' ') c = c.substring(1, c.length); // if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); // } // return null; //} function getDocumentCookie(name) { function escape(s) { return s.replace(/([.*+?\^$(){}|\[\]\/\\])/g, '\\$1'); } var match = document.cookie.match(RegExp('(?:^|;\\s*)' + escape(name) + '=([^;]*)')); return match ? match[1] : null; } !function (a) { markiteeModule.cartAdded = function () { var cartCookies = JSON.stringify(JSON.parse(decodeURIComponent(getDocumentCookie("Markitee_cart_popUp")))); if (null !== cartCookies && cartCookies !== undefined && "" !== cartCookies && cartCookies.length > 10 && cartCookies != null) { var CartList = []; var _obj = JSON.parse(JSON.stringify(cartCookies)); CartList = JSON.parse(JSON.stringify(JSON.parse(_obj).CartList)); if (CartList.length) { var items = ``); a('.shopping-cart-widget-footer').html(`

Subtotal: `+ JSON.parse(_obj).TOTAL + `EGP

View cartCheckout

`); } }else { var emptyState = `

No products in the cart.

Return To Shop
`; a('.shopping-cart-widget-body .wd-scroll-content').html(emptyState); } }, a(document).ready(function () { markiteeModule.cartAdded() }) }(jQuery); jQuery(function (d) { if ("undefined" == typeof wc_add_to_cart_params) return !1; var t = function () { this.requests = [], this.addRequest = this.addRequest.bind(this), this.run = this.run.bind(this), d(document.body).on("click", ".add_to_cart_button", { addToCartHandler: this }, this.onAddToCart).on("click", ".remove_from_cart_button", { addToCartHandler: this }, this.onRemoveFromCart) .on("added_to_cart", this.updateButton) .on("ajax_request_not_sent.adding_to_cart", this.updateButton) .on("added_to_cart removed_from_cart", { addToCartHandler: this }, this.updateFragments) }; t.prototype.addRequest = function (t) { this.requests.push(t), 1 === this.requests.length && this.run() }, t.prototype.run = function () { var t = this, a = t.requests[0].complete; t.requests[0].complete = function () { "function" == typeof a && a(), t.requests.shift(), 0 < t.requests.length && t.run() }, d.ajax(this.requests[0]) }, t.prototype.onAddToCart = function (t) { t.preventDefault(); var a = d(this); //if (iOS()) { // d(a).click(); //} if (a.is(".ajax_add_to_cart")) { //alert('hiiiii'); if (!a.attr("data-product_id")) return !0; if (t.preventDefault(), a.removeClass("added"), a.addClass("loading"), !1 === d(document.body) .triggerHandler("should_send_ajax_request.adding_to_cart", [a])) return d(document.body) .trigger("ajax_request_not_sent.adding_to_cart", [!1, !1, a]), !0; var e = {}; d.each(a.data(), function (t, a) { e[t] = a }), d.each(a[0].dataset, function (t, a) { e[t] = a }), d(document.body).trigger("adding_to_cart", [a, e]), t.data.addToCartHandler.addRequest({ type: "POST", //url: wc_add_to_cart_params.wc_ajax_url.toString() url: "/cart/saveCartProduct",//.toString().replace("%%endpoint%%", "addtocart"), data: e, success: function (t) { // console.log(JSON.stringify(t)); // Cookies.set('Markitee_cart_popUp', JSON.stringify(t), { expires: 2 }); //if (document.getElementsByClassName("cart_list").length > 0) //{ var items = ``); d('.shopping-cart-widget-footer').html(`

Subtotal: `+ t.TOTAL + `EGP

View cartCheckout

`); var cartCountList = document.getElementsByClassName("wd-cart-number"); for (var i = 0; i < cartCountList.length; i++) { d(cartCountList).html(cartCount + 1); } var cartTotalList = document.getElementsByClassName("markitee-cart-totals"); for (var i = 0; i < cartTotalList.length; i++) { d(cartTotalList).html(t.TOTAL + " EGP"); } cartTotal(d, t.TOTAL, t.offerfound, t.quantity); //} //else //{ // var newCart = ``; // d('.shopping-cart-widget-body .wd-scroll-content').html(newCart); //} d(document.body).trigger("added_to_cart", [t.fragments, t.cart_hash, a]); //t && (t.error && t.product_url // ? window.location = t.product_url // : "yes" // !== wc_add_to_cart_params.cart_redirect_after_add // ? d(document.body).trigger("added_to_cart", // [t.fragments, t.cart_hash, a]) : // window.location = wc_add_to_cart_params.cart_url) } , dataType: "json" }) } if (a.is(".added")) { d(document.body).trigger("added_to_cart", [t.fragments, t.cart_hash, a]); } }, t.prototype.onRemoveFromCart = function (t) { //alert('iiii'); var a = d(this), e = a.closest(".woocommerce-mini-cart-item"); t.preventDefault(), e.block({ message: null, overlayCSS: { opacity: .6 } }), t.data.addToCartHandler .addRequest({ type: "POST", //url: wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%", "remove_from_cart"), url: "/cart/saveCartProductPage".toString().replace("%%endpoint%%", "remove_from_cart"), data: { product_id: a.data("product_id"), product_sku: a.data("cart_item_key"), quantity: 1, action: "remove_from_cart" //a.parent().children[2].querySelector(".qty").val() }, success: function (t) { // Cookies.set('Markitee_cart_popUp', JSON.stringify(t), { expires: 2 }); if (a.hasClass("TrRemove")) { a.parent().parent().remove(); } else { a.parent().remove(); } //t && t.fragments ? // if (d(".cart_list li").length > 0) { var _obj = []; _obj = JSON.parse(JSON.stringify(t.CartList)); if (_obj.length > 0) { var cartCountList = document.getElementsByClassName("wd-cart-number"); for (var i = 0; i < cartCountList.length; i++) { d(cartCountList).html(t.cartCount); } var cartTotalList = document.getElementsByClassName("markitee-cart-totals"); for (var i = 0; i < cartTotalList.length; i++) { d(cartTotalList).html(t.TOTAL + " EGP"); } cartTotal(d, t.TOTAL, t.offerfound, t.quantity); var totalprice = document.getElementById("totalprice"); d(totalprice).html(t.TOTAL + `EGP`); // markiteeModule.$body.trigger("removed_from_cart", [c, d, e]); } else { var emptyState = `

No products in the cart.

Return To Shop
`; d('.shopping-cart-widget-body .wd-scroll-content').html(emptyState); d(document.body).trigger("removed_from_cart", [t.fragments, t.cart_hash, a]) d('.shopping-cart-widget-footer').html(''); var cartCountList = document.getElementsByClassName("wd-cart-number"); for (var i = 0; i < cartCountList.length; i++) { d(cartCountList).html(0); } var cartTotalList = document.getElementsByClassName("markitee-cart-totals"); for (var i = 0; i < cartTotalList.length; i++) { d(cartTotalList).html("0 EGP"); } cartTotal(d, 0, "", 0); } const el1 = document.querySelector('[href="?add-to-cart=' + a.data("product_id") + '"]'); d(el1).removeClass("wd-tooltip-inited"); d(el1).removeClass("added"); d(el1).addClass("ajax_add_to_cart"); d(el1).addClass("add-to-cart-loop"); d(el1).parent().replaceWith(`
Add to cart
`); // d(el1).parent().html(` // Add to cart //`); //d(el1).parent().removeClass("wd-action-btn"); // d(el1).parent().removeClass("wd-style-icon"); // d(el1).parent().removeClass("wd-add-cart-icon"); // d(el1).parent().addClass("wd-add-btn"); // d(el1).parent().addClass("wd-add-btn-replace"); //wd-add-btn wd-add-btn-replace woodmart-add-btn //wd-action-btn wd-style-icon wd-add-cart-icon woodmart-add-btn //a.parent().addClass("wd-add-btn"); //: window.location = a.attr("href") }, error: function () { //window.location = a.attr("href") } , dataType: "json" }) }, t.prototype.updateButton = function (t, a, e, r) { //alert('update'); //(r = void 0 !== r && r)&& ( r.removeClass("loading");//, a && r.parent().removeClass("wd-add-btn"); r.addClass("added");//, //safaa //r.removeClass("add_to_cart_button"); r.removeClass("ajax_add_to_cart"); r.removeClass("add-to-cart-loop"); //a &&!wc_add_to_cart_params.is_cart && // 0 === r.parent().find(".added_to_cart").length && r.after('' + wc_add_to_cart_params.i18n_view_cart + "");//, //safaa r.parent().removeClass("wd-add-btn-replace").addClass("wd-action-btn wd-style-icon wd-add-cart-icon"); d(document.body).trigger("wc_cart_button_updated", [r]);//) }, t.prototype.updateFragments = function (t, a) { //alert('update33'); a && (d.each(a, function (t) { d(t).addClass("updating").fadeTo("400", "0.6").block( { message: null, overlayCSS: { opacity: .6 } }) }), d.each(a, function (t, a) { d(t).replaceWith(a), d(t).stop(!0).css("opacity", "1").unblock() }), d(document.body).trigger("wc_fragments_loaded")) }, new t }); (function ($) { 'use strict'; $(document).ready(function () { $('body').on('adding_to_cart', function (event, $button, data) { //alert('uuuu'); if ($button && $button.hasClass('vc_gitem-link')) { $button.addClass('vc-gitem-add-to-cart-loading-btn') .parents('.vc_grid-item-mini') .addClass('vc-woocommerce-add-to-cart-loading') .append($('
')) } }).on('added_to_cart', function (event, fragments, cart_hash, $button) { //console.log('button'); console.log($button); if ('undefined' === typeof ($button)) { $button = $('.vc-gitem-add-to-cart-loading-btn') } if ($button && $button.hasClass('vc_gitem-link')) { $button.removeClass('vc-gitem-add-to-cart-loading-btn') .parents('.vc_grid-item-mini') .removeClass('vc-woocommerce-add-to-cart-loading') .find('.vc_wc-load-add-to-loader-wrapper').remove() } }) }) })(window.jQuery); !function (a) { markiteeModule.miniCartQuantity = function () { var b; markiteeModule.$document.on("change input", ".woocommerce-mini-cart .quantity .qty,.cart_item .quantity .qty", function () { //alert('mmmm'); var c = a(this), d = c.val(), e = c.parents(".woocommerce-mini-cart-item").data("key"), isCartpage = c.parents(".woocommerce-mini-cart-item").data("page"), f = markitee_settings.cart_hash_key, g = markitee_settings.fragment_name; clearTimeout(b), b = setTimeout(function () { c.parents(".mini_cart_item").addClass("wd-loading"), a.ajax({ //url: markitee_settings.ajaxurl, url: "/cart/saveCartProductPage", data: { action: "woodmart_update_cart_item", product_id: c.parents(".woocommerce-mini-cart-item").data("product_id"), product_sku: e, quantity: d }, success: function (b) { // Cookies.set('Markitee_cart_popUp', JSON.stringify(b), { expires: 2 }); var items = ``); a('.shopping-cart-widget-footer').html(`

Subtotal: `+ b.TOTAL + `EGP

View cartCheckout

`); var cartCountList = document.getElementsByClassName("wd-cart-number"); for (var i = 0; i < cartCountList.length; i++) { a(cartCountList).html(cartCount + 1); } var cartTotalList = document.getElementsByClassName("markitee-cart-totals"); for (var i = 0; i < cartTotalList.length; i++) { a(cartTotalList).html(b.TOTAL + " EGP"); } cartTotal(a, b.TOTAL, b.offerfound, b.q); }, dataType: "json", method: "post" }) }, 500) }) }, a(document).ready(function () { markiteeModule.miniCartQuantity() }) }(jQuery); function cartTotal(d, total, offerfound, qty) { debugger; if (total == 0) { d("#cartContainer").html(`

Your cart is currently empty.

Before proceed to checkout you must add some products to your shopping cart.
You will find a lot of interesting products on our "Shop" page.

Return to shop

`); } d("#cartSubTotal").html(total + " EGP"); if (offerfound == "freeShipping" && total >= 500) { shipping = "free"; d("#totalShipping").html("free"); d("#totalWithShipping").html(total + "EGP"); } else if (total < 500) { d("#totalShipping").html("50.00 EGP"); d("#totalWithShipping").html((total + 50) + "EGP"); } else { shipping = "free"; d("#totalShipping").html("free"); d("#totalWithShipping").html(total + "EGP"); } }