var site_url = $(location).attr('href'); /*window.onscroll = function () { if ($.cookie("stickyclose") == 0 || $.cookie("stickyclose") == undefined) { myFunction(); } };*/ function Wload(options) { this.defaultOpt = { text: '', time: '', el: '' } this.opt = $.extend({}, this.defaultOpt, options) } Wload.prototype.hide = function(obj) { if (obj.time) { var _this = this setTimeout(function() { $(_this.opt.el).find('.w_load_body').remove() $(_this.opt.el).removeClass('w_load_body_parent') }, obj.time) } else { $(this.opt.el).find('.w_load_body').remove() $(this.opt.el).removeClass('w_load_body_parent') } } Wload.prototype.bindEvent = function() {} Wload.prototype.creatDom = function() { var dom = $(this.opt.el) var div = $('
') div.append('
' + this.opt.text || '' + '
') dom.addClass('w_load_body_parent').append(div) var con = dom.find('.w_load_content') con.css({ 'margin-left': -con.outerWidth() / 2, 'margin-top': -con.outerHeight() / 2 }) } $.fn.Wload = function(options, other) { var dom = $(this) var opt = options if (typeof opt == 'object') { opt = opt.el ? opt : $.extend({}, opt, { el: dom }) } else { if (typeof other == 'object') { opt = $.extend({}, { el: dom }, other) } else { opt = { el: dom } } } var W = new Wload(opt) if (options == 'hide') { W['hide'](other) return } W.creatDom() } /*var footer = document.getElementById("myfooter"); var sticky = footer.offsetTop; function myFunction() { var docheight = $(document).height(); if (window.pageYOffset > sticky && window.pageYOffset < parseInt(docheight) / 3) { footer.classList.add("sticky-footer-show"); } else { footer.classList.remove("sticky-footer-show"); } }*/ $(".close-sticky-ftr").on("click", function() { $(".sticky-footer").removeClass("sticky-footer-show"); }); $("#btnstickySubscribe").click(function(event) { var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; var emailid = $("#stickyemailid").val(); if (emailid != "") { if (!regex.test(emailid)) { swal("Error!", "Please enter valid Email-Id", "error"); return false; } else { event.preventDefault(); $.ajax({ url: site_url + "home/checksubscribe", type: 'post', data: { emailid: emailid }, success: function(result) { var res = JSON.parse(result).valid; if (res == true) { $.ajax({ url: site_url + 'home/newsubscribe', type: 'post', data: { emailid: emailid }, success: function(result) { swal("Subscribe!", "You have subscribed successfully", "success"); $("#frmstickysubscribe")[0].reset(); $.cookie("stickyclose", 1, { expires: 1 }); }, error: function(jqXHR, textStatus, errorThrown) { $("#frmstickysubscribe")[0].reset(); } }) } else { swal("Error!", "Your Email-Id is already in Subscriber list", "error"); $("#frmstickysubscribe")[0].reset(); return false; } }, error: function(jqXHR, textStatus, errorThrown) {} }); } } else { swal("Error!", "Please enter Email-Id", "error"); return false; } }); function recaptcha_callback() { $('.captcha-error').hide(); $("#consultation_form").bootstrapValidator('revalidateField', "consult_firstname"); return true; } $(".close-sticky-ftr").click(function() { $.cookie("stickyclose", 1, { expires: 1 }); //$.cookie("subscribe", 0, { expires : 1 }); }); //ASHLEY JS START $(document).ready(function() { /*if ($('#landingpagepopup').length > 0) { $("#landingpagepopup").on('shown.bs.modal', function(e) { initialize(); }); } if ($.cookie("is_set_store_langpage_url") == 1) { window.location.href = $.cookie('store_langpage_url'); return false; } $("body").delegate("a", "click", function(e) { //e.preventDefault();e.stopImmediatePropagation(); var attr = $(this).attr('data-redirecturl'); if (typeof attr !== typeof undefined && attr !== false) { $.cookie('store_langpage_url', attr, { path: '/' }); $.cookie('is_set_store_langpage_url', 1, { path: '/' }); attr = attr.replace(/\/$/, ''); var hdn_clicked_url_pathname = $("#hdn_clicked_url_pathname").val(); // $(location).attr('href',attr+$(location).attr('pathname')); $(location).attr('href', attr + hdn_clicked_url_pathname); return false; } if ($('#landingpagepopup').length > 0) { if ($("#hdn_is_landingpage").val() == 1) { if ($.cookie("is_set_store_langpage_url") == 1) { window.location.href = $.cookie('store_langpage_url'); return false; } else { var clicked_href = $(this).attr('href'); if (typeof clicked_href !== typeof undefined && clicked_href !== false) { if (clicked_href.indexOf('/') != -1) { var reg = /.+?\:\/\/.+?(\/.+?)(?:#|\?|$)/; var pathname = reg.exec(clicked_href)[1]; $("#hdn_clicked_url_pathname").val(pathname); } else { $("#hdn_clicked_url_pathname").val(''); } } $('#landingpagepopup').modal('show'); } return false; } else { if ($.cookie("is_set_store_langpage_url") == 1) { window.location.href = $.cookie('store_langpage_url'); return false; } } } }); $("#landingpagepopup").delegate("area", "click", function(e) { e.preventDefault(); var href = $(this).attr('href'); $.cookie('store_langpage_url', href, { path: '/' }); $.cookie('is_set_store_langpage_url', 1, { path: '/' }); href = href.replace(/\/$/, ''); var hdn_clicked_url_pathname = $("#hdn_clicked_url_pathname").val(); // $(location).attr('href',href+$(location).attr('pathname')); $(location).attr('href', href + hdn_clicked_url_pathname); });*/ if ($.cookie("stickyclose") == 1) { $("#myfooter").removeClass("sticky-footer-show"); } if ($('.header-search-right-custom').length > 0) { //$("#mobile-menu-left ul li a").live('click', function (evt) { $("#mobile-menu-left ul li a").on('click', function(evt) { if (evt.target.tagName == 'a' || evt.target.tagName == 'A') { if ($(this).attr("href") != '' && $(this).attr("href") != 'javascript:void(0);') { evt.preventDefault(); window.location.href = $(this).attr("href"); } } }); var menuLeft = $('#mobile-menu-left').slideMenu({ position: 'left', submenuLinkAfter: ' ', backLinkBefore: ' ' }); if ($(window).width() > 767) { /*menuRight.close();*/ } $("#mariClick").click(function(e) { e.preventDefault(); menuLeft.toggle(); }); menuLeft.close(); $('.c-layout-header').on('click', '.c-search-toggler', function(e) { e.preventDefault(); $('body').addClass('c-layout-quick-search-shown'); if (App.isIE() === false) { $('.c-quick-search > .form-control').focus(); } }); } $("#textSurvey").attr("checked", false); $("body").delegate("#textsurveycancel", "click", function() { $('#textSurveyModal').modal('hide'); $("#agreetextsurvey").prop("checked", false); }); $("body").delegate("#textsurveyaccept", "click", function() { $('#textSurveyModal').modal('hide'); $("#textSurvey").prop("checked", true); }); $("#textSurvey").click(function(e) { if ($("#textSurvey").is(':checked')) { e.preventDefault(); $('#textSurveyModal').modal('show'); $('#textSurveyModal').modal({ keyboard: false, show: true, backdrop: 'static' }); $("#textSurveyModal").on("hide.bs.modal", function() {}); } else { $("#textSurvey").prop("checked", false); } }); $(".change_fabric_data").on('click', function() { var name = $(this).attr('data-fab-name'); var img = $(this).attr('data-fab-img'); var color = $(this).attr('data-fab-color'); var hover_img = $(this).attr('data-fabhover-img'); var alt = $(this).attr('data-fab-alt'); $("#fabrics_name").html(name); $("#fabrics_color").html(color); $("#fabimg").attr("alt", alt); $("#fabimg").attr("src", img); $("#fabimg").attr("data-hover-img", hover_img); }); $("#fabimg").on('hover', function() { var src = $(this).attr("src"); var hover_img = $(this).attr("data-hover-img"); $("#fabimg").attr("src", hover_img); $("#fabimg").attr("data-hover-img", src); }); $("#fabimg").mouseout(function() { var src = $(this).attr("src"); var hover_img = $(this).attr("data-hover-img"); $("#fabimg").attr("data-hover-img", hover_img); $("#fabimg").attr("src", src); }); }); if ($('#consult_country').length > 0) { $('#consult_country').on('change', function() { var country = $('#consult_country').val(); $.ajax({ type: "POST", cache: true, url: '/getstatecheckout', data: 'ctrid=' + country, success: function(result) { $('#consult_state').html(result); }, error: function(jqXHR, textStatus, errorThrown) { return false; } }); }); } if ($('#consult_state').length > 0) { $('#consult_state').on('change', function() { var state = $('#consult_state').val(); $.ajax({ type: "POST", cache: true, url: '/getcitycheckout', data: 'stateid=' + state, success: function(result) { $('#consult_city').html(result); }, error: function(jqXHR, textStatus, errorThrown) { return false; } }); }); } if ($(".portfolioFilter").size() > 0) { $(window).load(function() { var $container = $('.portfolioContainer'); $container.isotope({ filter: '*', animationOptions: { duration: 750, easing: 'linear', queue: false } }); $('.portfolioFilter li a').click(function() { var selector = $(this).attr('data-filter'); $container.isotope({ filter: selector, animationOptions: { duration: 750, easing: 'linear', queue: false } }); return false; }); }); } if ($(".fancybox").size() > 0) { $(".fancybox").fancybox({ openEffect: 'elastic', closeEffect: 'elastic', helpers: { title: { type: 'inside' } } }); } if ($('#slider4').size() > 0) { $('#slider4').ubislider({ arrowsToggle: true, type: 'ecommerce', hideArrows: false, autoSlideOnLastClick: true, modalOnClick: true, onTopImageChange: function() { $('#imageSlider4 img').elevateZoom(); }, position: 'vertical' }); } var originalLeave = $.fn.popover.Constructor.prototype.leave; $.fn.popover.Constructor.prototype.leave = function(obj) { var self = obj instanceof this.constructor ? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) var container, timeout; originalLeave.call(this, obj); if (obj.currentTarget) { container = $(obj.currentTarget).siblings('.popover') timeout = self.timeout; container.one('mouseenter', function() { clearTimeout(timeout); container.one('mouseleave', function() { $.fn.popover.Constructor.prototype.leave.call(self, self); }); }) } }; $('body').popover({ selector: '[data-toggle="popover"]', trigger: 'click hover', placement: 'auto', html: true, placement: 'bottom', delay: { show: 50, hide: 50 } }); if ($.cookie("stickyclose") == 1) { $("#myfooter").removeClass("sticky-footer-show"); } $("body").delegate(".modal-backdrop in", "click", function(e) { $(".modal-backdrop").remove(); }); //Review: Start var reviewCaptcha; var reviewCorrectCaptcha = function(response) { $("[id^='reviewmyModal'] [id^='reviewcaptcharesponse']").val(response); $("[id^='productreview_form']").bootstrapValidator('revalidateField', "reviewcaptcharesponse"); }; function productReviewDisplay(productId = "", captcha_site_key = "") { $("[id^='reviewmyModal" + productId + "']").find('form').trigger('reset'); $("[id^='quality_rating_star" + productId + "'],[id^='value_rating_star" + productId + "'],[id^='appearance_rating_star" + productId + "']").val(''); $("[id^='reviewmyModal" + productId + "']").modal('show'); if ($("[id^='productreview_form']").size() > 0) { $('[id^="productreview_form"]').bootstrapValidator({ feedbackIcons: { valid: 'fa', invalid: 'err', validating: 'fa' }, fields: { 'form[reviewTitle]': { validators: { notEmpty: { message: front_poduct_review_title_msg }, } }, 'form[qualityRatingStar]': { excluded: false, validators: { notEmpty: { message: front_poduct_review_quality_msg }, } }, 'form[valueRatingStar]': { excluded: false, validators: { notEmpty: { message: front_poduct_review_value_msg }, } }, 'form[appearanceRatingStar]': { excluded: false, validators: { notEmpty: { message: front_poduct_review_appearance_msg }, } }, 'form[reviewComments]': { validators: { notEmpty: { message: front_poduct_review_comment_msg }, } }, 'form[customerName]': { validators: { notEmpty: { message: front_poduct_review_name_msg }, } }, 'form[customerEmail]': { validators: { notEmpty: { message: front_email_validation }, emailAddress: { message: front_email_valid_msg }, } }, 'reviewcaptcharesponse': { excluded: false, validators: { notEmpty: { message: front_select_captcha_msg }, } }, 'confirmation': { validators: { notEmpty: { message: front_agree_terms_condition_msg } } } }, submitHandler: function(validator, form, submitButton) {} }); $("[id^='productreview_form']").data('bootstrapValidator').resetForm(); } if (captcha_site_key != '') { var obj = document.getElementById('reviewcaptcha' + productId); if(obj != null) { reviewCaptcha = grecaptcha.render('reviewcaptcha' + productId, { 'sitekey': captcha_site_key, }); } } if ($("[id^='qualityreviewrate']").size() > 0) { starRating($("[id^='qualityreviewrate']"), $("[id^='quality_rating_star']")); } if ($("[id^='valuereviewrate']").size() > 0) { starRating($("[id^='valuereviewrate']"), $("[id^='value_rating_star']")); } if ($("[id^='appearancereviewrate']").size() > 0) { starRating($("[id^='appearancereviewrate']"), $("[id^='appearance_rating_star']")); } if ($("[id^='appearancereviewrate']").size() > 0) { $("#recommendProduct").bootstrapSwitch(); } var baseUrl = getBaseUrl(); //DropZone Start Dropzone.autoDiscover = false; var site_url = $(location).attr('href'); var myDropzone = new Dropzone(".dropzone", { url: baseUrl + '/review/images', paramName: "reviewImages", uploadMultiple: true, autoProcessQueue: false, addRemoveLinks: true, acceptedFiles: 'image/*', maxFiles: 6, parallelUploads: 6, dataType: "json", type: 'POST', cache: false, dictRemoveFile: "Remove", dictRemoveFileConfirmation: front_product_review_remove_image_msg, init: function() { this.on("maxfilesexceeded", function(file) { this.removeFile(file); }); this.on("sending", function(file, xhr, formData) { var reviewId = $("#review_id").val(); formData.append("reviewId", reviewId); }); this.on("success", function(file, response) { $("#review_id").val(''); this.removeAllFiles(true); }) }, }); $('#upload').click(function(e) { e.preventDefault(); $('#importtocsv').modal('hide'); swal({ title: 'Are you sure you want to Import this File?', type: 'warning', showCancelButton: true, confirmButtonText: 'Yes, Import', cancelButtonText: 'No, Cancel', closeOnConfirm: false, closeOnCancel: true }, function() { $('.sa-confirm-button-container > button.confirm').attr('disabled', true); myDropzone.processQueue(); }); }); //DropZone End function starRating(star, hdnstarfield) { star.rating({ min: 0, max: 5, step: 1, size: 'md', showClear: true, }).on("rating:change rating:clear", function(event, value, caption) { hdnstarfield.val(value); $("[id^='productreview_form']").bootstrapValidator('revalidateField', hdnstarfield); }); //return true; } $('body').on('success.form.bv', '[id^="productreview_form"]', function(e) { e.preventDefault(); e.stopImmediatePropagation(); var productId = (this.id).replace("productreview_form", ""); var formData = $("form#productreview_form" + productId).serialize(); var recommendProductStatus = 0; if ($("#recommendProduct").bootstrapSwitch('state') == true) { recommendProductStatus = 1; } var baseUrl = getBaseUrl(); var customerId = $("#hdn_custid").val(); var reviewTitle = $("#form_reviewTitle").val(); $.ajax({ url: baseUrl + '/review/submit', type: 'post', data: 'formData=' + formData + '&reviewTitle=' + reviewTitle + '&recommendProductStatus=' + recommendProductStatus + '&prdDataId=' + productId + '&customerId=' + customerId, beforeSend: function() { $(".loader").removeClass("hide"); $(".loader").addClass('show'); }, success: function(result) { if (result > 0) { if (reviewCaptcha > 0) { grecaptcha.reset(reviewCaptcha); } if (myDropzone.files || myDropzone.files.length != '') { $("#review_id").val(result); myDropzone.processQueue(); } $("[id^='reviewmyModal" + productId + "']").modal('hide'); $('body').Wload('hide', { time: 5 }); $("[id^='productreview_form']").data('bootstrapValidator').resetForm(); $("[id^='productreview_form']")[0].reset(); swal(front_product_review_thanks_msg, front_product_review_thanks_text, "success"); $("[id^='qualityreviewrate'],[id^='valuereviewrate'],[id^='appearancereviewrate']").rating("clear"); $(".show_reviewsForm #dZUploadVideo").removeClass('show'); $(".show_reviewsForm #dZUploadVideo").addClass('hide'); $(".show_reviewsForm #uploadvideo").removeClass('hide'); $(".show_reviewsForm #uploadvideo").addClass('show'); $("#form_youtube_video_id").val(''); } else { swal({ title: front_product_review_error_msg, text: front_hd_fillchatcha, type: 'error' }, function() { $('[id^="reviewmyModal"]').modal('show'); }); } }, complete: function() { $(".loader").removeClass("show"); $(".loader").addClass('hide'); }, error: function(jqXHR, textStatus, errorThrown) { return false; } }) }); } //Function End $("body").delegate(".close_myform", "click", function(e) { $(".show_reviewsForm").modal('hide'); }); $("body").delegate(".close_myform_comment", "click", function(e) { $(".show_review_video").modal('hide'); }); // $("body").delegate(".show_review_video", "hidden.bs.modal", function (e) { // $(".modal").css("overflow-y", "auto"); // }); function getYouTubeVideoId(url) { var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/; var match = url.match(regExp); if (match && match[2].length == 11) { return match[2]; } else { return false; } } function reviewCommentVideo(productId = "") { $("[id^='showReviewVideo" + productId + "']").modal('show'); if ($("[id^='review_comment_video']").size() > 0) { $("[id^='review_comment_video']").bootstrapValidator({ feedbackIcons: { valid: 'fa', invalid: 'err', validating: 'fa' }, fields: { 'form[youtubeVideo]': { validators: { callback: { message: front_valid_youtube_link_msg, callback: function(value, validator, $field) { var videoId = getYouTubeVideoId(value); if (videoId == false) { return false; } return true; } }, } }, }, }).on('focusout', '#form_youtube_video', function(e) { var videoId = getYouTubeVideoId($(this).val()); if (videoId != false) { $('#iframe').html(''); $("#iframeVideoId").val(videoId); return true; } if (videoId == false) { $('#iframe').html(''); $("#iframeVideoId").val(''); $("[id^='review_comment_video']").data('bootstrapValidator').revalidateField('form[youtubeVideo]'); } }); } } $('body').on('success.form.bv', '[id^="review_comment_video"]', function(e) { e.preventDefault(); e.stopImmediatePropagation(); var youTubeId = $("#iframeVideoId").val(); if (youTubeId != '') { $(".show_reviewsForm #dZUploadVideo").removeClass('hide'); $(".show_reviewsForm #dZUploadVideo").addClass('show'); $(".show_reviewsForm #uploadvideo").removeClass('show'); $(".show_reviewsForm #uploadvideo").addClass('hide'); $("#form_youtube_video_id").val(youTubeId); Dropzone.autoDiscover = false; new Dropzone("#dZUploadVideo", { // $('#dZUploadVideo').dropzone({ url: 'post.php', method: 'post', addRemoveLinks: true, uploadMultiple: false, cache: false, acceptedFiles: 'image/*', autoProcessQueue: true, clickable: false, dictRemoveFile: "Remove", dictRemoveFileConfirmation: front_product_review_remove_image_msg, init: function() { var myDropzones = this; //myDropzones.destroy(); // myDropzones.removeAllFiles(true); myDropzones.destroy(); //myDropzones.removeAllFiles(true); var mockFile = { name: "YouTube Video", size: '12345' }; myDropzones.options.addedfile.call(myDropzones, mockFile); myDropzones.options.thumbnail.call(myDropzones, mockFile, '//img.youtube.com/vi/' + youTubeId + '/0.jpg'); myDropzones.removeAllFiles(true); // myDropzones.removeAllFiles(true); //myDropzones.disable(); this.on("removedfile", function() { $(".show_reviewsForm #uploadvideo").removeClass('hide'); $(".show_reviewsForm #uploadvideo").addClass('show'); $(".show_reviewsForm #dZUploadVideo").removeClass('show'); $(".show_reviewsForm #dZUploadVideo").addClass('hide'); $('#iframe').html(''); $("#iframeVideoId").val(''); $("#form_youtube_video_id").val(''); myDropzones.destroy(); }); this.on('resetFiles', function() { this.removeAllFiles(true); }); }, }); } else { $(".show_reviewsForm #dZUploadVideo").removeClass('show'); $(".show_reviewsForm #dZUploadVideo").addClass('hide'); $(".show_reviewsForm #uploadvideo").removeClass('hide'); $(".show_reviewsForm #uploadvideo").addClass('show'); $("#form_youtube_video_id").val(''); } $(".show_review_video").modal('hide'); }); //Review: End