$(document).ready(function () { if ($('.filter-applied').length > 0) { $('', { rel: 'stylesheet', type: 'text/css', href: '/edit/elements/filter/cssgram.css' }).appendTo('head'); } if ($('[class*="accent-"]').length > 0) { $('', { rel: 'stylesheet', type: 'text/css', href: '/assets/css/colors.css' }).appendTo('head'); } if ($('.type-it-out').length > 0) { $.ajaxSetup({ cache: true }); $.getScript("https://cdn.jsdelivr.net/jquery.typeit/4.4.0/typeit.min.js", function () { $('.type-it-out').typeIt({cursor: false}); }); } if ($('.cocoen').length > 0) { $('', { rel: 'stylesheet', type: 'text/css', href: '/edit/elements/filter/cocoen.css' }).appendTo('head'); $.getScript("/edit/elements/filter/cocoen.min.js", function () { document.querySelectorAll('.cocoen').forEach(function (element) { new Cocoen(element); }); }); } if ($('[data-tilt]').length > 0) { $.ajaxSetup({ cache: true }); $.getScript("/edit/elements/filter/tilt.min.js", function () { $("[data-tilt]").tilt({ speed: 1000, perspective: 3000, glare: true, maxGlare: 0.20, reset: true }); }); } if ($('.perspective').length > 0) { $.ajaxSetup({ cache: true }); $.getScript("/edit/elements/filter/perspective.min.js"); } var ID = function () { return '_' + Math.random().toString(36).substr(2, 9); }; if ($('#contact-form:not([no-captcha])').length > 0) { $.ajaxSetup({ cache: true }); $.getScript("/edit/elements/filter/captcha.js", function () { reinitializeCaptcha(); }); } function reinitializeCaptcha() { if ($('[captcha-modal]').length > 0) { $('[captcha-modal]').remove(); } $('#contact-form:not([no-captcha])').each(function (fo) { var elemId = ID(); var $this = $(this); $this.find('#contact-submit-button').attr('modal-elem-id', elemId); $this.find('.error-message').remove(); $this.find('.touched').removeClass("touched"); $this.find('[name]').each(function () { if ($(this).attr('error-message') && $(this).attr('error-message').length > 0) { var errorMessage = $(this).attr('error-message'); $('' + errorMessage + "").insertAfter($(this)); } }); $this.find('[name]').one('blur keydown', function () { $(this).addClass('touched'); }); $this.find('.upload-btn-wrapper button p').each(function (r) { if ($(this).attr('title') && $(this).attr('title').length > 0) { var titleMessage = $(this).attr('title'); $(this).text(titleMessage); } }); var modalBody = '

'; $('body').append(modalBody); $this.clientSideCaptcha({ input: "#captchaText-" + elemId, display: "#captcha-" + elemId, pass: function () { $('#' + elemId).removeClass('active'); var url = '/contact-site'; if ($this && $this.attr("form-url") && $this.attr("form-url").length > 0) { url = $this.attr("form-url"); $.ajax({ method: 'POST', url: url, data: new FormData($this[0]), cache: false, contentType: false, processData: false, success: function (data) { if (data && data.redirect) { var frm = $this[0]; frm.reset(); location.href = data.redirect; } else if (data && data.notify) { alert(data.notify); } else { var oldText = $this.find('#contact-submit-button')[0].innerText; $this.find('#contact-submit-button')[0].innerText = "Sent!"; setTimeout(function () { $this.find('#contact-submit-button')[0].innerText = oldText; }, 3000); var frm = $this[0]; frm.reset(); reinitializeCaptcha(); } }, error: function (xhr, desc, err) { console.log(err); } }); } else { $.ajax({ method: 'POST', url: url, data: $this.serialize(), success: function (data) { var oldText = $this.find('#contact-submit-button')[0].innerText; $this.find('#contact-submit-button')[0].innerText = "Sent!"; setTimeout(function () { $this.find('#contact-submit-button')[0].innerText = oldText; }, 3000); var frm = $this[0]; frm.reset(); reinitializeCaptcha(); }, error: function (xhr, desc, err) { console.log(err); } }); } return false; }, fail: function () { var errorEle = '

Please enter exact code shown in image above. Please note that it is case-sensitive.

'; $(errorEle).insertBefore($('#' + elemId).find('button')); return false; } }); $('#button-' + elemId).click(function (e) { if ($('.captcha-error').length > 0) { $('.captcha-error').remove(); } $this.submit(); }); $('#close-captcha-icon-' + elemId).click(function (e) { if ($('.captcha-error').length > 0) { $('.captcha-error').remove(); } $('#' + elemId).removeClass('active'); reinitializeCaptcha(); }); }); } $('#contact-form[no-captcha]').each(function (fo) { var $this = $(this); $this.find('#contact-submit-button').click(function (e) { $this.submit(); }); $this.submit(function (event) { event.preventDefault(); var url = '/contact-site'; if ($this && $this.attr("form-url") && $this.attr("form-url").length > 0) { url = $this.attr("form-url"); $.ajax({ method: 'POST', url: url, data: new FormData($this[0]), cache: false, contentType: false, processData: false, success: function (data) { if (data && data.redirect) { var frm = $this[0]; frm.reset(); location.href = data.redirect; } else if (data && data.notify) { alert(data.notify); } else { var oldText = $this.find('#contact-submit-button')[0].innerText; $this.find('#contact-submit-button')[0].innerText = "Sent!"; setTimeout(function () { $this.find('#contact-submit-button')[0].innerText = oldText; }, 3000); var frm = $this[0]; frm.reset(); } }, error: function (xhr, desc, err) { console.log(err); } }); } else { $.ajax({ method: 'POST', url: url, data: $this.serialize(), success: function (data) { var oldText = $this.find('#contact-submit-button')[0].innerText; $this.find('#contact-submit-button')[0].innerText = "Sent!"; setTimeout(function () { $this.find('#contact-submit-button')[0].innerText = oldText; }, 3000); var frm = $this[0]; frm.reset(); }, error: function (xhr, desc, err) { console.log(err); } }); } }); }); if ($('.open-image-picker-button').length > 0) { function getFileArray(element, cb) { var reader = new FileReader(); var file = $(element)[0].files[0]; reader.readAsArrayBuffer(file); var fileByteArray = []; reader.onloadend = function (evt) { if (evt.target.readyState == FileReader.DONE) { var arrayBuffer = evt.target.result, array = new Uint8Array(arrayBuffer); for (var i = 0; i < array.length; i++) { fileByteArray.push(array[i]); } cb(fileByteArray, element); } } } $('.upload-btn-wrapper input[type=file]').change(function (e) { getFileArray(this, function (fileByteArray, element) { if ($(element)[0].files.length > 0) { var files = $(element)[0].files; var fileNames = ""; for (var i = 0; i < files.length; i++) { if (i > 0) fileNames += ", "; fileNames += files[i].name; } $(element).parent().find('p').text(fileNames); } else { var file = $(element)[0].files[0]; $(element).parent().find('p').text(file.name); } }); }) } $("#contact-submit-button").click(function (event) { event.preventDefault(); var strongThis = this; if ($(strongThis).parents('form')[0].checkValidity()) { $('#' + $(this).attr('modal-elem-id')).addClass('active'); } else { $(strongThis).parents('form').find('input:invalid').addClass("touched"); } event.stopPropagation(); }); $('body').on('click', "#booking-submit-button", function (event) { var data = { name: $('.u_name').val(), mobile: $('.m_number').val(), email: $('.e_mail').val(), note: $('.comment').val() }; var date = $('#dpicker_name').text(); var time = $('#dpicker_date').text(); date = moment(date, 'DD/MM/YYYY').format('YYYY-MM-DD'); console.log(date) var sheduled = new Date(date + " " + time); data.startsAt = sheduled console.log(data); $.ajax({ method: 'POST', url: '/api/booking/', data: data, success: function (data) { var oldText = $('#booking-submit-button')[0].innerText; console.log(data); $('#booking-submit-button')[0].innerText = "Sent!"; setTimeout(function () { $('#booking-submit-button')[0].innerText = oldText; }, 3000); var frm = $('#contact-form')[0]; frm.reset(); }, error: function (xhr, desc, err) { console.log(err); } }); event.preventDefault(); }); $('.travel-booking').on('click', "#submit-bookquote", function (event) { var data = { name: $('#name').val(), email: $('#email').val(), mobile: $('#number').val(), from: $('#from').val(), to: $('#to').val(), departDate: $('#txtFrom').val(), returnDate: $('#txtTo').val() }; $.ajax({ method: 'POST', url: '/api/travelquote/', data: data, success: function (data) { console.log(data); var oldText = $('#submit-bookquote')[0].innerText; console.log(data); $('#submit-bookquote')[0].innerText = "Sent!"; setTimeout(function () { $('#submit-bookquote')[0].innerText = oldText; }, 3000); var frm = $('#travel-booking')[0]; frm.reset(); }, error: function (xhr, desc, err) { console.log(err); } }); event.preventDefault(); }); $("#subscription-form").submit(function (event) { event.preventDefault(); $.ajax({ method: 'POST', url: '/subscribe', data: $('#subscription-form').serialize(), success: function (data) { var oldText = $('#subscription-btn')[0].innerText; $('#subscription-btn')[0].innerText = "Subscribed!"; setTimeout(function () { $('#subscription-btn')[0].innerText = oldText; }, 3000); var frm = $('#subscription-form')[0]; frm.reset(); }, error: function (xhr, desc, err) { console.log(err); } }); }); for (var i = 0; i < $('[data-redirect-link]:not(a)').length; i++) { var el = $.parseHTML(''); $(el).append($('[data-redirect-link]:not(a)')[i].outerHTML); $($('[data-redirect-link]:not(a)')[i]).replaceWith(el); } $('[data-hover-color*="#"]').hover( function () { $(this).css('color', $(this).attr('data-hover-color')); }, function () { $(this).css('color', $(this).attr('data-color')); } ); $('[data-hover-border-color*="#"]').hover( function () { $(this).css('border-color', $(this).attr('data-hover-border-color')); }, function () { $(this).css('border-color', $(this).attr('data-border-color')); } ); $('[data-hover-background-color*="#"]').hover( function () { $(this).css('background', $(this).attr('data-hover-background-color')); }, function () { $(this).css('background', $(this).attr('data-background-color')); } ); var $o = {}; $o.loader = $.parseHTML('
') $o.categories = $("[data-type='categories']").length > 0 ? true : false; $o.collections = $("[data-type='collections']").length > 0 ? true : false; $o.productGrid = $("[product-grid]").length > 0 ? true : false; $o.slick = $("[data-slick]:not('[product-grid]')").length > 0 ? true : false; $o.swiper = $("[data-swiper-init]:not('[product-grid]')").length > 0 ? true : false; $o.callbackFunctions = $("[data-cb]").length > 0 ? true : false; $o.hasImagesForResponsiveLayout = $("[data-min-device-width-961]").length > 0 ? true : $("[data-min-device-width-768]").length > 0 ? true : $("[data-min-device-width-480]").length > 0 ? true : $("[data-min-device-width-0]").length > 0 ? true : false; if ($o.productGrid) { $.ajaxSetup({ cache: true }); var x = ''; $(x).insertAfter('body'); var x = ''; $(x).insertAfter('body'); } if ($o.callbackFunctions) { $("[data-cb]").each(function () { var cb = $(this).data('cb'); var x = eval(cb); if (typeof x == 'function') { x(); } }); } if ($o.hasImagesForResponsiveLayout) { $.ajaxSetup({ cache: true }); $.getScript("/edit/elements/filter/response.js", function () { Response.create({ "prop": "device-width", "prefix": "min-device-width-", breakpoints: [961, 768, 481, 0] }); }); } if ($o.slick) { $.ajaxSetup({ cache: true }); $.getScript("//cdn.jsdelivr.net/gh/kenwheeler/slick@1.8.1/slick/slick.min.js", function () { $('[data-slick]:not("[product-grid]")').slick(); $('.slider-controls .right-icon').click(function (e) { $($(this).parent().attr('data-slick-class') + ' .slick-next').trigger('click'); }); $('.slider-controls .left-icon').click(function (e) { $($(this).parent().attr('data-slick-class') + ' .slick-prev').trigger('click'); }); }); } if ($o.swiper) { $.ajaxSetup({ cache: true }); $.each($('[data-swiper-init]'), function (e) { new Swiper($(this), JSON.parse($(this).attr('data-swiper-init'))); }); } if (location.href.indexOf(".storearmy.com") == -1 || location.href == "www.storearmy.com") { var link = document.createElement('link'); link.setAttribute('rel', 'canonical'); link.setAttribute('href', 'https://' + (location.host.replace("www.", "")) + location.pathname); document.head.appendChild(link); } } );