Update interface script.
Showing
1 changed file
with
374 additions
and
426 deletions
public/files/js/interfaceGdrive.js
100644 → 100755
| 1 | //var pluginUrl = "http://localhost:8888/Forms"; | 1 | //var pluginUrl = "http://contact-form.dev"; |
| 2 | //var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; | 2 | //var pdf_customizer = "http://pdf-customizer.dev/public"; |
| 3 | |||
| 4 | var pluginUrl = "http://contact.gotenzing.com"; | ||
| 5 | var pdf_customizer = "http://pdf-customizer.synapsus.co"; | ||
| 6 | |||
| 7 | function getAuth() { | ||
| 8 | |||
| 9 | jQuery(document).ready(function($) { | ||
| 10 | |||
| 11 | var settings = { | ||
| 12 | "async": true, | ||
| 13 | "crossDomain": true, | ||
| 14 | "url": "" + pdf_customizer + "/api/authenticate", | ||
| 15 | "method": "POST", | ||
| 16 | "processData": false, | ||
| 17 | "contentType": false, | ||
| 18 | "mimeType": "multipart/form-data", | ||
| 19 | "data": form, | ||
| 20 | "success": function(data) { | ||
| 21 | getJson(user_id); | ||
| 22 | }, | ||
| 23 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | ||
| 24 | //alert(xhr.status); | ||
| 25 | document.getElementById('contentArea').innerHTML = xhr.responseText; | ||
| 26 | } | ||
| 27 | |||
| 28 | } | ||
| 29 | |||
| 30 | $.ajax(settings).done(function(response) { | ||
| 31 | console.log(response); | ||
| 32 | token = response; | ||
| 33 | }); | ||
| 34 | |||
| 35 | }); | ||
| 36 | |||
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | function offFocus(id) { | ||
| 43 | |||
| 44 | |||
| 45 | jQuery(document).ready(function($) { | ||
| 46 | |||
| 47 | |||
| 48 | $("#select" + id + "").removeClass("focus"); | ||
| 49 | $(".entry_block").mouseleave(function() { | ||
| 50 | $("#select" + id + "").addClass("focus"); | ||
| 51 | }); | ||
| 52 | }); | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | function ShowBox(pheight, pwidth, up, right, height, width, count, example) { | ||
| 57 | |||
| 58 | |||
| 59 | jQuery(document).ready(function($) { | ||
| 60 | $('span').hide(); | ||
| 61 | $('#span' + count).show(); | ||
| 62 | $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")"); | ||
| 63 | |||
| 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 | 3 | ||
| 4 | var pluginUrl = "http://contact.gotenzing.com"; | ||
| 5 | var pdf_customizer = "http://pdf-customizer.synapsus.co"; | ||
| 69 | 6 | ||
| 7 | function getAuth() { | ||
| 8 | jQuery(document).ready(function($) { | ||
| 9 | var settings = { | ||
| 10 | "async": true, | ||
| 11 | "crossDomain": true, | ||
| 12 | "url": "" + pdf_customizer + "/api/authenticate", | ||
| 13 | "method": "POST", | ||
| 14 | "processData": false, | ||
| 15 | "contentType": false, | ||
| 16 | "mimeType": "multipart/form-data", | ||
| 17 | "data": form, | ||
| 18 | "success": function(data) { | ||
| 19 | getJson(user_id); | ||
| 20 | }, | ||
| 21 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | ||
| 22 | //alert(xhr.status); | ||
| 23 | document.getElementById('contentArea').innerHTML = xhr.responseText; | ||
| 24 | } | ||
| 25 | }; | ||
| 70 | 26 | ||
| 71 | var down = pheight - (up + height); | 27 | $.ajax(settings).done(function(response) { |
| 72 | var scaleH = $("Canvas").height() / pheight; | 28 | console.log(response); |
| 73 | var scaleW = $("Canvas").width() / pwidth; | 29 | token = response; |
| 74 | var scaleDown = down * scaleH; | 30 | }); |
| 75 | var scaleRight = right * scaleW; | 31 | }); |
| 76 | var scalewidth = width * scaleW; | 32 | } |
| 77 | var scaleheight = height * scaleH; | ||
| 78 | 33 | ||
| 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 | 34 | ||
| 35 | function offFocus(id) { | ||
| 36 | jQuery(document).ready(function($) { | ||
| 37 | $("#select" + id + "").removeClass("focus"); | ||
| 38 | $(".entry_block").mouseleave(function() { | ||
| 39 | $("#select" + id + "").addClass("focus"); | ||
| 40 | }); | ||
| 41 | }); | ||
| 42 | } | ||
| 89 | 43 | ||
| 44 | function ShowBox(pheight, pwidth, up, right, height, width, count, example) { | ||
| 45 | jQuery(document).ready(function($) { | ||
| 46 | $('span').hide(); | ||
| 47 | $('#span' + count).show(); | ||
| 48 | $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")"); | ||
| 49 | |||
| 50 | var Qc = document.getElementById("Canvas"); | ||
| 51 | var Qctx = Qc.getContext("2d"); | ||
| 52 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | ||
| 53 | Qctx.restore(); | ||
| 54 | |||
| 55 | var down = pheight - (up + height); | ||
| 56 | var scaleH = $("Canvas").height() / pheight; | ||
| 57 | var scaleW = $("Canvas").width() / pwidth; | ||
| 58 | var scaleDown = down * scaleH; | ||
| 59 | var scaleRight = right * scaleW; | ||
| 60 | var scalewidth = width * scaleW; | ||
| 61 | var scaleheight = height * scaleH; | ||
| 62 | |||
| 63 | var c = document.getElementById("Canvas"); | ||
| 64 | var ctx = c.getContext("2d"); | ||
| 65 | ctx.save(); | ||
| 66 | ctx.rect(scaleRight, scaleDown, scalewidth, scaleheight); | ||
| 67 | console.log(scaleRight, scaleDown, scalewidth, scaleheight); | ||
| 68 | console.log($("Canvas").height(), $("Canvas").width(), scaleW, scaleH); | ||
| 69 | ctx.stroke(); | ||
| 70 | //console.log(pheight, pwidth,up, right, height, width); | ||
| 71 | // console.log(myrect ) | ||
| 72 | }); | ||
| 73 | } | ||
| 90 | 74 | ||
| 91 | }); | ||
| 92 | 75 | ||
| 93 | } | ||
| 94 | |||
| 95 | |||
| 96 | function SetFocus(i) { | 76 | function SetFocus(i) { |
| 97 | jQuery(document).ready(function($) { | 77 | jQuery(document).ready(function($) { |
| 98 | $("label#focusButton"+i).css({"border": "2px solid #F7A800 !important"}); | 78 | $("label#focusButton" + i).css({"border": "2px solid #F7A800 !important"}); |
| 99 | console.log($("label#focusButton"+i)); | 79 | console.log($("label#focusButton" + i)); |
| 100 | 80 | ||
| 101 | }); | 81 | }); |
| 102 | } | 82 | } |
| 103 | 83 | ||
| 104 | 84 | ||
| 105 | function HideBox() { | 85 | function HideBox() { |
| 106 | jQuery(document).ready(function($) { | 86 | jQuery(document).ready(function($) { |
| 107 | $('span').hide(); | 87 | $('span').hide(); |
| 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 | }); | ||
| 114 | |||
| 115 | } | ||
| 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 | }); | ||
| 124 | |||
| 125 | } | ||
| 126 | |||
| 127 | |||
| 128 | |||
| 129 | function getJson(user_id) { | ||
| 130 | |||
| 131 | jQuery(document).ready(function($) { | ||
| 132 | |||
| 133 | $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) { | ||
| 134 | // Get the element with id summary and set the inner text to the result. | ||
| 135 | var json = JSON.stringify(data); | ||
| 136 | pickPdfFromList(json); | ||
| 137 | |||
| 138 | }); | ||
| 139 | |||
| 140 | 88 | ||
| 89 | var cnv = document.getElementById("Canvas"); | ||
| 90 | var ctx = cnv.getContext('2d'); // gets reference to canvas context | ||
| 91 | ctx.beginPath(); // clear existing drawing paths | ||
| 92 | ctx.save(); // store the current transformation matrix | ||
| 93 | }); | ||
| 141 | 94 | ||
| 142 | }); | 95 | } |
| 143 | } | ||
| 144 | 96 | ||
| 145 | function getOneJson(id) { | 97 | function HideBoxwithdate() { |
| 98 | jQuery(document).ready(function($) { | ||
| 99 | var cnv = document.getElementById("Canvas"); | ||
| 100 | var ctx = cnv.getContext('2d'); // gets reference to canvas context | ||
| 101 | ctx.beginPath(); // clear existing drawing paths | ||
| 102 | ctx.save(); // store the current transformation matrix | ||
| 103 | }); | ||
| 146 | 104 | ||
| 147 | jQuery(document).ready(function($) { | 105 | } |
| 148 | 106 | ||
| 149 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) { | ||
| 150 | // Get the element with id summary and set the inner text to the result. | ||
| 151 | var json = JSON.stringify(data); | ||
| 152 | 107 | ||
| 153 | changePdfOptions(json); | 108 | function getJson(user_id) { |
| 109 | jQuery(document).ready(function($) { | ||
| 110 | $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) { | ||
| 111 | // Get the element with id summary and set the inner text to the result. | ||
| 112 | var json = JSON.stringify(data); | ||
| 113 | pickPdfFromList(json); | ||
| 114 | }); | ||
| 115 | }); | ||
| 116 | } | ||
| 154 | 117 | ||
| 155 | }); | 118 | function getOneJson(id) { |
| 119 | jQuery(document).ready(function($) { | ||
| 120 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) { | ||
| 121 | // Get the element with id summary and set the inner text to the result. | ||
| 122 | var json = JSON.stringify(data); | ||
| 156 | 123 | ||
| 124 | changePdfOptions(json); | ||
| 125 | }); | ||
| 126 | }); | ||
| 127 | } | ||
| 157 | 128 | ||
| 129 | function pickPdfFromList(json) { | ||
| 130 | jQuery(document).ready(function($) { | ||
| 131 | json = JSON.parse(json); | ||
| 132 | |||
| 133 | var strVar = ""; | ||
| 134 | var i; | ||
| 135 | var pdflist = ""; | ||
| 136 | for (i = 0; i < json.length; ++i) { | ||
| 137 | pdflist += '<div class="column">'; | ||
| 138 | pdflist += '<a href="#" onclick="getOneJson(' + json[i].idPDF + ');"><img class="thumbnail" src="' + pdf_customizer + '/fileentry/getImage/' + json[i].folder + '/' + json[i].image + '" height="270px"></a>'; | ||
| 139 | pdflist += " <h5>" + json[i].name + "</h5>"; | ||
| 140 | pdflist += "</div>"; | ||
| 141 | } | ||
| 142 | |||
| 143 | strVar += ' <div class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; | ||
| 144 | strVar += ' '; | ||
| 145 | document.getElementById('contentArea').innerHTML = strVar; | ||
| 146 | }); | ||
| 147 | } | ||
| 158 | 148 | ||
| 149 | function changePdfOptions(json) { | ||
| 150 | jQuery(function($) { | ||
| 151 | json = JSON.parse(json); | ||
| 152 | $(document).ready(function() { | ||
| 153 | |||
| 154 | $("#changescontentdate").datepicker({ | ||
| 155 | plugins: "tabfocus", | ||
| 156 | changeMonth: true, | ||
| 157 | changeYear: true, | ||
| 158 | yearRange: '2015:2025', | ||
| 159 | dateFormat: 'DD MM dd yy', | ||
| 160 | minDate: 0, | ||
| 161 | defaultDate: null | ||
| 162 | }).on('change', function() { | ||
| 163 | $(this).valid(); // triggers the validation test | ||
| 164 | // '$(this)' refers to '$("#datepicker")' | ||
| 159 | }); | 165 | }); |
| 160 | } | ||
| 161 | 166 | ||
| 162 | function pickPdfFromList(json) { | 167 | $("#changes").validate(); |
| 163 | json = JSON.parse(json); | 168 | }); |
| 164 | 169 | ||
| 165 | 170 | var strVar2 = ""; | |
| 166 | 171 | var pdflist = ""; | |
| 167 | 172 | var pdfChange = ""; | |
| 168 | var strVar = ""; | 173 | var f = 0; |
| 169 | 174 | ||
| 170 | 175 | var scaleImage = 400 / json[0].pwidth; | |
| 171 | var i; | 176 | var imageHeight = json[0].pheight * scaleImage; |
| 172 | var pdflist = ""; | 177 | var imageWidth = '400'; |
| 173 | for (i = 0; i < json.length; ++i) { | 178 | console.log(json[0].pheight, scaleImage, imageHeight); |
| 174 | pdflist += '<div class="column">'; | 179 | |
| 175 | pdflist += '<a href="#" onclick="getOneJson(' + json[i].idPDF + ');"> <img class="thumbnail" src="' + pdf_customizer + '/fileentry/getImage/' + json[i].folder + '/' + json[i].image + '" height="270px"></a>'; | 180 | pdflist += '<div id="pdfPreview" class="column">'; |
| 176 | pdflist += " <h5>" + json[i].name + "</h5>"; | 181 | // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; |
| 177 | pdflist += "</div>"; | 182 | 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>'; |
| 183 | pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>'; | ||
| 184 | pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; | ||
| 185 | for (i = 0; i < json.length; ++i) { | ||
| 186 | var example = json[0].folder + '/' + json[i].example; | ||
| 187 | |||
| 188 | if (json[i].change_type == "textflow") { | ||
| 189 | 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>'; | ||
| 190 | ++f; | ||
| 191 | pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 178 | } | 192 | } |
| 193 | if (json[i].change_type == "text") { | ||
| 194 | 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 + '"">'; | ||
| 195 | pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 196 | } | ||
| 197 | if (json[i].change_type == "img") { | ||
| 198 | pdfChange += json[i].names + ':<label id="focusButton' + i + '" class="custom-file-input" tabindex="0"><input tabindex="-1" 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 + ']" ><span class="file-button"><span class="file-name file-button"></span><strong>Browse</strong></span></label>'; | ||
| 199 | pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 200 | } | ||
| 201 | if (json[i].change_type == "date") { | ||
| 202 | 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 + '"">'; | ||
| 179 | 203 | ||
| 204 | } | ||
| 180 | 205 | ||
| 181 | strVar += ' <div class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; | 206 | } |
| 182 | strVar += ' '; | 207 | pdfChange += '<input type="submit" value="Save and download">'; |
| 183 | 208 | pdfChange += '</form>'; | |
| 184 | |||
| 185 | |||
| 186 | |||
| 187 | document.getElementById('contentArea').innerHTML = strVar; | ||
| 188 | |||
| 189 | |||
| 190 | |||
| 191 | |||
| 192 | } | ||
| 193 | |||
| 194 | |||
| 195 | function changePdfOptions(json) { | ||
| 196 | jQuery(function($) { | ||
| 197 | json = JSON.parse(json); | ||
| 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 | }); | ||
| 212 | |||
| 213 | $("#changes").validate(); | ||
| 214 | }); | ||
| 215 | |||
| 216 | |||
| 217 | |||
| 218 | var strVar2 = ""; | ||
| 219 | |||
| 220 | |||
| 221 | var pdflist = ""; | ||
| 222 | var pdfChange = ""; | ||
| 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/>'; | ||
| 248 | } | ||
| 249 | if (json[i].change_type == "img") { | ||
| 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/>'; | ||
| 252 | } | ||
| 253 | if (json[i].change_type == "date") { | ||
| 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 | |||
| 256 | } | ||
| 257 | |||
| 258 | } | ||
| 259 | pdfChange += '<input type="submit" value="Save and download">'; | ||
| 260 | pdfChange += '</form>'; | ||
| 261 | |||
| 262 | strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; | ||
| 263 | strVar2 += ''; | ||
| 264 | strVar2 += ' </div></div><div id="wrapper" class="black small-up-2 medium-up-3 large-up-3">'; | ||
| 265 | strVar2 += pdflist + '<div id="changesColumn" style="height:' + $("#changes").height() + ';" class="column" >' + pdfChange + '<div id="tezingLogo"></div></div><div id="pdfFooter"></div></div>'; | ||
| 266 | |||
| 267 | |||
| 268 | |||
| 269 | document.getElementById('contentArea').innerHTML = strVar2; | ||
| 270 | document.getElementById('google_drive').innerHTML = " "; | ||
| 271 | |||
| 272 | |||
| 273 | |||
| 274 | |||
| 275 | if ($(window).width() > 700) { | ||
| 276 | |||
| 277 | |||
| 278 | $('#pdfPreview').css('position', 'relative'); | ||
| 279 | var stickySidebar = $('#pdfPreview'); | ||
| 280 | |||
| 281 | if (stickySidebar.length > 0) { | ||
| 282 | var stickyHeight = stickySidebar.height(), | ||
| 283 | sidebarTop = stickySidebar.offset().top; | ||
| 284 | } | ||
| 285 | 209 | ||
| 286 | // on scroll move the sidebar | 210 | strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; |
| 287 | $(window).scroll(function() { | 211 | strVar2 += ''; |
| 288 | if (stickySidebar.length > 0) { | 212 | strVar2 += ' </div></div><div id="wrapper" class="black small-up-2 medium-up-3 large-up-3">'; |
| 289 | var scrollTop = $(window).scrollTop(); | 213 | strVar2 += pdflist + '<div id="changesColumn" style="height:' + $("#changes").height() + ';" class="column" >' + pdfChange + '<div id="tezingLogo"></div></div><div id="pdfFooter"></div></div>'; |
| 290 | 214 | ||
| 291 | if (sidebarTop < scrollTop) { | 215 | document.getElementById('contentArea').innerHTML = strVar2; |
| 292 | stickySidebar.css('top', scrollTop - sidebarTop); | 216 | document.getElementById('google_drive').innerHTML = " "; |
| 293 | 217 | ||
| 294 | // stop the sticky sidebar at the footer to avoid overlapping | 218 | if ($(window).width() > 700) { |
| 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 | }); | ||
| 306 | 219 | ||
| 307 | $(window).resize(function() { | 220 | $('#pdfPreview').css('position', 'relative'); |
| 308 | if (stickySidebar.length > 0) { | 221 | var stickySidebar = $('#pdfPreview'); |
| 309 | stickyHeight = stickySidebar.height(); | ||
| 310 | } | ||
| 311 | }); | ||
| 312 | 222 | ||
| 223 | if (stickySidebar.length > 0) { | ||
| 224 | var stickyHeight = stickySidebar.height(), | ||
| 225 | sidebarTop = stickySidebar.offset().top; | ||
| 226 | } | ||
| 313 | 227 | ||
| 228 | // on scroll move the sidebar | ||
| 229 | $(window).scroll(function() { | ||
| 230 | if (stickySidebar.length > 0) { | ||
| 231 | var scrollTop = $(window).scrollTop(); | ||
| 232 | |||
| 233 | if (sidebarTop < scrollTop) { | ||
| 234 | stickySidebar.css('top', scrollTop - sidebarTop); | ||
| 235 | |||
| 236 | // stop the sticky sidebar at the footer to avoid overlapping | ||
| 237 | var sidebarBottom = stickySidebar.offset().top + stickyHeight, | ||
| 238 | stickyStop = $('#changesColumn').offset().top + $('#changesColumn').height(); | ||
| 239 | if (stickyStop < sidebarBottom) { | ||
| 240 | var stopPosition = $('#changesColumn').height() - stickyHeight; | ||
| 241 | stickySidebar.css('top', stopPosition); | ||
| 242 | } | ||
| 243 | } else { | ||
| 244 | stickySidebar.css('top', '0'); | ||
| 314 | } | 245 | } |
| 315 | 246 | } | |
| 316 | tinymce.init({ | ||
| 317 | selector: '.textarea', | ||
| 318 | entity_encoding: "raw", | ||
| 319 | menubar: false, | ||
| 320 | toolbar: ' bold italic', | ||
| 321 | remove_linebreaks: false, | ||
| 322 | remove_trailing_brs: false, | ||
| 323 | |||
| 324 | |||
| 325 | setup: function(editor) { | ||
| 326 | editor.on('focus', function(e) { | ||
| 327 | console.log(editor.id); | ||
| 328 | $('#' + editor.id).trigger("onfocus"); | ||
| 329 | $(this).css('border', '2px solid #F7A800 !important'); | ||
| 330 | }); | ||
| 331 | editor.on('focusout', function(e) { | ||
| 332 | // console.log('out'+editor.id); | ||
| 333 | $(this).css('border', '0px solid #F7A800 !important'); | ||
| 334 | HideBox(); | ||
| 335 | }); | ||
| 336 | } | ||
| 337 | |||
| 338 | |||
| 339 | |||
| 340 | }); | ||
| 341 | |||
| 342 | var files; | ||
| 343 | var imagefiles = [];; | ||
| 344 | |||
| 345 | |||
| 346 | $(".fileupload").change(function(e) { | ||
| 347 | files = e.target.files; | ||
| 348 | for (var i = 0, file; file = files[i]; i++) { | ||
| 349 | //console.log(file); | ||
| 350 | imagefiles.push(file); | ||
| 351 | // console.log(imagefiles); | ||
| 352 | } | ||
| 353 | }); | ||
| 354 | |||
| 355 | |||
| 356 | $("#changes").submit(function(e) { | ||
| 357 | e.preventDefault(); | ||
| 358 | |||
| 359 | if ($("#changes").valid()) { | ||
| 360 | |||
| 361 | $(tinymce.get()).each(function(i, el) { | ||
| 362 | |||
| 363 | if (el.id) | ||
| 364 | document.getElementById(el.id).value = el.getContent(); | ||
| 365 | $('#changes').hide(); | ||
| 366 | tinymce.get(el.id).remove(); | ||
| 367 | }); | ||
| 368 | |||
| 369 | var form = $("#changes"); | ||
| 370 | |||
| 371 | returnfileOptions(imagefiles, form); | ||
| 372 | return false; | ||
| 373 | } else { | ||
| 374 | return false; | ||
| 375 | } | ||
| 376 | }); | ||
| 377 | |||
| 378 | }); | 247 | }); |
| 379 | 248 | ||
| 380 | } | 249 | $(window).resize(function() { |
| 381 | 250 | if (stickySidebar.length > 0) { | |
| 382 | 251 | stickyHeight = stickySidebar.height(); | |
| 383 | function returnfileOptions(files, form) { | 252 | } |
| 384 | jQuery(function($) { | ||
| 385 | |||
| 386 | var data = new FormData(); | ||
| 387 | $.each(files, function(key, value) { | ||
| 388 | data.append(key, value); | ||
| 389 | |||
| 390 | }); | ||
| 391 | |||
| 392 | $.ajax({ | ||
| 393 | url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files', | ||
| 394 | type: 'POST', | ||
| 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 { | ||
| 404 | // Handle errors here | ||
| 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 | } | ||
| 414 | }); | ||
| 415 | |||
| 416 | }); | 253 | }); |
| 417 | } | 254 | } |
| 418 | 255 | ||
| 419 | 256 | var tinymces = tinymce.init({ | |
| 420 | function returnOptions(form) { | 257 | selector: '.textarea', |
| 421 | 258 | entity_encoding: "raw", | |
| 259 | menubar: false, | ||
| 260 | toolbar: ' bold italic', | ||
| 261 | remove_linebreaks: false, | ||
| 262 | remove_trailing_brs: false, | ||
| 263 | init_instance_callback: function(editor) { | ||
| 264 | var editorDoc = document.getElementById(editor.id + '_ifr'); | ||
| 265 | var editorDocContent = editorDoc.contentDocument; | ||
| 266 | editorDoc.style.border = "2px solid #131212"; | ||
| 267 | editorDocContent.body.style.backgroundColor = "#131212"; | ||
| 268 | editorDocContent.body.style.color = "#ccc"; | ||
| 269 | }, | ||
| 270 | setup: function(editor) { | ||
| 271 | editor.on('focus', function(e) { | ||
| 272 | console.log(editor.id); | ||
| 273 | |||
| 274 | var editorDoc = document.getElementById(editor.id + '_ifr'); | ||
| 275 | var editorDocContent = editorDoc.contentDocument; | ||
| 276 | editorDoc.style.border = "2px solid #F7A800"; | ||
| 277 | |||
| 278 | //$('#' + editor.id).trigger("focus"); | ||
| 279 | //$(this).css('border', '2px solid #F7A800 !important'); | ||
| 280 | }); | ||
| 281 | editor.on('blur', function(e) { | ||
| 282 | console.log('out' + editor.id); | ||
| 283 | var editorDoc = document.getElementById(editor.id + '_ifr'); | ||
| 284 | var editorDocContent = editorDoc.contentDocument; | ||
| 285 | editorDoc.style.border = "2px solid #131212"; | ||
| 286 | |||
| 287 | //$(this).css('border', '0px solid #F7A800 !important'); | ||
| 288 | //HideBox(); | ||
| 289 | }); | ||
| 290 | } | ||
| 291 | }); | ||
| 292 | |||
| 293 | var files; | ||
| 294 | var imagefiles = []; | ||
| 295 | |||
| 296 | $(".fileupload").change(function(e) { | ||
| 297 | var target = e.target; | ||
| 298 | files = e.target.files; | ||
| 299 | console.log(files); | ||
| 300 | |||
| 301 | if(files.length >= 1) { | ||
| 302 | for (var i = 0, file; file = files[i]; i++) { | ||
| 303 | var fileName = file.name; | ||
| 304 | // insert file name | ||
| 305 | if(fileName) { | ||
| 306 | $(target).parent('label').find('.file-name').text(fileName); | ||
| 307 | } else { | ||
| 308 | $(target).parent('label').find('.file-name').text(''); | ||
| 309 | } | ||
| 422 | 310 | ||
| 311 | imagefiles.push(file); | ||
| 312 | // console.log(imagefiles); | ||
| 313 | } | ||
| 314 | } else { | ||
| 315 | $(target).parent('label').find('.file-name').text(''); | ||
| 316 | } | ||
| 317 | }); | ||
| 423 | 318 | ||
| 424 | 319 | ||
| 425 | jQuery(function($) { | 320 | $("#changes").submit(function(e) { |
| 321 | e.preventDefault(); | ||
| 426 | 322 | ||
| 427 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { | 323 | if ($("#changes").valid()) { |
| 428 | // Get the element with id summary and set the inner text to the result. | ||
| 429 | var json = dataReturnd; | ||
| 430 | //console.log(json); | ||
| 431 | 324 | ||
| 325 | $(tinymce.get()).each(function(i, el) { | ||
| 432 | 326 | ||
| 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":[' | 327 | if (el.id) |
| 434 | var e = 1; | 328 | document.getElementById(el.id).value = el.getContent(); |
| 435 | for (i = 0; i < json.length; ++i) { | 329 | $('#changes').hide(); |
| 330 | tinymce.get(el.id).remove(); | ||
| 331 | }); | ||
| 436 | 332 | ||
| 333 | var form = $("#changes"); | ||
| 437 | 334 | ||
| 335 | returnfileOptions(imagefiles, form); | ||
| 336 | return false; | ||
| 337 | } else { | ||
| 338 | return false; | ||
| 339 | } | ||
| 340 | }); | ||
| 438 | 341 | ||
| 439 | var style = JSON.stringify(json[i].style); | 342 | }); |
| 440 | var content = JSON.stringify(form[0][e].value); | ||
| 441 | console.log(form[0][e].value); | ||
| 442 | 343 | ||
| 344 | } | ||
| 443 | 345 | ||
| 444 | 346 | ||
| 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/"}'; | 347 | function returnfileOptions(files, form) { |
| 348 | jQuery(function($) { | ||
| 349 | |||
| 350 | var data = new FormData(); | ||
| 351 | $.each(files, function(key, value) { | ||
| 352 | data.append(key, value); | ||
| 353 | |||
| 354 | }); | ||
| 355 | |||
| 356 | $.ajax({ | ||
| 357 | url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files', | ||
| 358 | type: 'POST', | ||
| 359 | data: data, | ||
| 360 | cache: false, | ||
| 361 | dataType: 'json', | ||
| 362 | processData: false, // Don't process the files | ||
| 363 | contentType: false, // Set content type to false as jQuery will tell the server its a query string request | ||
| 364 | success: function(data, textStatus, jqXHR) { | ||
| 365 | if (typeof data.error === 'undefined') { | ||
| 366 | returnOptions(form); | ||
| 367 | } else { | ||
| 368 | // Handle errors here | ||
| 369 | |||
| 370 | console.log('ERRORS: ' + data.error); | ||
| 371 | } | ||
| 372 | }, | ||
| 373 | error: function(jqXHR, textStatus, errorThrown) { | ||
| 374 | // Handle errors here | ||
| 375 | console.log('ERRORS: ' + textStatus); | ||
| 376 | // STOP LOADING SPINNER | ||
| 377 | } | ||
| 378 | }); | ||
| 446 | 379 | ||
| 380 | }); | ||
| 381 | } | ||
| 447 | 382 | ||
| 448 | if (i < json.length - 1) { | ||
| 449 | jsonReturn += ','; | ||
| 450 | } | ||
| 451 | ++e | ||
| 452 | } | ||
| 453 | jsonReturn += ' ]}'; | ||
| 454 | // console.log(jsonReturn); | ||
| 455 | 383 | ||
| 384 | function returnOptions(form) { | ||
| 385 | jQuery(function($) { | ||
| 456 | 386 | ||
| 387 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { | ||
| 388 | // Get the element with id summary and set the inner text to the result. | ||
| 389 | var json = dataReturnd; | ||
| 390 | //console.log(json); | ||
| 457 | 391 | ||
| 458 | 392 | ||
| 459 | $.ajax({ | 393 | var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '","pageWidth":"' + json[0].pageWidth + '","pageHeight":"' + json[0].pageHeight + '"}],"changes":[' |
| 460 | url: "" + pdf_customizer + "/api/update", | 394 | var e = 1; |
| 461 | type: "POST", | 395 | for (i = 0; i < json.length; ++i) { |
| 462 | dataType: 'json', | ||
| 463 | data: jsonReturn, | ||
| 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 | 396 | ||
| 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 | } | ||
| 481 | 397 | ||
| 482 | }); | 398 | var style = JSON.stringify(json[i].style); |
| 399 | var content = JSON.stringify(form[0][e].value); | ||
| 400 | console.log(form[0][e].value); | ||
| 483 | 401 | ||
| 484 | 402 | ||
| 403 | 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/"}'; | ||
| 485 | 404 | ||
| 486 | 405 | ||
| 487 | }); | 406 | if (i < json.length - 1) { |
| 407 | jsonReturn += ','; | ||
| 408 | } | ||
| 409 | ++e | ||
| 410 | } | ||
| 411 | jsonReturn += ' ]}'; | ||
| 412 | // console.log(jsonReturn); | ||
| 413 | |||
| 414 | |||
| 415 | $.ajax({ | ||
| 416 | url: "" + pdf_customizer + "/api/update", | ||
| 417 | type: "POST", | ||
| 418 | dataType: 'json', | ||
| 419 | data: jsonReturn, | ||
| 420 | processData: false, | ||
| 421 | contentType: "application/json", | ||
| 422 | CrossDomain: true, | ||
| 423 | async: true, | ||
| 424 | success: function(data) { | ||
| 425 | var strVar2 = "" | ||
| 426 | strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>'; | ||
| 427 | strVar2 += '</div></div><div class="row small-up-2 medium-up-3 large-up-3">'; | ||
| 428 | 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>'; | ||
| 488 | 429 | ||
| 489 | 430 | ||
| 431 | document.getElementById('contentArea').innerHTML = strVar2 | ||
| 432 | }, | ||
| 433 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | ||
| 434 | alert(xhr.status); | ||
| 435 | document.getElementById('contentArea').innerHTML = xhr.responseText; | ||
| 436 | } | ||
| 490 | }); | 437 | }); |
| 491 | 438 | ||
| 492 | |||
| 493 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 439 | }); | ||
| 440 | }); | ||
| 441 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment