Merge pull request #17074 from joshgowans/patch-4
[civicrm-core.git] / templates / CRM / common / importProgress.tpl
CommitLineData
8cebffb2
JP
1{*
2 +--------------------------------------------------------------------+
1188c7a8 3 | Copyright CiviCRM LLC. All rights reserved. |
8cebffb2 4 | |
1188c7a8
TO
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8cebffb2
JP
8 +--------------------------------------------------------------------+
9*}
10{literal}
11<script type="text/javascript">
12CRM.$(function($) {
badf5061 13 var loop;
8cebffb2 14 $("form#Preview").on('submit', function (e) {
90aa3a9a
JP
15 if (!confirm("{/literal}{ts escape='js'}Backing up your database before importing is recommended, as there is no Undo for this. Are you sure you want to import now?{/ts}{literal}")) {
16 e.preventDefault();
17 }
18 else {
19 showProgressBar();
20 }
8cebffb2
JP
21 });
22 function setIntermediate() {
8838f818 23 var dataUrl = {/literal}{$statusUrl|@json_encode}{literal};
8cebffb2
JP
24 $.getJSON(dataUrl, function(response) {
25 var dataStr = response.toString();
26 var result = dataStr.split(",");
27 $("#intermediate").html(result[1]);
28 $("#importProgressBar .ui-progressbar-value").show();
29 if (result[0] < 100) {
30 $("#importProgressBar .ui-progressbar-value").animate({width: result[0] + "%"}, 500);
31 $("#status").text(result[0] + "% Completed");
32 }
90aa3a9a
JP
33 else {
34 window.clearInterval(loop);
35 }
8cebffb2
JP
36 });
37 }
38
90aa3a9a 39 function showProgressBar() {
8cebffb2
JP
40 $("#id-processing").show( ).dialog({
41 modal : true,
42 width : 450,
43 height : 200,
44 resizable : false,
45 draggable : true,
46 closeOnEscape : false,
47 open : function () {
48 $("#id-processing").dialog().parents(".ui-dialog").find(".ui-dialog-titlebar").remove();
49 }
50 });
51 $("#importProgressBar" ).progressbar({value:0});
52 $("#importProgressBar").show( );
8a0852e2 53 loop = window.setInterval(setIntermediate, 5000)
8cebffb2
JP
54 }
55});
56</script>
57{/literal}
58
59{* Import Progress Bar and Info *}
60<div id="id-processing" class="hiddenElement">
61 <h3>Importing records...</h3><br />
62 <div id="status" style="margin-left:6px;"></div>
63 <div class="progressBar" id="importProgressBar" style="margin-left:6px;display:none;"></div>
64 <div id="intermediate"></div>
65 <div id="error_status"></div>
66</div>