diff --git a/src/components/com_tjcertificate/media/js/certificateImage.js b/src/components/com_tjcertificate/media/js/certificateImage.js index 78d39538..5e5f8903 100644 --- a/src/components/com_tjcertificate/media/js/certificateImage.js +++ b/src/components/com_tjcertificate/media/js/certificateImage.js @@ -37,7 +37,15 @@ var certificateImage = { }, success: function(data) { result = data; + + var certificateId = jQuery("#certificateId").val(); + var imagePath = certRootUrl + 'media/com_tjcertificate/certificates/'; + var img = document.createElement('img'); + jQuery('#certificateContent').hide(); + img.src = imagePath + certificateId + ".png"; + jQuery("#previewImage").append(img); Joomla.loadingLayer('hide'); + } }); @@ -45,8 +53,6 @@ var certificateImage = { }, generateImage: function(element) { - var certificateId = jQuery("#certificateId").val(); - var imagePath = certRootUrl + 'media/com_tjcertificate/certificates/'; jQuery('#certificateContent').width(element.offsetWidth).height(element.offsetHeight); Joomla.loadingLayer('show'); diff --git a/src/components/com_tjcertificate/media/js/certificateImage.min.js b/src/components/com_tjcertificate/media/js/certificateImage.min.js index 9d996655..a58dd14c 100644 --- a/src/components/com_tjcertificate/media/js/certificateImage.min.js +++ b/src/components/com_tjcertificate/media/js/certificateImage.min.js @@ -1 +1 @@ -var certificateImage={printCertificate:function(e){var t=document.getElementById(e).innerHTML,o=document.body.innerHTML;document.body.innerHTML=t,window.print(),document.body.innerHTML=o,certificateImage.enableDownloadShareBtns()},enableDownloadShareBtns:function(){jQuery("#download-popover").popover({trigger:"focus",html:!0,content:jQuery("#download-popover-content").html()}),jQuery("#sharing-popover").popover({trigger:"focus",html:!0,content:jQuery("#sharing-popover-content").html()})},uploadImage:function(e){var t=!1,o=jQuery("#certificateId").val();return jQuery.ajax({url:certRootUrl+"index.php?option=com_tjcertificate&task=certificate.uploadCertificate",type:"POST",data:{image:e,certificateId:o},success:function(e){t=e,Joomla.loadingLayer("hide")}}),t},generateImage:function(e){jQuery("#certificateId").val(),certRootUrl;jQuery("#certificateContent").width(e.offsetWidth).height(e.offsetHeight),Joomla.loadingLayer("show"),html2canvas(e,{scale:2,scrollX:0,scrollY:-window.scrollY,allowTaint:!0}).then(function(e){jQuery("#downloadImage").attr("href",e.toDataURL("image/png")),certificateImage.enableDownloadShareBtns(),certificateImage.uploadImage(e.toDataURL("image/png"))})}}; +var certificateImage={printCertificate:function(e){var t=document.getElementById(e).innerHTML,a=document.body.innerHTML;document.body.innerHTML=t,window.print(),document.body.innerHTML=a,certificateImage.enableDownloadShareBtns()},enableDownloadShareBtns:function(){jQuery("#download-popover").popover({trigger:"focus",html:!0,content:jQuery("#download-popover-content").html()}),jQuery("#sharing-popover").popover({trigger:"focus",html:!0,content:jQuery("#sharing-popover-content").html()})},uploadImage:function(e){var t=!1,a=jQuery("#certificateId").val();return jQuery.ajax({url:certRootUrl+"index.php?option=com_tjcertificate&task=certificate.uploadCertificate",type:"POST",data:{image:e,certificateId:a},success:function(e){t=e;var a=jQuery("#certificateId").val(),o=certRootUrl+"media/com_tjcertificate/certificates/",n=document.createElement("img");jQuery("#certificateContent").hide(),n.src=o+a+".png",jQuery("#previewImage").append(n),Joomla.loadingLayer("hide")}}),t},generateImage:function(e){jQuery("#certificateContent").width(e.offsetWidth).height(e.offsetHeight),Joomla.loadingLayer("show"),html2canvas(e,{scale:2,scrollX:0,scrollY:-window.scrollY,allowTaint:!0}).then(function(e){jQuery("#downloadImage").attr("href",e.toDataURL("image/png")),certificateImage.enableDownloadShareBtns(),certificateImage.uploadImage(e.toDataURL("image/png"))})}}; \ No newline at end of file