f24e58e8 by Jeff Balicki

commit

1 parent 083324e1
...@@ -132,7 +132,13 @@ function HideBoxwithdate() { ...@@ -132,7 +132,13 @@ function HideBoxwithdate() {
132 132
133 } 133 }
134 134
135 function fullScreen() {
136 jQuery(document).ready(function($) {
137 $('#bbox').toggleClass('fullscreen');
138 //$('#bbox').animate({ width: "100%", height: "100%", position: "fixed", top: "0", left: "0" });
135 139
140 });
141 }
136 function getJson(user_id) { 142 function getJson(user_id) {
137 jQuery(document).ready(function($) { 143 jQuery(document).ready(function($) {
138 $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) { 144 $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) {
...@@ -150,6 +156,7 @@ function getOneJson(id) { ...@@ -150,6 +156,7 @@ function getOneJson(id) {
150 // Get the element with id summary and set the inner text to the result. 156 // Get the element with id summary and set the inner text to the result.
151 var json = JSON.stringify(data); 157 var json = JSON.stringify(data);
152 edit = false; 158 edit = false;
159
153 changePdfOptions(json,edit); 160 changePdfOptions(json,edit);
154 }); 161 });
155 }); 162 });
...@@ -163,7 +170,7 @@ function getBackOneJson(id) { ...@@ -163,7 +170,7 @@ function getBackOneJson(id) {
163 edit = true; 170 edit = true;
164 171
165 172
166 changePdfOptions(json,edit); 173 changePdfOptions(json,edi);
167 }); 174 });
168 }); 175 });
169 } 176 }
...@@ -182,12 +189,22 @@ function pickPdfFromList(json) { ...@@ -182,12 +189,22 @@ function pickPdfFromList(json) {
182 pdflist += "</div>"; 189 pdflist += "</div>";
183 } 190 }
184 191
185 strVar += ' <div id="callout" class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; 192 strVar += ' <div id="callout" class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1> <a href="#" class="fsbutton" onclick="fullScreen();">Full Screen</a>';
186 strVar += '</div></div></div><div id="contentAreaOver"></div> '; 193 strVar += '</div></div></div><div id="contentAreaOver"></div> ';
187 document.getElementById('contentArea').innerHTML = strVar; 194 document.getElementById('contentArea').innerHTML = strVar;
195
196
197
188 }); 198 });
189 } 199 }
190 200
201 function setPreview(){
202
203 document.getElementById("preview").checked = true;
204
205 }
206
207
191 function changePdfOptions(json, edit) { 208 function changePdfOptions(json, edit) {
192 jQuery(function($) { 209 jQuery(function($) {
193 if(edit == false){ 210 if(edit == false){
...@@ -195,10 +212,9 @@ function changePdfOptions(json, edit) { ...@@ -195,10 +212,9 @@ function changePdfOptions(json, edit) {
195 } 212 }
196 213
197 214
198 console.log( json );
199
200 json = JSON.parse(json);
201 215
216 json = JSON.parse(json);
217
202 $(document).ready(function() { 218 $(document).ready(function() {
203 219
204 220
...@@ -263,7 +279,7 @@ function changePdfOptions(json, edit) { ...@@ -263,7 +279,7 @@ function changePdfOptions(json, edit) {
263 279
264 pdflist += '<div id="pdfPreview" style="" class="column">'; 280 pdflist += '<div id="pdfPreview" style="" class="column">';
265 // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; 281 // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">';
266 pdflist += '<canvas id="Canvas" width="' + imageWidth + '" height="' + imageHeight + '" style=" margin-top:'+imgTop+'%; display: block; margin-left: auto; margin-right: auto; border-style: solid; border-width:1px; background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:' + imageWidth + 'px ' + imageHeight + 'px"></div>'; 282 pdflist += '<canvas id="Canvas" width="' + imageWidth + '" height="' + imageHeight + '" style=" margin-top:'+imgTop+'%; display: block; margin-left: auto; margin-right: auto; border-style: solid; border-width:1px; background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:' + imageWidth + 'px ' + imageHeight + 'px"></canvas><div id="pdfPreviewInner"></div></div>';
267 pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>'; 283 pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>';
268 pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; 284 pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">';
269 for (i = 0; i < json.length; ++i) { 285 for (i = 0; i < json.length; ++i) {
...@@ -309,16 +325,20 @@ function changePdfOptions(json, edit) { ...@@ -309,16 +325,20 @@ function changePdfOptions(json, edit) {
309 325
310 326
311 } 327 }
328 pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;"><input type="submit" onClick="setPreview();" value="Preview">';
312 pdfChange += '<input type="submit" value="Save and Continue">'; 329 pdfChange += '<input type="submit" value="Save and Continue">';
330
313 pdfChange += '</form>'; 331 pdfChange += '</form>';
314 332
315 strVar2 += ''; 333 strVar2 += '';
316 strVar2 += ''; 334 strVar2 += '';
317 strVar2 += '</div><div id="wrapper" class="black small-up-2 medium-up-3 large-up-3" style="height:'+windowHBG+'px;"> <a class="closeEditer"><i class="fa fa-times fa-1x"></i></a>'; 335 strVar2 += '</div><div id="wrapper" class="black small-up-2 medium-up-3 large-up-3" style="height:'+windowHBG+'px;"> <a class="closeEditer"><i class="fa fa-times fa-1x"></i></a>';
318 strVar2 += pdflist + '<div id="changesColumn" style="height:'+windowHBG+'px;" class="column" >' + pdfChange + '<div id="tezingLogo"></div></div><div id="pdfFooter"></div></div>'; 336 strVar2 += pdflist + '<div id="changesColumn" style="height:'+windowHBG+'px;" class="column" >' + pdfChange + '<div id="tezingLogo"></div><div id="controls"></div></div><div id="pdfFooter"></div></div>';
319 337
320 document.getElementById('contentAreaOver').innerHTML = strVar2; 338 document.getElementById('contentAreaOver').innerHTML = strVar2;
321 339
340
341
322 if(edit == false){ 342 if(edit == false){
323 $("#contentAreaOver").slideToggle(); 343 $("#contentAreaOver").slideToggle();
324 $('#google_drive').slideToggle(); 344 $('#google_drive').slideToggle();
...@@ -410,6 +430,80 @@ function changePdfOptions(json, edit) { ...@@ -410,6 +430,80 @@ function changePdfOptions(json, edit) {
410 $("#changes").submit(function(e) { 430 $("#changes").submit(function(e) {
411 431
412 e.preventDefault(); 432 e.preventDefault();
433 if($('#preview').prop('checked')==true){
434
435 $(tinymce.get()).each(function(i, el) {
436
437 if (el.id)
438 document.getElementById(el.id).value = el.getContent();
439 $('#changes').hide();
440 tinymce.get(el.id).remove();
441 });
442
443
444 var ids =[];
445 if(edit == true){
446 $("#changes input[type=file]").each(function() {
447 if($(this).get(0).files.length == 0 ){
448
449
450 document.getElementById(this.id).remove();
451 }else{
452 console.log("hidden"+this.id);
453 document.getElementById("hidden"+this.id).remove();
454
455
456 }
457 });}
458 var form = $("#changes");
459 //console.log(form);
460
461 returnfileOptions(imagefiles, form, preview = true);
462
463
464 var tinymces = tinymce.init({
465 selector: '.textarea',
466 entity_encoding: "raw",
467 menubar: false,
468 toolbar: ' bold italic',
469 remove_linebreaks: false,
470 remove_trailing_brs: false,
471 init_instance_callback: function(editor) {
472 var editorDoc = document.getElementById(editor.id + '_ifr');
473 var editorDocContent = editorDoc.contentDocument;
474 editorDoc.style.border = "0px solid #131212";
475 editorDocContent.body.style.backgroundColor = "#131212";
476 editorDocContent.body.style.color = "#ccc";
477 },
478 setup: function(editor) {
479 editor.on('focus', function(e) {
480 //console.log(editor.id);
481
482 var editorDoc = document.getElementById(editor.id + '_ifr');
483 var editorDocContent = editorDoc.contentDocument;
484 editorDoc.style.border = "2px solid #F7A800";
485
486 $('#' + editor.id).trigger("onfocus");
487 //$(this).css('border', '2px solid #F7A800 !important');
488 });
489 editor.on('blur', function(e) {
490 //console.log('out' + editor.id);
491 var editorDoc = document.getElementById(editor.id + '_ifr');
492 var editorDocContent = editorDoc.contentDocument;
493 editorDoc.style.border = "2px solid #131212";
494
495 //$(this).css('border', '0px solid #F7A800 !important');
496 HideBox();
497 });
498 }
499 });
500 document.getElementById("preview").checked = false;
501
502
503 }else{
504
505
506
413 507
414 if ($("#changes").valid()) { 508 if ($("#changes").valid()) {
415 509
...@@ -430,7 +524,7 @@ function changePdfOptions(json, edit) { ...@@ -430,7 +524,7 @@ function changePdfOptions(json, edit) {
430 524
431 document.getElementById(this.id).remove(); 525 document.getElementById(this.id).remove();
432 }else{ 526 }else{
433 console.log("hidden"+this.id); 527 //console.log("hidden"+this.id);
434 document.getElementById("hidden"+this.id).remove(); 528 document.getElementById("hidden"+this.id).remove();
435 529
436 530
...@@ -439,11 +533,12 @@ function changePdfOptions(json, edit) { ...@@ -439,11 +533,12 @@ function changePdfOptions(json, edit) {
439 var form = $("#changes"); 533 var form = $("#changes");
440 //console.log(form); 534 //console.log(form);
441 535
442 returnfileOptions(imagefiles, form); 536 returnfileOptions(imagefiles, form, preview = false);
443 return false; 537 return false;
444 } else { 538 } else {
445 return false; 539 return false;
446 } 540 }
541 }
447 }); 542 });
448 543
449 }); 544 });
...@@ -451,7 +546,7 @@ function changePdfOptions(json, edit) { ...@@ -451,7 +546,7 @@ function changePdfOptions(json, edit) {
451 } 546 }
452 547
453 548
454 function returnfileOptions(files, form) { 549 function returnfileOptions(files, form, preview) {
455 jQuery(function($) { 550 jQuery(function($) {
456 551
457 var data = new FormData(); 552 var data = new FormData();
...@@ -470,7 +565,7 @@ function returnfileOptions(files, form) { ...@@ -470,7 +565,7 @@ function returnfileOptions(files, form) {
470 contentType: false, // Set content type to false as jQuery will tell the server its a query string request 565 contentType: false, // Set content type to false as jQuery will tell the server its a query string request
471 success: function(data, textStatus, jqXHR) { 566 success: function(data, textStatus, jqXHR) {
472 if (typeof data.error === 'undefined') { 567 if (typeof data.error === 'undefined') {
473 returnOptions(form); 568 returnOptions(form , preview);
474 } else { 569 } else {
475 // Handle errors here 570 // Handle errors here
476 571
...@@ -490,9 +585,11 @@ function returnfileOptions(files, form) { ...@@ -490,9 +585,11 @@ function returnfileOptions(files, form) {
490 585
491 586
492 587
493 function returnOptions(form) { 588 function returnOptions(form, preview) {
494 jQuery(function($) { 589 jQuery(function($) {
495 590
591
592
496 $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { 593 $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) {
497 // Get the element with id summary and set the inner text to the result. 594 // Get the element with id summary and set the inner text to the result.
498 595
...@@ -502,6 +599,7 @@ function returnOptions(form) { ...@@ -502,6 +599,7 @@ function returnOptions(form) {
502 599
503 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":[' 600 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":['
504 var e = 1; 601 var e = 1;
602 var o = 1;
505 for (i = 0; i < json.length; ++i) { 603 for (i = 0; i < json.length; ++i) {
506 604
507 605
...@@ -509,31 +607,46 @@ function returnOptions(form) { ...@@ -509,31 +607,46 @@ function returnOptions(form) {
509 var content = JSON.stringify(form[0][e].value); 607 var content = JSON.stringify(form[0][e].value);
510 //console.log(form[0][e].value); 608 //console.log(form[0][e].value);
511 //console.log(json[i].label+' '+json[i].order); 609 //console.log(json[i].label+' '+json[i].order);
610
611 if(content != '""') {
612 if (o !== 1) {
613 jsonReturn += ',';
614
615 }
512 616
513 jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style +', "names":"' + json[i].names +'", "example":"' + json[i].example +'", "tips":"' + json[i].tips + '", "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/uploads/pdf/"}'; 617 jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style +', "names":"' + json[i].names +'", "example":"' + json[i].example +'", "tips":"' + json[i].tips + '", "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/uploads/pdf/"}';
514 618
515 619 ++o
516 if (i < json.length - 1) { 620
517 jsonReturn += ','; 621 };
518 }
519 ++e 622 ++e
623
624
520 } 625 }
521 jsonReturn += ' ]}'; 626 jsonReturn += ' ]}';
627
628
629
630
522 631
523 var windowWidth = 0.75 * $("#wrapper").width(); 632
524 var windowHeight = 0.75 * $("#wrapper").height(); 633 var windowWidth = 0.90 * $(".layout-grid").width();
634 var windowHeight = 0.90 * $(".layout-grid").height();
635
525 636
526 var windowHBG = 0.923 * $(window).height(); 637 var windowHBG = 0.923 * $(window).height();
527 var pwidth = parseInt(json[0].pwidth); 638 var pwidth = parseInt(json[0].pwidth);
528 var pheight = parseInt(json[0].pheight); 639 var pheight = parseInt(json[0].pheight);
529 640
530 641 //console.log( windowWidth+' '+windowHeight);
642 //console.log( pwidth+' '+pheight);
531 if(pwidth > pheight){ 643 if(pwidth > pheight){
644 //console.log('wide')
532 var scaleImage = windowWidth / pwidth; 645 var scaleImage = windowWidth / pwidth;
533 var imageHeight = pheight * scaleImage; 646 var imageHeight = pheight * scaleImage;
534 var imageWidth = windowWidth; 647 var imageWidth = windowWidth;
535 var imgLeft = 0; 648 var imgLeft = 0;
536 var imgTop = 25; 649 var imgTop = 40;
537 }else{ 650 }else{
538 var scaleImage = windowHeight / pheight; 651 var scaleImage = windowHeight / pheight;
539 var imageHeight = windowHeight; 652 var imageHeight = windowHeight;
...@@ -541,15 +654,17 @@ function returnOptions(form) { ...@@ -541,15 +654,17 @@ function returnOptions(form) {
541 var imgLeft = 30; 654 var imgLeft = 30;
542 var imgTop = 2; 655 var imgTop = 2;
543 } 656 }
544 // console.log(jsonReturn); 657
658 // console.log(jsonReturn);
545 659
546 660
547 661
548 662
549 $("#Canvas").fadeOut(60000000); 663 $("#Canvas").hide();
550 664 $('#controls').show();
551 665 $('#pdfPreviewInner').show();
552 666
667
553 668
554 $.ajax({ 669 $.ajax({
555 url: "" + pdf_customizer + "/api/update", 670 url: "" + pdf_customizer + "/api/update",
...@@ -561,19 +676,21 @@ function returnOptions(form) { ...@@ -561,19 +676,21 @@ function returnOptions(form) {
561 CrossDomain: true, 676 CrossDomain: true,
562 677
563 success: function(data) { 678 success: function(data) {
564 679
565 var strVar2 = "" 680 var strVar2 = ""
566 // strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; 681 // strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>';
567 //strVar2 += '</div></div><div class="row small-up-2 medium-up-3 large-up-3">'; 682 //strVar2 += '</div></div><div class="row small-up-2 medium-up-3 large-up-3">';
568 strVar2 += '<div id="seepdf" style=" display:hidden; width:'+imageWidth+'px;" ><a class="media" style="display: block; margin-left:auto; margin-right:auto; " href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ></a></div>'; 683 strVar2 += '<div id="seepdf" style=" display:hidden; width:'+imageWidth+'px;" ><a class="media" style="display: block; margin-left:auto; margin-right:auto; " href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ></a></div>';
569 //<i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a> 684 //<i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a>
570 685
571 document.getElementById('pdfPreview').innerHTML = strVar2; 686 document.getElementById('pdfPreviewInner').innerHTML = strVar2;
572 $('#changes').replaceWith('<div id="changes"></div>') 687 // $('#changes').replaceWith('<div id="changes"></div>')
688
573 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>'; 689 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>';
574 document.getElementById('changes').innerHTML = strVar3; 690 document.getElementById('controls').innerHTML = strVar3;
575 691
576 // console.log(data); 692 console.log(imageWidth);
693 console.log(imageHeight);
577 694
578 // $('#changes').show(); 695 // $('#changes').show();
579 696
...@@ -582,8 +699,15 @@ function returnOptions(form) { ...@@ -582,8 +699,15 @@ function returnOptions(form) {
582 699
583 $('#editMe').click(function() { 700 $('#editMe').click(function() {
584 $("#google_drive").hide(); 701 $("#google_drive").hide();
585 getBackOneJson(data); 702 //getBackOneJson(data,jsonForEdit);
586 }); 703 $('#controls').hide();
704 $('#changes').show();
705 $('#pdfPreviewInner').hide();
706 $("#Canvas").show();
707 });
708 $('#downloadMe').click(function() {
709 $(".closeEditer").click();
710 });
587 711
588 712
589 713
......