diff --git a/img/loader.gif b/img/loader.gif new file mode 100644 index 0000000..030dbe0 Binary files /dev/null and b/img/loader.gif differ diff --git a/index.php b/index.php index 8f20d74..6d59d10 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,8 @@ - - - + + - -
- +renderView("test.html"); - $html2Jpeg->renderView("test.html"); - $html2Jpeg->renderView("test.html"); - $html2Jpeg->renderHtml("

Test

"); - $html2Jpeg->renderHtml("

Test

"); - $html2Jpeg->renderView("test.html"); - $html2Jpeg->renderHtml("

Test

"); +//Example code +$html2Jpeg->renderView("test.html"); +$html2Jpeg->renderView("test.html"); +$html2Jpeg->renderView("test.html"); +$html2Jpeg->renderHtml("

Test

"); +$html2Jpeg->renderHtml("

Test

"); +$html2Jpeg->renderView("test.html"); +$html2Jpeg->renderHtml("

Test

"); +//Form creating +echo $html2Jpeg->output(); - //Form creating - echo $html2Jpeg->output(); - ?> +?> diff --git a/js/render.js b/js/render.js index d455c4c..f3fa2f8 100644 --- a/js/render.js +++ b/js/render.js @@ -1,30 +1,36 @@ +var i = 0; +$(document).ready(function() { -$(document).ready(function(){ - var i = 0; - $('.'+content_class_name).each(function() { - html2canvas(this,{ - onrendered: function (canvas) { - //Set hidden field's value to image data (base-64 string) - $('#'+form_id).append(''); - i++; - console.log(i); - } + $('.' + content_class_name).each(function() { - }); + var contentItem = $(this); + var contentEle = contentItem.get(0); + var formItem = $('#' + form_id); + + var canvasOnRender = function(canvas) { + var rendered_html = canvas.toDataURL("image/png"); + rendered_html = String(rendered_html).trim(); + + // Set hidden field's value to image data (base-64 string) + formItem.append(''); + formItem.append(''); + // Increment i + i++; + }; + + var canvasOptions = {}; + html2canvas(contentEle, canvasOptions).then(canvasOnRender); }); - var timer = setInterval(function () { - if(i == $('.'+content_class_name).length){ + var timer = setInterval(function() { + var contentClassLen = $('.' + content_class_name).length; + if (i == contentClassLen) { $('.se-pre-con').hide(); - $('.'+content_class_name).hide(); + $('.' + content_class_name).hide(); clearInterval(timer); } }, 1000); -}); - - - - +}); \ No newline at end of file