preview after every input
Showing
3 changed files
with
126 additions
and
131 deletions
| ... | @@ -33,8 +33,7 @@ class ApiController extends Controller | ... | @@ -33,8 +33,7 @@ class ApiController extends Controller |
| 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,32 +83,55 @@ class ApiController extends Controller | ... | @@ -92,32 +83,55 @@ class ApiController extends Controller |
| 92 | $curl->close(); | 83 | $curl->close(); |
| 93 | 84 | ||
| 94 | } | 85 | } |
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 95 | 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(); | ||
| 96 | 98 | ||
| 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 | ||
| 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); | ||
| 99 | } | 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 | |||
| 110 | $pdfLocation = $json->pdf[0]->pdfLocation; | 129 | $pdfLocation = $json->pdf[0]->pdfLocation; |
| 111 | $cust_id = $json->pdf[0]->custId; | 130 | $cust_id = $json->pdf[0]->custId; |
| 112 | |||
| 113 | |||
| 114 | |||
| 115 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); | 131 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); |
| 116 | 132 | ||
| 117 | |||
| 118 | foreach ($json->changes as $change) { | 133 | foreach ($json->changes as $change) { |
| 119 | if ($change->change_type == 'img') { | 134 | if ($change->change_type == 'img') { |
| 120 | |||
| 121 | $folder = str_replace(' ', '-', $json->pdf[0]->folder); // Replaces all spaces with hyphens. | 135 | $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; |
| ... | @@ -127,35 +141,25 @@ class ApiController extends Controller | ... | @@ -127,35 +141,25 @@ 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); | ||
| 131 | |||
| 132 | } | 144 | } |
| 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(); | ||
| 149 | //$UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id); | ||
| 150 | return Response::json( $response, $statusCode); | ||
| 151 | |||
| 152 | |||
| 153 | |||
| 154 | 157 | ||
| 158 | return Response::json( $response, $statusCode); | ||
| 159 | $UploaqdPdf = new GoogledriveuploadpdfController(); | ||
| 160 | $UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id); | ||
| 155 | } | 161 | } |
| 156 | 162 | ||
| 157 | |||
| 158 | |||
| 159 | public function getList($json) | 163 | public function getList($json) |
| 160 | { | 164 | { |
| 161 | $rows = new pdfModel(); | 165 | $rows = new pdfModel(); |
| ... | @@ -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,8 +195,6 @@ class ApiController extends Controller | ... | @@ -195,8 +195,6 @@ 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 | |||
| 199 | |||
| 200 | $rows = $rows->getpdf($id[0]->pdfid)->get(); | 198 | $rows = $rows->getpdf($id[0]->pdfid)->get(); |
| 201 | $response = $rows; | 199 | $response = $rows; |
| 202 | $statusCode = 200; | 200 | $statusCode = 200; | ... | ... |
| ... | @@ -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 | |||
| 27 | Route::resource('add', 'ApiController@insert'); | 26 | 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 | 31 | ||
| 34 | |||
| 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 | ||
| ... | @@ -50,15 +50,15 @@ function offFocus(id) { | ... | @@ -50,15 +50,15 @@ function offFocus(id) { |
| 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 | } |
| ... | @@ -87,8 +87,8 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { | ... | @@ -87,8 +87,8 @@ function ShowBox(pheight, pwidth, up, right, height, width, count, example) { |
| 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 | }); |
| ... | @@ -111,7 +111,7 @@ function HideBox(kind) { | ... | @@ -111,7 +111,7 @@ function HideBox(kind) { |
| 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 | } |
| ... | @@ -133,13 +133,14 @@ function HideBoxwithdate() { | ... | @@ -133,13 +133,14 @@ function HideBoxwithdate() { |
| 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 | 140 | ||
| 141 | }); | 141 | }); |
| 142 | } | 142 | } |
| 143 | |||
| 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) { |
| ... | @@ -158,10 +159,11 @@ function getOneJson(id) { | ... | @@ -158,10 +159,11 @@ function getOneJson(id) { |
| 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); |
| 162 | }); | 163 | }); |
| 163 | }); | 164 | }); |
| 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) { |
| ... | @@ -171,7 +173,7 @@ function getBackOneJson(id) { | ... | @@ -171,7 +173,7 @@ function getBackOneJson(id) { |
| 171 | edit = true; | 173 | edit = true; |
| 172 | 174 | ||
| 173 | 175 | ||
| 174 | changePdfOptions(json,edi); | 176 | changePdfOptions(json, edi); |
| 175 | }); | 177 | }); |
| 176 | }); | 178 | }); |
| 177 | } | 179 | } |
| ... | @@ -204,9 +206,9 @@ function pickPdfFromList(json) { | ... | @@ -204,9 +206,9 @@ function pickPdfFromList(json) { |
| 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 | 212 | ||
| 211 | 213 | ||
| 212 | 214 | ||
| ... | @@ -233,14 +235,14 @@ function changePdfOptions(json, edit) { | ... | @@ -233,14 +235,14 @@ function changePdfOptions(json, edit) { |
| 233 | $("#changes").validate({ | 235 | $("#changes").validate({ |
| 234 | errorPlacement: function(error, element) { | 236 | errorPlacement: function(error, element) { |
| 235 | var isFile = $(element).attr('type') == 'file'; | 237 | var isFile = $(element).attr('type') == 'file'; |
| 236 | if(isFile) { | 238 | if (isFile) { |
| 237 | error.insertAfter($(element).parent('label')); | 239 | error.insertAfter($(element).parent('label')); |
| 238 | } else { | 240 | } else { |
| 239 | error.insertAfter(element); | 241 | error.insertAfter(element); |
| 240 | } | 242 | } |
| 241 | } | 243 | } |
| 242 | 244 | ||
| 243 | }); | 245 | }); |
| 244 | }); | 246 | }); |
| 245 | 247 | ||
| 246 | var strVar2 = ""; | 248 | var strVar2 = ""; |
| ... | @@ -258,14 +260,14 @@ function changePdfOptions(json, edit) { | ... | @@ -258,14 +260,14 @@ function changePdfOptions(json, edit) { |
| 258 | 260 | ||
| 259 | //console.log( windowWidth+' '+windowHeight); | 261 | //console.log( windowWidth+' '+windowHeight); |
| 260 | //console.log( pwidth+' '+pheight); | 262 | //console.log( pwidth+' '+pheight); |
| 261 | if(pwidth > pheight){ | 263 | if (pwidth > pheight) { |
| 262 | //console.log('wide') | 264 | //console.log('wide') |
| 263 | var scaleImage = windowWidth / pwidth; | 265 | var scaleImage = windowWidth / pwidth; |
| 264 | var imageHeight = pheight * scaleImage; | 266 | var imageHeight = pheight * scaleImage; |
| 265 | var imageWidth = windowWidth; | 267 | var imageWidth = windowWidth; |
| 266 | var imgLeft = 0; | 268 | var imgLeft = 0; |
| 267 | var imgTop = 40; | 269 | var imgTop = 40; |
| 268 | }else{ | 270 | } else { |
| 269 | var scaleImage = windowHeight / pheight; | 271 | var scaleImage = windowHeight / pheight; |
| 270 | var imageHeight = windowHeight; | 272 | var imageHeight = windowHeight; |
| 271 | var imageWidth = pwidth * scaleImage; | 273 | var imageWidth = pwidth * scaleImage; |
| ... | @@ -277,8 +279,8 @@ function changePdfOptions(json, edit) { | ... | @@ -277,8 +279,8 @@ function changePdfOptions(json, edit) { |
| 277 | // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight); | 279 | // console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight); |
| 278 | 280 | ||
| 279 | pdflist += '<div id="pdfPreview" style="" class="column">'; | 281 | pdflist += '<div id="pdfPreview" style="" class="column">'; |
| 280 | 282 | // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; | |
| 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>'; | 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>'; |
| 282 | pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>'; | 284 | 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 + '">'; | 285 | pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; |
| 284 | for (i = 0; i < json.length; ++i) { | 286 | for (i = 0; i < json.length; ++i) { |
| ... | @@ -294,12 +296,12 @@ function changePdfOptions(json, edit) { | ... | @@ -294,12 +296,12 @@ function changePdfOptions(json, edit) { |
| 294 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | 296 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; |
| 295 | } | 297 | } |
| 296 | if (json[i].change_type == "img") { | 298 | if (json[i].change_type == "img") { |
| 297 | if(edit == true){ | 299 | if (edit == true) { |
| 298 | pdfChange += '<input value="'+json[i].content+'" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >'; | 300 | 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>'; | 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>'; |
| 300 | 302 | ||
| 301 | }else{ | 303 | } 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>'; | 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>'; |
| 303 | } | 305 | } |
| 304 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | 306 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; |
| 305 | 307 | ||
| ... | @@ -311,12 +313,13 @@ function changePdfOptions(json, edit) { | ... | @@ -311,12 +313,13 @@ function changePdfOptions(json, edit) { |
| 311 | } | 313 | } |
| 312 | if (json[i].change_type == "user") { | 314 | if (json[i].change_type == "user") { |
| 313 | var str = json[i].content; | 315 | var str = json[i].content; |
| 314 | if(str.startsWith('*')){ | 316 | if (str.startsWith('*')) { |
| 315 | var s =json[i].content.substr(1); | 317 | var s = json[i].content.substr(1); |
| 316 | //findUserInfoMatch(s); | 318 | //findUserInfoMatch(s); |
| 317 | var content_string = eval(s); | 319 | var content_string = eval(s); |
| 318 | }else{ | 320 | } else { |
| 319 | var content_string =json[i].content; } | 321 | var content_string = json[i].content; |
| 322 | } | ||
| 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 + '"">'; | 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 + '"">'; |
| 321 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; | 324 | pdfChange += '<span class="tip" id="span' + i + '">' + json[i].tips + '</span><br/>'; |
| 322 | 325 | ||
| ... | @@ -331,18 +334,18 @@ function changePdfOptions(json, edit) { | ... | @@ -331,18 +334,18 @@ function changePdfOptions(json, edit) { |
| 331 | 334 | ||
| 332 | strVar2 += ''; | 335 | strVar2 += ''; |
| 333 | strVar2 += ''; | 336 | 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>'; | 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>'; |
| 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>'; | 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>'; |
| 336 | 339 | ||
| 337 | document.getElementById('contentAreaOver').innerHTML = strVar2; | 340 | document.getElementById('contentAreaOver').innerHTML = strVar2; |
| 338 | 341 | ||
| 339 | 342 | ||
| 340 | 343 | ||
| 341 | if(edit == false){ | 344 | if (edit == false) { |
| 342 | $("#contentAreaOver").slideToggle(); | 345 | $("#contentAreaOver").slideToggle(); |
| 343 | $('#google_drive').slideToggle(); | 346 | $('#google_drive').slideToggle(); |
| 344 | //document.getElementById('google_drive').innerHTML = " "; | 347 | //document.getElementById('google_drive').innerHTML = " "; |
| 345 | } | 348 | } |
| 346 | 349 | ||
| 347 | 350 | ||
| 348 | var tinymces = tinymce.init({ | 351 | var tinymces = tinymce.init({ |
| ... | @@ -383,7 +386,7 @@ function changePdfOptions(json, edit) { | ... | @@ -383,7 +386,7 @@ function changePdfOptions(json, edit) { |
| 383 | }); | 386 | }); |
| 384 | 387 | ||
| 385 | $('.closeEditer').click(function() { | 388 | $('.closeEditer').click(function() { |
| 386 | $("#contentAreaOver").slideToggle(function(){ | 389 | $("#contentAreaOver").slideToggle(function() { |
| 387 | edit = false; | 390 | edit = false; |
| 388 | tinyMCE.remove(); | 391 | tinyMCE.remove(); |
| 389 | }); | 392 | }); |
| ... | @@ -398,11 +401,11 @@ function changePdfOptions(json, edit) { | ... | @@ -398,11 +401,11 @@ function changePdfOptions(json, edit) { |
| 398 | files = e.target.files; | 401 | files = e.target.files; |
| 399 | // console.log(files); | 402 | // console.log(files); |
| 400 | 403 | ||
| 401 | if(files.length >= 1) { | 404 | if (files.length >= 1) { |
| 402 | for (var i = 0, file; file = files[i]; i++) { | 405 | for (var i = 0, file; file = files[i]; i++) { |
| 403 | var fileName = file.name; | 406 | var fileName = file.name; |
| 404 | // insert file name | 407 | // insert file name |
| 405 | if(fileName) { | 408 | if (fileName) { |
| 406 | $(target).parent('label').find('.file-name').text(fileName); | 409 | $(target).parent('label').find('.file-name').text(fileName); |
| 407 | } else { | 410 | } else { |
| 408 | $(target).parent('label').find('.file-name').text(''); | 411 | $(target).parent('label').find('.file-name').text(''); |
| ... | @@ -415,7 +418,7 @@ function changePdfOptions(json, edit) { | ... | @@ -415,7 +418,7 @@ function changePdfOptions(json, edit) { |
| 415 | $(target).parent('label').find('.file-name').text(''); | 418 | $(target).parent('label').find('.file-name').text(''); |
| 416 | } | 419 | } |
| 417 | $(target).parent('label').trigger('focus'); | 420 | $(target).parent('label').trigger('focus'); |
| 418 | if( $(target).val()){ | 421 | if ($(target).val()) { |
| 419 | document.getElementById("preview").checked = true; | 422 | document.getElementById("preview").checked = true; |
| 420 | $('#changes').trigger('submit'); | 423 | $('#changes').trigger('submit'); |
| 421 | } | 424 | } |
| ... | @@ -423,7 +426,7 @@ function changePdfOptions(json, edit) { | ... | @@ -423,7 +426,7 @@ function changePdfOptions(json, edit) { |
| 423 | }); | 426 | }); |
| 424 | 427 | ||
| 425 | $('.custom-file-input').keypress(function(event) { | 428 | $('.custom-file-input').keypress(function(event) { |
| 426 | if(event.which == 13) { | 429 | if (event.which == 13) { |
| 427 | $(this).trigger('click'); | 430 | $(this).trigger('click'); |
| 428 | 431 | ||
| 429 | } | 432 | } |
| ... | @@ -432,9 +435,9 @@ function changePdfOptions(json, edit) { | ... | @@ -432,9 +435,9 @@ function changePdfOptions(json, edit) { |
| 432 | $("#changes").submit(function(e) { | 435 | $("#changes").submit(function(e) { |
| 433 | 436 | ||
| 434 | e.preventDefault(); | 437 | e.preventDefault(); |
| 435 | if($('#preview').prop('checked')==true){ | 438 | if ($('#preview').prop('checked') == true) { |
| 436 | 439 | ||
| 437 | $(tinymce.get()).each(function(i, el) { | 440 | $(tinymce.get()).each(function(i, el) { |
| 438 | 441 | ||
| 439 | if (el.id) | 442 | if (el.id) |
| 440 | document.getElementById(el.id).value = el.getContent(); | 443 | document.getElementById(el.id).value = el.getContent(); |
| ... | @@ -443,20 +446,21 @@ $(tinymce.get()).each(function(i, el) { | ... | @@ -443,20 +446,21 @@ $(tinymce.get()).each(function(i, el) { |
| 443 | }); | 446 | }); |
| 444 | 447 | ||
| 445 | 448 | ||
| 446 | var ids =[]; | 449 | var ids = []; |
| 447 | if(edit == true){ | 450 | if (edit == true) { |
| 448 | $("#changes input[type=file]").each(function() { | 451 | $("#changes input[type=file]").each(function() { |
| 449 | if($(this).get(0).files.length == 0 ){ | 452 | if ($(this).get(0).files.length == 0) { |
| 450 | 453 | ||
| 451 | 454 | ||
| 452 | document.getElementById(this.id).remove(); | 455 | document.getElementById(this.id).remove(); |
| 453 | }else{ | 456 | } else { |
| 454 | console.log("hidden"+this.id); | 457 | console.log("hidden" + this.id); |
| 455 | document.getElementById("hidden"+this.id).remove(); | 458 | document.getElementById("hidden" + this.id).remove(); |
| 456 | 459 | ||
| 457 | 460 | ||
| 458 | } | 461 | } |
| 459 | });} | 462 | }); |
| 463 | } | ||
| 460 | var form = $("#changes"); | 464 | var form = $("#changes"); |
| 461 | //console.log(form); | 465 | //console.log(form); |
| 462 | 466 | ||
| ... | @@ -503,7 +507,7 @@ $(tinymce.get()).each(function(i, el) { | ... | @@ -503,7 +507,7 @@ $(tinymce.get()).each(function(i, el) { |
| 503 | $("#changes").validate().cancelSubmit = true; | 507 | $("#changes").validate().cancelSubmit = true; |
| 504 | 508 | ||
| 505 | 509 | ||
| 506 | }else{ | 510 | } else { |
| 507 | 511 | ||
| 508 | 512 | ||
| 509 | 513 | ||
| ... | @@ -519,20 +523,21 @@ $(tinymce.get()).each(function(i, el) { | ... | @@ -519,20 +523,21 @@ $(tinymce.get()).each(function(i, el) { |
| 519 | }); | 523 | }); |
| 520 | 524 | ||
| 521 | 525 | ||
| 522 | var ids =[]; | 526 | var ids = []; |
| 523 | if(edit == true){ | 527 | if (edit == true) { |
| 524 | $("#changes input[type=file]").each(function() { | 528 | $("#changes input[type=file]").each(function() { |
| 525 | if($(this).get(0).files.length == 0 ){ | 529 | if ($(this).get(0).files.length == 0) { |
| 526 | 530 | ||
| 527 | 531 | ||
| 528 | document.getElementById(this.id).remove(); | 532 | document.getElementById(this.id).remove(); |
| 529 | }else{ | 533 | } else { |
| 530 | //console.log("hidden"+this.id); | 534 | //console.log("hidden"+this.id); |
| 531 | document.getElementById("hidden"+this.id).remove(); | 535 | document.getElementById("hidden" + this.id).remove(); |
| 532 | 536 | ||
| 533 | 537 | ||
| 534 | } | 538 | } |
| 535 | });} | 539 | }); |
| 540 | } | ||
| 536 | var form = $("#changes"); | 541 | var form = $("#changes"); |
| 537 | //console.log(form); | 542 | //console.log(form); |
| 538 | 543 | ||
| ... | @@ -568,7 +573,7 @@ function returnfileOptions(files, form, preview) { | ... | @@ -568,7 +573,7 @@ function returnfileOptions(files, form, preview) { |
| 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 |
| 574 | 579 | ||
| ... | @@ -600,7 +605,7 @@ function returnOptions(form, preview) { | ... | @@ -600,7 +605,7 @@ function returnOptions(form, preview) { |
| 600 | 605 | ||
| 601 | 606 | ||
| 602 | 607 | ||
| 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":[' | 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":[' |
| 604 | var e = 1; | 609 | var e = 1; |
| 605 | var o = 1; | 610 | var o = 1; |
| 606 | for (i = 0; i < json.length; ++i) { | 611 | for (i = 0; i < json.length; ++i) { |
| ... | @@ -611,13 +616,13 @@ function returnOptions(form, preview) { | ... | @@ -611,13 +616,13 @@ function returnOptions(form, preview) { |
| 611 | //console.log(form[0][e].value); | 616 | //console.log(form[0][e].value); |
| 612 | //console.log(json[i].label+' '+json[i].order); | 617 | //console.log(json[i].label+' '+json[i].order); |
| 613 | 618 | ||
| 614 | if(content != '""') { | 619 | if (content != '""') { |
| 615 | if (o !== 1) { | 620 | if (o !== 1) { |
| 616 | jsonReturn += ','; | 621 | jsonReturn += ','; |
| 617 | 622 | ||
| 618 | } | 623 | } |
| 619 | 624 | ||
| 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/"}'; | 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/"}'; |
| 621 | 626 | ||
| 622 | ++o | 627 | ++o |
| 623 | 628 | ||
| ... | @@ -631,8 +636,6 @@ function returnOptions(form, preview) { | ... | @@ -631,8 +636,6 @@ function returnOptions(form, preview) { |
| 631 | 636 | ||
| 632 | 637 | ||
| 633 | 638 | ||
| 634 | |||
| 635 | |||
| 636 | var windowWidth = 0.90 * $(".layout-grid").width(); | 639 | var windowWidth = 0.90 * $(".layout-grid").width(); |
| 637 | var windowHeight = 0.90 * $(".layout-grid").height(); | 640 | var windowHeight = 0.90 * $(".layout-grid").height(); |
| 638 | 641 | ||
| ... | @@ -643,14 +646,14 @@ function returnOptions(form, preview) { | ... | @@ -643,14 +646,14 @@ function returnOptions(form, preview) { |
| 643 | 646 | ||
| 644 | //console.log( windowWidth+' '+windowHeight); | 647 | //console.log( windowWidth+' '+windowHeight); |
| 645 | //console.log( pwidth+' '+pheight); | 648 | //console.log( pwidth+' '+pheight); |
| 646 | if(pwidth > pheight){ | 649 | if (pwidth > pheight) { |
| 647 | //console.log('wide') | 650 | //console.log('wide') |
| 648 | var scaleImage = windowWidth / pwidth; | 651 | var scaleImage = windowWidth / pwidth; |
| 649 | var imageHeight = pheight * scaleImage; | 652 | var imageHeight = pheight * scaleImage; |
| 650 | var imageWidth = windowWidth; | 653 | var imageWidth = windowWidth; |
| 651 | var imgLeft = 0; | 654 | var imgLeft = 0; |
| 652 | var imgTop = 40; | 655 | var imgTop = 40; |
| 653 | }else{ | 656 | } else { |
| 654 | var scaleImage = windowHeight / pheight; | 657 | var scaleImage = windowHeight / pheight; |
| 655 | var imageHeight = windowHeight; | 658 | var imageHeight = windowHeight; |
| 656 | var imageWidth = pwidth * scaleImage; | 659 | var imageWidth = pwidth * scaleImage; |
| ... | @@ -660,12 +663,12 @@ function returnOptions(form, preview) { | ... | @@ -660,12 +663,12 @@ function returnOptions(form, preview) { |
| 660 | } | 663 | } |
| 661 | // console.log(jsonReturn); | 664 | // console.log(jsonReturn); |
| 662 | 665 | ||
| 663 | if(preview == false){ | 666 | if (preview == false) { |
| 664 | $("#Canvas").css('z-index','0'); | 667 | $("#Canvas").css('z-index', '0'); |
| 665 | $('#changes').hide(); | 668 | $('#changes').hide(); |
| 666 | $('#controls').show(); | 669 | $('#controls').show(); |
| 667 | url = 'update'; | 670 | url = 'update'; |
| 668 | }else{ | 671 | } else { |
| 669 | $("#changes").validate().cancelSubmit = false; | 672 | $("#changes").validate().cancelSubmit = false; |
| 670 | document.getElementById("preview").checked = false; | 673 | document.getElementById("preview").checked = false; |
| 671 | url = 'preview'; | 674 | url = 'preview'; |
| ... | @@ -676,7 +679,7 @@ function returnOptions(form, preview) { | ... | @@ -676,7 +679,7 @@ function returnOptions(form, preview) { |
| 676 | 679 | ||
| 677 | 680 | ||
| 678 | $.ajax({ | 681 | $.ajax({ |
| 679 | url: "" + pdf_customizer + "/api/"+url, | 682 | url: "" + pdf_customizer + "/api/" + url, |
| 680 | type: "POST", | 683 | type: "POST", |
| 681 | dataType: 'json', | 684 | dataType: 'json', |
| 682 | data: jsonReturn, | 685 | data: jsonReturn, |
| ... | @@ -686,23 +689,25 @@ function returnOptions(form, preview) { | ... | @@ -686,23 +689,25 @@ function returnOptions(form, preview) { |
| 686 | success: function(data) { | 689 | success: function(data) { |
| 687 | 690 | ||
| 688 | var strVar2 = "" | 691 | 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>'; | 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>'; |
| 690 | document.getElementById('pdfPreviewInner').innerHTML = strVar2; | 693 | document.getElementById('pdfPreviewInner').innerHTML = strVar2; |
| 691 | 694 | ||
| 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>'; | 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>'; |
| 693 | document.getElementById('controls').innerHTML = strVar3; | 696 | document.getElementById('controls').innerHTML = strVar3; |
| 694 | 697 | ||
| 695 | $.LoadingOverlaySetup({ color : "rgba(0, 0, 0, 0.9)"}); | 698 | $.LoadingOverlaySetup({ |
| 699 | color: "rgba(0, 0, 0, 0.9)" | ||
| 700 | }); | ||
| 696 | $('#Canvas').LoadingOverlay("show"); | 701 | $('#Canvas').LoadingOverlay("show"); |
| 697 | $('#Canvas').delay(600).queue(function() { | 702 | $('#Canvas').delay(600).queue(function() { |
| 698 | $(this).css("background-image", ""); | 703 | $(this).css("background-image", ""); |
| 699 | }); | 704 | }); |
| 700 | 705 | ||
| 701 | setTimeout(function(){ | 706 | setTimeout(function() { |
| 702 | $('#Canvas').LoadingOverlay("hide", true); | 707 | $('#Canvas').LoadingOverlay("hide", true); |
| 703 | }, 600); | 708 | }, 600); |
| 704 | 709 | ||
| 705 | if(preview == false){ | 710 | if (preview == false) { |
| 706 | $('#controls').show(); | 711 | $('#controls').show(); |
| 707 | } | 712 | } |
| 708 | 713 | ||
| ... | @@ -713,15 +718,12 @@ function returnOptions(form, preview) { | ... | @@ -713,15 +718,12 @@ function returnOptions(form, preview) { |
| 713 | $('#controls').hide(); | 718 | $('#controls').hide(); |
| 714 | $('#changes').show(); | 719 | $('#changes').show(); |
| 715 | $("#Canvas").show(); | 720 | $("#Canvas").show(); |
| 716 | $("#Canvas").css('z-index','10'); | 721 | $("#Canvas").css('z-index', '10'); |
| 717 | }); | 722 | }); |
| 718 | 723 | ||
| 719 | $('#downloadMe').click(function() { | 724 | $('#downloadMe').click(function() { |
| 720 | $(".closeEditer").click(); | 725 | $(".closeEditer").click(); |
| 721 | }); | 726 | }); |
| 722 | |||
| 723 | |||
| 724 | |||
| 725 | }, | 727 | }, |
| 726 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | 728 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response |
| 727 | alert(xhr.status); | 729 | alert(xhr.status); | ... | ... |
-
Please register or sign in to post a comment