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,19 +67,19 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) { ...@@ -67,19 +67,19 @@ 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();
74 // $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")"); 74 // $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")");
75 75
76 var Qc = document.getElementById("Canvas"); 76 var Qc = document.getElementById("Canvas");
77 var Qctx = Qc.getContext("2d"); 77 var Qctx = Qc.getContext("2d");
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,22 +94,21 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { ...@@ -94,22 +94,21 @@ 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 }
102 102
103 }); 103 });
104 104
105 setpage = PageChangeOn; 105 setpage = PageChangeOn;
106 } 106 }
107 107
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();
...@@ -118,7 +117,7 @@ function HideBox(kind,page) { ...@@ -118,7 +117,7 @@ function HideBox(kind,page) {
118 var Qctx = Qc.getContext("2d"); 117 var Qctx = Qc.getContext("2d");
119 Qctx.clearRect(0, 0, Qc.width, Qc.height); 118 Qctx.clearRect(0, 0, Qc.width, Qc.height);
120 Qctx.restore(); 119 Qctx.restore();
121 120
122 if (kind != 'file') { 121 if (kind != 'file') {
123 document.getElementById("preview").checked = true; 122 document.getElementById("preview").checked = true;
124 $('#changes').trigger('submit'); 123 $('#changes').trigger('submit');
...@@ -128,13 +127,13 @@ function HideBox(kind,page) { ...@@ -128,13 +127,13 @@ 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");
135 Qctx.clearRect(0, 0, Qc.width, Qc.height); 134 Qctx.clearRect(0, 0, Qc.width, Qc.height);
136 Qctx.restore(); 135 Qctx.restore();
137 136
138 137
139 138
140 }); 139 });
...@@ -142,15 +141,33 @@ function HideBoxwithdate(kind,page) { ...@@ -142,15 +141,33 @@ 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;
159
160 }
161
162 function setPreview(off) {
163
164 document.getElementById("preview").checked = false;
148 165
149 } 166 }
150 167
151 function setPageChangeOn(page) { 168 function setPageChangeOn(page) {
152 169
153 PageChangeOn = page; 170 PageChangeOn = page;
154 171
155 } 172 }
156 173
...@@ -225,7 +242,7 @@ function pickPdfFromList(json) { ...@@ -225,7 +242,7 @@ function pickPdfFromList(json) {
225 242
226 function setTinyMce() { 243 function setTinyMce() {
227 jQuery(document).ready(function($) { 244 jQuery(document).ready(function($) {
228 var tinymces = tinymce.init({ 245 var tinymces = tinymce.init({
229 selector: '.textarea', 246 selector: '.textarea',
230 entity_encoding: "raw", 247 entity_encoding: "raw",
231 menubar: false, 248 menubar: false,
...@@ -268,30 +285,30 @@ function setTinyMce() { ...@@ -268,30 +285,30 @@ function setTinyMce() {
268 function setDatePicker() { 285 function setDatePicker() {
269 jQuery(document).ready(function($) { 286 jQuery(document).ready(function($) {
270 287
271 $("#changescontentdate").datepicker({ 288 $("#changescontentdate").datepicker({
272 plugins: "tabfocus", 289 plugins: "tabfocus",
273 changeMonth: true, 290 changeMonth: true,
274 changeYear: true, 291 changeYear: true,
275 yearRange: '2015:2025', 292 yearRange: '2015:2025',
276 dateFormat: 'DD MM dd yy', 293 dateFormat: 'DD MM dd yy',
277 minDate: 0, 294 minDate: 0,
278 defaultDate: null 295 defaultDate: null
279 }).on('change', function() { 296 }).on('change', function() {
280 $(this).valid(); // triggers the validation test 297 $(this).valid(); // triggers the validation test
281 document.getElementById("preview").checked = true; 298 document.getElementById("preview").checked = true;
282 $('#changes').trigger('submit'); 299 $('#changes').trigger('submit');
283 300
284 }); 301 });
285 302
286 303
287 }); 304 });
288 } 305 }
289 306
290 function getPdfSize(json) { 307 function getPdfSize(json) {
291 308
292 jQuery(document).ready(function($) { 309 jQuery(document).ready(function($) {
293 json = JSON.parse(json); 310 json = JSON.parse(json);
294 //console.log(json); 311 //console.log(json);
295 312
296 var windowWidth = 0.90 * $(".layout-grid").width(); 313 var windowWidth = 0.90 * $(".layout-grid").width();
297 var windowHeight = 0.90 * $(".layout-grid").height(); 314 var windowHeight = 0.90 * $(".layout-grid").height();
...@@ -302,7 +319,7 @@ function getPdfSize(json) { ...@@ -302,7 +319,7 @@ function getPdfSize(json) {
302 pheight = parseInt(json[0].pheight); 319 pheight = parseInt(json[0].pheight);
303 320
304 if (pwidth > pheight) { 321 if (pwidth > pheight) {
305 var scaleImage = windowWidth / pwidth; 322 var scaleImage = windowWidth / pwidth;
306 vimageHeight = pheight * scaleImage; 323 vimageHeight = pheight * scaleImage;
307 vimageWidth = windowWidth; 324 vimageWidth = windowWidth;
308 vimgLeft = 0; 325 vimgLeft = 0;
...@@ -314,20 +331,20 @@ function getPdfSize(json) { ...@@ -314,20 +331,20 @@ function getPdfSize(json) {
314 vimgLeft = 30; 331 vimgLeft = 30;
315 vimgTop = 2; 332 vimgTop = 2;
316 } 333 }
334 console.log(pwidth, pheight, vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
335 setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
317 336
318 setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
319
320 }); 337 });
321 338
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
...@@ -339,11 +356,11 @@ function changePdfOptions(json, edit) { ...@@ -339,11 +356,11 @@ function changePdfOptions(json, edit) {
339 $('#contentAreaOver').hide(); 356 $('#contentAreaOver').hide();
340 } 357 }
341 358
342 359
343 360
344 json = JSON.parse(json); 361 json = JSON.parse(json);
345 362
346 363
347 $(document).ready(function() { 364 $(document).ready(function() {
348 365
349 setDatePicker(); 366 setDatePicker();
...@@ -365,7 +382,7 @@ function changePdfOptions(json, edit) { ...@@ -365,7 +382,7 @@ function changePdfOptions(json, edit) {
365 var pdflist = ""; 382 var pdflist = "";
366 var pdfChange = ""; 383 var pdfChange = "";
367 var f = 0; 384 var f = 0;
368 385
369 386
370 387
371 // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight); 388 // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight);
...@@ -375,34 +392,34 @@ function changePdfOptions(json, edit) { ...@@ -375,34 +392,34 @@ function changePdfOptions(json, edit) {
375 pdflist += '<canvas id="Canvas" width="' + imageWidth + '" height="' + imageHeight + '" style=" background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:' + imageWidth + 'px ' + imageHeight + 'px; position: relative; z-index: 10; margin-top:' + imgTop + '%; display: block; margin-left: auto; margin-right: auto; border-style: solid; border-width:1px; background-size:' + imageWidth + 'px ' + imageHeight + 'px"></canvas><div id="pdfPreviewInner" style=" position: relative; top: -' + imageHeight + 'px;"></div></div>'; 392 pdflist += '<canvas id="Canvas" width="' + imageWidth + '" height="' + imageHeight + '" style=" background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:' + imageWidth + 'px ' + imageHeight + 'px; position: relative; z-index: 10; margin-top:' + imgTop + '%; display: block; margin-left: auto; margin-right: auto; border-style: solid; border-width:1px; background-size:' + imageWidth + 'px ' + imageHeight + 'px"></canvas><div id="pdfPreviewInner" style=" position: relative; top: -' + imageHeight + 'px;"></div></div>';
376 pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>'; 393 pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>';
377 pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; 394 pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">';
378 setPage(json[0].pages); 395 setPage(json[0].pages);
379 for (i = 0; i < json.length; ++i) { 396 for (i = 0; i < json.length; ++i) {
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 }
408 if (json[i].change_type == "user") { 425 if (json[i].change_type == "user") {
...@@ -414,15 +431,15 @@ function changePdfOptions(json, edit) { ...@@ -414,15 +431,15 @@ function changePdfOptions(json, edit) {
414 } else { 431 } else {
415 var content_string = json[i].content; 432 var content_string = json[i].content;
416 } 433 }
417 pdfChange += json[i].names + ': <input onfocusout="HideBox()" onfocus="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="' + content_string + '"">'; 434 pdfChange += json[i].names + ': <input onfocusout="HideBox()" onfocus="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="' + content_string + '"">';
418 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; 435 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
419 436
420 } 437 }
421 438
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
...@@ -441,8 +458,8 @@ function changePdfOptions(json, edit) { ...@@ -441,8 +458,8 @@ function changePdfOptions(json, edit) {
441 //document.getElementById('google_drive').innerHTML = " "; 458 //document.getElementById('google_drive').innerHTML = " ";
442 } 459 }
443 460
444 setTinyMce(); 461 setTinyMce();
445 462
446 463
447 $('.closeEditer').click(function() { 464 $('.closeEditer').click(function() {
448 $("#contentAreaOver").slideToggle(function() { 465 $("#contentAreaOver").slideToggle(function() {
...@@ -501,7 +518,7 @@ function changePdfOptions(json, edit) { ...@@ -501,7 +518,7 @@ function changePdfOptions(json, edit) {
501 if (el.id) 518 if (el.id)
502 document.getElementById(el.id).value = el.getContent(); 519 document.getElementById(el.id).value = el.getContent();
503 //$('#changes').hide(); 520 //$('#changes').hide();
504 521
505 }); 522 });
506 523
507 524
...@@ -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)
...@@ -543,7 +562,7 @@ function changePdfOptions(json, edit) { ...@@ -543,7 +562,7 @@ function changePdfOptions(json, edit) {
543 }); 562 });
544 } 563 }
545 var form = $("#changes"); 564 var form = $("#changes");
546 565
547 //console.log(form); 566 //console.log(form);
548 567
549 returnfileOptions(imagefiles, form, preview = false); 568 returnfileOptions(imagefiles, form, preview = false);
...@@ -605,16 +624,16 @@ function returnOptions(form, preview) { ...@@ -605,16 +624,16 @@ function returnOptions(form, preview) {
605 624
606 $.getJSON(pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { 625 $.getJSON(pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) {
607 626
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 }
615 } 634 }
616 635
617 636
618 637
619 // Get the element with id summary and set the inner text to the result. 638 // Get the element with id summary and set the inner text to the result.
620 639
...@@ -623,14 +642,14 @@ function returnOptions(form, preview) { ...@@ -623,14 +642,14 @@ function returnOptions(form, preview) {
623 642
624 643
625 var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '","pageWidth":"' + json[0].pwidth + '","pageHeight":"' + json[0].pheight + '", "custId":"' + user_id + '"}],"changes":[' 644 var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '","pageWidth":"' + json[0].pwidth + '","pageHeight":"' + json[0].pheight + '", "custId":"' + user_id + '"}],"changes":['
626 645
627 var o = 1; 646 var o = 1;
628 var e = 1; 647 var e = 1;
629 648
630 649
631 for (i = 0; i < json.length; ++i) { 650 for (i = 0; i < json.length; ++i) {
632 var style = JSON.stringify(json[i].style); 651 var style = JSON.stringify(json[i].style);
633 652
634 if (content[e] != '""') { 653 if (content[e] != '""') {
635 if (o !== 1) { 654 if (o !== 1) {
636 jsonReturn += ','; 655 jsonReturn += ',';
...@@ -642,14 +661,17 @@ function returnOptions(form, preview) { ...@@ -642,14 +661,17 @@ function returnOptions(form, preview) {
642 ++o 661 ++o
643 662
644 }; 663 };
645 664
646 ++e 665 ++e
647 666
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
...@@ -682,66 +704,69 @@ function returnOptions(form, preview) { ...@@ -682,66 +704,69 @@ function returnOptions(form, preview) {
682 704
683 function finalPdf(data, json) { 705 function finalPdf(data, json) {
684 706
685 jQuery(function($) { 707 jQuery(function($) {
686 708
687 709
688
689 710
690 // console.log(jsonReturn);
691 711
692 if (preview == false) { 712 // console.log(jsonReturn);
693 $("#Canvas").css('z-index', '0');
694 $('#changes').hide();
695 $('#controls').show();
696 url = 'update';
697 } else {
698 $("#changes").validate().cancelSubmit = false;
699 document.getElementById("preview").checked = false;
700 url = 'preview';
701 }
702 $('#controls').hide();
703 $('#pdfPreviewInner').show();
704 713
705 var strVar2 = "" 714 if (preview == false) {
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>'; 715 $("#Canvas").css('z-index', '0');
707 document.getElementById('pdfPreviewInner').innerHTML = strVar2; 716 $('#changes').hide();
717 $('#controls').show();
718
719 } else {
720 $("#changes").validate().cancelSubmit = false;
721 document.getElementById("preview").checked = false;
722
723 }
724 $('#controls').hide();
725 $('#pdfPreviewInner').show()
726
708 727
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>'; 728 var strVar2 = ""
710 document.getElementById('controls').innerHTML = strVar3; 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>';
730 document.getElementById('pdfPreviewInner').innerHTML = strVar2;
711 731
712 $.LoadingOverlaySetup({ 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>';
713 color: "rgba(0, 0, 0, 0.9)" 733 document.getElementById('controls').innerHTML = strVar3;
714 });
715 $('#Canvas').LoadingOverlay("show");
716 $('#Canvas').delay(500).queue(function() {
717 $(this).css("background-image", "");
718 });
719 734
720 setTimeout(function() { 735 $.LoadingOverlaySetup({
721 $('#Canvas').LoadingOverlay("hide", true); 736 color: "rgba(0, 0, 0, 0.9)",
722 }, 500); 737 image: pluginUrl+"/wp-content/plugins/pdf-customizer-plugin/public/js/loading.gif",
738 });
739 $('#Canvas').LoadingOverlay("show");
740 $('#Canvas').delay(600).queue(function() {
741 $(this).css("background-image", "");
742 });
723 743
724 if (preview == false) { 744 setTimeout(function() {
725 $('#controls').show(); 745 $('#Canvas').LoadingOverlay("hide", true);
726 } 746 }, 600);
727 747
748 if (preview == false) {
749 $('#controls').show();
750 setSubmit('on');
751 }
728 752
729 753
730 $('#editMe').click(function() {
731 $("#google_drive").hide();
732 $('#controls').hide();
733 $('#changes').show();
734 $("#Canvas").show();
735 $("#Canvas").css('z-index', '10');
736 754
737 755 $('#editMe').click(function() {
738 }); 756 $("#google_drive").hide();
757 $('#controls').hide();
758 $('#changes').show();
759 $("#Canvas").show();
760 $("#Canvas").css('z-index', '10');
761 setTinyMce();
739 762
740 $('#downloadMe').click(function() { 763 });
741 $(".closeEditer").click();
742 });
743 764
765 $('#downloadMe').click(function() {
766 $(".closeEditer").click();
767 });
744 768
745 });
746 769
747 } 770 });
771
772 }
...\ No newline at end of file ...\ No newline at end of file
......