a5cdde8f by Jeff Balicki

changes to preview

1 parent 11ddae0a
...@@ -154,10 +154,11 @@ class ApiController extends Controller ...@@ -154,10 +154,11 @@ class ApiController extends Controller
154 $pdf = $pdf->pdf($pdfId); 154 $pdf = $pdf->pdf($pdfId);
155 $response = $pdfId; 155 $response = $pdfId;
156 $statusCode = 200; 156 $statusCode = 200;
157
158 return Response::json( $response, $statusCode);
159 $UploaqdPdf = new GoogledriveuploadpdfController(); 157 $UploaqdPdf = new GoogledriveuploadpdfController();
160 $UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id); 158 $UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id);
159
160 return Response::json( $response, $statusCode);
161
161 } 162 }
162 163
163 public function getList($json) 164 public function getList($json)
......
1 var pluginUrl = window.location.protocol + '//' + window.location.host + '/commonwell'; 1 //var pluginUrl = window.location.protocol + '//' + window.location.host + '/commonwell';
2 var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; 2 //var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
3 3
4 4
5 //var pluginUrl = "http://contact.gotenzing.com"; 5 var pluginUrl = window.location.protocol + '//' + window.location.host;
6 //var pdf_customizer = "http://pdf-customizer.synapsus.co"; 6 var pdf_customizer = "http://pdf-customizer.synapsus.co";
7 7
8 8
9 var imageHeight = ""; 9 var imageHeight = "";
...@@ -67,7 +67,7 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) { ...@@ -67,7 +67,7 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
67 return this; 67 return this;
68 } 68 }
69 69
70 function ShowBox(pheight, pwidth, up, right, height, width, count, example) { 70 function ShowBox(pheight, pwidth, bup, right, height, width, count, example) {
71 jQuery(document).ready(function($) { 71 jQuery(document).ready(function($) {
72 $('span').hide(); 72 $('span').hide();
73 $('#span' + count).show(); 73 $('#span' + count).show();
...@@ -78,8 +78,8 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { ...@@ -78,8 +78,8 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
78 Qctx.clearRect(0, 0, Qc.width, Qc.height); 78 Qctx.clearRect(0, 0, Qc.width, Qc.height);
79 Qctx.restore(); 79 Qctx.restore();
80 80
81 81 var fix = 3;
82 82 var up = bup - fix;
83 var down = pheight - (up + height); 83 var down = pheight - (up + height);
84 var scaleH = $("Canvas").height() / pheight; 84 var scaleH = $("Canvas").height() / pheight;
85 var scaleW = $("Canvas").width() / pwidth; 85 var scaleW = $("Canvas").width() / pwidth;
...@@ -94,8 +94,8 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { ...@@ -94,8 +94,8 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
94 ctx.lineWidth = 2; 94 ctx.lineWidth = 2;
95 ctx.strokeStyle = $('.callout').css("background-color") 95 ctx.strokeStyle = $('.callout').css("background-color")
96 ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke(); 96 ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke();
97 console.log(PageChangeOn , setpage); 97 console.log(PageChangeOn, setpage);
98 if(PageChangeOn != setpage ){ 98 if (PageChangeOn != setpage) {
99 document.getElementById("preview").checked = true; 99 document.getElementById("preview").checked = true;
100 $('#changes').trigger('submit'); 100 $('#changes').trigger('submit');
101 } 101 }
...@@ -108,8 +108,7 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { ...@@ -108,8 +108,7 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
108 108
109 109
110 110
111 111 function HideBox(kind, page) {
112 function HideBox(kind,page) {
113 112
114 jQuery(document).ready(function($) { 113 jQuery(document).ready(function($) {
115 $('span').hide(); 114 $('span').hide();
...@@ -128,7 +127,7 @@ function HideBox(kind,page) { ...@@ -128,7 +127,7 @@ function HideBox(kind,page) {
128 127
129 } 128 }
130 129
131 function HideBoxwithdate(kind,page) { 130 function HideBoxwithdate(kind, page) {
132 jQuery(document).ready(function($) { 131 jQuery(document).ready(function($) {
133 var Qc = document.getElementById("Canvas"); 132 var Qc = document.getElementById("Canvas");
134 var Qctx = Qc.getContext("2d"); 133 var Qctx = Qc.getContext("2d");
...@@ -142,12 +141,30 @@ function HideBoxwithdate(kind,page) { ...@@ -142,12 +141,30 @@ function HideBoxwithdate(kind,page) {
142 141
143 } 142 }
144 143
144
145 function setSubmit(off){
146 jQuery(document).ready(function($) {
147 if(off != 'on'){
148 $('input:submit').attr("disabled", true);
149 }else{
150 $('input:submit').attr("disabled", false);
151
152 }
153 });
154 }
155
145 function setPage(page) { 156 function setPage(page) {
146 157
147 setpage = page; 158 setpage = page;
148 159
149 } 160 }
150 161
162 function setPreview(off) {
163
164 document.getElementById("preview").checked = false;
165
166 }
167
151 function setPageChangeOn(page) { 168 function setPageChangeOn(page) {
152 169
153 PageChangeOn = page; 170 PageChangeOn = page;
...@@ -314,7 +331,7 @@ function getPdfSize(json) { ...@@ -314,7 +331,7 @@ function getPdfSize(json) {
314 vimgLeft = 30; 331 vimgLeft = 30;
315 vimgTop = 2; 332 vimgTop = 2;
316 } 333 }
317 334 console.log(pwidth, pheight, vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
318 setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth); 335 setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
319 336
320 }); 337 });
...@@ -322,12 +339,12 @@ function getPdfSize(json) { ...@@ -322,12 +339,12 @@ function getPdfSize(json) {
322 } 339 }
323 340
324 function setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth) { 341 function setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth) {
325 console.log(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth); 342 // console.log(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
326 imgLeft = vimgLeft; 343 imgLeft = vimgLeft;
327 imgTop = vimgTop; 344 imgTop = vimgTop;
328 windowHBG = vwindowHBG; 345 windowHBG = vwindowHBG;
329 imageHeight = vimageHeight; 346 imageHeight = vimageHeight;
330 imageWidth = vimageWidth; 347 imageWidth = vimageWidth;
331 348
332 } 349 }
333 350
...@@ -380,28 +397,28 @@ function changePdfOptions(json, edit) { ...@@ -380,28 +397,28 @@ function changePdfOptions(json, edit) {
380 var example = json[0].folder + '/' + json[i].example; 397 var example = json[0].folder + '/' + json[i].example;
381 398
382 if (json[i].change_type == "textflow") { 399 if (json[i].change_type == "textflow") {
383 pdfChange += json[i].names + ': <textarea onfocusout="HideBox(\'textflow\')" onfocus="setPageChangeOn(\''+json[i].pages+'\'),ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="changescontent' + [f] + '" class="textarea required" value="' + json[i].content + '" name="content[' + i + ']">' + json[i].content + '</textarea>'; 400 pdfChange += json[i].names + ': <textarea onfocusout="HideBox(\'textflow\')" onfocus="setPageChangeOn(\'' + json[i].pages + '\'),ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="changescontent' + [f] + '" class="textarea required" value="' + json[i].content + '" name="content[' + i + ']">' + json[i].content + '</textarea>';
384 ++f; 401 ++f;
385 402
386 pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; 403 pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>';
387 } 404 }
388 if (json[i].change_type == "text") { 405 if (json[i].change_type == "text") {
389 pdfChange += json[i].names + ': <input onfocusout="HideBox(\'text\')" onfocus="setPageChangeOn(\''+json[i].pages+'\'),ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="changescontent[' + i + ']" type="text" class="required" name="content[' + i + ']" value="' + json[i].content + '"">'; 406 pdfChange += json[i].names + ': <input onfocusout="HideBox(\'text\')" onfocus="setPageChangeOn(\'' + json[i].pages + '\'),ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="changescontent[' + i + ']" type="text" class="required" name="content[' + i + ']" value="' + json[i].content + '"">';
390 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; 407 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
391 } 408 }
392 if (json[i].change_type == "img") { 409 if (json[i].change_type == "img") {
393 if (edit == true) { 410 if (edit == true) {
394 pdfChange += '<input value="' + json[i].content + '" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >'; 411 pdfChange += '<input value="' + json[i].content + '" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >';
395 pdfChange += json[i].names + ':<label onfocusout="HideBox(\'file\')" onfocus="setPageChangeOn(\''+json[i].pages+'\'),ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="focusButton' + i + '" class="custom-file-input" tabindex="0"><input tabindex="-1" class="fileupload upload" id="changescontent[' + i + ']" type="file" name="content[' + i + ']" ><span class="file-button"><span class="file-name file-button">' + json[i].content + '</span><strong>Browse</strong></span></label>'; 412 pdfChange += json[i].names + ':<label onfocusout="HideBox(\'file\')" onfocus="setPageChangeOn(\'' + json[i].pages + '\'),ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="focusButton' + i + '" class="custom-file-input" tabindex="0"><input tabindex="-1" class="fileupload upload" id="changescontent[' + i + ']" type="file" name="content[' + i + ']" ><span class="file-button"><span class="file-name file-button">' + json[i].content + '</span><strong>Browse</strong></span></label>';
396 413
397 } else { 414 } else {
398 pdfChange += json[i].names + ':<label onfocusout="HideBox(\'file\')" onfocus="setPageChangeOn(\''+json[i].pages+'\'), ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="focusButton' + i + '" class="custom-file-input" tabindex="0"><input value="' + json[i].content + '" tabindex="-1" class="fileupload upload required" id="changescontent[' + i + ']" type="file" name="content[' + i + ']" ><span class="file-button"><span class="file-name file-button">' + json[i].content + '</span><strong>Browse</strong></span></label>'; 415 pdfChange += json[i].names + ':<label onfocusout="HideBox(\'file\')" onfocus="setPageChangeOn(\'' + json[i].pages + '\'), ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="focusButton' + i + '" class="custom-file-input" tabindex="0"><input value="' + json[i].content + '" tabindex="-1" class="fileupload upload required" id="changescontent[' + i + ']" type="file" name="content[' + i + ']" ><span class="file-button"><span class="file-name file-button">' + json[i].content + '</span><strong>Browse</strong></span></label>';
399 } 416 }
400 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; 417 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
401 418
402 } 419 }
403 if (json[i].change_type == "date") { 420 if (json[i].change_type == "date") {
404 pdfChange += json[i].names + ': <input onfocusout="HideBoxwithdate(\'date\')" onfocus="setPageChangeOn(\''+json[i].pages+'\'),ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="changescontentdate" type="text" class="required date" name="content[' + i + ']" value="' + json[i].content + '"">'; 421 pdfChange += json[i].names + ': <input onfocusout="HideBoxwithdate(\'date\')" onfocus="setPageChangeOn(\'' + json[i].pages + '\'),ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="changescontentdate" type="text" class="required date" name="content[' + i + ']" value="' + json[i].content + '"">';
405 pdfChange += '<span class="tip" id="span' + i + '"> </span><br/>'; 422 pdfChange += '<span class="tip" id="span' + i + '"> </span><br/>';
406 423
407 } 424 }
...@@ -422,7 +439,7 @@ function changePdfOptions(json, edit) { ...@@ -422,7 +439,7 @@ function changePdfOptions(json, edit) {
422 439
423 } 440 }
424 pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;">'; 441 pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;">';
425 pdfChange += '<input type="submit" value="Save and Continue">'; 442 pdfChange += '<input id="saveButton" type="submit" onclick="setPreview(\'off\')" value="Save and Continue">';
426 443
427 pdfChange += '</form>'; 444 pdfChange += '</form>';
428 445
...@@ -518,6 +535,8 @@ function changePdfOptions(json, edit) { ...@@ -518,6 +535,8 @@ function changePdfOptions(json, edit) {
518 535
519 if ($("#changes").valid()) { 536 if ($("#changes").valid()) {
520 537
538 setSubmit('off');
539
521 $(tinymce.get()).each(function(i, el) { 540 $(tinymce.get()).each(function(i, el) {
522 541
523 if (el.id) 542 if (el.id)
...@@ -608,7 +627,7 @@ function returnOptions(form, preview) { ...@@ -608,7 +627,7 @@ function returnOptions(form, preview) {
608 var content = []; 627 var content = [];
609 628
610 for (e = 0; e < form[0].length; ++e) { 629 for (e = 0; e < form[0].length; ++e) {
611 if(form[0][e].type != 'button'){ 630 if (form[0][e].type != 'button') {
612 content.push(JSON.stringify(form[0][e].value)); 631 content.push(JSON.stringify(form[0][e].value));
613 632
614 } 633 }
...@@ -648,8 +667,11 @@ function returnOptions(form, preview) { ...@@ -648,8 +667,11 @@ function returnOptions(form, preview) {
648 } 667 }
649 jsonReturn += ' ]}'; 668 jsonReturn += ' ]}';
650 669
651 if (preview == false) { url = 'update'; 670 if (preview == false) {
652 } else { url = 'preview';} 671 url = 'update';
672 } else {
673 url = 'preview';
674 }
653 675
654 676
655 677
...@@ -663,7 +685,7 @@ function returnOptions(form, preview) { ...@@ -663,7 +685,7 @@ function returnOptions(form, preview) {
663 685
664 success: function(data) { 686 success: function(data) {
665 687
666 finalPdf(data, json) 688 finalPdf(data, json);
667 689
668 }, 690 },
669 error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response 691 error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
...@@ -693,36 +715,39 @@ function finalPdf(data, json) { ...@@ -693,36 +715,39 @@ function finalPdf(data, json) {
693 $("#Canvas").css('z-index', '0'); 715 $("#Canvas").css('z-index', '0');
694 $('#changes').hide(); 716 $('#changes').hide();
695 $('#controls').show(); 717 $('#controls').show();
696 url = 'update'; 718
697 } else { 719 } else {
698 $("#changes").validate().cancelSubmit = false; 720 $("#changes").validate().cancelSubmit = false;
699 document.getElementById("preview").checked = false; 721 document.getElementById("preview").checked = false;
700 url = 'preview'; 722
701 } 723 }
702 $('#controls').hide(); 724 $('#controls').hide();
703 $('#pdfPreviewInner').show(); 725 $('#pdfPreviewInner').show()
726
704 727
705 var strVar2 = "" 728 var strVar2 = ""
706 strVar2 += '<div id="seepdf" style=" width:' + imageWidth + 'px; height: ' + imageHeight + 'px; overflow: hidden;" ><embed src="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '#page='+setpage+'&toolbar=0&navpanes=0&scrollbar=0statusbar=0" width="' + imageWidth + '" height="' + imageHeight + '" type="application/pdf" id="pdfloaded"></div>'; 729 strVar2 += '<div id="seepdf" style=" width:' + imageWidth + 'px; height: ' + imageHeight + 'px; overflow: hidden;" ><embed src="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '#page=' + setpage + '&toolbar=0&navpanes=0&zoom=scale,left,top&;scrollbar=0&statusbar=0" width="' + imageWidth + '" height="' + imageHeight + '" type="application/pdf" id="pdfloaded"></embed></div>';
707 document.getElementById('pdfPreviewInner').innerHTML = strVar2; 730 document.getElementById('pdfPreviewInner').innerHTML = strVar2;
708 731
709 var strVar3 = '<div id="button"><input id="editMe" type="submit" value="Edit"><a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ><input id="downloadMe" type="submit" value="Download"></a> </div>'; 732 var strVar3 = '<div id="button"><input id="editMe" type="submit" value="Edit"><a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ><input id="downloadMe" type="submit" value="Download"></a> </div>';
710 document.getElementById('controls').innerHTML = strVar3; 733 document.getElementById('controls').innerHTML = strVar3;
711 734
712 $.LoadingOverlaySetup({ 735 $.LoadingOverlaySetup({
713 color: "rgba(0, 0, 0, 0.9)" 736 color: "rgba(0, 0, 0, 0.9)",
737 image: pluginUrl+"/wp-content/plugins/pdf-customizer-plugin/public/js/loading.gif",
714 }); 738 });
715 $('#Canvas').LoadingOverlay("show"); 739 $('#Canvas').LoadingOverlay("show");
716 $('#Canvas').delay(500).queue(function() { 740 $('#Canvas').delay(600).queue(function() {
717 $(this).css("background-image", ""); 741 $(this).css("background-image", "");
718 }); 742 });
719 743
720 setTimeout(function() { 744 setTimeout(function() {
721 $('#Canvas').LoadingOverlay("hide", true); 745 $('#Canvas').LoadingOverlay("hide", true);
722 }, 500); 746 }, 600);
723 747
724 if (preview == false) { 748 if (preview == false) {
725 $('#controls').show(); 749 $('#controls').show();
750 setSubmit('on');
726 } 751 }
727 752
728 753
...@@ -733,7 +758,7 @@ function finalPdf(data, json) { ...@@ -733,7 +758,7 @@ function finalPdf(data, json) {
733 $('#changes').show(); 758 $('#changes').show();
734 $("#Canvas").show(); 759 $("#Canvas").show();
735 $("#Canvas").css('z-index', '10'); 760 $("#Canvas").css('z-index', '10');
736 761 setTinyMce();
737 762
738 }); 763 });
739 764
...@@ -742,6 +767,6 @@ function finalPdf(data, json) { ...@@ -742,6 +767,6 @@ function finalPdf(data, json) {
742 }); 767 });
743 768
744 769
745 }); 770 });
746 771
747 } 772 }
...\ No newline at end of file ...\ No newline at end of file
......