preview after every input
Showing
3 changed files
with
689 additions
and
694 deletions
| ... | @@ -32,9 +32,8 @@ class ApiController extends Controller | ... | @@ -32,9 +32,8 @@ class ApiController extends Controller |
| 32 | { | 32 | { |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | // $json = '{"pdf":[{"name":"Sample PDF Document","folder":"Sample","pdfLocation":"http://hotelpodlipou.sk/uploads/files/sample.pdf"}],"changes":[{"label":"none","locationUp":"400","locationRight":90,"pages":"1","content":"logo-sample-text_355-558.jpg","z-index":null,"idstylesPDF":1,"order":"2","style":null,"idchange_typePDF":2,"change_type":"2","fileLocation":"https://image.freepik.com/free-vector/logo-sample-text_355-558.jpg"},{"label":"text style","locationUp":"60","locationRight":290,"pages":"1","content":"519.642.4404 London","z-index":null,"idstylesPDF":2,"order":"1","style":"a:3:{s:11:\"font-family\";s:11:\"TradeGothic\";s:9:\"font-size\";s:2:\"14\";s:10:\"font-color\";s:16:\"cmyk 0 0.6 0.5 0\";}","idchange_typePDF":1,"change_type":"1"}]}'; | 35 | // $json = '{"pdf":[{"name":"Sample PDF Document","folder":"Sample","pdfLocation":"http://hotelpodlipou.sk/uploads/files/sample.pdf"}],"changes":[{"label":"none","locationUp":"400","locationRight":90,"pages":"1","content":"logo-sample-text_355-558.jpg","z-index":null,"idstylesPDF":1,"order":"2","style":null,"idchange_typePDF":2,"change_type":"2","fileLocation":"https://image.freepik.com/free-vector/logo-sample-text_355-558.jpg"},{"label":"text style","locationUp":"60","locationRight":290,"pages":"1","content":"519.642.4404 London","z-index":null,"idstylesPDF":2,"order":"1","style":"a:3:{s:11:\"font-family\";s:11:\"TradeGothic\";s:9:\"font-size\";s:2:\"14\";s:10:\"font-color\";s:16:\"cmyk 0 0.6 0.5 0\";}","idchange_typePDF":1,"change_type":"1"}]}'; |
| 36 | 36 | //$styles = serialize(array("font-family"=>"Barber","font-size"=>"20","font-color"=>"cmyk 0 0 0 0","alignment"=>"left")); | |
| 37 | //$styles = serialize(array("font-family"=>"Barber","font-size"=>"20","font-color"=>"cmyk 0 0 0 0","alignment"=>"left")); | ||
| 38 | //print_r($styles); | 37 | //print_r($styles); |
| 39 | //die(); | 38 | //die(); |
| 40 | $apiCallId = new pdfModel(); | 39 | $apiCallId = new pdfModel(); |
| ... | @@ -43,10 +42,6 @@ class ApiController extends Controller | ... | @@ -43,10 +42,6 @@ class ApiController extends Controller |
| 43 | $pdfId = new pdfModel(); | 42 | $pdfId = new pdfModel(); |
| 44 | $pdfId = $pdfId->addPdf($apiCallId, $json); | 43 | $pdfId = $pdfId->addPdf($apiCallId, $json); |
| 45 | $json = json_decode($json); | 44 | $json = json_decode($json); |
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); | 45 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); |
| 51 | $folder = str_replace(' ', '-', $json->pdf[0]->name); // Replaces all spaces with hyphens. | 46 | $folder = str_replace(' ', '-', $json->pdf[0]->name); // Replaces all spaces with hyphens. |
| 52 | $folder = preg_replace('/[^A-Za-z0-9\-]/', '', $folder); | 47 | $folder = preg_replace('/[^A-Za-z0-9\-]/', '', $folder); |
| ... | @@ -66,10 +61,6 @@ class ApiController extends Controller | ... | @@ -66,10 +61,6 @@ class ApiController extends Controller |
| 66 | $curl->download($pdfLocation, $storagePath . $folder . '/' . $file); | 61 | $curl->download($pdfLocation, $storagePath . $folder . '/' . $file); |
| 67 | $curl->close(); | 62 | $curl->close(); |
| 68 | $fileEntry = New FileEntryController(); | 63 | $fileEntry = New FileEntryController(); |
| 69 | // echo $storagePath . $folder . '/' . $file; | ||
| 70 | //$fileEntry->addfile( $folder . '/' . $file); | ||
| 71 | |||
| 72 | |||
| 73 | $im = new Imagick(); | 64 | $im = new Imagick(); |
| 74 | $im->setResolution(300, 300); //set the resolution of the resulting jpg | 65 | $im->setResolution(300, 300); //set the resolution of the resulting jpg |
| 75 | if (! is_readable($storagePath . $folder . '/' . $file)) { | 66 | if (! is_readable($storagePath . $folder . '/' . $file)) { |
| ... | @@ -92,33 +83,56 @@ class ApiController extends Controller | ... | @@ -92,33 +83,56 @@ class ApiController extends Controller |
| 92 | $curl->close(); | 83 | $curl->close(); |
| 93 | 84 | ||
| 94 | } | 85 | } |
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | |||
| 90 | public function preview() | ||
| 91 | { | ||
| 92 | $json = Input::all(); | ||
| 93 | $json = json_encode($json); | ||
| 94 | $json = json_decode($json); | ||
| 95 | $pdfLocation = $json->pdf[0]->pdfLocation; | ||
| 96 | $cust_id = $json->pdf[0]->custId; | ||
| 97 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); | ||
| 95 | 98 | ||
| 96 | 99 | foreach ($json->changes as $change) { | |
| 100 | if ($change->change_type == 'img') { | ||
| 101 | $folder = str_replace(' ', '-', $json->pdf[0]->folder); // Replaces all spaces with hyphens. | ||
| 102 | $folder = preg_replace('/[^A-Za-z0-9\-]/', '', $folder); | ||
| 103 | $fileLocation = $change->fileLocation; | ||
| 104 | $file = explode('\\', $change->content); | ||
| 105 | $file = end($file); | ||
| 106 | $fileClean = str_replace(' ', '-', $file); | ||
| 107 | $curl = new Curl(); | ||
| 108 | $curl->download($fileLocation.'/'.$fileClean , $storagePath . $folder . '/' . $fileClean); | ||
| 109 | $curl->close(); | ||
| 110 | } | ||
| 97 | } | 111 | } |
| 98 | 112 | ||
| 99 | } | 113 | $json = json_encode($json); |
| 114 | $apiCallId = "3"; | ||
| 115 | $pdfId = new pdfModel(); | ||
| 116 | $pdfId = $pdfId->changePdf($apiCallId, $json); | ||
| 117 | $pdf = new PdfController(); | ||
| 118 | $pdf = $pdf->pdf($pdfId); | ||
| 119 | $response = $pdfId; | ||
| 120 | $statusCode = 200; | ||
| 121 | return Response::json( $response, $statusCode); | ||
| 122 | } | ||
| 100 | 123 | ||
| 101 | public function update() | 124 | public function update() |
| 102 | { | 125 | { |
| 103 | |||
| 104 | |||
| 105 | $json = Input::all(); | 126 | $json = Input::all(); |
| 106 | |||
| 107 | $json = json_encode($json); | 127 | $json = json_encode($json); |
| 108 | $json = json_decode($json); | 128 | $json = json_decode($json); |
| 109 | 129 | $pdfLocation = $json->pdf[0]->pdfLocation; | |
| 110 | $pdfLocation = $json->pdf[0]->pdfLocation; | ||
| 111 | $cust_id = $json->pdf[0]->custId; | 130 | $cust_id = $json->pdf[0]->custId; |
| 131 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); | ||
| 112 | 132 | ||
| 113 | 133 | foreach ($json->changes as $change) { | |
| 114 | |||
| 115 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); | ||
| 116 | |||
| 117 | |||
| 118 | foreach ($json->changes as $change) { | ||
| 119 | if ($change->change_type == 'img') { | 134 | if ($change->change_type == 'img') { |
| 120 | 135 | $folder = str_replace(' ', '-', $json->pdf[0]->folder); // Replaces all spaces with hyphens. | |
| 121 | $folder = str_replace(' ', '-', $json->pdf[0]->folder); // Replaces all spaces with hyphens. | ||
| 122 | $folder = preg_replace('/[^A-Za-z0-9\-]/', '', $folder); | 136 | $folder = preg_replace('/[^A-Za-z0-9\-]/', '', $folder); |
| 123 | $fileLocation = $change->fileLocation; | 137 | $fileLocation = $change->fileLocation; |
| 124 | $file = explode('\\', $change->content); | 138 | $file = explode('\\', $change->content); |
| ... | @@ -127,36 +141,26 @@ class ApiController extends Controller | ... | @@ -127,36 +141,26 @@ class ApiController extends Controller |
| 127 | $curl = new Curl(); | 141 | $curl = new Curl(); |
| 128 | $curl->download($fileLocation.'/'.$fileClean , $storagePath . $folder . '/' . $fileClean); | 142 | $curl->download($fileLocation.'/'.$fileClean , $storagePath . $folder . '/' . $fileClean); |
| 129 | $curl->close(); | 143 | $curl->close(); |
| 130 | // chmod( $storagePath . $folder . '/' . $fileClean, 0777); | 144 | } |
| 131 | |||
| 132 | } | ||
| 133 | } | 145 | } |
| 134 | 146 | ||
| 135 | $json = json_encode($json); | 147 | $json = json_encode($json); |
| 136 | // $json = '{"pdf":[{"name":"Sample PDF Document","folder":"Sample","pdfLocation":"http://hotelpodlipou.sk/uploads/files/sample.pdf"}],"changes":[{"label":"none","locationUp":"400","locationRight":90,"pages":"1","content":"logo-sample-text_355-558.jpg","z-index":null,"idstylesPDF":1,"order":"2","style":null,"idchange_typePDF":2,"change_type":"2","fileLocation":"https://image.freepik.com/free-vector/logo-sample-text_355-558.jpg"},{"label":"text style","locationUp":"60","locationRight":290,"pages":"1","content":"519.642.4404 London","z-index":null,"idstylesPDF":2,"order":"1","style":"a:3:{s:11:\"font-family\";s:11:\"TradeGothic\";s:9:\"font-size\";s:2:\"14\";s:10:\"font-color\";s:16:\"cmyk 0 0.6 0.5 0\";}","idchange_typePDF":1,"change_type":"1"}]}'; | ||
| 137 | |||
| 138 | //$apiCallId = new pdfModel(); | 148 | //$apiCallId = new pdfModel(); |
| 139 | // $apiCallId = $apiCallId->addApiCall('1',$json); | 149 | // $apiCallId = $apiCallId->addApiCall('1',$json); |
| 140 | $apiCallId = "3"; | 150 | $apiCallId = "3"; |
| 141 | $pdfId = new pdfModel(); | 151 | $pdfId = new pdfModel(); |
| 142 | $pdfId = $pdfId->changePdf($apiCallId, $json); | 152 | $pdfId = $pdfId->changePdf($apiCallId, $json); |
| 143 | |||
| 144 | $pdf = new PdfController(); | 153 | $pdf = new PdfController(); |
| 145 | $pdf = $pdf->pdf($pdfId); | 154 | $pdf = $pdf->pdf($pdfId); |
| 146 | $response = $pdfId; | 155 | $response = $pdfId; |
| 147 | $statusCode = 200; | 156 | $statusCode = 200; |
| 148 | //$UploaqdPdf = new GoogledriveuploadpdfController(); | 157 | |
| 149 | //$UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id); | ||
| 150 | return Response::json( $response, $statusCode); | 158 | return Response::json( $response, $statusCode); |
| 151 | 159 | $UploaqdPdf = new GoogledriveuploadpdfController(); | |
| 152 | 160 | $UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id); | |
| 153 | |||
| 154 | |||
| 155 | } | 161 | } |
| 156 | 162 | ||
| 157 | 163 | public function getList($json) | |
| 158 | |||
| 159 | public function getList($json) | ||
| 160 | { | 164 | { |
| 161 | $rows = new pdfModel(); | 165 | $rows = new pdfModel(); |
| 162 | $rows = $rows->getList($json)->get(); | 166 | $rows = $rows->getList($json)->get(); |
| ... | @@ -170,8 +174,6 @@ class ApiController extends Controller | ... | @@ -170,8 +174,6 @@ class ApiController extends Controller |
| 170 | 174 | ||
| 171 | public function getPdf($json) | 175 | public function getPdf($json) |
| 172 | { | 176 | { |
| 173 | |||
| 174 | |||
| 175 | $rows = new pdfModel(); | 177 | $rows = new pdfModel(); |
| 176 | $rows = $rows->getpdf($json)->get(); | 178 | $rows = $rows->getpdf($json)->get(); |
| 177 | $response = $rows; | 179 | $response = $rows; |
| ... | @@ -181,8 +183,6 @@ class ApiController extends Controller | ... | @@ -181,8 +183,6 @@ class ApiController extends Controller |
| 181 | } | 183 | } |
| 182 | public function getPdfPriev($json) | 184 | public function getPdfPriev($json) |
| 183 | { | 185 | { |
| 184 | |||
| 185 | |||
| 186 | $rows = new pdfModel(); | 186 | $rows = new pdfModel(); |
| 187 | $rows = $rows->getpdf($json)->get(); | 187 | $rows = $rows->getpdf($json)->get(); |
| 188 | $response = $rows; | 188 | $response = $rows; |
| ... | @@ -195,9 +195,7 @@ class ApiController extends Controller | ... | @@ -195,9 +195,7 @@ class ApiController extends Controller |
| 195 | 195 | ||
| 196 | $rows = new pdfModel(); | 196 | $rows = new pdfModel(); |
| 197 | $id = $rows->getpdfid($json)->get(); | 197 | $id = $rows->getpdfid($json)->get(); |
| 198 | 198 | $rows = $rows->getpdf($id[0]->pdfid)->get(); | |
| 199 | |||
| 200 | $rows = $rows->getpdf($id[0]->pdfid)->get(); | ||
| 201 | $response = $rows; | 199 | $response = $rows; |
| 202 | $statusCode = 200; | 200 | $statusCode = 200; |
| 203 | //var_dump($rows); | 201 | //var_dump($rows); | ... | ... |
| ... | @@ -23,34 +23,29 @@ Route::get('pdf/{id}', 'PdfController@pdf'); | ... | @@ -23,34 +23,29 @@ Route::get('pdf/{id}', 'PdfController@pdf'); |
| 23 | 23 | ||
| 24 | Route::group(array('prefix' => 'api/v1'), function($json) | 24 | Route::group(array('prefix' => 'api/v1'), function($json) |
| 25 | { | 25 | { |
| 26 | 26 | Route::resource('add', 'ApiController@insert'); | |
| 27 | Route::resource('add', 'ApiController@insert'); | ||
| 28 | |||
| 29 | Route::resource('get-list', 'ApiController@getList'); | 27 | Route::resource('get-list', 'ApiController@getList'); |
| 30 | Route::resource('get-pdf', 'ApiController@getpdf'); | 28 | Route::resource('get-pdf', 'ApiController@getpdf'); |
| 31 | Route::resource('api', 'FileEntryController@getApi'); | 29 | Route::resource('api', 'FileEntryController@getApi'); |
| 32 | Route::resource('get-pdf-google', 'ApiController@getpdfgoogle'); | 30 | Route::resource('get-pdf-google', 'ApiController@getpdfgoogle'); |
| 33 | |||
| 34 | 31 | ||
| 35 | }); | 32 | }); |
| 36 | 33 | ||
| 34 | |||
| 37 | Route::any('api/update', 'ApiController@update'); | 35 | Route::any('api/update', 'ApiController@update'); |
| 36 | Route::any('api/preview', 'ApiController@preview'); | ||
| 38 | Route::post('api/authenticate', 'AuthenticateController@authenticate'); | 37 | Route::post('api/authenticate', 'AuthenticateController@authenticate'); |
| 39 | Route::get('api/authenticate/user', 'AuthenticateController@getAuthenticatedUser'); | 38 | Route::get('api/authenticate/user', 'AuthenticateController@getAuthenticatedUser'); |
| 40 | 39 | ||
| 41 | 40 | ||
| 42 | Route::any('fileentry/postUpload', 'FileEntryController@postUpload'); | ||
| 43 | |||
| 44 | Route::get('fileentry/get/{filename}', [ | ||
| 45 | 'as' => 'getentry', 'uses' => 'FileEntryController@get']); | ||
| 46 | |||
| 47 | 41 | ||
| 42 | Route::any('fileentry/postUpload', 'FileEntryController@postUpload'); | ||
| 43 | Route::get('fileentry/get/{filename}', [ 'as' => 'getentry', 'uses' => 'FileEntryController@get']); | ||
| 48 | Route::get('fileentry', 'FileEntryController@index'); | 44 | Route::get('fileentry', 'FileEntryController@index'); |
| 49 | Route::get('fileentry/getImage/{folder}/{filename}', 'FileEntryController@getImage'); | 45 | Route::get('fileentry/getImage/{folder}/{filename}', 'FileEntryController@getImage'); |
| 50 | Route::get('fileentry/getPDF/{folder}/{filename}', 'FileEntryController@getPDF'); | 46 | Route::get('fileentry/getPDF/{folder}/{filename}', 'FileEntryController@getPDF'); |
| 47 | Route::post('fileentry/add',[ 'as' => 'addentry', 'uses' => 'FileEntryController@add']); | ||
| 51 | 48 | ||
| 52 | Route::post('fileentry/add',[ | ||
| 53 | 'as' => 'addentry', 'uses' => 'FileEntryController@add']); | ||
| 54 | 49 | ||
| 55 | Route::get('api/googlePdfUpload/{folder}/{filename}/{pdfid}/{id}', 'GoogledriveuploadpdfController@google_drive_upload'); | 50 | Route::get('api/googlePdfUpload/{folder}/{filename}/{pdfid}/{id}', 'GoogledriveuploadpdfController@google_drive_upload'); |
| 56 | Route::get('auth/google/callback', 'GoogledriveuploadpdfController@google_drive_upload'); | 51 | Route::get('auth/google/callback', 'GoogledriveuploadpdfController@google_drive_upload'); | ... | ... |
| 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 = "http://contact.gotenzing.com"; | 5 | var pluginUrl = window.location.protocol + '//' + window.location.host; |
| 6 | //var pdf_customizer = "http://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 | ||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | function getAuth() { | 15 | function getAuth() { |
| 16 | jQuery(document).ready(function($) { | 16 | jQuery(document).ready(function($) { |
| 17 | var settings = { | 17 | var settings = { |
| 18 | "async": true, | 18 | "async": true, |
| 19 | "crossDomain": true, | 19 | "crossDomain": true, |
| 20 | "url": "" + pdf_customizer + "/api/authenticate", | 20 | "url": "" + pdf_customizer + "/api/authenticate", |
| 21 | "method": "POST", | 21 | "method": "POST", |
| 22 | "processData": false, | 22 | "processData": false, |
| 23 | "contentType": false, | 23 | "contentType": false, |
| 24 | "mimeType": "multipart/form-data", | 24 | "mimeType": "multipart/form-data", |
| 25 | "data": form, | 25 | "data": form, |
| 26 | "success": function(data) { | 26 | "success": function(data) { |
| 27 | getJson(user_id); | 27 | getJson(user_id); |
| 28 | }, | 28 | }, |
| 29 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | 29 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response |
| 30 | //alert(xhr.status); | 30 | //alert(xhr.status); |
| 31 | document.getElementById('contentArea').innerHTML = xhr.responseText; | 31 | document.getElementById('contentArea').innerHTML = xhr.responseText; |
| 32 | } | 32 | } |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | $.ajax(settings).done(function(response) { | 35 | $.ajax(settings).done(function(response) { |
| 36 | console.log(response); | 36 | console.log(response); |
| 37 | 37 | ||
| 38 | }); | ||
| 38 | }); | 39 | }); |
| 39 | }); | ||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | function offFocus(id) { | 43 | function offFocus(id) { |
| 44 | jQuery(document).ready(function($) { | 44 | jQuery(document).ready(function($) { |
| 45 | $("#select" + id + "").removeClass("focus"); | 45 | $("#select" + id + "").removeClass("focus"); |
| 46 | $(".entry_block").mouseleave(function() { | 46 | $(".entry_block").mouseleave(function() { |
| 47 | $("#select" + id + "").addClass("focus"); | 47 | $("#select" + id + "").addClass("focus"); |
| 48 | 48 | ||
| 49 | }); | ||
| 49 | }); | 50 | }); |
| 50 | }); | ||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | CanvasRenderingContext2D.prototype.roundRect = function (x, y, w, h, r) { | 53 | CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) { |
| 54 | if (w < 2 * r) r = w / 2; | 54 | if (w < 2 * r) r = w / 2; |
| 55 | if (h < 2 * r) r = h / 2; | 55 | if (h < 2 * r) r = h / 2; |
| 56 | this.beginPath(); | 56 | this.beginPath(); |
| 57 | this.moveTo(x+r, y); | 57 | this.moveTo(x + r, y); |
| 58 | this.arcTo(x+w, y, x+w, y+h, r); | 58 | this.arcTo(x + w, y, x + w, y + h, r); |
| 59 | this.arcTo(x+w, y+h, x, y+h, r); | 59 | this.arcTo(x + w, y + h, x, y + h, r); |
| 60 | this.arcTo(x, y+h, x, y, r); | 60 | this.arcTo(x, y + h, x, y, r); |
| 61 | this.arcTo(x, y, x+w, y, r); | 61 | this.arcTo(x, y, x + w, y, r); |
| 62 | this.closePath(); | 62 | this.closePath(); |
| 63 | return this; | 63 | return this; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | function ShowBox(pheight, pwidth, up, right, height, width, count, example) { | 66 | function ShowBox(pheight, pwidth, up, right, height, width, count, example) { |
| 67 | jQuery(document).ready(function($) { | 67 | jQuery(document).ready(function($) { |
| 68 | $('span').hide(); | 68 | $('span').hide(); |
| 69 | $('#span' + count).show(); | 69 | $('#span' + count).show(); |
| 70 | // $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")"); | 70 | // $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")"); |
| 71 | 71 | ||
| 72 | var Qc = document.getElementById("Canvas"); | 72 | var Qc = document.getElementById("Canvas"); |
| 73 | var Qctx = Qc.getContext("2d"); | 73 | var Qctx = Qc.getContext("2d"); |
| 74 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | 74 | Qctx.clearRect(0, 0, Qc.width, Qc.height); |
| 75 | Qctx.restore(); | 75 | Qctx.restore(); |
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | 78 | ||
| 79 | var down = pheight - (up + height); | 79 | var down = pheight - (up + height); |
| 80 | var scaleH = $("Canvas").height() / pheight; | 80 | var scaleH = $("Canvas").height() / pheight; |
| 81 | var scaleW = $("Canvas").width() / pwidth; | 81 | var scaleW = $("Canvas").width() / pwidth; |
| 82 | var scaleDown = down * scaleH; | 82 | var scaleDown = down * scaleH; |
| 83 | var scaleRight = right * scaleW; | 83 | var scaleRight = right * scaleW; |
| 84 | var scalewidth = width * scaleW; | 84 | var scalewidth = width * scaleW; |
| 85 | var scaleheight = height * scaleH; | 85 | var scaleheight = height * scaleH; |
| 86 | 86 | ||
| 87 | var c = document.getElementById("Canvas"); | 87 | var c = document.getElementById("Canvas"); |
| 88 | var ctx = c.getContext("2d"); | 88 | var ctx = c.getContext("2d"); |
| 89 | ctx.save(); | 89 | ctx.save(); |
| 90 | ctx.lineWidth=2; | 90 | ctx.lineWidth = 2; |
| 91 | ctx.strokeStyle= $('.callout').css("background-color") | 91 | ctx.strokeStyle = $('.callout').css("background-color") |
| 92 | ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke(); | 92 | ctx.roundRect(scaleRight, scaleDown, scalewidth, scaleheight, 5).stroke(); |
| 93 | 93 | ||
| 94 | }); | 94 | }); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | 97 | ||
| 98 | function findUserInfoMatch(data) { | 98 | function findUserInfoMatch(data) { |
| 99 | 99 | ||
| 100 | 100 | ||
| 101 | 101 | ||
| 102 | } | 102 | } |
| ... | @@ -104,635 +104,637 @@ function findUserInfoMatch(data) { | ... | @@ -104,635 +104,637 @@ function findUserInfoMatch(data) { |
| 104 | 104 | ||
| 105 | function HideBox(kind) { | 105 | function HideBox(kind) { |
| 106 | 106 | ||
| 107 | jQuery(document).ready(function($) { | 107 | jQuery(document).ready(function($) { |
| 108 | $('span').hide(); | 108 | $('span').hide(); |
| 109 | //console.log('hide'); | 109 | //console.log('hide'); |
| 110 | var Qc = document.getElementById("Canvas"); | 110 | var Qc = document.getElementById("Canvas"); |
| 111 | var Qctx = Qc.getContext("2d"); | 111 | var Qctx = Qc.getContext("2d"); |
| 112 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | 112 | Qctx.clearRect(0, 0, Qc.width, Qc.height); |
| 113 | Qctx.restore(); | 113 | Qctx.restore(); |
| 114 | if(kind !='file'){ | 114 | if (kind != 'file') { |
| 115 | document.getElementById("preview").checked = true; | 115 | document.getElementById("preview").checked = true; |
| 116 | $('#changes').trigger('submit'); | 116 | $('#changes').trigger('submit'); |
| 117 | } | 117 | } |
| 118 | }); | 118 | }); |
| 119 | 119 | ||
| 120 | 120 | ||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | function HideBoxwithdate() { | 123 | function HideBoxwithdate() { |
| 124 | jQuery(document).ready(function($) { | 124 | jQuery(document).ready(function($) { |
| 125 | var Qc = document.getElementById("Canvas"); | 125 | var Qc = document.getElementById("Canvas"); |
| 126 | var Qctx = Qc.getContext("2d"); | 126 | var Qctx = Qc.getContext("2d"); |
| 127 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | 127 | Qctx.clearRect(0, 0, Qc.width, Qc.height); |
| 128 | Qctx.restore(); | 128 | Qctx.restore(); |
| 129 | 129 | ||
| 130 | 130 | ||
| 131 | }); | 131 | }); |
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | function fullScreen() { | 136 | function fullScreen() { |
| 137 | jQuery(document).ready(function($) { | 137 | jQuery(document).ready(function($) { |
| 138 | $('#bbox').toggleClass('fullscreen'); | 138 | $('#bbox').toggleClass('fullscreen'); |
| 139 | //$('#bbox').animate({ width: "100%", height: "100%", position: "fixed", top: "0", left: "0" }); | 139 | //$('#bbox').animate({ width: "100%", height: "100%", position: "fixed", top: "0", left: "0" }); |
| 140 | |||
| 141 | }); | ||
| 142 | } | ||
| 140 | 143 | ||
| 141 | }); | ||
| 142 | } | ||
| 143 | function getJson(user_id) { | 144 | function getJson(user_id) { |
| 144 | jQuery(document).ready(function($) { | 145 | jQuery(document).ready(function($) { |
| 145 | $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) { | 146 | $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) { |
| 146 | // Get the element with id summary and set the inner text to the result. | 147 | // Get the element with id summary and set the inner text to the result. |
| 147 | var json = JSON.stringify(data); | 148 | var json = JSON.stringify(data); |
| 148 | pickPdfFromList(json); | 149 | pickPdfFromList(json); |
| 149 | 150 | ||
| 151 | }); | ||
| 150 | }); | 152 | }); |
| 151 | }); | ||
| 152 | } | 153 | } |
| 153 | 154 | ||
| 154 | function getOneJson(id) { | 155 | function getOneJson(id) { |
| 155 | jQuery(document).ready(function($) { | 156 | jQuery(document).ready(function($) { |
| 156 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) { | 157 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) { |
| 157 | // Get the element with id summary and set the inner text to the result. | 158 | // Get the element with id summary and set the inner text to the result. |
| 158 | var json = JSON.stringify(data); | 159 | var json = JSON.stringify(data); |
| 159 | edit = false; | 160 | edit = false; |
| 160 | 161 | ||
| 161 | changePdfOptions(json,edit); | 162 | changePdfOptions(json, edit); |
| 163 | }); | ||
| 162 | }); | 164 | }); |
| 163 | }); | ||
| 164 | } | 165 | } |
| 166 | |||
| 165 | function getBackOneJson(id) { | 167 | function getBackOneJson(id) { |
| 166 | jQuery(document).ready(function($) { | 168 | jQuery(document).ready(function($) { |
| 167 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id, function(data) { | 169 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id, function(data) { |
| 168 | // Get the element with id summary and set the inner text to the result. | 170 | // Get the element with id summary and set the inner text to the result. |
| 169 | var json = JSON.stringify(data); | 171 | var json = JSON.stringify(data); |
| 170 | //$('#google_drive').show(); | 172 | //$('#google_drive').show(); |
| 171 | edit = true; | 173 | edit = true; |
| 172 | 174 | ||
| 173 | 175 | ||
| 174 | changePdfOptions(json,edi); | 176 | changePdfOptions(json, edi); |
| 177 | }); | ||
| 175 | }); | 178 | }); |
| 176 | }); | ||
| 177 | } | 179 | } |
| 178 | 180 | ||
| 179 | function pickPdfFromList(json) { | 181 | function pickPdfFromList(json) { |
| 180 | jQuery(document).ready(function($) { | 182 | jQuery(document).ready(function($) { |
| 181 | json = JSON.parse(json); | 183 | json = JSON.parse(json); |
| 182 | 184 | ||
| 183 | var strVar = ""; | 185 | var strVar = ""; |
| 184 | var i; | 186 | var i; |
| 185 | var pdflist = ""; | 187 | var pdflist = ""; |
| 186 | for (i = 0; i < json.length; ++i) { | 188 | for (i = 0; i < json.length; ++i) { |
| 187 | pdflist += '<div class="column">'; | 189 | pdflist += '<div class="column">'; |
| 188 | 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>'; | 190 | 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>'; |
| 189 | pdflist += " <h5>" + json[i].name + "</h5>"; | 191 | pdflist += " <h5>" + json[i].name + "</h5>"; |
| 190 | pdflist += "</div>"; | 192 | pdflist += "</div>"; |
| 191 | } | 193 | } |
| 192 | 194 | ||
| 193 | strVar += ' <div id="callout" class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1> <a href="#" class="fsbutton" onclick="fullScreen();">Full Screen</a>'; | 195 | strVar += ' <div id="callout" class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1> <a href="#" class="fsbutton" onclick="fullScreen();">Full Screen</a>'; |
| 194 | strVar += '</div></div></div><div id="contentAreaOver"></div> '; | 196 | strVar += '</div></div></div><div id="contentAreaOver"></div> '; |
| 195 | document.getElementById('contentArea').innerHTML = strVar; | 197 | document.getElementById('contentArea').innerHTML = strVar; |
| 196 | 198 | ||
| 197 | 199 | ||
| 198 | 200 | ||
| 199 | }); | 201 | }); |
| 200 | } | 202 | } |
| 201 | 203 | ||
| 202 | 204 | ||
| 203 | 205 | ||
| 204 | 206 | ||
| 205 | function changePdfOptions(json, edit) { | 207 | function changePdfOptions(json, edit) { |
| 206 | jQuery(function($) { | 208 | jQuery(function($) { |
| 207 | if(edit == false){ | 209 | if (edit == false) { |
| 208 | $('#contentAreaOver').hide(); | 210 | $('#contentAreaOver').hide(); |
| 209 | } | 211 | } |
| 210 | |||
| 211 | |||
| 212 | |||
| 213 | json = JSON.parse(json); | ||
| 214 | |||
| 215 | $(document).ready(function() { | ||
| 216 | |||
| 217 | |||
| 218 | $("#changescontentdate").datepicker({ | ||
| 219 | plugins: "tabfocus", | ||
| 220 | changeMonth: true, | ||
| 221 | changeYear: true, | ||
| 222 | yearRange: '2015:2025', | ||
| 223 | dateFormat: 'DD MM dd yy', | ||
| 224 | minDate: 0, | ||
| 225 | defaultDate: null | ||
| 226 | }).on('change', function() { | ||
| 227 | $(this).valid(); // triggers the validation test | ||
| 228 | document.getElementById("preview").checked = true; | ||
| 229 | $('#changes').trigger('submit'); | ||
| 230 | |||
| 231 | }); | ||
| 232 | |||
| 233 | $("#changes").validate({ | ||
| 234 | errorPlacement: function(error, element) { | ||
| 235 | var isFile = $(element).attr('type') == 'file'; | ||
| 236 | if(isFile) { | ||
| 237 | error.insertAfter($(element).parent('label')); | ||
| 238 | } else { | ||
| 239 | error.insertAfter(element); | ||
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | }); | ||
| 244 | }); | ||
| 245 | 212 | ||
| 246 | var strVar2 = ""; | 213 | |
| 247 | var pdflist = ""; | 214 | |
| 248 | var pdfChange = ""; | 215 | json = JSON.parse(json); |
| 249 | var f = 0; | 216 | |
| 250 | 217 | $(document).ready(function() { | |
| 251 | var windowWidth = 0.90 * $(".layout-grid").width(); | 218 | |
| 252 | var windowHeight = 0.90 * $(".layout-grid").height(); | 219 | |
| 253 | 220 | $("#changescontentdate").datepicker({ | |
| 254 | 221 | plugins: "tabfocus", | |
| 255 | var windowHBG = 0.923 * $(window).height(); | 222 | changeMonth: true, |
| 256 | var pwidth = parseInt(json[0].pwidth); | 223 | changeYear: true, |
| 257 | var pheight = parseInt(json[0].pheight); | 224 | yearRange: '2015:2025', |
| 258 | 225 | dateFormat: 'DD MM dd yy', | |
| 259 | //console.log( windowWidth+' '+windowHeight); | 226 | minDate: 0, |
| 260 | //console.log( pwidth+' '+pheight); | 227 | defaultDate: null |
| 261 | if(pwidth > pheight){ | 228 | }).on('change', function() { |
| 262 | //console.log('wide') | 229 | $(this).valid(); // triggers the validation test |
| 263 | var scaleImage = windowWidth / pwidth; | 230 | document.getElementById("preview").checked = true; |
| 264 | var imageHeight = pheight * scaleImage; | 231 | $('#changes').trigger('submit'); |
| 265 | var imageWidth = windowWidth; | 232 | |
| 266 | var imgLeft = 0; | 233 | }); |
| 267 | var imgTop = 40; | 234 | |
| 268 | }else{ | 235 | $("#changes").validate({ |
| 269 | var scaleImage = windowHeight / pheight; | 236 | errorPlacement: function(error, element) { |
| 270 | var imageHeight = windowHeight; | 237 | var isFile = $(element).attr('type') == 'file'; |
| 271 | var imageWidth = pwidth * scaleImage; | 238 | if (isFile) { |
| 272 | var imgLeft = 30; | 239 | error.insertAfter($(element).parent('label')); |
| 273 | var imgTop = 2; | 240 | } else { |
| 274 | } | 241 | error.insertAfter(element); |
| 275 | 242 | } | |
| 276 | 243 | } | |
| 277 | // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight); | 244 | |
| 278 | 245 | }); | |
| 279 | pdflist += '<div id="pdfPreview" style="" class="column">'; | ||
| 280 | |||
| 281 | 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>'; | ||
| 282 | pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>'; | ||
| 283 | pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; | ||
| 284 | for (i = 0; i < json.length; ++i) { | ||
| 285 | var example = json[0].folder + '/' + json[i].example; | ||
| 286 | |||
| 287 | if (json[i].change_type == "textflow") { | ||
| 288 | 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>'; | ||
| 289 | ++f; | ||
| 290 | pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 291 | } | ||
| 292 | if (json[i].change_type == "text") { | ||
| 293 | 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 + '"">'; | ||
| 294 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 295 | } | ||
| 296 | if (json[i].change_type == "img") { | ||
| 297 | if(edit == true){ | ||
| 298 | pdfChange += '<input value="'+json[i].content+'" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >'; | ||
| 299 | 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>'; | ||
| 300 | |||
| 301 | }else{ | ||
| 302 | 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>'; | ||
| 303 | } | ||
| 304 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 305 | |||
| 306 | } | ||
| 307 | if (json[i].change_type == "date") { | ||
| 308 | 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 + '"">'; | ||
| 309 | pdfChange += '<span class="tip" id="span' + i + '"> </span><br/>'; | ||
| 310 | |||
| 311 | } | ||
| 312 | if (json[i].change_type == "user") { | ||
| 313 | var str = json[i].content; | ||
| 314 | if(str.startsWith('*')){ | ||
| 315 | var s =json[i].content.substr(1); | ||
| 316 | //findUserInfoMatch(s); | ||
| 317 | var content_string = eval(s); | ||
| 318 | }else{ | ||
| 319 | var content_string =json[i].content; } | ||
| 320 | 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 + '"">'; | ||
| 321 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 322 | |||
| 323 | } | ||
| 324 | |||
| 325 | |||
| 326 | } | ||
| 327 | pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;">'; | ||
| 328 | pdfChange += '<input type="submit" value="Save and Continue">'; | ||
| 329 | |||
| 330 | pdfChange += '</form>'; | ||
| 331 | |||
| 332 | strVar2 += ''; | ||
| 333 | strVar2 += ''; | ||
| 334 | 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>'; | ||
| 335 | 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>'; | ||
| 336 | |||
| 337 | document.getElementById('contentAreaOver').innerHTML = strVar2; | ||
| 338 | |||
| 339 | |||
| 340 | |||
| 341 | if(edit == false){ | ||
| 342 | $("#contentAreaOver").slideToggle(); | ||
| 343 | $('#google_drive').slideToggle(); | ||
| 344 | //document.getElementById('google_drive').innerHTML = " "; | ||
| 345 | } | ||
| 346 | |||
| 347 | |||
| 348 | var tinymces = tinymce.init({ | ||
| 349 | selector: '.textarea', | ||
| 350 | entity_encoding: "raw", | ||
| 351 | menubar: false, | ||
| 352 | toolbar: ' bold italic', | ||
| 353 | remove_linebreaks: false, | ||
| 354 | remove_trailing_brs: false, | ||
| 355 | init_instance_callback: function(editor) { | ||
| 356 | var editorDoc = document.getElementById(editor.id + '_ifr'); | ||
| 357 | var editorDocContent = editorDoc.contentDocument; | ||
| 358 | editorDoc.style.border = "0px solid #131212"; | ||
| 359 | editorDocContent.body.style.backgroundColor = "#131212"; | ||
| 360 | editorDocContent.body.style.color = "#ccc"; | ||
| 361 | }, | ||
| 362 | setup: function(editor) { | ||
| 363 | editor.on('focus', function(e) { | ||
| 364 | //console.log(editor.id); | ||
| 365 | |||
| 366 | var editorDoc = document.getElementById(editor.id + '_ifr'); | ||
| 367 | var editorDocContent = editorDoc.contentDocument; | ||
| 368 | editorDoc.style.border = "2px solid #F7A800"; | ||
| 369 | |||
| 370 | $('#' + editor.id).trigger("onfocus"); | ||
| 371 | //$(this).css('border', '2px solid #F7A800 !important'); | ||
| 372 | }); | ||
| 373 | editor.on('blur', function(e) { | ||
| 374 | //console.log('out' + editor.id); | ||
| 375 | var editorDoc = document.getElementById(editor.id + '_ifr'); | ||
| 376 | var editorDocContent = editorDoc.contentDocument; | ||
| 377 | editorDoc.style.border = "2px solid #131212"; | ||
| 378 | |||
| 379 | //$(this).css('border', '0px solid #F7A800 !important'); | ||
| 380 | HideBox(); | ||
| 381 | }); | ||
| 382 | } | ||
| 383 | }); | ||
| 384 | |||
| 385 | $('.closeEditer').click(function() { | ||
| 386 | $("#contentAreaOver").slideToggle(function(){ | ||
| 387 | edit = false; | ||
| 388 | tinyMCE.remove(); | ||
| 389 | }); | 246 | }); |
| 390 | $('#google_drive').slideToggle(); | 247 | |
| 391 | }); | 248 | var strVar2 = ""; |
| 392 | 249 | var pdflist = ""; | |
| 393 | var files; | 250 | var pdfChange = ""; |
| 394 | var imagefiles = []; | 251 | var f = 0; |
| 395 | 252 | ||
| 396 | $(".fileupload").change(function(e) { | 253 | var windowWidth = 0.90 * $(".layout-grid").width(); |
| 397 | var target = e.target; | 254 | var windowHeight = 0.90 * $(".layout-grid").height(); |
| 398 | files = e.target.files; | 255 | |
| 399 | // console.log(files); | 256 | |
| 400 | 257 | var windowHBG = 0.923 * $(window).height(); | |
| 401 | if(files.length >= 1) { | 258 | var pwidth = parseInt(json[0].pwidth); |
| 402 | for (var i = 0, file; file = files[i]; i++) { | 259 | var pheight = parseInt(json[0].pheight); |
| 403 | var fileName = file.name; | 260 | |
| 404 | // insert file name | 261 | //console.log( windowWidth+' '+windowHeight); |
| 405 | if(fileName) { | 262 | //console.log( pwidth+' '+pheight); |
| 406 | $(target).parent('label').find('.file-name').text(fileName); | 263 | if (pwidth > pheight) { |
| 407 | } else { | 264 | //console.log('wide') |
| 408 | $(target).parent('label').find('.file-name').text(''); | 265 | var scaleImage = windowWidth / pwidth; |
| 409 | } | 266 | var imageHeight = pheight * scaleImage; |
| 410 | 267 | var imageWidth = windowWidth; | |
| 411 | imagefiles.push(file); | 268 | var imgLeft = 0; |
| 412 | // console.log(imagefiles); | 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; | ||
| 413 | } | 276 | } |
| 414 | } else { | ||
| 415 | $(target).parent('label').find('.file-name').text(''); | ||
| 416 | } | ||
| 417 | $(target).parent('label').trigger('focus'); | ||
| 418 | if( $(target).val()){ | ||
| 419 | document.getElementById("preview").checked = true; | ||
| 420 | $('#changes').trigger('submit'); | ||
| 421 | } | ||
| 422 | |||
| 423 | }); | ||
| 424 | 277 | ||
| 425 | $('.custom-file-input').keypress(function(event) { | ||
| 426 | if(event.which == 13) { | ||
| 427 | $(this).trigger('click'); | ||
| 428 | |||
| 429 | } | ||
| 430 | 278 | ||
| 431 | }); | 279 | // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight); |
| 432 | $("#changes").submit(function(e) { | 280 | |
| 281 | pdflist += '<div id="pdfPreview" style="" class="column">'; | ||
| 282 | // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; | ||
| 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>'; | ||
| 284 | 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 + '">'; | ||
| 286 | for (i = 0; i < json.length; ++i) { | ||
| 287 | var example = json[0].folder + '/' + json[i].example; | ||
| 288 | |||
| 289 | 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>'; | ||
| 291 | ++f; | ||
| 292 | pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 293 | } | ||
| 294 | 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 + '"">'; | ||
| 296 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 297 | } | ||
| 298 | if (json[i].change_type == "img") { | ||
| 299 | if (edit == true) { | ||
| 300 | 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>'; | ||
| 302 | |||
| 303 | } 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>'; | ||
| 305 | } | ||
| 306 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 307 | |||
| 308 | } | ||
| 309 | 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 + '"">'; | ||
| 311 | pdfChange += '<span class="tip" id="span' + i + '"> </span><br/>'; | ||
| 312 | |||
| 313 | } | ||
| 314 | if (json[i].change_type == "user") { | ||
| 315 | var str = json[i].content; | ||
| 316 | if (str.startsWith('*')) { | ||
| 317 | var s = json[i].content.substr(1); | ||
| 318 | //findUserInfoMatch(s); | ||
| 319 | var content_string = eval(s); | ||
| 320 | } else { | ||
| 321 | var content_string = json[i].content; | ||
| 322 | } | ||
| 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 + '"">'; | ||
| 324 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | ||
| 325 | |||
| 326 | } | ||
| 327 | |||
| 328 | |||
| 329 | } | ||
| 330 | pdfChange += '<input type="checkbox" id="preview" name="preview" style="display: none;">'; | ||
| 331 | pdfChange += '<input type="submit" value="Save and Continue">'; | ||
| 332 | |||
| 333 | pdfChange += '</form>'; | ||
| 334 | |||
| 335 | strVar2 += ''; | ||
| 336 | 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>'; | ||
| 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>'; | ||
| 339 | |||
| 340 | document.getElementById('contentAreaOver').innerHTML = strVar2; | ||
| 341 | |||
| 433 | 342 | ||
| 434 | e.preventDefault(); | ||
| 435 | if($('#preview').prop('checked')==true){ | ||
| 436 | |||
| 437 | $(tinymce.get()).each(function(i, el) { | ||
| 438 | 343 | ||
| 439 | if (el.id) | 344 | if (edit == false) { |
| 440 | document.getElementById(el.id).value = el.getContent(); | 345 | $("#contentAreaOver").slideToggle(); |
| 441 | //$('#changes').hide(); | 346 | $('#google_drive').slideToggle(); |
| 442 | tinymce.get(el.id).remove(); | 347 | //document.getElementById('google_drive').innerHTML = " "; |
| 348 | } | ||
| 349 | |||
| 350 | |||
| 351 | var tinymces = tinymce.init({ | ||
| 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 | } | ||
| 443 | }); | 386 | }); |
| 444 | 387 | ||
| 445 | 388 | $('.closeEditer').click(function() { | |
| 446 | var ids =[]; | 389 | $("#contentAreaOver").slideToggle(function() { |
| 447 | if(edit == true){ | 390 | edit = false; |
| 448 | $("#changes input[type=file]").each(function() { | 391 | tinyMCE.remove(); |
| 449 | if($(this).get(0).files.length == 0 ){ | 392 | }); |
| 450 | 393 | $('#google_drive').slideToggle(); | |
| 451 | |||
| 452 | document.getElementById(this.id).remove(); | ||
| 453 | }else{ | ||
| 454 | console.log("hidden"+this.id); | ||
| 455 | document.getElementById("hidden"+this.id).remove(); | ||
| 456 | |||
| 457 | |||
| 458 | } | ||
| 459 | });} | ||
| 460 | var form = $("#changes"); | ||
| 461 | //console.log(form); | ||
| 462 | |||
| 463 | returnfileOptions(imagefiles, form, preview = true); | ||
| 464 | |||
| 465 | |||
| 466 | |||
| 467 | var tinymces = tinymce.init({ | ||
| 468 | selector: '.textarea', | ||
| 469 | entity_encoding: "raw", | ||
| 470 | menubar: false, | ||
| 471 | toolbar: ' bold italic', | ||
| 472 | remove_linebreaks: false, | ||
| 473 | remove_trailing_brs: false, | ||
| 474 | init_instance_callback: function(editor) { | ||
| 475 | var editorDoc = document.getElementById(editor.id + '_ifr'); | ||
| 476 | var editorDocContent = editorDoc.contentDocument; | ||
| 477 | editorDoc.style.border = "0px solid #131212"; | ||
| 478 | editorDocContent.body.style.backgroundColor = "#131212"; | ||
| 479 | editorDocContent.body.style.color = "#ccc"; | ||
| 480 | }, | ||
| 481 | setup: function(editor) { | ||
| 482 | editor.on('focus', function(e) { | ||
| 483 | //console.log(editor.id); | ||
| 484 | |||
| 485 | var editorDoc = document.getElementById(editor.id + '_ifr'); | ||
| 486 | var editorDocContent = editorDoc.contentDocument; | ||
| 487 | editorDoc.style.border = "2px solid #F7A800"; | ||
| 488 | |||
| 489 | $('#' + editor.id).trigger("onfocus"); | ||
| 490 | //$(this).css('border', '2px solid #F7A800 !important'); | ||
| 491 | }); | 394 | }); |
| 492 | editor.on('blur', function(e) { | 395 | |
| 493 | //console.log('out' + editor.id); | 396 | var files; |
| 494 | var editorDoc = document.getElementById(editor.id + '_ifr'); | 397 | var imagefiles = []; |
| 495 | var editorDocContent = editorDoc.contentDocument; | 398 | |
| 496 | editorDoc.style.border = "2px solid #131212"; | 399 | $(".fileupload").change(function(e) { |
| 497 | 400 | var target = e.target; | |
| 498 | //$(this).css('border', '0px solid #F7A800 !important'); | 401 | files = e.target.files; |
| 499 | HideBox(); | 402 | // console.log(files); |
| 403 | |||
| 404 | if (files.length >= 1) { | ||
| 405 | for (var i = 0, file; file = files[i]; i++) { | ||
| 406 | var fileName = file.name; | ||
| 407 | // insert file name | ||
| 408 | if (fileName) { | ||
| 409 | $(target).parent('label').find('.file-name').text(fileName); | ||
| 410 | } else { | ||
| 411 | $(target).parent('label').find('.file-name').text(''); | ||
| 412 | } | ||
| 413 | |||
| 414 | imagefiles.push(file); | ||
| 415 | // console.log(imagefiles); | ||
| 416 | } | ||
| 417 | } else { | ||
| 418 | $(target).parent('label').find('.file-name').text(''); | ||
| 419 | } | ||
| 420 | $(target).parent('label').trigger('focus'); | ||
| 421 | if ($(target).val()) { | ||
| 422 | document.getElementById("preview").checked = true; | ||
| 423 | $('#changes').trigger('submit'); | ||
| 424 | } | ||
| 425 | |||
| 500 | }); | 426 | }); |
| 501 | } | ||
| 502 | }); | ||
| 503 | $("#changes").validate().cancelSubmit = true; | ||
| 504 | 427 | ||
| 428 | $('.custom-file-input').keypress(function(event) { | ||
| 429 | if (event.which == 13) { | ||
| 430 | $(this).trigger('click'); | ||
| 505 | 431 | ||
| 506 | }else{ | 432 | } |
| 507 | 433 | ||
| 434 | }); | ||
| 435 | $("#changes").submit(function(e) { | ||
| 508 | 436 | ||
| 437 | e.preventDefault(); | ||
| 438 | if ($('#preview').prop('checked') == true) { | ||
| 509 | 439 | ||
| 440 | $(tinymce.get()).each(function(i, el) { | ||
| 510 | 441 | ||
| 511 | if ($("#changes").valid()) { | 442 | if (el.id) |
| 443 | document.getElementById(el.id).value = el.getContent(); | ||
| 444 | //$('#changes').hide(); | ||
| 445 | tinymce.get(el.id).remove(); | ||
| 446 | }); | ||
| 512 | 447 | ||
| 513 | $(tinymce.get()).each(function(i, el) { | ||
| 514 | 448 | ||
| 515 | if (el.id) | 449 | var ids = []; |
| 516 | document.getElementById(el.id).value = el.getContent(); | 450 | if (edit == true) { |
| 517 | $('#changes').hide(); | 451 | $("#changes input[type=file]").each(function() { |
| 518 | tinymce.get(el.id).remove(); | 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"); | ||
| 465 | //console.log(form); | ||
| 466 | |||
| 467 | 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; | ||
| 508 | |||
| 509 | |||
| 510 | } else { | ||
| 511 | |||
| 512 | |||
| 513 | |||
| 514 | |||
| 515 | if ($("#changes").valid()) { | ||
| 516 | |||
| 517 | $(tinymce.get()).each(function(i, el) { | ||
| 518 | |||
| 519 | if (el.id) | ||
| 520 | document.getElementById(el.id).value = el.getContent(); | ||
| 521 | $('#changes').hide(); | ||
| 522 | tinymce.get(el.id).remove(); | ||
| 523 | }); | ||
| 524 | |||
| 525 | |||
| 526 | var ids = []; | ||
| 527 | if (edit == true) { | ||
| 528 | $("#changes input[type=file]").each(function() { | ||
| 529 | if ($(this).get(0).files.length == 0) { | ||
| 530 | |||
| 531 | |||
| 532 | document.getElementById(this.id).remove(); | ||
| 533 | } else { | ||
| 534 | //console.log("hidden"+this.id); | ||
| 535 | document.getElementById("hidden" + this.id).remove(); | ||
| 536 | |||
| 537 | |||
| 538 | } | ||
| 539 | }); | ||
| 540 | } | ||
| 541 | var form = $("#changes"); | ||
| 542 | //console.log(form); | ||
| 543 | |||
| 544 | returnfileOptions(imagefiles, form, preview = false); | ||
| 545 | return false; | ||
| 546 | } else { | ||
| 547 | return false; | ||
| 548 | } | ||
| 549 | } | ||
| 519 | }); | 550 | }); |
| 520 | |||
| 521 | |||
| 522 | var ids =[]; | ||
| 523 | if(edit == true){ | ||
| 524 | $("#changes input[type=file]").each(function() { | ||
| 525 | if($(this).get(0).files.length == 0 ){ | ||
| 526 | |||
| 527 | |||
| 528 | document.getElementById(this.id).remove(); | ||
| 529 | }else{ | ||
| 530 | //console.log("hidden"+this.id); | ||
| 531 | document.getElementById("hidden"+this.id).remove(); | ||
| 532 | |||
| 533 | |||
| 534 | } | ||
| 535 | });} | ||
| 536 | var form = $("#changes"); | ||
| 537 | //console.log(form); | ||
| 538 | |||
| 539 | returnfileOptions(imagefiles, form, preview = false); | ||
| 540 | return false; | ||
| 541 | } else { | ||
| 542 | return false; | ||
| 543 | } | ||
| 544 | } | ||
| 545 | }); | ||
| 546 | 551 | ||
| 547 | }); | 552 | }); |
| 548 | 553 | ||
| 549 | } | 554 | } |
| 550 | 555 | ||
| 551 | 556 | ||
| 552 | function returnfileOptions(files, form, preview) { | 557 | function returnfileOptions(files, form, preview) { |
| 553 | jQuery(function($) { | 558 | jQuery(function($) { |
| 554 | 559 | ||
| 555 | var data = new FormData(); | 560 | var data = new FormData(); |
| 556 | $.each(files, function(key, value) { | 561 | $.each(files, function(key, value) { |
| 557 | data.append(key, value); | 562 | data.append(key, value); |
| 558 | 563 | ||
| 559 | }); | 564 | }); |
| 560 | 565 | ||
| 561 | $.ajax({ | 566 | $.ajax({ |
| 562 | url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files', | 567 | url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files', |
| 563 | type: 'POST', | 568 | type: 'POST', |
| 564 | data: data, | 569 | data: data, |
| 565 | cache: false, | 570 | cache: false, |
| 566 | dataType: 'json', | 571 | dataType: 'json', |
| 567 | processData: false, // Don't process the files | 572 | processData: false, // Don't process the files |
| 568 | contentType: false, // Set content type to false as jQuery will tell the server its a query string request | 573 | contentType: false, // Set content type to false as jQuery will tell the server its a query string request |
| 569 | success: function(data, textStatus, jqXHR) { | 574 | success: function(data, textStatus, jqXHR) { |
| 570 | if (typeof data.error === 'undefined') { | 575 | if (typeof data.error === 'undefined') { |
| 571 | returnOptions(form , preview); | 576 | returnOptions(form, preview); |
| 572 | } else { | 577 | } else { |
| 573 | // Handle errors here | 578 | // Handle errors here |
| 579 | |||
| 580 | console.log('ERRORS: ' + data.error); | ||
| 581 | } | ||
| 582 | }, | ||
| 583 | error: function(jqXHR, textStatus, errorThrown) { | ||
| 584 | // Handle errors here | ||
| 585 | console.log('ERRORS: ' + textStatus); | ||
| 586 | // STOP LOADING SPINNER | ||
| 587 | } | ||
| 588 | }); | ||
| 574 | 589 | ||
| 575 | console.log('ERRORS: ' + data.error); | ||
| 576 | } | ||
| 577 | }, | ||
| 578 | error: function(jqXHR, textStatus, errorThrown) { | ||
| 579 | // Handle errors here | ||
| 580 | console.log('ERRORS: ' + textStatus); | ||
| 581 | // STOP LOADING SPINNER | ||
| 582 | } | ||
| 583 | }); | 590 | }); |
| 584 | |||
| 585 | }); | ||
| 586 | } | 591 | } |
| 587 | 592 | ||
| 588 | 593 | ||
| 589 | 594 | ||
| 590 | 595 | ||
| 591 | function returnOptions(form, preview) { | 596 | function returnOptions(form, preview) { |
| 592 | jQuery(function($) { | 597 | jQuery(function($) { |
| 593 | 598 | ||
| 594 | |||
| 595 | 599 | ||
| 596 | $.getJSON(pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { | ||
| 597 | // Get the element with id summary and set the inner text to the result. | ||
| 598 | 600 | ||
| 599 | var json = dataReturnd; | 601 | $.getJSON(pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { |
| 600 | 602 | // Get the element with id summary and set the inner text to the result. | |
| 601 | 603 | ||
| 604 | var json = dataReturnd; | ||
| 602 | 605 | ||
| 603 | 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":[' | ||
| 604 | var e = 1; | ||
| 605 | var o = 1; | ||
| 606 | for (i = 0; i < json.length; ++i) { | ||
| 607 | 606 | ||
| 608 | 607 | ||
| 609 | var style = JSON.stringify(json[i].style); | 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":[' |
| 610 | var content = JSON.stringify(form[0][e].value); | 609 | var e = 1; |
| 611 | //console.log(form[0][e].value); | 610 | var o = 1; |
| 612 | //console.log(json[i].label+' '+json[i].order); | 611 | for (i = 0; i < json.length; ++i) { |
| 613 | |||
| 614 | if(content != '""') { | ||
| 615 | if (o !== 1) { | ||
| 616 | jsonReturn += ','; | ||
| 617 | |||
| 618 | } | ||
| 619 | 612 | ||
| 620 | 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/"}'; | ||
| 621 | |||
| 622 | ++o | ||
| 623 | |||
| 624 | }; | ||
| 625 | ++e | ||
| 626 | |||
| 627 | |||
| 628 | } | ||
| 629 | jsonReturn += ' ]}'; | ||
| 630 | |||
| 631 | |||
| 632 | |||
| 633 | |||
| 634 | |||
| 635 | |||
| 636 | var windowWidth = 0.90 * $(".layout-grid").width(); | ||
| 637 | var windowHeight = 0.90 * $(".layout-grid").height(); | ||
| 638 | |||
| 639 | |||
| 640 | var windowHBG = 0.923 * $(window).height(); | ||
| 641 | var pwidth = parseInt(json[0].pwidth); | ||
| 642 | var pheight = parseInt(json[0].pheight); | ||
| 643 | |||
| 644 | //console.log( windowWidth+' '+windowHeight); | ||
| 645 | //console.log( pwidth+' '+pheight); | ||
| 646 | if(pwidth > pheight){ | ||
| 647 | //console.log('wide') | ||
| 648 | var scaleImage = windowWidth / pwidth; | ||
| 649 | var imageHeight = pheight * scaleImage; | ||
| 650 | var imageWidth = windowWidth; | ||
| 651 | var imgLeft = 0; | ||
| 652 | var imgTop = 40; | ||
| 653 | }else{ | ||
| 654 | var scaleImage = windowHeight / pheight; | ||
| 655 | var imageHeight = windowHeight; | ||
| 656 | var imageWidth = pwidth * scaleImage; | ||
| 657 | var imgLeft = 30; | ||
| 658 | var imgTop = 2; | ||
| 659 | var url; | ||
| 660 | } | ||
| 661 | // console.log(jsonReturn); | ||
| 662 | |||
| 663 | if(preview == false){ | ||
| 664 | $("#Canvas").css('z-index','0'); | ||
| 665 | $('#changes').hide(); | ||
| 666 | $('#controls').show(); | ||
| 667 | url = 'update'; | ||
| 668 | }else{ | ||
| 669 | $("#changes").validate().cancelSubmit = false; | ||
| 670 | document.getElementById("preview").checked = false; | ||
| 671 | url = 'preview'; | ||
| 672 | } | ||
| 673 | $('#controls').hide(); | ||
| 674 | $('#pdfPreviewInner').show(); | ||
| 675 | |||
| 676 | |||
| 677 | |||
| 678 | $.ajax({ | ||
| 679 | url: "" + pdf_customizer + "/api/"+url, | ||
| 680 | type: "POST", | ||
| 681 | dataType: 'json', | ||
| 682 | data: jsonReturn, | ||
| 683 | contentType: "application/json", | ||
| 684 | CrossDomain: true, | ||
| 685 | |||
| 686 | success: function(data) { | ||
| 687 | |||
| 688 | var strVar2 = "" | ||
| 689 | 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>'; | ||
| 690 | document.getElementById('pdfPreviewInner').innerHTML = strVar2; | ||
| 691 | |||
| 692 | 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>'; | ||
| 693 | document.getElementById('controls').innerHTML = strVar3; | ||
| 694 | |||
| 695 | $.LoadingOverlaySetup({ color : "rgba(0, 0, 0, 0.9)"}); | ||
| 696 | $('#Canvas').LoadingOverlay("show"); | ||
| 697 | $('#Canvas').delay(600).queue(function() { | ||
| 698 | $(this).css("background-image", ""); | ||
| 699 | }); | ||
| 700 | |||
| 701 | setTimeout(function(){ | ||
| 702 | $('#Canvas').LoadingOverlay("hide", true); | ||
| 703 | }, 600); | ||
| 704 | |||
| 705 | if(preview == false){ | ||
| 706 | $('#controls').show(); | ||
| 707 | } | ||
| 708 | |||
| 709 | |||
| 710 | |||
| 711 | $('#editMe').click(function() { | ||
| 712 | $("#google_drive").hide(); | ||
| 713 | $('#controls').hide(); | ||
| 714 | $('#changes').show(); | ||
| 715 | $("#Canvas").show(); | ||
| 716 | $("#Canvas").css('z-index','10'); | ||
| 717 | }); | ||
| 718 | |||
| 719 | $('#downloadMe').click(function() { | ||
| 720 | $(".closeEditer").click(); | ||
| 721 | }); | ||
| 722 | |||
| 723 | |||
| 724 | |||
| 725 | }, | ||
| 726 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | ||
| 727 | alert(xhr.status); | ||
| 728 | document.getElementById('pdfPreview').innerHTML = xhr.responseText; | ||
| 729 | |||
| 730 | } | ||
| 731 | |||
| 732 | 613 | ||
| 733 | }); | 614 | var style = JSON.stringify(json[i].style); |
| 615 | var content = JSON.stringify(form[0][e].value); | ||
| 616 | //console.log(form[0][e].value); | ||
| 617 | //console.log(json[i].label+' '+json[i].order); | ||
| 618 | |||
| 619 | if (content != '""') { | ||
| 620 | if (o !== 1) { | ||
| 621 | jsonReturn += ','; | ||
| 622 | |||
| 623 | } | ||
| 624 | |||
| 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/"}'; | ||
| 626 | |||
| 627 | ++o | ||
| 628 | |||
| 629 | }; | ||
| 630 | ++e | ||
| 631 | |||
| 632 | |||
| 633 | } | ||
| 634 | jsonReturn += ' ]}'; | ||
| 635 | |||
| 636 | |||
| 637 | |||
| 638 | |||
| 639 | var windowWidth = 0.90 * $(".layout-grid").width(); | ||
| 640 | var windowHeight = 0.90 * $(".layout-grid").height(); | ||
| 641 | |||
| 642 | |||
| 643 | var windowHBG = 0.923 * $(window).height(); | ||
| 644 | var pwidth = parseInt(json[0].pwidth); | ||
| 645 | var pheight = parseInt(json[0].pheight); | ||
| 646 | |||
| 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); | ||
| 665 | |||
| 666 | if (preview == false) { | ||
| 667 | $("#Canvas").css('z-index', '0'); | ||
| 668 | $('#changes').hide(); | ||
| 669 | $('#controls').show(); | ||
| 670 | url = 'update'; | ||
| 671 | } else { | ||
| 672 | $("#changes").validate().cancelSubmit = false; | ||
| 673 | document.getElementById("preview").checked = false; | ||
| 674 | url = 'preview'; | ||
| 675 | } | ||
| 676 | $('#controls').hide(); | ||
| 677 | $('#pdfPreviewInner').show(); | ||
| 734 | 678 | ||
| 735 | 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 = "" | ||
| 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>'; | ||
| 693 | document.getElementById('pdfPreviewInner').innerHTML = strVar2; | ||
| 694 | |||
| 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>'; | ||
| 696 | document.getElementById('controls').innerHTML = strVar3; | ||
| 697 | |||
| 698 | $.LoadingOverlaySetup({ | ||
| 699 | color: "rgba(0, 0, 0, 0.9)" | ||
| 700 | }); | ||
| 701 | $('#Canvas').LoadingOverlay("show"); | ||
| 702 | $('#Canvas').delay(600).queue(function() { | ||
| 703 | $(this).css("background-image", ""); | ||
| 704 | }); | ||
| 705 | |||
| 706 | setTimeout(function() { | ||
| 707 | $('#Canvas').LoadingOverlay("hide", true); | ||
| 708 | }, 600); | ||
| 709 | |||
| 710 | if (preview == false) { | ||
| 711 | $('#controls').show(); | ||
| 712 | } | ||
| 713 | |||
| 714 | |||
| 715 | |||
| 716 | $('#editMe').click(function() { | ||
| 717 | $("#google_drive").hide(); | ||
| 718 | $('#controls').hide(); | ||
| 719 | $('#changes').show(); | ||
| 720 | $("#Canvas").show(); | ||
| 721 | $("#Canvas").css('z-index', '10'); | ||
| 722 | }); | ||
| 723 | |||
| 724 | $('#downloadMe').click(function() { | ||
| 725 | $(".closeEditer").click(); | ||
| 726 | }); | ||
| 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 | |||
| 732 | } | ||
| 733 | |||
| 734 | |||
| 735 | }); | ||
| 736 | |||
| 737 | |||
| 738 | }); | ||
| 736 | }); | 739 | }); |
| 737 | }); | ||
| 738 | } | 740 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment