preivew before using jsbeautifier to clean up code
Showing
1 changed file
with
69 additions
and
60 deletions
| 1 | var pluginUrl = window.location.protocol+'//'+window.location.host; | 1 | var pluginUrl = window.location.protocol+'//'+window.location.host+'/commonwell'; |
| 2 | var pdf_customizer = "https://pdf-customizer.synapsus.co"; | 2 | var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; |
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | //var pluginUrl = "http://contact.gotenzing.com"; | 5 | //var pluginUrl = "http://contact.gotenzing.com"; |
| ... | @@ -45,6 +45,7 @@ function offFocus(id) { | ... | @@ -45,6 +45,7 @@ function offFocus(id) { |
| 45 | $("#select" + id + "").removeClass("focus"); | 45 | $("#select" + id + "").removeClass("focus"); |
| 46 | $(".entry_block").mouseleave(function() { | 46 | $(".entry_block").mouseleave(function() { |
| 47 | $("#select" + id + "").addClass("focus"); | 47 | $("#select" + id + "").addClass("focus"); |
| 48 | |||
| 48 | }); | 49 | }); |
| 49 | }); | 50 | }); |
| 50 | } | 51 | } |
| ... | @@ -89,15 +90,7 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { | ... | @@ -89,15 +90,7 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { |
| 89 | ctx.lineWidth=2; | 90 | ctx.lineWidth=2; |
| 90 | ctx.strokeStyle= $('.callout').css("background-color") | 91 | ctx.strokeStyle= $('.callout').css("background-color") |
| 91 | ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke(); | 92 | ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke(); |
| 92 | //ctx.rect(scaleRight, scaleDown, scalewidth, scaleheight ); | 93 | |
| 93 | //console.log(scaleRight, scaleDown, scalewidth, scaleheight); | ||
| 94 | //console.log($("Canvas").height(), $("Canvas").width(), scaleW, scaleH); | ||
| 95 | // | ||
| 96 | //ctx.lineWidth=2; | ||
| 97 | //ctx.lineCap = "round"; | ||
| 98 | //ctx.stroke(); | ||
| 99 | //console.log(pheight, pwidth,up, right, height, width); | ||
| 100 | // console.log(myrect ) | ||
| 101 | }); | 94 | }); |
| 102 | } | 95 | } |
| 103 | 96 | ||
| ... | @@ -109,7 +102,8 @@ function findUserInfoMatch(data) { | ... | @@ -109,7 +102,8 @@ function findUserInfoMatch(data) { |
| 109 | } | 102 | } |
| 110 | 103 | ||
| 111 | 104 | ||
| 112 | function HideBox() { | 105 | function HideBox(kind) { |
| 106 | |||
| 113 | jQuery(document).ready(function($) { | 107 | jQuery(document).ready(function($) { |
| 114 | $('span').hide(); | 108 | $('span').hide(); |
| 115 | //console.log('hide'); | 109 | //console.log('hide'); |
| ... | @@ -117,9 +111,13 @@ function HideBox() { | ... | @@ -117,9 +111,13 @@ function HideBox() { |
| 117 | var Qctx = Qc.getContext("2d"); | 111 | var Qctx = Qc.getContext("2d"); |
| 118 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | 112 | Qctx.clearRect(0, 0, Qc.width, Qc.height); |
| 119 | Qctx.restore(); | 113 | Qctx.restore(); |
| 120 | 114 | if(kind !='file'){ | |
| 115 | document.getElementById("preview").checked = true; | ||
| 116 | $('#changes').trigger('submit'); | ||
| 117 | } | ||
| 121 | }); | 118 | }); |
| 122 | 119 | ||
| 120 | |||
| 123 | } | 121 | } |
| 124 | 122 | ||
| 125 | function HideBoxwithdate() { | 123 | function HideBoxwithdate() { |
| ... | @@ -128,8 +126,10 @@ function HideBoxwithdate() { | ... | @@ -128,8 +126,10 @@ function HideBoxwithdate() { |
| 128 | var Qctx = Qc.getContext("2d"); | 126 | var Qctx = Qc.getContext("2d"); |
| 129 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | 127 | Qctx.clearRect(0, 0, Qc.width, Qc.height); |
| 130 | Qctx.restore(); | 128 | Qctx.restore(); |
| 131 | 129 | ||
| 130 | |||
| 132 | }); | 131 | }); |
| 132 | |||
| 133 | 133 | ||
| 134 | } | 134 | } |
| 135 | 135 | ||
| ... | @@ -199,11 +199,7 @@ function pickPdfFromList(json) { | ... | @@ -199,11 +199,7 @@ function pickPdfFromList(json) { |
| 199 | }); | 199 | }); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | function setPreview(){ | ||
| 203 | |||
| 204 | document.getElementById("preview").checked = true; | ||
| 205 | 202 | ||
| 206 | } | ||
| 207 | 203 | ||
| 208 | 204 | ||
| 209 | function changePdfOptions(json, edit) { | 205 | function changePdfOptions(json, edit) { |
| ... | @@ -229,7 +225,9 @@ function changePdfOptions(json, edit) { | ... | @@ -229,7 +225,9 @@ function changePdfOptions(json, edit) { |
| 229 | defaultDate: null | 225 | defaultDate: null |
| 230 | }).on('change', function() { | 226 | }).on('change', function() { |
| 231 | $(this).valid(); // triggers the validation test | 227 | $(this).valid(); // triggers the validation test |
| 232 | // '$(this)' refers to '$("#datepicker")' | 228 | document.getElementById("preview").checked = true; |
| 229 | $('#changes').trigger('submit'); | ||
| 230 | |||
| 233 | }); | 231 | }); |
| 234 | 232 | ||
| 235 | $("#changes").validate({ | 233 | $("#changes").validate({ |
| ... | @@ -279,8 +277,8 @@ function changePdfOptions(json, edit) { | ... | @@ -279,8 +277,8 @@ function changePdfOptions(json, edit) { |
| 279 | // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight); | 277 | // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight); |
| 280 | 278 | ||
| 281 | pdflist += '<div id="pdfPreview" style="" class="column">'; | 279 | pdflist += '<div id="pdfPreview" style="" class="column">'; |
| 282 | // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; | 280 | |
| 283 | 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-size:' + imageWidth + 'px ' + imageHeight + 'px"></canvas><div id="pdfPreviewInner"></div></div>'; | 281 | 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>'; |
| 284 | pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>'; | 282 | pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>'; |
| 285 | pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; | 283 | pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; |
| 286 | for (i = 0; i < json.length; ++i) { | 284 | for (i = 0; i < json.length; ++i) { |
| ... | @@ -298,10 +296,10 @@ function changePdfOptions(json, edit) { | ... | @@ -298,10 +296,10 @@ function changePdfOptions(json, edit) { |
| 298 | if (json[i].change_type == "img") { | 296 | if (json[i].change_type == "img") { |
| 299 | if(edit == true){ | 297 | if(edit == true){ |
| 300 | pdfChange += '<input value="'+json[i].content+'" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >'; | 298 | pdfChange += '<input value="'+json[i].content+'" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >'; |
| 301 | pdfChange += json[i].names + ':<label 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="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>'; | 299 | pdfChange += json[i].names + ':<label onfocusout="HideBox(\'file\')" onfocus=" 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>'; |
| 302 | 300 | ||
| 303 | }else{ | 301 | }else{ |
| 304 | pdfChange += json[i].names + ':<label 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="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>'; | 302 | pdfChange += json[i].names + ':<label onfocusout="HideBox(\'file\')" onfocus=" 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>'; |
| 305 | } | 303 | } |
| 306 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | 304 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; |
| 307 | 305 | ||
| ... | @@ -326,7 +324,7 @@ function changePdfOptions(json, edit) { | ... | @@ -326,7 +324,7 @@ function changePdfOptions(json, edit) { |
| 326 | 324 | ||
| 327 | 325 | ||
| 328 | } | 326 | } |
| 329 | pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;"><input type="submit" onClick="setPreview();" value="Preview">'; | 327 | pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;">'; |
| 330 | pdfChange += '<input type="submit" value="Save and Continue">'; | 328 | pdfChange += '<input type="submit" value="Save and Continue">'; |
| 331 | 329 | ||
| 332 | pdfChange += '</form>'; | 330 | pdfChange += '</form>'; |
| ... | @@ -417,7 +415,10 @@ function changePdfOptions(json, edit) { | ... | @@ -417,7 +415,10 @@ function changePdfOptions(json, edit) { |
| 417 | $(target).parent('label').find('.file-name').text(''); | 415 | $(target).parent('label').find('.file-name').text(''); |
| 418 | } | 416 | } |
| 419 | $(target).parent('label').trigger('focus'); | 417 | $(target).parent('label').trigger('focus'); |
| 420 | 418 | if( $(target).val()){ | |
| 419 | document.getElementById("preview").checked = true; | ||
| 420 | $('#changes').trigger('submit'); | ||
| 421 | } | ||
| 421 | 422 | ||
| 422 | }); | 423 | }); |
| 423 | 424 | ||
| ... | @@ -437,7 +438,7 @@ $(tinymce.get()).each(function(i, el) { | ... | @@ -437,7 +438,7 @@ $(tinymce.get()).each(function(i, el) { |
| 437 | 438 | ||
| 438 | if (el.id) | 439 | if (el.id) |
| 439 | document.getElementById(el.id).value = el.getContent(); | 440 | document.getElementById(el.id).value = el.getContent(); |
| 440 | $('#changes').hide(); | 441 | //$('#changes').hide(); |
| 441 | tinymce.get(el.id).remove(); | 442 | tinymce.get(el.id).remove(); |
| 442 | }); | 443 | }); |
| 443 | 444 | ||
| ... | @@ -460,7 +461,8 @@ $(tinymce.get()).each(function(i, el) { | ... | @@ -460,7 +461,8 @@ $(tinymce.get()).each(function(i, el) { |
| 460 | //console.log(form); | 461 | //console.log(form); |
| 461 | 462 | ||
| 462 | returnfileOptions(imagefiles, form, preview = true); | 463 | returnfileOptions(imagefiles, form, preview = true); |
| 463 | 464 | ||
| 465 | |||
| 464 | 466 | ||
| 465 | var tinymces = tinymce.init({ | 467 | var tinymces = tinymce.init({ |
| 466 | selector: '.textarea', | 468 | selector: '.textarea', |
| ... | @@ -498,7 +500,7 @@ $(tinymce.get()).each(function(i, el) { | ... | @@ -498,7 +500,7 @@ $(tinymce.get()).each(function(i, el) { |
| 498 | }); | 500 | }); |
| 499 | } | 501 | } |
| 500 | }); | 502 | }); |
| 501 | document.getElementById("preview").checked = false; | 503 | $("#changes").validate().cancelSubmit = true; |
| 502 | 504 | ||
| 503 | 505 | ||
| 504 | }else{ | 506 | }else{ |
| ... | @@ -654,62 +656,69 @@ function returnOptions(form, preview) { | ... | @@ -654,62 +656,69 @@ function returnOptions(form, preview) { |
| 654 | var imageWidth = pwidth * scaleImage; | 656 | var imageWidth = pwidth * scaleImage; |
| 655 | var imgLeft = 30; | 657 | var imgLeft = 30; |
| 656 | var imgTop = 2; | 658 | var imgTop = 2; |
| 659 | var url; | ||
| 657 | } | 660 | } |
| 658 | // console.log(jsonReturn); | 661 | // console.log(jsonReturn); |
| 659 | 662 | ||
| 660 | 663 | if(preview == false){ | |
| 661 | 664 | $("#Canvas").css('z-index','0'); | |
| 662 | |||
| 663 | $("#Canvas").hide(); | ||
| 664 | $('#changes').hide(); | 665 | $('#changes').hide(); |
| 665 | $('#controls').show(); | 666 | $('#controls').show(); |
| 666 | 667 | url = 'update'; | |
| 668 | }else{ | ||
| 669 | $("#changes").validate().cancelSubmit = false; | ||
| 670 | document.getElementById("preview").checked = false; | ||
| 671 | url = 'preview'; | ||
| 672 | } | ||
| 673 | $('#controls').hide(); | ||
| 667 | $('#pdfPreviewInner').show(); | 674 | $('#pdfPreviewInner').show(); |
| 668 | 675 | ||
| 669 | 676 | ||
| 670 | 677 | ||
| 671 | $.ajax({ | 678 | $.ajax({ |
| 672 | url: "" + pdf_customizer + "/api/update", | 679 | url: "" + pdf_customizer + "/api/"+url, |
| 673 | type: "POST", | 680 | type: "POST", |
| 674 | dataType: 'json', | 681 | dataType: 'json', |
| 675 | data: jsonReturn, | 682 | data: jsonReturn, |
| 676 | |||
| 677 | contentType: "application/json", | 683 | contentType: "application/json", |
| 678 | CrossDomain: true, | 684 | CrossDomain: true, |
| 679 | 685 | ||
| 680 | success: function(data) { | 686 | success: function(data) { |
| 681 | 687 | ||
| 682 | var strVar2 = "" | 688 | var strVar2 = "" |
| 683 | // strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; | 689 | 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=1&toolbar=0&navpanes=0&scrollbar=0statusbar=0" width="'+imageWidth+'" height="'+imageHeight+'" type="application/pdf" id="pdfloaded"><div id="holddf" style="opacity: 0.0;"></div> </div>'; |
| 684 | //strVar2 += '</div></div><div class="row small-up-2 medium-up-3 large-up-3">'; | 690 | document.getElementById('pdfPreviewInner').innerHTML = strVar2; |
| 685 | strVar2 += '<div id="seepdf" style=" display:hidden; width:'+imageWidth+'px;" ><embed src="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '#page=1&toolbar=0&navpanes=0&scrollbar=0statusbar=0" width="'+imageWidth+'" height="'+imageHeight+'" type="application/pdf"></div>'; | 691 | |
| 686 | //<i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a> | ||
| 687 | |||
| 688 | document.getElementById('pdfPreviewInner').innerHTML = strVar2; | ||
| 689 | // $('#changes').replaceWith('<div id="changes"></div>') | ||
| 690 | |||
| 691 | 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>'; | 692 | 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>'; |
| 692 | document.getElementById('controls').innerHTML = strVar3; | 693 | document.getElementById('controls').innerHTML = strVar3; |
| 694 | |||
| 695 | $.LoadingOverlaySetup({ color : "rgba(0, 0, 0, 0.9)"}); | ||
| 696 | $('#Canvas').LoadingOverlay("show"); | ||
| 697 | $('#Canvas').delay(600).queue(function() { | ||
| 698 | $(this).css("background-image", ""); | ||
| 699 | }); | ||
| 700 | |||
| 701 | setTimeout(function(){ | ||
| 702 | $('#Canvas').LoadingOverlay("hide", true); | ||
| 703 | }, 600); | ||
| 693 | 704 | ||
| 694 | console.log(imageWidth); | 705 | if(preview == false){ |
| 695 | console.log(imageHeight); | 706 | $('#controls').show(); |
| 707 | } | ||
| 708 | |||
| 696 | 709 | ||
| 697 | // $('#changes').show(); | ||
| 698 | |||
| 699 | $("#seepdf").fadeIn(60000000); | ||
| 700 | $('a.media').media({width:imageWidth, height:imageHeight}); | ||
| 701 | 710 | ||
| 702 | $('#editMe').click(function() { | 711 | $('#editMe').click(function() { |
| 703 | $("#google_drive").hide(); | 712 | $("#google_drive").hide(); |
| 704 | //getBackOneJson(data,jsonForEdit); | 713 | $('#controls').hide(); |
| 705 | $('#controls').hide(); | 714 | $('#changes').show(); |
| 706 | $('#changes').show(); | 715 | $("#Canvas").show(); |
| 707 | $('#pdfPreviewInner').hide(); | 716 | $("#Canvas").css('z-index','10'); |
| 708 | $("#Canvas").show(); | 717 | }); |
| 709 | }); | 718 | |
| 710 | $('#downloadMe').click(function() { | 719 | $('#downloadMe').click(function() { |
| 711 | $(".closeEditer").click(); | 720 | $(".closeEditer").click(); |
| 712 | }); | 721 | }); |
| 713 | 722 | ||
| 714 | 723 | ||
| 715 | 724 | ... | ... |
-
Please register or sign in to post a comment