11ddae0a by Jeff Balicki

more object

1 parent be58a396
1 //var pluginUrl = window.location.protocol + '//' + window.location.host + '/commonwell'; 1 var pluginUrl = window.location.protocol + '//' + window.location.host + '/commonwell';
2 //var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; 2 var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
3 3
4 4
5 var pluginUrl = window.location.protocol + '//' + window.location.host; 5 //var pluginUrl = "http://contact.gotenzing.com";
6 var pdf_customizer = "https://pdf-customizer.synapsus.co"; 6 //var pdf_customizer = "http://pdf-customizer.synapsus.co";
7 7
8 8
9 var imageHeight = ""; 9 var imageHeight = "";
10 var imageWidth = ""; 10 var imageWidth = "";
11 var edit = false; 11 var edit = false;
12 12 var setpage;
13 var imgLeft;
14 var imgTop;
15 var windowHBG;
16 var PageChangeOn;
13 17
14 18
15 function getAuth() { 19 function getAuth() {
...@@ -67,7 +71,7 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { ...@@ -67,7 +71,7 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
67 jQuery(document).ready(function($) { 71 jQuery(document).ready(function($) {
68 $('span').hide(); 72 $('span').hide();
69 $('#span' + count).show(); 73 $('#span' + count).show();
70 // $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")"); 74 // $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")");
71 75
72 var Qc = document.getElementById("Canvas"); 76 var Qc = document.getElementById("Canvas");
73 var Qctx = Qc.getContext("2d"); 77 var Qctx = Qc.getContext("2d");
...@@ -90,19 +94,22 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { ...@@ -90,19 +94,22 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) {
90 ctx.lineWidth = 2; 94 ctx.lineWidth = 2;
91 ctx.strokeStyle = $('.callout').css("background-color") 95 ctx.strokeStyle = $('.callout').css("background-color")
92 ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke(); 96 ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke();
93 97 console.log(PageChangeOn , setpage);
98 if(PageChangeOn != setpage ){
99 document.getElementById("preview").checked = true;
100 $('#changes').trigger('submit');
101 }
102
94 }); 103 });
104
105 setpage = PageChangeOn;
95 } 106 }
96 107
97 108
98 function findUserInfoMatch(data) {
99 109
100 110
101 111
102 } 112 function HideBox(kind,page) {
103
104
105 function HideBox(kind) {
106 113
107 jQuery(document).ready(function($) { 114 jQuery(document).ready(function($) {
108 $('span').hide(); 115 $('span').hide();
...@@ -111,6 +118,7 @@ function HideBox(kind) { ...@@ -111,6 +118,7 @@ function HideBox(kind) {
111 var Qctx = Qc.getContext("2d"); 118 var Qctx = Qc.getContext("2d");
112 Qctx.clearRect(0, 0, Qc.width, Qc.height); 119 Qctx.clearRect(0, 0, Qc.width, Qc.height);
113 Qctx.restore(); 120 Qctx.restore();
121
114 if (kind != 'file') { 122 if (kind != 'file') {
115 document.getElementById("preview").checked = true; 123 document.getElementById("preview").checked = true;
116 $('#changes').trigger('submit'); 124 $('#changes').trigger('submit');
...@@ -120,12 +128,13 @@ function HideBox(kind) { ...@@ -120,12 +128,13 @@ function HideBox(kind) {
120 128
121 } 129 }
122 130
123 function HideBoxwithdate() { 131 function HideBoxwithdate(kind,page) {
124 jQuery(document).ready(function($) { 132 jQuery(document).ready(function($) {
125 var Qc = document.getElementById("Canvas"); 133 var Qc = document.getElementById("Canvas");
126 var Qctx = Qc.getContext("2d"); 134 var Qctx = Qc.getContext("2d");
127 Qctx.clearRect(0, 0, Qc.width, Qc.height); 135 Qctx.clearRect(0, 0, Qc.width, Qc.height);
128 Qctx.restore(); 136 Qctx.restore();
137
129 138
130 139
131 }); 140 });
...@@ -133,6 +142,18 @@ function HideBoxwithdate() { ...@@ -133,6 +142,18 @@ function HideBoxwithdate() {
133 142
134 } 143 }
135 144
145 function setPage(page) {
146
147 setpage = page;
148
149 }
150
151 function setPageChangeOn(page) {
152
153 PageChangeOn = page;
154
155 }
156
136 function fullScreen() { 157 function fullScreen() {
137 jQuery(document).ready(function($) { 158 jQuery(document).ready(function($) {
138 $('#bbox').toggleClass('fullscreen'); 159 $('#bbox').toggleClass('fullscreen');
...@@ -202,20 +223,50 @@ function pickPdfFromList(json) { ...@@ -202,20 +223,50 @@ function pickPdfFromList(json) {
202 } 223 }
203 224
204 225
226 function setTinyMce() {
227 jQuery(document).ready(function($) {
228 var tinymces = tinymce.init({
229 selector: '.textarea',
230 entity_encoding: "raw",
231 menubar: false,
232 toolbar: ' bold italic',
233 remove_linebreaks: false,
234 remove_trailing_brs: false,
235 init_instance_callback: function(editor) {
236 var editorDoc = document.getElementById(editor.id + '_ifr');
237 var editorDocContent = editorDoc.contentDocument;
238 editorDoc.style.border = "0px solid #131212";
239 editorDocContent.body.style.backgroundColor = "#131212";
240 editorDocContent.body.style.color = "#ccc";
241 },
242 setup: function(editor) {
243 editor.on('focus', function(e) {
244 //console.log(editor.id);
205 245
246 var editorDoc = document.getElementById(editor.id + '_ifr');
247 var editorDocContent = editorDoc.contentDocument;
248 editorDoc.style.border = "2px solid #0096D6";
206 249
207 function changePdfOptions(json, edit) { 250 $('#' + editor.id).trigger("onfocus");
208 jQuery(function($) { 251 //$(this).css('border', '2px solid #F7A800 !important');
209 if (edit == false) { 252 });
210 $('#contentAreaOver').hide(); 253 editor.on('blur', function(e) {
211 } 254 //console.log('out' + editor.id);
212 255 var editorDoc = document.getElementById(editor.id + '_ifr');
213 256 var editorDocContent = editorDoc.contentDocument;
257 editorDoc.style.border = "0px solid #131212";
214 258
215 json = JSON.parse(json); 259 //$(this).css('border', '0px solid #F7A800 !important');
260 HideBox();
261 });
262 }
263 });
216 264
217 $(document).ready(function() { 265 });
266 }
218 267
268 function setDatePicker() {
269 jQuery(document).ready(function($) {
219 270
220 $("#changescontentdate").datepicker({ 271 $("#changescontentdate").datepicker({
221 plugins: "tabfocus", 272 plugins: "tabfocus",
...@@ -232,6 +283,71 @@ function changePdfOptions(json, edit) { ...@@ -232,6 +283,71 @@ function changePdfOptions(json, edit) {
232 283
233 }); 284 });
234 285
286
287 });
288 }
289
290 function getPdfSize(json) {
291
292 jQuery(document).ready(function($) {
293 json = JSON.parse(json);
294 //console.log(json);
295
296 var windowWidth = 0.90 * $(".layout-grid").width();
297 var windowHeight = 0.90 * $(".layout-grid").height();
298
299
300 vwindowHBG = 0.923 * $(window).height();
301 pwidth = parseInt(json[0].pwidth);
302 pheight = parseInt(json[0].pheight);
303
304 if (pwidth > pheight) {
305 var scaleImage = windowWidth / pwidth;
306 vimageHeight = pheight * scaleImage;
307 vimageWidth = windowWidth;
308 vimgLeft = 0;
309 vimgTop = 40;
310 } else {
311 var scaleImage = windowHeight / pheight;
312 vimageHeight = windowHeight;
313 vimageWidth = pwidth * scaleImage;
314 vimgLeft = 30;
315 vimgTop = 2;
316 }
317
318 setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
319
320 });
321
322 }
323
324 function setPdfSize(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth) {
325 console.log(vimgLeft, vimgTop, vwindowHBG, vimageHeight, vimageWidth);
326 imgLeft = vimgLeft;
327 imgTop = vimgTop;
328 windowHBG = vwindowHBG;
329 imageHeight = vimageHeight;
330 imageWidth = vimageWidth;
331
332 }
333
334
335 function changePdfOptions(json, edit) {
336 getPdfSize(json);
337 jQuery(function($) {
338 if (edit == false) {
339 $('#contentAreaOver').hide();
340 }
341
342
343
344 json = JSON.parse(json);
345
346
347 $(document).ready(function() {
348
349 setDatePicker();
350
235 $("#changes").validate({ 351 $("#changes").validate({
236 errorPlacement: function(error, element) { 352 errorPlacement: function(error, element) {
237 var isFile = $(element).attr('type') == 'file'; 353 var isFile = $(element).attr('type') == 'file';
...@@ -249,31 +365,7 @@ function changePdfOptions(json, edit) { ...@@ -249,31 +365,7 @@ function changePdfOptions(json, edit) {
249 var pdflist = ""; 365 var pdflist = "";
250 var pdfChange = ""; 366 var pdfChange = "";
251 var f = 0; 367 var f = 0;
252 368
253 var windowWidth = 0.90 * $(".layout-grid").width();
254 var windowHeight = 0.90 * $(".layout-grid").height();
255
256
257 var windowHBG = 0.923 * $(window).height();
258 var pwidth = parseInt(json[0].pwidth);
259 var pheight = parseInt(json[0].pheight);
260
261 //console.log( windowWidth+' '+windowHeight);
262 //console.log( pwidth+' '+pheight);
263 if (pwidth > pheight) {
264 //console.log('wide')
265 var scaleImage = windowWidth / pwidth;
266 var imageHeight = pheight * scaleImage;
267 var imageWidth = windowWidth;
268 var imgLeft = 0;
269 var imgTop = 40;
270 } else {
271 var scaleImage = windowHeight / pheight;
272 var imageHeight = windowHeight;
273 var imageWidth = pwidth * scaleImage;
274 var imgLeft = 30;
275 var imgTop = 2;
276 }
277 369
278 370
279 // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight); 371 // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight);
...@@ -283,32 +375,34 @@ function changePdfOptions(json, edit) { ...@@ -283,32 +375,34 @@ function changePdfOptions(json, edit) {
283 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>'; 375 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>'; 376 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 + '">'; 377 pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">';
378 setPage(json[0].pages);
286 for (i = 0; i < json.length; ++i) { 379 for (i = 0; i < json.length; ++i) {
287 var example = json[0].folder + '/' + json[i].example; 380 var example = json[0].folder + '/' + json[i].example;
288 381
289 if (json[i].change_type == "textflow") { 382 if (json[i].change_type == "textflow") {
290 pdfChange += json[i].names + ': <textarea onfocus="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>'; 383 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>';
291 ++f; 384 ++f;
385
292 pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; 386 pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>';
293 } 387 }
294 if (json[i].change_type == "text") { 388 if (json[i].change_type == "text") {
295 pdfChange += json[i].names + ': <input 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="changescontent[' + i + ']" type="text" class="required" name="content[' + i + ']" value="' + json[i].content + '"">'; 389 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 + '"">';
296 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; 390 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
297 } 391 }
298 if (json[i].change_type == "img") { 392 if (json[i].change_type == "img") {
299 if (edit == true) { 393 if (edit == true) {
300 pdfChange += '<input value="' + json[i].content + '" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >'; 394 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(\'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>'; 395 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>';
302 396
303 } else { 397 } else {
304 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>'; 398 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>';
305 } 399 }
306 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; 400 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
307 401
308 } 402 }
309 if (json[i].change_type == "date") { 403 if (json[i].change_type == "date") {
310 pdfChange += json[i].names + ': <input onfocusout="HideBoxwithdate()" onfocus="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 + '"">'; 404 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 + '"">';
311 pdfChange += '<span class="tip" id="span' + i + '"> </span><br/>'; 405 pdfChange += '<span class="tip" id="span' + i + '"> </span><br/>';
312 406
313 } 407 }
314 if (json[i].change_type == "user") { 408 if (json[i].change_type == "user") {
...@@ -320,8 +414,8 @@ function changePdfOptions(json, edit) { ...@@ -320,8 +414,8 @@ function changePdfOptions(json, edit) {
320 } else { 414 } else {
321 var content_string = json[i].content; 415 var content_string = json[i].content;
322 } 416 }
323 pdfChange += json[i].names + ': <input 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="changescontent[' + i + ']" type="text" class="required" name="content[' + i + ']" value="' + content_string + '"">'; 417 pdfChange += json[i].names + ': <input 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="changescontent[' + i + ']" type="text" class="required" name="content[' + i + ']" value="' + content_string + '"">';
324 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; 418 pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>';
325 419
326 } 420 }
327 421
...@@ -335,7 +429,7 @@ function changePdfOptions(json, edit) { ...@@ -335,7 +429,7 @@ function changePdfOptions(json, edit) {
335 strVar2 += ''; 429 strVar2 += '';
336 strVar2 += ''; 430 strVar2 += '';
337 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>'; 431 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>';
338 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>'; 432 strVar2 += pdflist + '<div id="changesColumn" style="height:' + windowHBG + 'px;" class="column" >' + pdfChange + '<div id="tezingLogo"></div><div id="controls"></div></div></div>';
339 433
340 document.getElementById('contentAreaOver').innerHTML = strVar2; 434 document.getElementById('contentAreaOver').innerHTML = strVar2;
341 435
...@@ -347,43 +441,8 @@ function changePdfOptions(json, edit) { ...@@ -347,43 +441,8 @@ function changePdfOptions(json, edit) {
347 //document.getElementById('google_drive').innerHTML = " "; 441 //document.getElementById('google_drive').innerHTML = " ";
348 } 442 }
349 443
350 444 setTinyMce();
351 var tinymces = tinymce.init({ 445
352 selector: '.textarea',
353 entity_encoding: "raw",
354 menubar: false,
355 toolbar: ' bold italic',
356 remove_linebreaks: false,
357 remove_trailing_brs: false,
358 init_instance_callback: function(editor) {
359 var editorDoc = document.getElementById(editor.id + '_ifr');
360 var editorDocContent = editorDoc.contentDocument;
361 editorDoc.style.border = "0px solid #131212";
362 editorDocContent.body.style.backgroundColor = "#131212";
363 editorDocContent.body.style.color = "#ccc";
364 },
365 setup: function(editor) {
366 editor.on('focus', function(e) {
367 //console.log(editor.id);
368
369 var editorDoc = document.getElementById(editor.id + '_ifr');
370 var editorDocContent = editorDoc.contentDocument;
371 editorDoc.style.border = "2px solid #F7A800";
372
373 $('#' + editor.id).trigger("onfocus");
374 //$(this).css('border', '2px solid #F7A800 !important');
375 });
376 editor.on('blur', function(e) {
377 //console.log('out' + editor.id);
378 var editorDoc = document.getElementById(editor.id + '_ifr');
379 var editorDocContent = editorDoc.contentDocument;
380 editorDoc.style.border = "2px solid #131212";
381
382 //$(this).css('border', '0px solid #F7A800 !important');
383 HideBox();
384 });
385 }
386 });
387 446
388 $('.closeEditer').click(function() { 447 $('.closeEditer').click(function() {
389 $("#contentAreaOver").slideToggle(function() { 448 $("#contentAreaOver").slideToggle(function() {
...@@ -442,68 +501,13 @@ function changePdfOptions(json, edit) { ...@@ -442,68 +501,13 @@ function changePdfOptions(json, edit) {
442 if (el.id) 501 if (el.id)
443 document.getElementById(el.id).value = el.getContent(); 502 document.getElementById(el.id).value = el.getContent();
444 //$('#changes').hide(); 503 //$('#changes').hide();
445 tinymce.get(el.id).remove(); 504
446 }); 505 });
447 506
448 507
449 var ids = []; 508 var ids = [];
450 if (edit == true) {
451 $("#changes input[type=file]").each(function() {
452 if ($(this).get(0).files.length == 0) {
453
454
455 document.getElementById(this.id).remove();
456 } else {
457 console.log("hidden" + this.id);
458 document.getElementById("hidden" + this.id).remove();
459
460
461 }
462 });
463 }
464 var form = $("#changes"); 509 var form = $("#changes");
465 //console.log(form);
466
467 returnfileOptions(imagefiles, form, preview = true); 510 returnfileOptions(imagefiles, form, preview = true);
468
469
470
471 var tinymces = tinymce.init({
472 selector: '.textarea',
473 entity_encoding: "raw",
474 menubar: false,
475 toolbar: ' bold italic',
476 remove_linebreaks: false,
477 remove_trailing_brs: false,
478 init_instance_callback: function(editor) {
479 var editorDoc = document.getElementById(editor.id + '_ifr');
480 var editorDocContent = editorDoc.contentDocument;
481 editorDoc.style.border = "0px solid #131212";
482 editorDocContent.body.style.backgroundColor = "#131212";
483 editorDocContent.body.style.color = "#ccc";
484 },
485 setup: function(editor) {
486 editor.on('focus', function(e) {
487 //console.log(editor.id);
488
489 var editorDoc = document.getElementById(editor.id + '_ifr');
490 var editorDocContent = editorDoc.contentDocument;
491 editorDoc.style.border = "2px solid #F7A800";
492
493 $('#' + editor.id).trigger("onfocus");
494 //$(this).css('border', '2px solid #F7A800 !important');
495 });
496 editor.on('blur', function(e) {
497 //console.log('out' + editor.id);
498 var editorDoc = document.getElementById(editor.id + '_ifr');
499 var editorDocContent = editorDoc.contentDocument;
500 editorDoc.style.border = "2px solid #131212";
501
502 //$(this).css('border', '0px solid #F7A800 !important');
503 HideBox();
504 });
505 }
506 });
507 $("#changes").validate().cancelSubmit = true; 511 $("#changes").validate().cancelSubmit = true;
508 512
509 513
...@@ -539,6 +543,7 @@ function changePdfOptions(json, edit) { ...@@ -539,6 +543,7 @@ function changePdfOptions(json, edit) {
539 }); 543 });
540 } 544 }
541 var form = $("#changes"); 545 var form = $("#changes");
546
542 //console.log(form); 547 //console.log(form);
543 548
544 returnfileOptions(imagefiles, form, preview = false); 549 returnfileOptions(imagefiles, form, preview = false);
...@@ -599,6 +604,18 @@ function returnOptions(form, preview) { ...@@ -599,6 +604,18 @@ function returnOptions(form, preview) {
599 604
600 605
601 $.getJSON(pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { 606 $.getJSON(pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) {
607
608 var content = [];
609
610 for (e = 0; e < form[0].length; ++e) {
611 if(form[0][e].type != 'button'){
612 content.push(JSON.stringify(form[0][e].value));
613
614 }
615 }
616
617
618
602 // Get the element with id summary and set the inner text to the result. 619 // Get the element with id summary and set the inner text to the result.
603 620
604 var json = dataReturnd; 621 var json = dataReturnd;
...@@ -606,61 +623,70 @@ function returnOptions(form, preview) { ...@@ -606,61 +623,70 @@ function returnOptions(form, preview) {
606 623
607 624
608 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":[' 625 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":['
609 var e = 1; 626
610 var o = 1; 627 var o = 1;
611 for (i = 0; i < json.length; ++i) { 628 var e = 1;
612 629
613 630
631 for (i = 0; i < json.length; ++i) {
614 var style = JSON.stringify(json[i].style); 632 var style = JSON.stringify(json[i].style);
615 var content = JSON.stringify(form[0][e].value); 633
616 //console.log(form[0][e].value); 634 if (content[e] != '""') {
617 //console.log(json[i].label+' '+json[i].order);
618
619 if (content != '""') {
620 if (o !== 1) { 635 if (o !== 1) {
621 jsonReturn += ','; 636 jsonReturn += ',';
622 637
623 } 638 }
624 639
625 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/"}'; 640 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[e] + ', "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/"}';
626 641
627 ++o 642 ++o
628 643
629 }; 644 };
630 ++e 645
631 646 ++e
632 647
633 } 648 }
634 jsonReturn += ' ]}'; 649 jsonReturn += ' ]}';
635 650
651 if (preview == false) { url = 'update';
652 } else { url = 'preview';}
636 653
637 654
638 655
639 var windowWidth = 0.90 * $(".layout-grid").width(); 656 $.ajax({
640 var windowHeight = 0.90 * $(".layout-grid").height(); 657 url: "" + pdf_customizer + "/api/" + url,
658 type: "POST",
659 dataType: 'json',
660 data: jsonReturn,
661 contentType: "application/json",
662 CrossDomain: true,
641 663
664 success: function(data) {
642 665
643 var windowHBG = 0.923 * $(window).height(); 666 finalPdf(data, json)
644 var pwidth = parseInt(json[0].pwidth); 667
645 var pheight = parseInt(json[0].pheight); 668 },
669 error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
670 alert(xhr.status);
671 document.getElementById('pdfPreview').innerHTML = xhr.responseText;
672
673 }
674
675
676 });
677
678
679 });
680 });
681 }
682
683 function finalPdf(data, json) {
684
685 jQuery(function($) {
686
687
688
646 689
647 //console.log( windowWidth+' '+windowHeight);
648 //console.log( pwidth+' '+pheight);
649 if (pwidth > pheight) {
650 //console.log('wide')
651 var scaleImage = windowWidth / pwidth;
652 var imageHeight = pheight * scaleImage;
653 var imageWidth = windowWidth;
654 var imgLeft = 0;
655 var imgTop = 40;
656 } else {
657 var scaleImage = windowHeight / pheight;
658 var imageHeight = windowHeight;
659 var imageWidth = pwidth * scaleImage;
660 var imgLeft = 30;
661 var imgTop = 2;
662 var url;
663 }
664 // console.log(jsonReturn); 690 // console.log(jsonReturn);
665 691
666 if (preview == false) { 692 if (preview == false) {
...@@ -676,20 +702,8 @@ function returnOptions(form, preview) { ...@@ -676,20 +702,8 @@ function returnOptions(form, preview) {
676 $('#controls').hide(); 702 $('#controls').hide();
677 $('#pdfPreviewInner').show(); 703 $('#pdfPreviewInner').show();
678 704
679
680
681 $.ajax({
682 url: "" + pdf_customizer + "/api/" + url,
683 type: "POST",
684 dataType: 'json',
685 data: jsonReturn,
686 contentType: "application/json",
687 CrossDomain: true,
688
689 success: function(data) {
690
691 var strVar2 = "" 705 var strVar2 = ""
692 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>'; 706 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>';
693 document.getElementById('pdfPreviewInner').innerHTML = strVar2; 707 document.getElementById('pdfPreviewInner').innerHTML = strVar2;
694 708
695 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>'; 709 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>';
...@@ -699,13 +713,13 @@ function returnOptions(form, preview) { ...@@ -699,13 +713,13 @@ function returnOptions(form, preview) {
699 color: "rgba(0, 0, 0, 0.9)" 713 color: "rgba(0, 0, 0, 0.9)"
700 }); 714 });
701 $('#Canvas').LoadingOverlay("show"); 715 $('#Canvas').LoadingOverlay("show");
702 $('#Canvas').delay(600).queue(function() { 716 $('#Canvas').delay(500).queue(function() {
703 $(this).css("background-image", ""); 717 $(this).css("background-image", "");
704 }); 718 });
705 719
706 setTimeout(function() { 720 setTimeout(function() {
707 $('#Canvas').LoadingOverlay("hide", true); 721 $('#Canvas').LoadingOverlay("hide", true);
708 }, 600); 722 }, 500);
709 723
710 if (preview == false) { 724 if (preview == false) {
711 $('#controls').show(); 725 $('#controls').show();
...@@ -719,22 +733,15 @@ function returnOptions(form, preview) { ...@@ -719,22 +733,15 @@ function returnOptions(form, preview) {
719 $('#changes').show(); 733 $('#changes').show();
720 $("#Canvas").show(); 734 $("#Canvas").show();
721 $("#Canvas").css('z-index', '10'); 735 $("#Canvas").css('z-index', '10');
736
737
722 }); 738 });
723 739
724 $('#downloadMe').click(function() { 740 $('#downloadMe').click(function() {
725 $(".closeEditer").click(); 741 $(".closeEditer").click();
726 }); 742 });
727 },
728 error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
729 alert(xhr.status);
730 document.getElementById('pdfPreview').innerHTML = xhr.responseText;
731 743
732 }
733 744
745 });
734 746
735 });
736
737
738 });
739 });
740 }
...\ No newline at end of file ...\ No newline at end of file
747 }
......