f24e58e8 by Jeff Balicki

commit

1 parent 083324e1
......@@ -132,7 +132,13 @@ function HideBoxwithdate() {
}
function fullScreen() {
jQuery(document).ready(function($) {
$('#bbox').toggleClass('fullscreen');
//$('#bbox').animate({ width: "100%", height: "100%", position: "fixed", top: "0", left: "0" });
});
}
function getJson(user_id) {
jQuery(document).ready(function($) {
$.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) {
......@@ -150,6 +156,7 @@ function getOneJson(id) {
// Get the element with id summary and set the inner text to the result.
var json = JSON.stringify(data);
edit = false;
changePdfOptions(json,edit);
});
});
......@@ -163,7 +170,7 @@ function getBackOneJson(id) {
edit = true;
changePdfOptions(json,edit);
changePdfOptions(json,edi);
});
});
}
......@@ -182,12 +189,22 @@ function pickPdfFromList(json) {
pdflist += "</div>";
}
strVar += ' <div id="callout" class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>';
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>';
strVar += '</div></div></div><div id="contentAreaOver"></div> ';
document.getElementById('contentArea').innerHTML = strVar;
});
}
function setPreview(){
document.getElementById("preview").checked = true;
}
function changePdfOptions(json, edit) {
jQuery(function($) {
if(edit == false){
......@@ -195,7 +212,6 @@ function changePdfOptions(json, edit) {
}
console.log( json );
json = JSON.parse(json);
......@@ -263,7 +279,7 @@ function changePdfOptions(json, edit) {
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-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:' + imageWidth + 'px ' + imageHeight + 'px"></div>';
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>';
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) {
......@@ -309,16 +325,20 @@ 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="submit" value="Save and Continue">';
pdfChange += '</form>';
strVar2 += '';
strVar2 += '';
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>';
strVar2 += pdflist + '<div id="changesColumn" style="height:'+windowHBG+'px;" class="column" >' + pdfChange + '<div id="tezingLogo"></div></div><div id="pdfFooter"></div></div>';
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>';
document.getElementById('contentAreaOver').innerHTML = strVar2;
if(edit == false){
$("#contentAreaOver").slideToggle();
$('#google_drive').slideToggle();
......@@ -410,6 +430,80 @@ function changePdfOptions(json, edit) {
$("#changes").submit(function(e) {
e.preventDefault();
if($('#preview').prop('checked')==true){
$(tinymce.get()).each(function(i, el) {
if (el.id)
document.getElementById(el.id).value = el.getContent();
$('#changes').hide();
tinymce.get(el.id).remove();
});
var ids =[];
if(edit == true){
$("#changes input[type=file]").each(function() {
if($(this).get(0).files.length == 0 ){
document.getElementById(this.id).remove();
}else{
console.log("hidden"+this.id);
document.getElementById("hidden"+this.id).remove();
}
});}
var form = $("#changes");
//console.log(form);
returnfileOptions(imagefiles, form, preview = true);
var tinymces = tinymce.init({
selector: '.textarea',
entity_encoding: "raw",
menubar: false,
toolbar: ' bold italic',
remove_linebreaks: false,
remove_trailing_brs: false,
init_instance_callback: function(editor) {
var editorDoc = document.getElementById(editor.id + '_ifr');
var editorDocContent = editorDoc.contentDocument;
editorDoc.style.border = "0px solid #131212";
editorDocContent.body.style.backgroundColor = "#131212";
editorDocContent.body.style.color = "#ccc";
},
setup: function(editor) {
editor.on('focus', function(e) {
//console.log(editor.id);
var editorDoc = document.getElementById(editor.id + '_ifr');
var editorDocContent = editorDoc.contentDocument;
editorDoc.style.border = "2px solid #F7A800";
$('#' + editor.id).trigger("onfocus");
//$(this).css('border', '2px solid #F7A800 !important');
});
editor.on('blur', function(e) {
//console.log('out' + editor.id);
var editorDoc = document.getElementById(editor.id + '_ifr');
var editorDocContent = editorDoc.contentDocument;
editorDoc.style.border = "2px solid #131212";
//$(this).css('border', '0px solid #F7A800 !important');
HideBox();
});
}
});
document.getElementById("preview").checked = false;
}else{
if ($("#changes").valid()) {
......@@ -430,7 +524,7 @@ function changePdfOptions(json, edit) {
document.getElementById(this.id).remove();
}else{
console.log("hidden"+this.id);
//console.log("hidden"+this.id);
document.getElementById("hidden"+this.id).remove();
......@@ -439,11 +533,12 @@ function changePdfOptions(json, edit) {
var form = $("#changes");
//console.log(form);
returnfileOptions(imagefiles, form);
returnfileOptions(imagefiles, form, preview = false);
return false;
} else {
return false;
}
}
});
});
......@@ -451,7 +546,7 @@ function changePdfOptions(json, edit) {
}
function returnfileOptions(files, form) {
function returnfileOptions(files, form, preview) {
jQuery(function($) {
var data = new FormData();
......@@ -470,7 +565,7 @@ function returnfileOptions(files, form) {
contentType: false, // Set content type to false as jQuery will tell the server its a query string request
success: function(data, textStatus, jqXHR) {
if (typeof data.error === 'undefined') {
returnOptions(form);
returnOptions(form , preview);
} else {
// Handle errors here
......@@ -490,9 +585,11 @@ function returnfileOptions(files, form) {
function returnOptions(form) {
function returnOptions(form, preview) {
jQuery(function($) {
$.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) {
// Get the element with id summary and set the inner text to the result.
......@@ -502,6 +599,7 @@ function returnOptions(form) {
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":['
var e = 1;
var o = 1;
for (i = 0; i < json.length; ++i) {
......@@ -510,30 +608,45 @@ function returnOptions(form) {
//console.log(form[0][e].value);
//console.log(json[i].label+' '+json[i].order);
if(content != '""') {
if (o !== 1) {
jsonReturn += ',';
}
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/"}';
++o
if (i < json.length - 1) {
jsonReturn += ',';
}
};
++e
}
jsonReturn += ' ]}';
var windowWidth = 0.75 * $("#wrapper").width();
var windowHeight = 0.75 * $("#wrapper").height();
var windowWidth = 0.90 * $(".layout-grid").width();
var windowHeight = 0.90 * $(".layout-grid").height();
var windowHBG = 0.923 * $(window).height();
var pwidth = parseInt(json[0].pwidth);
var pheight = parseInt(json[0].pheight);
//console.log( windowWidth+' '+windowHeight);
//console.log( pwidth+' '+pheight);
if(pwidth > pheight){
//console.log('wide')
var scaleImage = windowWidth / pwidth;
var imageHeight = pheight * scaleImage;
var imageWidth = windowWidth;
var imgLeft = 0;
var imgTop = 25;
var imgTop = 40;
}else{
var scaleImage = windowHeight / pheight;
var imageHeight = windowHeight;
......@@ -541,13 +654,15 @@ function returnOptions(form) {
var imgLeft = 30;
var imgTop = 2;
}
// console.log(jsonReturn);
// console.log(jsonReturn);
$("#Canvas").fadeOut(60000000);
$("#Canvas").hide();
$('#controls').show();
$('#pdfPreviewInner').show();
......@@ -568,12 +683,14 @@ function returnOptions(form) {
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>';
//<i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a>
document.getElementById('pdfPreview').innerHTML = strVar2;
$('#changes').replaceWith('<div id="changes"></div>')
document.getElementById('pdfPreviewInner').innerHTML = strVar2;
// $('#changes').replaceWith('<div id="changes"></div>')
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('changes').innerHTML = strVar3;
document.getElementById('controls').innerHTML = strVar3;
// console.log(data);
console.log(imageWidth);
console.log(imageHeight);
// $('#changes').show();
......@@ -582,7 +699,14 @@ function returnOptions(form) {
$('#editMe').click(function() {
$("#google_drive").hide();
getBackOneJson(data);
//getBackOneJson(data,jsonForEdit);
$('#controls').hide();
$('#changes').show();
$('#pdfPreviewInner').hide();
$("#Canvas").show();
});
$('#downloadMe').click(function() {
$(".closeEditer").click();
});
......