2917db69 by Jeff Balicki

preivew before using jsbeautifier to clean up code

1 parent a985e315
var pluginUrl = window.location.protocol+'//'+window.location.host;
var pdf_customizer = "https://pdf-customizer.synapsus.co";
var pluginUrl = window.location.protocol+'//'+window.location.host+'/commonwell';
var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
//var pluginUrl = "http://contact.gotenzing.com";
......@@ -45,6 +45,7 @@ function offFocus(id) {
$("#select" + id + "").removeClass("focus");
$(".entry_block").mouseleave(function() {
$("#select" + id + "").addClass("focus");
});
});
}
......@@ -89,15 +90,7 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
ctx.lineWidth=2;
ctx.strokeStyle= $('.callout').css("background-color")
ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke();
//ctx.rect(scaleRight, scaleDown, scalewidth, scaleheight );
//console.log(scaleRight, scaleDown, scalewidth, scaleheight);
//console.log($("Canvas").height(), $("Canvas").width(), scaleW, scaleH);
//
//ctx.lineWidth=2;
//ctx.lineCap = "round";
//ctx.stroke();
//console.log(pheight, pwidth,up, right, height, width);
// console.log(myrect )
});
}
......@@ -109,7 +102,8 @@ function findUserInfoMatch(data) {
}
function HideBox() {
function HideBox(kind) {
jQuery(document).ready(function($) {
$('span').hide();
//console.log('hide');
......@@ -117,9 +111,13 @@ function HideBox() {
var Qctx = Qc.getContext("2d");
Qctx.clearRect(0, 0, Qc.width, Qc.height);
Qctx.restore();
if(kind !='file'){
document.getElementById("preview").checked = true;
$('#changes').trigger('submit');
}
});
}
function HideBoxwithdate() {
......@@ -128,8 +126,10 @@ function HideBoxwithdate() {
var Qctx = Qc.getContext("2d");
Qctx.clearRect(0, 0, Qc.width, Qc.height);
Qctx.restore();
});
}
......@@ -199,11 +199,7 @@ function pickPdfFromList(json) {
});
}
function setPreview(){
document.getElementById("preview").checked = true;
}
function changePdfOptions(json, edit) {
......@@ -229,7 +225,9 @@ function changePdfOptions(json, edit) {
defaultDate: null
}).on('change', function() {
$(this).valid(); // triggers the validation test
// '$(this)' refers to '$("#datepicker")'
document.getElementById("preview").checked = true;
$('#changes').trigger('submit');
});
$("#changes").validate({
......@@ -279,8 +277,8 @@ function changePdfOptions(json, edit) {
// console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight);
pdflist += '<div id="pdfPreview" style="" class="column">';
// pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">';
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>';
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>';
pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>';
pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">';
for (i = 0; i < json.length; ++i) {
......@@ -298,10 +296,10 @@ function changePdfOptions(json, edit) {
if (json[i].change_type == "img") {
if(edit == true){
pdfChange += '<input value="'+json[i].content+'" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >';
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>';
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>';
}else{
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>';
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>';
}
pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
......@@ -326,7 +324,7 @@ function changePdfOptions(json, edit) {
}
pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;"><input type="submit" onClick="setPreview();" value="Preview">';
pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;">';
pdfChange += '<input type="submit" value="Save and Continue">';
pdfChange += '</form>';
......@@ -417,7 +415,10 @@ function changePdfOptions(json, edit) {
$(target).parent('label').find('.file-name').text('');
}
$(target).parent('label').trigger('focus');
if( $(target).val()){
document.getElementById("preview").checked = true;
$('#changes').trigger('submit');
}
});
......@@ -437,7 +438,7 @@ $(tinymce.get()).each(function(i, el) {
if (el.id)
document.getElementById(el.id).value = el.getContent();
$('#changes').hide();
//$('#changes').hide();
tinymce.get(el.id).remove();
});
......@@ -460,7 +461,8 @@ $(tinymce.get()).each(function(i, el) {
//console.log(form);
returnfileOptions(imagefiles, form, preview = true);
var tinymces = tinymce.init({
selector: '.textarea',
......@@ -498,7 +500,7 @@ $(tinymce.get()).each(function(i, el) {
});
}
});
document.getElementById("preview").checked = false;
$("#changes").validate().cancelSubmit = true;
}else{
......@@ -654,62 +656,69 @@ function returnOptions(form, preview) {
var imageWidth = pwidth * scaleImage;
var imgLeft = 30;
var imgTop = 2;
var url;
}
// console.log(jsonReturn);
$("#Canvas").hide();
if(preview == false){
$("#Canvas").css('z-index','0');
$('#changes').hide();
$('#controls').show();
url = 'update';
}else{
$("#changes").validate().cancelSubmit = false;
document.getElementById("preview").checked = false;
url = 'preview';
}
$('#controls').hide();
$('#pdfPreviewInner').show();
$.ajax({
url: "" + pdf_customizer + "/api/update",
url: "" + pdf_customizer + "/api/"+url,
type: "POST",
dataType: 'json',
data: jsonReturn,
contentType: "application/json",
CrossDomain: true,
success: function(data) {
var strVar2 = ""
// strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>';
//strVar2 += '</div></div><div class="row small-up-2 medium-up-3 large-up-3">';
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>';
//<i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a>
document.getElementById('pdfPreviewInner').innerHTML = strVar2;
// $('#changes').replaceWith('<div id="changes"></div>')
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>';
document.getElementById('pdfPreviewInner').innerHTML = strVar2;
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>';
document.getElementById('controls').innerHTML = strVar3;
$.LoadingOverlaySetup({ color : "rgba(0, 0, 0, 0.9)"});
$('#Canvas').LoadingOverlay("show");
$('#Canvas').delay(600).queue(function() {
$(this).css("background-image", "");
});
setTimeout(function(){
$('#Canvas').LoadingOverlay("hide", true);
}, 600);
console.log(imageWidth);
console.log(imageHeight);
if(preview == false){
$('#controls').show();
}
// $('#changes').show();
$("#seepdf").fadeIn(60000000);
$('a.media').media({width:imageWidth, height:imageHeight});
$('#editMe').click(function() {
$("#google_drive").hide();
//getBackOneJson(data,jsonForEdit);
$('#controls').hide();
$('#changes').show();
$('#pdfPreviewInner').hide();
$("#Canvas").show();
});
$('#downloadMe').click(function() {
$(".closeEditer").click();
});
$("#google_drive").hide();
$('#controls').hide();
$('#changes').show();
$("#Canvas").show();
$("#Canvas").css('z-index','10');
});
$('#downloadMe').click(function() {
$(".closeEditer").click();
});
......