design changes
Showing
2 changed files
with
313 additions
and
315 deletions
| ... | @@ -181,9 +181,46 @@ try { | ... | @@ -181,9 +181,46 @@ try { |
| 181 | $num_optlist = "fillcolor={".$fontColor." } position={".$fontAlignment."} boxsize={" . $textwidth." ".$textheight . "} fontsize=".$fontSize." ".$fitm. " "; | 181 | $num_optlist = "fillcolor={".$fontColor." } position={".$fontAlignment."} boxsize={" . $textwidth." ".$textheight . "} fontsize=".$fontSize." ".$fitm. " "; |
| 182 | 182 | ||
| 183 | $p->fit_textline($textline, $textLRight, $textLUp, $num_optlist); | 183 | $p->fit_textline($textline, $textLRight, $textLUp, $num_optlist); |
| 184 | } | 184 | } else if ($row->change_type == 'date') { |
| 185 | 185 | $yoff = 50; | |
| 186 | else if ($row->change_type == 'img') { | 186 | //Get font var from row |
| 187 | |||
| 188 | $textline = $row->content; | ||
| 189 | $textLUp = $row->locationUp; | ||
| 190 | $textwidth = $row->width; | ||
| 191 | $textheight = $row->height; | ||
| 192 | $textLRight = $row->locationRight; | ||
| 193 | $fontStyles = unserialize($row->style); | ||
| 194 | $fitmethod = $fontStyles["fitmethod"]; | ||
| 195 | |||
| 196 | $fontAlignment = $fontStyles["alignment"]; | ||
| 197 | $fontFamily = $fontStyles["font-family"]; | ||
| 198 | $fontSize = $fontStyles["font-size"]; | ||
| 199 | if(isset($fontStyles["font-color"])) { | ||
| 200 | $fontColor = $fontStyles["font-color"]; | ||
| 201 | }else{ | ||
| 202 | $fontColor = 'cmyk 0.75 0.68 0.67 0.90'; | ||
| 203 | |||
| 204 | } | ||
| 205 | /// Load and insert text and font | ||
| 206 | |||
| 207 | $p->set_option("FontOutline={" . $fontFamily . "=" . $storagePath . $folder . "/" . $fontFamily . ".otf}"); | ||
| 208 | /* For PDFlib Lite: change "unicode" to "winansi" */ | ||
| 209 | $font = $p->load_font($fontFamily, "unicode", "embedding"); | ||
| 210 | if ($font == 0) { | ||
| 211 | die("Error: " . $p->get_errmsg()); | ||
| 212 | } | ||
| 213 | $p->setfont($font, $fontSize); | ||
| 214 | //$num_optlist = "fontname=".$fontFamily." fontsize=".$fontSize." encoding=unicode alignment=".$fontAlignment." fillcolor={".$fontColor." }"; | ||
| 215 | if($fitmethod == ''){$fitm =""; | ||
| 216 | }else{ $fitm = "fitmethod=".$fitmethod;} | ||
| 217 | |||
| 218 | $num_optlist = "fillcolor={".$fontColor." } position={".$fontAlignment."} boxsize={" . $textwidth." ".$textheight . "} fontsize=".$fontSize." ".$fitm. " "; | ||
| 219 | |||
| 220 | $p->fit_textline($textline, $textLRight, $textLUp, $num_optlist); | ||
| 221 | } | ||
| 222 | |||
| 223 | else if ($row->change_type == 'img') { | ||
| 187 | 224 | ||
| 188 | //Get image var from row | 225 | //Get image var from row |
| 189 | 226 | ... | ... |
| 1 | //var pluginUrl = "http://localhost:8888/Forms"; | 1 | //var pluginUrl = "http://localhost:8888/Forms"; |
| 2 | //var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; | 2 | //var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; |
| 3 | 3 | ||
| 4 | var pluginUrl = "http://contact.gotenzing.com"; | 4 | var pluginUrl = "http://contact.gotenzing.com"; |
| 5 | var pdf_customizer = "http://pdf-customizer.synapsus.co"; | 5 | var pdf_customizer = "http://pdf-customizer.synapsus.co"; |
| 6 | 6 | ||
| 7 | function getAuth() { | 7 | function getAuth() { |
| 8 | 8 | ||
| 9 | jQuery(document).ready(function($) { | 9 | jQuery(document).ready(function($) { |
| 10 | 10 | ||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | var settings = { | 11 | var settings = { |
| 15 | "async": true, | 12 | "async": true, |
| 16 | "crossDomain": true, | 13 | "crossDomain": true, |
| 17 | "url": "" + pdf_customizer + "/api/authenticate", | 14 | "url": "" + pdf_customizer + "/api/authenticate", |
| 18 | "method": "POST", | 15 | "method": "POST", |
| 19 | |||
| 20 | "processData": false, | 16 | "processData": false, |
| 21 | "contentType": false, | 17 | "contentType": false, |
| 22 | "mimeType": "multipart/form-data", | 18 | "mimeType": "multipart/form-data", |
| ... | @@ -34,14 +30,10 @@ | ... | @@ -34,14 +30,10 @@ |
| 34 | $.ajax(settings).done(function(response) { | 30 | $.ajax(settings).done(function(response) { |
| 35 | console.log(response); | 31 | console.log(response); |
| 36 | token = response; | 32 | token = response; |
| 37 | 33 | }); | |
| 38 | 34 | ||
| 39 | }); | 35 | }); |
| 40 | 36 | ||
| 41 | |||
| 42 | |||
| 43 | }); | ||
| 44 | |||
| 45 | } | 37 | } |
| 46 | 38 | ||
| 47 | 39 | ||
| ... | @@ -57,72 +49,80 @@ | ... | @@ -57,72 +49,80 @@ |
| 57 | $(".entry_block").mouseleave(function() { | 49 | $(".entry_block").mouseleave(function() { |
| 58 | $("#select" + id + "").addClass("focus"); | 50 | $("#select" + id + "").addClass("focus"); |
| 59 | }); | 51 | }); |
| 52 | }); | ||
| 53 | } | ||
| 60 | 54 | ||
| 61 | 55 | ||
| 56 | function ShowBox(pheight, pwidth, up, right, height, width, count, example) { | ||
| 62 | 57 | ||
| 63 | 58 | ||
| 64 | }); | 59 | jQuery(document).ready(function($) { |
| 65 | } | 60 | $('span').hide(); |
| 61 | $('#span' + count).show(); | ||
| 62 | $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")"); | ||
| 66 | 63 | ||
| 67 | function ShowBox(pheight, pwidth,up, right, height, width, count, example) { | 64 | var Qc = document.getElementById("Canvas"); |
| 65 | var Qctx = Qc.getContext("2d"); | ||
| 66 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | ||
| 67 | Qctx.restore(); | ||
| 68 | 68 | ||
| 69 | |||
| 70 | jQuery(document).ready(function($) { | ||
| 71 | $('span').hide(); | ||
| 72 | $('#span'+count).show(); | ||
| 73 | $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' +example+")"); | ||
| 74 | |||
| 75 | var Qc = document.getElementById("Canvas"); | ||
| 76 | var Qctx = Qc.getContext("2d"); | ||
| 77 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | ||
| 78 | Qctx.restore(); | ||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | var down = pheight - (up + height); | ||
| 83 | var scaleH = $("Canvas").height() / pheight ; | ||
| 84 | var scaleW = $("Canvas").width() / pwidth ; | ||
| 85 | var scaleDown = down * scaleH; | ||
| 86 | var scaleRight = right* scaleW; | ||
| 87 | var scalewidth = width * scaleW; | ||
| 88 | var scaleheight = height * scaleH; | ||
| 89 | |||
| 90 | var c = document.getElementById("Canvas"); | ||
| 91 | var ctx = c.getContext("2d"); | ||
| 92 | ctx.save(); | ||
| 93 | ctx.rect(scaleRight, scaleDown , scalewidth, scaleheight); | ||
| 94 | console.log(scaleRight, scaleDown , scalewidth, scaleheight); | ||
| 95 | console.log($("Canvas").height(), $("Canvas").width(), scaleW, scaleH); | ||
| 96 | ctx.stroke(); | ||
| 97 | //console.log(pheight, pwidth,up, right, height, width); | ||
| 98 | // console.log(myrect ) | ||
| 99 | 69 | ||
| 100 | 70 | ||
| 71 | var down = pheight - (up + height); | ||
| 72 | var scaleH = $("Canvas").height() / pheight; | ||
| 73 | var scaleW = $("Canvas").width() / pwidth; | ||
| 74 | var scaleDown = down * scaleH; | ||
| 75 | var scaleRight = right * scaleW; | ||
| 76 | var scalewidth = width * scaleW; | ||
| 77 | var scaleheight = height * scaleH; | ||
| 78 | |||
| 79 | var c = document.getElementById("Canvas"); | ||
| 80 | var ctx = c.getContext("2d"); | ||
| 81 | ctx.save(); | ||
| 82 | ctx.rect(scaleRight, scaleDown, scalewidth, scaleheight); | ||
| 83 | console.log(scaleRight, scaleDown, scalewidth, scaleheight); | ||
| 84 | console.log($("Canvas").height(), $("Canvas").width(), scaleW, scaleH); | ||
| 85 | ctx.stroke(); | ||
| 86 | //console.log(pheight, pwidth,up, right, height, width); | ||
| 87 | // console.log(myrect ) | ||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 | }); | ||
| 92 | |||
| 93 | } | ||
| 94 | |||
| 95 | |||
| 96 | function SetFocus(i) { | ||
| 97 | jQuery(document).ready(function($) { | ||
| 98 | $("label#focusButton"+i).css({"border": "2px solid #F7A800 !important"}); | ||
| 99 | console.log($("label#focusButton"+i)); | ||
| 101 | 100 | ||
| 102 | }); | 101 | }); |
| 103 | |||
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | 104 | ||
| 107 | function HideBox() { | 105 | function HideBox() { |
| 108 | jQuery(document).ready(function($) { | 106 | jQuery(document).ready(function($) { |
| 109 | $('span').hide(); | 107 | $('span').hide(); |
| 110 | |||
| 111 | var cnv = document.getElementById("Canvas"); | ||
| 112 | var ctx = cnv.getContext('2d'); // gets reference to canvas context | ||
| 113 | ctx.beginPath(); // clear existing drawing paths | ||
| 114 | ctx.save(); // store the current transformation matrix | ||
| 115 | 108 | ||
| 109 | var cnv = document.getElementById("Canvas"); | ||
| 110 | var ctx = cnv.getContext('2d'); // gets reference to canvas context | ||
| 111 | ctx.beginPath(); // clear existing drawing paths | ||
| 112 | ctx.save(); // store the current transformation matrix | ||
| 113 | }); | ||
| 116 | 114 | ||
| 117 | 115 | } | |
| 118 | //console.log(0, 0, $("Canvas").width(), $("Canvas").height()); | ||
| 119 | |||
| 120 | |||
| 121 | 116 | ||
| 117 | function HideBoxwithdate() { | ||
| 118 | jQuery(document).ready(function($) { | ||
| 119 | var cnv = document.getElementById("Canvas"); | ||
| 120 | var ctx = cnv.getContext('2d'); // gets reference to canvas context | ||
| 121 | ctx.beginPath(); // clear existing drawing paths | ||
| 122 | ctx.save(); // store the current transformation matrix | ||
| 123 | }); | ||
| 122 | 124 | ||
| 123 | }); | 125 | } |
| 124 | |||
| 125 | } | ||
| 126 | 126 | ||
| 127 | 127 | ||
| 128 | 128 | ||
| ... | @@ -178,9 +178,8 @@ | ... | @@ -178,9 +178,8 @@ |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | 180 | ||
| 181 | strVar += ' <div class="callout primary"><div class="row column"> <h1>Welcome to Synapsus Online PDF Editor</h1>'; | 181 | strVar += ' <div class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; |
| 182 | strVar += ' <p class="lead">Please pick a PDF</p> </div></div> <div class="row small-up-2 medium-up-3 large-up-4/>'; | 182 | strVar += ' '; |
| 183 | strVar += ' </div>'; | ||
| 184 | 183 | ||
| 185 | 184 | ||
| 186 | 185 | ||
| ... | @@ -194,339 +193,301 @@ | ... | @@ -194,339 +193,301 @@ |
| 194 | 193 | ||
| 195 | 194 | ||
| 196 | function changePdfOptions(json) { | 195 | function changePdfOptions(json) { |
| 197 | jQuery(function($) { | 196 | jQuery(function($) { |
| 198 | json = JSON.parse(json); | 197 | json = JSON.parse(json); |
| 199 | 198 | $(document).ready(function() { | |
| 199 | |||
| 200 | $("#changescontentdate").datepicker({ | ||
| 201 | plugins: "tabfocus", | ||
| 202 | changeMonth: true, | ||
| 203 | changeYear: true, | ||
| 204 | yearRange: '2015:2025', | ||
| 205 | dateFormat: 'DD MM dd yy', | ||
| 206 | minDate: 0, | ||
| 207 | defaultDate: null | ||
| 208 | }).on('change', function() { | ||
| 209 | $(this).valid(); // triggers the validation test | ||
| 210 | // '$(this)' refers to '$("#datepicker")' | ||
| 211 | }); | ||
| 200 | 212 | ||
| 213 | $("#changes").validate(); | ||
| 214 | }); | ||
| 201 | 215 | ||
| 202 | var strVar2 = ""; | ||
| 203 | 216 | ||
| 204 | 217 | ||
| 205 | var pdflist = ""; | 218 | var strVar2 = ""; |
| 206 | var pdfChange = ""; | 219 | |
| 207 | var f = 0; | ||
| 208 | |||
| 209 | if(json[0].pwidth > 300){ | ||
| 210 | var scaleImage = 300 / json[0].pwidth; | ||
| 211 | var imageHeight = json[0].pheight * scaleImage; | ||
| 212 | var imageWidth = '300'; | ||
| 213 | console.log(json[0].pheight , scaleImage, imageHeight); | ||
| 214 | }else{ | ||
| 215 | var imageWidth = json[0].pwidth; | ||
| 216 | var imageHeight = json[0].pheight; | ||
| 217 | console.log(json[0].pheight , scaleImage); | ||
| 218 | |||
| 219 | } | ||
| 220 | pdflist += '<div id="pdfPreview" class="column">'; | ||
| 221 | // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; | ||
| 222 | pdflist += '<canvas id="Canvas" width="'+imageWidth+'" height="'+imageHeight+'" style=" margin-top:60px; 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>'; | ||
| 223 | pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"><h4>' + json[0].name + '</h4>'; | ||
| 224 | pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; | ||
| 225 | for (i = 0; i < json.length; ++i) { | ||
| 226 | var example = json[0].folder + '/' +json[i].example | ||
| 227 | 220 | ||
| 228 | if (json[i].change_type == "textflow") { | 221 | var pdflist = ""; |
| 229 | 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>'; | 222 | var pdfChange = ""; |
| 230 | ++f | 223 | var f = 0; |
| 224 | |||
| 225 | |||
| 226 | var scaleImage = 400 / json[0].pwidth; | ||
| 227 | var imageHeight = json[0].pheight * scaleImage; | ||
| 228 | var imageWidth = '400'; | ||
| 229 | console.log(json[0].pheight, scaleImage, imageHeight); | ||
| 230 | |||
| 231 | |||
| 232 | pdflist += '<div id="pdfPreview" class="column">'; | ||
| 233 | // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; | ||
| 234 | pdflist += '<canvas id="Canvas" width="' + imageWidth + '" height="' + imageHeight + '" style=" margin-top:60px; 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>'; | ||
| 235 | pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>'; | ||
| 236 | pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; | ||
| 237 | for (i = 0; i < json.length; ++i) { | ||
| 238 | var example = json[0].folder + '/' + json[i].example | ||
| 239 | |||
| 240 | if (json[i].change_type == "textflow") { | ||
| 241 | 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>'; | ||
| 242 | ++f | ||
| 243 | pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 244 | } | ||
| 245 | if (json[i].change_type == "text") { | ||
| 246 | 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 + '"">'; | ||
| 247 | pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 231 | } | 248 | } |
| 232 | if (json[i].change_type == "text") { | 249 | if (json[i].change_type == "img") { |
| 233 | 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" type="text" class="required" name="content['+i+']" value="' + json[i].content + '"">'; | 250 | pdfChange += json[i].names + ':<label id="focusButton' + i + '" class="custom-file-input"><input onfocusout="HideBox()" onfocus="SetFocus('+i+'), ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" class="fileupload upload required" id="changescontent[' + i + ']" type="file" name="content[' + i + ']" ></label>'; |
| 251 | pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 234 | } | 252 | } |
| 235 | if (json[i].change_type == "img") { | 253 | if (json[i].change_type == "date") { |
| 236 | 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 + '\')" class="fileupload required" id="changescontent" style="display: block; box-sizing: border-box; width: 100%; height: 2.4375rem; padding: .5rem; border: 1px solid #cacaca; margin: 0 0 1rem; font-family: inherit; font-size: 1rem; color: #8a8a8a; background-color: #fefefe; box-shadow: inset 0 1px 2px rgba(10,10,10,.1); border-radius: 0; transition: box-shadow .5s,border-color .25s ease-in-out; -webkit-appearance: none; -moz-appearance: none;" type="file" name="content['+i+']" >'; | 254 | 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 + '"">'; |
| 255 | |||
| 237 | } | 256 | } |
| 238 | pdfChange += '<span id="span'+i+'">'+json[i].tips+'</span><br/>'; | 257 | |
| 239 | } | 258 | } |
| 240 | pdfChange += '<input type="submit" value="Submit">'; | 259 | pdfChange += '<input type="submit" value="Save and download">'; |
| 241 | pdfChange += '</form>'; | 260 | pdfChange += '</form>'; |
| 242 | 261 | ||
| 243 | strVar2 += ' <div class="callout primary"><div class="row column"><h1>Welcome to Synapsus Online PDF Editor</h1>'; | 262 | strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; |
| 244 | strVar2 += '<p class="lead">Please make your changes or return <a href="#" onclick="location.reload();">back to the list</a></p>'; | 263 | strVar2 += ''; |
| 245 | strVar2 += ' </div></div><div id="wrapper" class="row small-up-2 medium-up-3 large-up-3">'; | 264 | strVar2 += ' </div></div><div id="wrapper" class="black small-up-2 medium-up-3 large-up-3">'; |
| 246 | strVar2 += pdflist + '<div id="changesColumn" style="height:'+$("#changes").height()+';" class="column" >' + pdfChange + '</div><div id="pdfFooter"></div></div>'; | 265 | strVar2 += pdflist + '<div id="changesColumn" style="height:' + $("#changes").height() + ';" class="column" >' + pdfChange + '<div id="tezingLogo"></div></div><div id="pdfFooter"></div></div>'; |
| 247 | 266 | ||
| 248 | 267 | ||
| 249 | 268 | ||
| 250 | document.getElementById('contentArea').innerHTML = strVar2; | 269 | document.getElementById('contentArea').innerHTML = strVar2; |
| 251 | document.getElementById('google_drive').innerHTML = " "; | 270 | document.getElementById('google_drive').innerHTML = " "; |
| 252 | 271 | ||
| 253 | $(document).ready(function() { | ||
| 254 | $("#changes").validate(); | ||
| 255 | }); | ||
| 256 | |||
| 257 | 272 | ||
| 258 | |||
| 259 | if($(window).width() > 700){ | ||
| 260 | 273 | ||
| 261 | if($("#pdfPreview").height() > $("#changes").height()){ | ||
| 262 | $('#changesColumn').css('position' ,'relative'); | ||
| 263 | var stickySidebar = $('#changesColumn'); | ||
| 264 | 274 | ||
| 265 | if (stickySidebar.length > 0) { | 275 | if ($(window).width() > 700) { |
| 266 | var stickyHeight = stickySidebar.height(), | ||
| 267 | sidebarTop = stickySidebar.offset().top; | ||
| 268 | } | ||
| 269 | 276 | ||
| 270 | // on scroll move the sidebar | ||
| 271 | $(window).scroll(function () { | ||
| 272 | if (stickySidebar.length > 0) { | ||
| 273 | var scrollTop = $(window).scrollTop(); | ||
| 274 | |||
| 275 | if (sidebarTop < scrollTop) { | ||
| 276 | stickySidebar.css('top', scrollTop - sidebarTop); | ||
| 277 | |||
| 278 | // stop the sticky sidebar at the footer to avoid overlapping | ||
| 279 | var sidebarBottom = stickySidebar.offset().top + stickyHeight, | ||
| 280 | stickyStop = $('#pdfPreview').offset().top + $('#pdfPreview').height(); | ||
| 281 | if (stickyStop < sidebarBottom) { | ||
| 282 | var stopPosition = $('#pdfPreview').height() - stickyHeight; | ||
| 283 | stickySidebar.css('top', stopPosition); | ||
| 284 | } | ||
| 285 | } | ||
| 286 | else { | ||
| 287 | stickySidebar.css('top', '0'); | ||
| 288 | } | ||
| 289 | } | ||
| 290 | }); | ||
| 291 | 277 | ||
| 292 | $(window).resize(function () { | 278 | $('#pdfPreview').css('position', 'relative'); |
| 293 | if (stickySidebar.length > 0) { | 279 | var stickySidebar = $('#pdfPreview'); |
| 294 | stickyHeight = stickySidebar.height(); | ||
| 295 | } | ||
| 296 | }); | ||
| 297 | 280 | ||
| 298 | }else{ | 281 | if (stickySidebar.length > 0) { |
| 282 | var stickyHeight = stickySidebar.height(), | ||
| 283 | sidebarTop = stickySidebar.offset().top; | ||
| 284 | } | ||
| 299 | 285 | ||
| 300 | console.log('false'); | 286 | // on scroll move the sidebar |
| 301 | var stickySidebar = $('#pdfPreview'); | 287 | $(window).scroll(function() { |
| 288 | if (stickySidebar.length > 0) { | ||
| 289 | var scrollTop = $(window).scrollTop(); | ||
| 290 | |||
| 291 | if (sidebarTop < scrollTop) { | ||
| 292 | stickySidebar.css('top', scrollTop - sidebarTop); | ||
| 293 | |||
| 294 | // stop the sticky sidebar at the footer to avoid overlapping | ||
| 295 | var sidebarBottom = stickySidebar.offset().top + stickyHeight, | ||
| 296 | stickyStop = $('#changesColumn').offset().top + $('#changesColumn').height(); | ||
| 297 | if (stickyStop < sidebarBottom) { | ||
| 298 | var stopPosition = $('#changesColumn').height() - stickyHeight; | ||
| 299 | stickySidebar.css('top', stopPosition); | ||
| 300 | } | ||
| 301 | } else { | ||
| 302 | stickySidebar.css('top', '0'); | ||
| 303 | } | ||
| 304 | } | ||
| 305 | }); | ||
| 302 | 306 | ||
| 303 | if (stickySidebar.length > 0) { | 307 | $(window).resize(function() { |
| 304 | var stickyHeight = stickySidebar.height(), | 308 | if (stickySidebar.length > 0) { |
| 305 | sidebarTop = stickySidebar.offset().top; | 309 | stickyHeight = stickySidebar.height(); |
| 306 | } | 310 | } |
| 311 | }); | ||
| 307 | 312 | ||
| 308 | // on scroll move the sidebar | ||
| 309 | $(window).scroll(function () { | ||
| 310 | if (stickySidebar.length > 0) { | ||
| 311 | var scrollTop = $(window).scrollTop(); | ||
| 312 | |||
| 313 | if (sidebarTop < scrollTop) { | ||
| 314 | stickySidebar.css('top', scrollTop - sidebarTop); | ||
| 315 | |||
| 316 | // stop the sticky sidebar at the footer to avoid overlapping | ||
| 317 | var sidebarBottom = stickySidebar.offset().top + stickyHeight, | ||
| 318 | stickyStop = $('#changesColumn').offset().top + $('#changesColumn').height(); | ||
| 319 | if (stickyStop < sidebarBottom) { | ||
| 320 | var stopPosition = $('#changesColumn').height() - stickyHeight; | ||
| 321 | stickySidebar.css('top', stopPosition); | ||
| 322 | } | ||
| 323 | } | ||
| 324 | else { | ||
| 325 | stickySidebar.css('top', '0'); | ||
| 326 | } | ||
| 327 | } | ||
| 328 | }); | ||
| 329 | 313 | ||
| 330 | $(window).resize(function () { | 314 | } |
| 331 | if (stickySidebar.length > 0) { | ||
| 332 | stickyHeight = stickySidebar.height(); | ||
| 333 | } | ||
| 334 | }); | ||
| 335 | 315 | ||
| 336 | } | 316 | tinymce.init({ |
| 337 | 317 | selector: '.textarea', | |
| 338 | 318 | entity_encoding: "raw", | |
| 339 | } | 319 | menubar: false, |
| 340 | 320 | toolbar: ' bold italic', | |
| 341 | 321 | remove_linebreaks: false, | |
| 342 | 322 | remove_trailing_brs: false, | |
| 343 | 323 | ||
| 344 | tinymce.init({ | 324 | |
| 345 | selector: '.textarea', | 325 | setup: function(editor) { |
| 346 | entity_encoding: "raw", | 326 | editor.on('focus', function(e) { |
| 347 | menubar: false, | 327 | console.log(editor.id); |
| 348 | toolbar: ' bold italic', | 328 | $('#' + editor.id).trigger("onfocus"); |
| 349 | remove_linebreaks: false, | 329 | $(this).css('border', '2px solid #F7A800 !important'); |
| 350 | remove_trailing_brs: false, | 330 | }); |
| 351 | setup: function(editor) { | 331 | editor.on('focusout', function(e) { |
| 352 | editor.on('focus', function(e) { | 332 | // console.log('out'+editor.id); |
| 353 | console.log(editor.id); | 333 | $(this).css('border', '0px solid #F7A800 !important'); |
| 354 | $('#' + editor.id).trigger("onfocus"); | 334 | HideBox(); |
| 355 | }); | 335 | }); |
| 356 | editor.on('focusout', function(e) { | 336 | } |
| 357 | console.log('out'+editor.id); | ||
| 358 | HideBox(); | ||
| 359 | }); | ||
| 360 | } | ||
| 361 | |||
| 362 | 337 | ||
| 363 | 338 | ||
| 364 | }); | ||
| 365 | 339 | ||
| 366 | var files; | 340 | }); |
| 367 | var imagefiles = [];; | ||
| 368 | 341 | ||
| 342 | var files; | ||
| 343 | var imagefiles = [];; | ||
| 369 | 344 | ||
| 370 | $(".fileupload").change(function(e) { | 345 | |
| 371 | files = e.target.files; | 346 | $(".fileupload").change(function(e) { |
| 372 | for (var i = 0, file; file = files[i]; i++) { | 347 | files = e.target.files; |
| 373 | console.log(file); | 348 | for (var i = 0, file; file = files[i]; i++) { |
| 374 | imagefiles.push(file); | 349 | //console.log(file); |
| 375 | // console.log(imagefiles); | 350 | imagefiles.push(file); |
| 376 | } | 351 | // console.log(imagefiles); |
| 377 | }); | 352 | } |
| 353 | }); | ||
| 378 | 354 | ||
| 379 | 355 | ||
| 380 | $("#changes").submit(function(e) { | 356 | $("#changes").submit(function(e) { |
| 381 | e.preventDefault(); | 357 | e.preventDefault(); |
| 382 | 358 | ||
| 383 | if($("#changes").valid()) { | 359 | if ($("#changes").valid()) { |
| 384 | 360 | ||
| 385 | $(tinymce.get()).each(function(i, el) { | 361 | $(tinymce.get()).each(function(i, el) { |
| 386 | 362 | ||
| 387 | if (el.id) | 363 | if (el.id) |
| 388 | document.getElementById(el.id).value = el.getContent(); | 364 | document.getElementById(el.id).value = el.getContent(); |
| 389 | ///console.log(el.id); | 365 | $('#changes').hide(); |
| 390 | tinymce.get(el.id).remove(); | 366 | tinymce.get(el.id).remove(); |
| 391 | |||
| 392 | |||
| 393 | }); | 367 | }); |
| 394 | 368 | ||
| 395 | 369 | var form = $("#changes"); | |
| 396 | 370 | ||
| 397 | 371 | returnfileOptions(imagefiles, form); | |
| 398 | var form = $("#changes"); | ||
| 399 | |||
| 400 | |||
| 401 | |||
| 402 | returnfileOptions(imagefiles, form); | ||
| 403 | return false; | 372 | return false; |
| 404 | }else{return false;} | 373 | } else { |
| 405 | }); | 374 | return false; |
| 406 | 375 | } | |
| 407 | |||
| 408 | |||
| 409 | }); | 376 | }); |
| 377 | |||
| 378 | }); | ||
| 410 | 379 | ||
| 411 | } | 380 | } |
| 412 | |||
| 413 | 381 | ||
| 414 | function returnfileOptions(files, form) { | ||
| 415 | jQuery(function($) { | ||
| 416 | 382 | ||
| 417 | var data = new FormData(); | 383 | function returnfileOptions(files, form) { |
| 418 | $.each(files, function(key, value) { | 384 | jQuery(function($) { |
| 419 | data.append(key, value); | ||
| 420 | 385 | ||
| 421 | }); | 386 | var data = new FormData(); |
| 387 | $.each(files, function(key, value) { | ||
| 388 | data.append(key, value); | ||
| 422 | 389 | ||
| 423 | $.ajax({ | 390 | }); |
| 424 | url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files', | ||
| 425 | type: 'POST', | ||
| 426 | data: data, | ||
| 427 | cache: false, | ||
| 428 | dataType: 'json', | ||
| 429 | processData: false, // Don't process the files | ||
| 430 | contentType: false, // Set content type to false as jQuery will tell the server its a query string request | ||
| 431 | success: function(data, textStatus, jqXHR) { | ||
| 432 | if (typeof data.error === 'undefined') { | ||
| 433 | returnOptions(form); | ||
| 434 | } else { | ||
| 435 | // Handle errors here | ||
| 436 | 391 | ||
| 437 | console.log('ERRORS: ' + data.error); | 392 | $.ajax({ |
| 438 | } | 393 | url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files', |
| 439 | }, | 394 | type: 'POST', |
| 440 | error: function(jqXHR, textStatus, errorThrown) { | 395 | data: data, |
| 396 | cache: false, | ||
| 397 | dataType: 'json', | ||
| 398 | processData: false, // Don't process the files | ||
| 399 | contentType: false, // Set content type to false as jQuery will tell the server its a query string request | ||
| 400 | success: function(data, textStatus, jqXHR) { | ||
| 401 | if (typeof data.error === 'undefined') { | ||
| 402 | returnOptions(form); | ||
| 403 | } else { | ||
| 441 | // Handle errors here | 404 | // Handle errors here |
| 442 | console.log('ERRORS: ' + textStatus); | ||
| 443 | // STOP LOADING SPINNER | ||
| 444 | } | ||
| 445 | }); | ||
| 446 | 405 | ||
| 406 | console.log('ERRORS: ' + data.error); | ||
| 407 | } | ||
| 408 | }, | ||
| 409 | error: function(jqXHR, textStatus, errorThrown) { | ||
| 410 | // Handle errors here | ||
| 411 | console.log('ERRORS: ' + textStatus); | ||
| 412 | // STOP LOADING SPINNER | ||
| 413 | } | ||
| 447 | }); | 414 | }); |
| 448 | } | ||
| 449 | 415 | ||
| 416 | }); | ||
| 417 | } | ||
| 450 | 418 | ||
| 451 | function returnOptions(form) { | ||
| 452 | 419 | ||
| 420 | function returnOptions(form) { | ||
| 453 | 421 | ||
| 454 | 422 | ||
| 455 | |||
| 456 | 423 | ||
| 457 | 424 | ||
| 458 | jQuery(function($) { | 425 | jQuery(function($) { |
| 459 | 426 | ||
| 460 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { | 427 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { |
| 461 | // Get the element with id summary and set the inner text to the result. | 428 | // Get the element with id summary and set the inner text to the result. |
| 462 | var json = dataReturnd; | 429 | var json = dataReturnd; |
| 463 | //console.log(json); | 430 | //console.log(json); |
| 464 | 431 | ||
| 465 | 432 | ||
| 466 | var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '","pageWidth":"' + json[0].pageWidth + '","pageHeight":"' + json[0].pageHeight + '"}],"changes":[' | 433 | var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '","pageWidth":"' + json[0].pageWidth + '","pageHeight":"' + json[0].pageHeight + '"}],"changes":[' |
| 467 | var e = 1; | 434 | var e = 1; |
| 468 | for (i = 0; i < json.length; ++i) { | 435 | for (i = 0; i < json.length; ++i) { |
| 469 | 436 | ||
| 470 | 437 | ||
| 471 | 438 | ||
| 472 | var style = JSON.stringify(json[i].style); | 439 | var style = JSON.stringify(json[i].style); |
| 473 | var content = JSON.stringify(form[0][e].value); | 440 | var content = JSON.stringify(form[0][e].value); |
| 474 | console.log(form[0][e].value); | 441 | console.log(form[0][e].value); |
| 475 | 442 | ||
| 476 | 443 | ||
| 477 | 444 | ||
| 478 | 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 + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/uploads/pdf/"}'; | 445 | 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 + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/uploads/pdf/"}'; |
| 479 | 446 | ||
| 480 | 447 | ||
| 481 | if (i < json.length - 1) { | 448 | if (i < json.length - 1) { |
| 482 | jsonReturn += ','; | 449 | jsonReturn += ','; |
| 483 | } | ||
| 484 | ++e | ||
| 485 | } | 450 | } |
| 486 | jsonReturn += ' ]}'; | 451 | ++e |
| 487 | // console.log(jsonReturn); | 452 | } |
| 488 | 453 | jsonReturn += ' ]}'; | |
| 489 | 454 | // console.log(jsonReturn); | |
| 490 | |||
| 491 | |||
| 492 | $.ajax({ | ||
| 493 | url: "" + pdf_customizer + "/api/update", | ||
| 494 | type: "POST", | ||
| 495 | dataType: 'json', | ||
| 496 | data: jsonReturn, | ||
| 497 | processData: false, | ||
| 498 | |||
| 499 | contentType: "application/json", | ||
| 500 | CrossDomain: true, | ||
| 501 | |||
| 502 | 455 | ||
| 503 | 456 | ||
| 504 | 457 | ||
| 505 | async: true, | ||
| 506 | success: function(data) { | ||
| 507 | var strVar2 = "" | ||
| 508 | strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>"; | ||
| 509 | strVar2 += "<p class=\"lead\">Please download your file below or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>"; | ||
| 510 | strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">"; | ||
| 511 | strVar2 += "<div class=\"column\">" + '<a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ><i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a>'; + | ||
| 512 | "<\/div><\/div>"; | ||
| 513 | 458 | ||
| 514 | document.getElementById('contentArea').innerHTML = strVar2 | 459 | $.ajax({ |
| 515 | }, | 460 | url: "" + pdf_customizer + "/api/update", |
| 516 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | 461 | type: "POST", |
| 517 | alert(xhr.status); | 462 | dataType: 'json', |
| 518 | document.getElementById('contentArea').innerHTML = xhr.responseText; | 463 | data: jsonReturn, |
| 519 | } | 464 | processData: false, |
| 465 | contentType: "application/json", | ||
| 466 | CrossDomain: true, | ||
| 467 | async: true, | ||
| 468 | success: function(data) { | ||
| 469 | var strVar2 = "" | ||
| 470 | strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; | ||
| 471 | strVar2 += '</div></div><div class="row small-up-2 medium-up-3 large-up-3">'; | ||
| 472 | strVar2 += '<br/><br/>' + '<a class="downloadpdf" href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ><i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a></div>'; | ||
| 473 | |||
| 474 | |||
| 475 | document.getElementById('contentArea').innerHTML = strVar2 | ||
| 476 | }, | ||
| 477 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | ||
| 478 | alert(xhr.status); | ||
| 479 | document.getElementById('contentArea').innerHTML = xhr.responseText; | ||
| 480 | } | ||
| 520 | 481 | ||
| 521 | }); | 482 | }); |
| 522 | 483 | ||
| 523 | 484 | ||
| 524 | 485 | ||
| 525 | 486 | ||
| 526 | }); | 487 | }); |
| 527 | 488 | ||
| 528 | 489 | ||
| 529 | }); | 490 | }); |
| 530 | 491 | ||
| 531 | 492 | ||
| 532 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 493 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment