pos-gis/public/assets/js/pages/builder.min.js

1 line
3.4 KiB
JavaScript
Raw Normal View History

2024-10-07 06:13:42 +00:00
"use strict";var KTLayoutBuilder=function(){var e={init:function(){},startLoad:function(e){$("#builder_export").addClass("spinner spinner-right spinner-primary").find("span").text("Exporting...").closest(".card-footer").find(".btn").attr("disabled",!0),toastr.info(e.title,e.message)},doneLoad:function(){$("#builder_export").removeClass("spinner spinner-right spinner-primary").find("span").text("Export").closest(".card-footer").find(".btn").attr("disabled",!1)},exportHtml:function(t){e.startLoad({title:"Generate HTML Partials",message:"Process started and it may take a while."}),$.ajax("index.php",{method:"POST",data:{builder_export:1,export_type:"partial",demo:t,theme:"metronic"}}).done(function(t){var a=JSON.parse(t);if(a.message)e.stopWithNotify(a.message);else var i=setInterval(function(){$.ajax("index.php",{method:"POST",data:{builder_export:1,builder_check:a.id}}).done(function(t){var a=JSON.parse(t);void 0!==a&&1===a.export_status&&$("<iframe/>").attr({src:"index.php?builder_export&builder_download&id="+a.id,style:"visibility:hidden;display:none"}).ready(function(){toastr.success("Export HTML Version Layout","HTML version exported."),e.doneLoad(),clearInterval(i)}).appendTo("body")})},15e3)})},stopWithNotify:function(t,a){a=a||"danger",void 0!==toastr[a]&&toastr[a]("Verification failed",t),e.doneLoad()}},t={reCaptchaVerified:function(){return $.ajax("../tools/builder/recaptcha.php?recaptcha",{method:"POST",data:{response:$("#g-recaptcha-response").val()}}).fail(function(){grecaptcha.reset(),$("#alert-message").removeClass("alert-success d-hide").addClass("alert-danger").html("Invalid reCaptcha validation")})},init:function(){var a;$("#builder_export").click(function(e){e.preventDefault(),a=$(this),$("#kt-modal-purchase").modal("show"),$("#alert-message").addClass("d-hide"),grecaptcha.reset()}),$("#submit-verify").click(function(i){i.preventDefault(),$("#g-recaptcha-response").val()?t.reCaptchaVerified().done(function(t){if(t.success){$('[data-dismiss="modal"]').trigger("click");var i=$(a).data("demo");switch($(a).attr("id")){case"builder_export":case"builder_export_html":e.exportHtml(i)}}else grecaptcha.reset(),$("#alert-message").removeClass("alert-success d-hide").addClass("alert-danger").html("Invalid reCaptcha validation")}):$("#alert-message").removeClass("alert-success d-hide").addClass("alert-danger").html("Invalid reCaptcha validation")})}},a=function(){e.init(),$('[name="builder_submit"]').click(function(e){e.preventDefault();var t=$(this);$(t).addClass("spinner spinner-right spinner-white").closest(".card-footer").find(".btn").attr("disabled",!0),$(".nav[data-remember-tab]").each(function(){var e=$(this).data("remember-tab"),t=$(this).find('.nav-link.active[data-toggle="tab"]').attr("href");$("#"+e).val(t)}),$.ajax("index.php?demo="+$(t).data("demo"),{method:"POST",data:$("[name]").serialize()}).done(function(e){toastr.success("Preview updated","Preview has been updated with current configured layout.")}).always(function(){setTimeout(function(){location.reload()},600)})}),$('[name="builder_reset"]').click(function(e){e.preventDefault();var t=$(this);$(t).addClass("spinner spinner-right spinner-primary").closest(".card-footer").find(".btn").attr("disabled",!0),$.ajax("index.php?demo="+$(t).data("demo"),{method:"POST",data:{builder_reset:1,demo:$(t).data("demo")}}).done(function(e){}).always(function(){location.reload()})})};return{init:function(){t.init(),a()}}}();jQuery(document).ready(function(){KTLayoutBuilder.init()});