/** * We offer the best and most useful modules PrestaShop and modifications for your online store. * * We are experts and professionals in PrestaShop * * @author PresTeamShop.com * @copyright 2011-2017 PresTeamShop * @license see file: LICENSE.txt * @category PrestaShop * @category Module */ $(function () { AppOPC.init() //$('#checkbox_create_account_guest').trigger('click'); }) var AppOPC = { $opc: false, $opc_step_one: false, $opc_step_two: false, $opc_step_three: false, $opc_step_review: false, initialized: false, load_offer: true, is_valid_all_form: false, jqOPC: typeof $jqOPC === typeof undefined ? $ : $jqOPC, init: function () { AppOPC.initialized = true AppOPC.$opc = $("#onepagecheckoutps") AppOPC.$opc_step_one = $( "#onepagecheckoutps div#onepagecheckoutps_step_one" ) AppOPC.$opc_step_two = $( "#onepagecheckoutps div#onepagecheckoutps_step_two" ) AppOPC.$opc_step_three = $( "#onepagecheckoutps div#onepagecheckoutps_step_three" ) AppOPC.$opc_step_review = $( "#onepagecheckoutps div#onepagecheckoutps_step_review" ) if (typeof OnePageCheckoutPS !== typeof undefined) { if (typeof jeoquery !== typeof undefined) { jeoquery.defaultCountryCode = OnePageCheckoutPS.iso_code_country_delivery_default jeoquery.defaultLanguage = prestashop.language.iso_code jeoquery.defaultData.lang = prestashop.language.iso_code } //launch validate fields if ( typeof $.formUtils !== typeof undefined && typeof $.validate !== typeof undefined ) { $.formUtils.loadModules( "prestashop.js, security.js, brazil.js", OnePageCheckoutPS.ONEPAGECHECKOUTPS_DIR + "views/js/lib/form-validator/" ) $.validate({ form: "div#onepagecheckoutps #form_login, div#onepagecheckoutps #form_onepagecheckoutps", validateHiddenInputs: true, language: messageValidate, onError: function () { AppOPC.is_valid_all_form = false }, onSuccess: function () { AppOPC.is_valid_all_form = true return false }, }) } $(OnePageCheckoutPS.CONFIGS.OPC_ID_CONTENT_PAGE) .css({ margin: 0, }) .addClass("opc_center_column") .removeClass("col-sm-push-3") Address.launch() Fronted.launch() if (!OnePageCheckoutPS.REGISTER_CUSTOMER) { $(OnePageCheckoutPS.CONFIGS.OPC_ID_CONTENT_PAGE).css({ width: "100%" }) Carrier.launch() Payment.launch() Review.launch() } $( 'div#onepagecheckoutps #onepagecheckoutps_step_one input[data-validation*="isBirthDate"]' ).datepicker({ dateFormat: OnePageCheckoutPS.date_format_language, changeMonth: true, changeYear: true, showButtonPanel: true, yearRange: "-100:+0", isRTL: parseInt(prestashop.language.is_rtl), }) $( 'div#onepagecheckoutps #onepagecheckoutps_step_one input[data-validation*="isDate"]' ).datepicker({ dateFormat: OnePageCheckoutPS.date_format_language, //cuando necesita des-habilitar dias anteriores al actual //minDate: 0, changeMonth: true, changeYear: true, showButtonPanel: true, yearRange: "-100:+0", isRTL: parseInt(prestashop.language.is_rtl), }) } else { //redirect to checkout if have he option OPC_REDIRECT_DIRECTLY_TO_OPC actived $(".cart-detailed-actions a").attr( "href", prestashop.urls.current_url + "?checkout=1" ) $("form#voucher").attr("action", prestashop.urls.current_url) var href_delete_voucher = $("a.price_discount_delete").attr("href") if (typeof href_delete_voucher != "undefined") { href_delete_voucher = href_delete_voucher.split("?") $("a.price_discount_delete").attr( "href", prestashop.urls.current_url + "?" + href_delete_voucher[1] ) } } }, } var Fronted = { launch: function () { $("div#onepagecheckoutps #opc_show_login").click(function () { Fronted.showModal({ type: "normal", title: $("#opc_login").attr("title"), title_icon: "fa-pts-user", content: $("#opc_login"), }) }) /*if (AppOPC.$opc.hasClass('rc')) { AppOPC.$opc.find('#opc_show_login').trigger('click'); }*/ AppOPC.$opc .find("#opc_login") .on("click", "#btn_login", Fronted.loginCustomer) AppOPC.$opc .find("#div_onepagecheckoutps_login") .on("click", "#btn_logout", function () { $.totalStorageOPC("id_address_delivery", null) $.totalStorageOPC("id_address_invoice", null) }) AppOPC.$opc.on("click", "#btn_continue_shopping", function () { var link = $("div#onepagecheckoutps #btn_continue_shopping").data("link") if (typeof link === typeof undefined) { link = prestashop.urls.pages.index } window.location = link }) AppOPC.$opc.on("click", "#btn-logout", function (e) { window.location = $(e.currentTarget).data("link") }) AppOPC.$opc.find("#opc_login #txt_login_password").keypress(function (e) { var code = e.keyCode ? e.keyCode : e.which if (code == 13) Fronted.loginCustomer() }) //evita copiar, pegar y cortar en los campos de confirmacion. /*AppOPC.$opc_step_one.find('#customer_conf_email, #customer_conf_passwd').bind("cut copy paste", function(e) { e.preventDefault(); });*/ }, openCMS: function (params) { var param = $.extend( {}, { id_cms: "", }, params ) var data = { url_call: prestashop.urls.current_url + "?rand=" + new Date().getTime(), is_ajax: true, dataType: "html", action: "loadCMS", id_cms: param.id_cms, } var _json = { data: data, beforeSend: function () { Fronted.loadingBig(true) }, success: function (html) { if (!$.isEmpty(html)) { Fronted.showModal({ name: "cms_modal", content: html }) // Fronted.showModal({name: 'cms_modal', content: html, callback_close: function () { // Fronted.loadingBig(false); return true; // }}); } }, complete: function () { Fronted.loadingBig(false) }, } $.makeRequest(_json) }, loadingBig: function (show) { if (show) { /*var window_height = $('#onepagecheckoutps').height(); var window_width = $('#onepagecheckoutps').width(); var min_top = 50; var max_top = (window_height - 22) - min_top; //var opc = $('#onepagecheckoutps').offset(); //ubicamos el icono de loading_big AppOPC.$opc.find('.loading_big i').css({ left: (window_width / 2) - 22, top: min_top }); AppOPC.$opc.find('.loading_big').show(); $(window).scroll(function() { var top = $(window).scrollTop() + min_top; if (top >= min_top && top <= max_top) { AppOPC.$opc.find('.loading_big i').css({ top: top }); } });*/ AppOPC.$opc.addClass("opc_overlay") if ($(window).width() >= 1024) { AppOPC.$opc.find(".loading_big").show() } else { $("body").append( '
' + OnePageCheckoutPS.Msg.processing_purchase + '
' ) $("div#opc_loading").addClass("animate") } } else { AppOPC.$opc.removeClass("opc_overlay") if ($(window).width() >= 1024) { AppOPC.$opc.find(".loading_big").hide() } else { $("div#opc_loading").remove() } } }, showModal: function (params) { var param = $.extend( {}, { name: "opc_modal", type: "normal", title: "", title_icon: "", message: "", content: "", close: true, button_close: false, size: "", callback: "", callback_close: "", }, params ) $("#" + param.name).remove() var windows_height = $(window).height() //var windows_width = $(window).width(); var parent_content = "" if (typeof param.content === "object") { parent_content = param.content.parent() } var $modal = $("
").attr({ id: param.name, class: "modal fade", role: "dialog", }) var $modal_dialog = $("
").attr({ class: "modal-dialog " + param.size, }) var $modal_header = $("
").attr({ class: "modal-header" }) var $modal_content = $("
").attr({ class: "modal-content" }) var $modal_body = $("
").attr({ class: "modal-body" }) var $modal_footer = $("
").attr({ class: "modal-footer" }) var $modal_button_close = $("