a5cdde8f by Jeff Balicki

changes to preview

1 parent 11ddae0a
......@@ -154,10 +154,11 @@ class ApiController extends Controller
$pdf = $pdf->pdf($pdfId);
$response = $pdfId;
$statusCode = 200;
return Response::json( $response, $statusCode);
$UploaqdPdf = new GoogledriveuploadpdfController();
$UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id);
return Response::json( $response, $statusCode);
}
public function getList($json)
......
var pluginUrl = window.location.protocol + '//' + window.location.host + '/commonwell';
var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
//var pluginUrl = window.location.protocol + '//' + window.location.host + '/commonwell';
//var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
//var pluginUrl = "http://contact.gotenzing.com";
//var pdf_customizer = "http://pdf-customizer.synapsus.co";
var pluginUrl = window.location.protocol + '//' + window.location.host;
var pdf_customizer = "http://pdf-customizer.synapsus.co";
var imageHeight = "";
......@@ -67,7 +67,7 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
return this;
}
function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
function ShowBox(pheight, pwidth, bup, right, height, width, count, example) {
jQuery(document).ready(function($) {
$('span').hide();
$('#span' + count).show();
......@@ -78,8 +78,8 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
Qctx.clearRect(0, 0, Qc.width, Qc.height);
Qctx.restore();
var fix = 3;
var up = bup - fix;
var down = pheight - (up + height);
var scaleH = $("Canvas").height() / pheight;
var scaleW = $("Canvas").width() / pwidth;
......@@ -94,8 +94,8 @@ 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();
console.log(PageChangeOn , setpage);
if(PageChangeOn != setpage ){
console.log(PageChangeOn, setpage);
if (PageChangeOn != setpage) {
document.getElementById("preview").checked = true;
$('#changes').trigger('submit');
}
......@@ -108,8 +108,7 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
function HideBox(kind,page) {
function HideBox(kind, page) {
jQuery(document).ready(function($) {
$('span').hide();
......@@ -128,7 +127,7 @@ function HideBox(kind,page) {
}
function HideBoxwithdate(kind,page) {
function HideBoxwithdate(kind, page) {
jQuery(document).ready(function($) {
var Qc = document.getElementById("Canvas");
var Qctx = Qc.getContext("2d");
......@@ -142,12 +141,30 @@ function HideBoxwithdate(kind,page) {
}
function setSubmit(off){
jQuery(document).ready(function($) {
if(off != 'on'){
$('input:submit').attr("disabled", true);
}else{
$('input:submit').attr("disabled", false);
}
});
}
function setPage(page) {
setpage = page;
}
function setPreview(off) {
document.getElementById("preview").checked = false;
}
function setPageChangeOn(page) {
PageChangeOn = page;
......@@ -314,7 +331,7 @@ function getPdfSize(json) {
vimgLeft = 30;
vimgTop = 2;
}
console.log(pwidth, pheight, vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
});
......@@ -322,12 +339,12 @@ function getPdfSize(json) {
}
function setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth) {
console.log(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
imgLeft = vimgLeft;
imgTop = vimgTop;
windowHBG = vwindowHBG;
imageHeight = vimageHeight;
imageWidth = vimageWidth;
// console.log(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
imgLeft = vimgLeft;
imgTop = vimgTop;
windowHBG = vwindowHBG;
imageHeight = vimageHeight;
imageWidth = vimageWidth;
}
......@@ -380,28 +397,28 @@ function changePdfOptions(json, edit) {
var example = json[0].folder + '/' + json[i].example;
if (json[i].change_type == "textflow") {
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>';
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>';
++f;
pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>';
}
if (json[i].change_type == "text") {
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 + '"">';
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 + '"">';
pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
}
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(\'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>';
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>';
} else {
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>';
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>';
}
pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
}
if (json[i].change_type == "date") {
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 + '"">';
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 + '"">';
pdfChange += '<span class="tip" id="span' + i + '"> </span><br/>';
}
......@@ -422,7 +439,7 @@ function changePdfOptions(json, edit) {
}
pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;">';
pdfChange += '<input type="submit" value="Save and Continue">';
pdfChange += '<input id="saveButton" type="submit" onclick="setPreview(\'off\')" value="Save and Continue">';
pdfChange += '</form>';
......@@ -518,6 +535,8 @@ function changePdfOptions(json, edit) {
if ($("#changes").valid()) {
setSubmit('off');
$(tinymce.get()).each(function(i, el) {
if (el.id)
......@@ -608,7 +627,7 @@ function returnOptions(form, preview) {
var content = [];
for (e = 0; e < form[0].length; ++e) {
if(form[0][e].type != 'button'){
if (form[0][e].type != 'button') {
content.push(JSON.stringify(form[0][e].value));
}
......@@ -648,8 +667,11 @@ function returnOptions(form, preview) {
}
jsonReturn += ' ]}';
if (preview == false) { url = 'update';
} else { url = 'preview';}
if (preview == false) {
url = 'update';
} else {
url = 'preview';
}
......@@ -663,7 +685,7 @@ function returnOptions(form, preview) {
success: function(data) {
finalPdf(data, json)
finalPdf(data, json);
},
error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
......@@ -693,36 +715,39 @@ function finalPdf(data, json) {
$("#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();
$('#pdfPreviewInner').show()
var strVar2 = ""
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>';
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>';
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)"
color: "rgba(0, 0, 0, 0.9)",
image: pluginUrl+"/wp-content/plugins/pdf-customizer-plugin/public/js/loading.gif",
});
$('#Canvas').LoadingOverlay("show");
$('#Canvas').delay(500).queue(function() {
$('#Canvas').delay(600).queue(function() {
$(this).css("background-image", "");
});
setTimeout(function() {
$('#Canvas').LoadingOverlay("hide", true);
}, 500);
}, 600);
if (preview == false) {
$('#controls').show();
setSubmit('on');
}
......@@ -733,7 +758,7 @@ function finalPdf(data, json) {
$('#changes').show();
$("#Canvas").show();
$("#Canvas").css('z-index', '10');
setTinyMce();
});
......@@ -742,6 +767,6 @@ function finalPdf(data, json) {
});
});
});
}
\ No newline at end of file
......