Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
pdf-customizer
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
dfb40125
authored
2016-09-07 09:53:58 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
preview after every input
1 parent
2917db69
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
689 additions
and
694 deletions
app/Http/Controllers/ApiController.php
app/Http/routes.php
public/files/js/interfaceGdrive.js
app/Http/Controllers/ApiController.php
View file @
dfb4012
...
...
@@ -32,9 +32,8 @@ class ApiController extends Controller
{
// $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"}]}';
//$styles = serialize(array("font-family"=>"Barber","font-size"=>"20","font-color"=>"cmyk 0 0 0 0","alignment"=>"left"));
// $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"}]}';
//$styles = serialize(array("font-family"=>"Barber","font-size"=>"20","font-color"=>"cmyk 0 0 0 0","alignment"=>"left"));
//print_r($styles);
//die();
$apiCallId
=
new
pdfModel
();
...
...
@@ -43,10 +42,6 @@ class ApiController extends Controller
$pdfId
=
new
pdfModel
();
$pdfId
=
$pdfId
->
addPdf
(
$apiCallId
,
$json
);
$json
=
json_decode
(
$json
);
$storagePath
=
Storage
::
disk
(
'public'
)
->
getDriver
()
->
getAdapter
()
->
getPathPrefix
();
$folder
=
str_replace
(
' '
,
'-'
,
$json
->
pdf
[
0
]
->
name
);
// Replaces all spaces with hyphens.
$folder
=
preg_replace
(
'/[^A-Za-z0-9\-]/'
,
''
,
$folder
);
...
...
@@ -66,10 +61,6 @@ class ApiController extends Controller
$curl
->
download
(
$pdfLocation
,
$storagePath
.
$folder
.
'/'
.
$file
);
$curl
->
close
();
$fileEntry
=
New
FileEntryController
();
// echo $storagePath . $folder . '/' . $file;
//$fileEntry->addfile( $folder . '/' . $file);
$im
=
new
Imagick
();
$im
->
setResolution
(
300
,
300
);
//set the resolution of the resulting jpg
if
(
!
is_readable
(
$storagePath
.
$folder
.
'/'
.
$file
))
{
...
...
@@ -92,33 +83,56 @@ class ApiController extends Controller
$curl
->
close
();
}
}
}
public
function
preview
()
{
$json
=
Input
::
all
();
$json
=
json_encode
(
$json
);
$json
=
json_decode
(
$json
);
$pdfLocation
=
$json
->
pdf
[
0
]
->
pdfLocation
;
$cust_id
=
$json
->
pdf
[
0
]
->
custId
;
$storagePath
=
Storage
::
disk
(
'public'
)
->
getDriver
()
->
getAdapter
()
->
getPathPrefix
();
foreach
(
$json
->
changes
as
$change
)
{
if
(
$change
->
change_type
==
'img'
)
{
$folder
=
str_replace
(
' '
,
'-'
,
$json
->
pdf
[
0
]
->
folder
);
// Replaces all spaces with hyphens.
$folder
=
preg_replace
(
'/[^A-Za-z0-9\-]/'
,
''
,
$folder
);
$fileLocation
=
$change
->
fileLocation
;
$file
=
explode
(
'\\'
,
$change
->
content
);
$file
=
end
(
$file
);
$fileClean
=
str_replace
(
' '
,
'-'
,
$file
);
$curl
=
new
Curl
();
$curl
->
download
(
$fileLocation
.
'/'
.
$fileClean
,
$storagePath
.
$folder
.
'/'
.
$fileClean
);
$curl
->
close
();
}
}
}
$json
=
json_encode
(
$json
);
$apiCallId
=
"3"
;
$pdfId
=
new
pdfModel
();
$pdfId
=
$pdfId
->
changePdf
(
$apiCallId
,
$json
);
$pdf
=
new
PdfController
();
$pdf
=
$pdf
->
pdf
(
$pdfId
);
$response
=
$pdfId
;
$statusCode
=
200
;
return
Response
::
json
(
$response
,
$statusCode
);
}
public
function
update
()
public
function
update
()
{
$json
=
Input
::
all
();
$json
=
json_encode
(
$json
);
$json
=
json_decode
(
$json
);
$pdfLocation
=
$json
->
pdf
[
0
]
->
pdfLocation
;
$pdfLocation
=
$json
->
pdf
[
0
]
->
pdfLocation
;
$cust_id
=
$json
->
pdf
[
0
]
->
custId
;
$storagePath
=
Storage
::
disk
(
'public'
)
->
getDriver
()
->
getAdapter
()
->
getPathPrefix
();
$storagePath
=
Storage
::
disk
(
'public'
)
->
getDriver
()
->
getAdapter
()
->
getPathPrefix
();
foreach
(
$json
->
changes
as
$change
)
{
foreach
(
$json
->
changes
as
$change
)
{
if
(
$change
->
change_type
==
'img'
)
{
$folder
=
str_replace
(
' '
,
'-'
,
$json
->
pdf
[
0
]
->
folder
);
// Replaces all spaces with hyphens.
$folder
=
str_replace
(
' '
,
'-'
,
$json
->
pdf
[
0
]
->
folder
);
// Replaces all spaces with hyphens.
$folder
=
preg_replace
(
'/[^A-Za-z0-9\-]/'
,
''
,
$folder
);
$fileLocation
=
$change
->
fileLocation
;
$file
=
explode
(
'\\'
,
$change
->
content
);
...
...
@@ -127,36 +141,26 @@ class ApiController extends Controller
$curl
=
new
Curl
();
$curl
->
download
(
$fileLocation
.
'/'
.
$fileClean
,
$storagePath
.
$folder
.
'/'
.
$fileClean
);
$curl
->
close
();
// chmod( $storagePath . $folder . '/' . $fileClean, 0777);
}
}
}
$json
=
json_encode
(
$json
);
// $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"}]}';
//$apiCallId = new pdfModel();
// $apiCallId = $apiCallId->addApiCall('1',$json);
// $apiCallId = $apiCallId->addApiCall('1',$json);
$apiCallId
=
"3"
;
$pdfId
=
new
pdfModel
();
$pdfId
=
$pdfId
->
changePdf
(
$apiCallId
,
$json
);
$pdf
=
new
PdfController
();
$pdf
=
$pdf
->
pdf
(
$pdfId
);
$response
=
$pdfId
;
$statusCode
=
200
;
//$UploaqdPdf = new GoogledriveuploadpdfController();
//$UploaqdPdf->google_drive_upload($folder, 'new_'.$pdfLocation,$pdfId,$cust_id);
return
Response
::
json
(
$response
,
$statusCode
);
$UploaqdPdf
=
new
GoogledriveuploadpdfController
();
$UploaqdPdf
->
google_drive_upload
(
$folder
,
'new_'
.
$pdfLocation
,
$pdfId
,
$cust_id
);
}
public
function
getList
(
$json
)
public
function
getList
(
$json
)
{
$rows
=
new
pdfModel
();
$rows
=
$rows
->
getList
(
$json
)
->
get
();
...
...
@@ -170,8 +174,6 @@ class ApiController extends Controller
public
function
getPdf
(
$json
)
{
$rows
=
new
pdfModel
();
$rows
=
$rows
->
getpdf
(
$json
)
->
get
();
$response
=
$rows
;
...
...
@@ -181,8 +183,6 @@ class ApiController extends Controller
}
public
function
getPdfPriev
(
$json
)
{
$rows
=
new
pdfModel
();
$rows
=
$rows
->
getpdf
(
$json
)
->
get
();
$response
=
$rows
;
...
...
@@ -195,9 +195,7 @@ class ApiController extends Controller
$rows
=
new
pdfModel
();
$id
=
$rows
->
getpdfid
(
$json
)
->
get
();
$rows
=
$rows
->
getpdf
(
$id
[
0
]
->
pdfid
)
->
get
();
$rows
=
$rows
->
getpdf
(
$id
[
0
]
->
pdfid
)
->
get
();
$response
=
$rows
;
$statusCode
=
200
;
//var_dump($rows);
...
...
app/Http/routes.php
View file @
dfb4012
...
...
@@ -23,34 +23,29 @@ Route::get('pdf/{id}', 'PdfController@pdf');
Route
::
group
(
array
(
'prefix'
=>
'api/v1'
),
function
(
$json
)
{
Route
::
resource
(
'add'
,
'ApiController@insert'
);
Route
::
resource
(
'add'
,
'ApiController@insert'
);
Route
::
resource
(
'get-list'
,
'ApiController@getList'
);
Route
::
resource
(
'get-pdf'
,
'ApiController@getpdf'
);
Route
::
resource
(
'api'
,
'FileEntryController@getApi'
);
Route
::
resource
(
'get-pdf-google'
,
'ApiController@getpdfgoogle'
);
});
Route
::
any
(
'api/update'
,
'ApiController@update'
);
Route
::
any
(
'api/preview'
,
'ApiController@preview'
);
Route
::
post
(
'api/authenticate'
,
'AuthenticateController@authenticate'
);
Route
::
get
(
'api/authenticate/user'
,
'AuthenticateController@getAuthenticatedUser'
);
Route
::
any
(
'fileentry/postUpload'
,
'FileEntryController@postUpload'
);
Route
::
get
(
'fileentry/get/{filename}'
,
[
'as'
=>
'getentry'
,
'uses'
=>
'FileEntryController@get'
]);
Route
::
any
(
'fileentry/postUpload'
,
'FileEntryController@postUpload'
);
Route
::
get
(
'fileentry/get/{filename}'
,
[
'as'
=>
'getentry'
,
'uses'
=>
'FileEntryController@get'
]);
Route
::
get
(
'fileentry'
,
'FileEntryController@index'
);
Route
::
get
(
'fileentry/getImage/{folder}/{filename}'
,
'FileEntryController@getImage'
);
Route
::
get
(
'fileentry/getPDF/{folder}/{filename}'
,
'FileEntryController@getPDF'
);
Route
::
post
(
'fileentry/add'
,[
'as'
=>
'addentry'
,
'uses'
=>
'FileEntryController@add'
]);
Route
::
post
(
'fileentry/add'
,[
'as'
=>
'addentry'
,
'uses'
=>
'FileEntryController@add'
]);
Route
::
get
(
'api/googlePdfUpload/{folder}/{filename}/{pdfid}/{id}'
,
'GoogledriveuploadpdfController@google_drive_upload'
);
Route
::
get
(
'auth/google/callback'
,
'GoogledriveuploadpdfController@google_drive_upload'
);
...
...
public/files/js/interfaceGdrive.js
View file @
dfb4012
var
pluginUrl
=
window
.
location
.
protocol
+
'//'
+
window
.
location
.
host
+
'/commonwell'
;
var
pdf_customizer
=
"http://localhost:8888/pdf-customizer/public"
;
//var pluginUrl = window.location.protocol + '//' + window.location.host +
'/commonwell';
//
var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
//var pluginUrl = "http://contact.gotenzing.com"
;
//
var pdf_customizer = "http://pdf-customizer.synapsus.co";
var
pluginUrl
=
window
.
location
.
protocol
+
'//'
+
window
.
location
.
host
;
var
pdf_customizer
=
"http://pdf-customizer.synapsus.co"
;
var
imageHeight
=
""
;
var
imageWidth
=
""
;
var
edit
=
false
;
var
imageHeight
=
""
;
var
imageWidth
=
""
;
var
edit
=
false
;
function
getAuth
()
{
jQuery
(
document
).
ready
(
function
(
$
)
{
var
settings
=
{
"async"
:
true
,
"crossDomain"
:
true
,
"url"
:
""
+
pdf_customizer
+
"/api/authenticate"
,
"method"
:
"POST"
,
"processData"
:
false
,
"contentType"
:
false
,
"mimeType"
:
"multipart/form-data"
,
"data"
:
form
,
"success"
:
function
(
data
)
{
getJson
(
user_id
);
},
error
:
function
(
xhr
,
ajaxOptions
,
thrownError
)
{
//Add these parameters to display the required response
//alert(xhr.status);
document
.
getElementById
(
'contentArea'
).
innerHTML
=
xhr
.
responseText
;
}
};
$
.
ajax
(
settings
).
done
(
function
(
response
)
{
console
.
log
(
response
);
jQuery
(
document
).
ready
(
function
(
$
)
{
var
settings
=
{
"async"
:
true
,
"crossDomain"
:
true
,
"url"
:
""
+
pdf_customizer
+
"/api/authenticate"
,
"method"
:
"POST"
,
"processData"
:
false
,
"contentType"
:
false
,
"mimeType"
:
"multipart/form-data"
,
"data"
:
form
,
"success"
:
function
(
data
)
{
getJson
(
user_id
);
},
error
:
function
(
xhr
,
ajaxOptions
,
thrownError
)
{
//Add these parameters to display the required response
//alert(xhr.status);
document
.
getElementById
(
'contentArea'
).
innerHTML
=
xhr
.
responseText
;
}
};
$
.
ajax
(
settings
).
done
(
function
(
response
)
{
console
.
log
(
response
);
});
});
});
}
function
offFocus
(
id
)
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
"#select"
+
id
+
""
).
removeClass
(
"focus"
);
$
(
".entry_block"
).
mouseleave
(
function
()
{
$
(
"#select"
+
id
+
""
).
addClass
(
"focus"
);
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
"#select"
+
id
+
""
).
removeClass
(
"focus"
);
$
(
".entry_block"
).
mouseleave
(
function
()
{
$
(
"#select"
+
id
+
""
).
addClass
(
"focus"
);
});
});
});
}
CanvasRenderingContext2D
.
prototype
.
roundRect
=
function
(
x
,
y
,
w
,
h
,
r
)
{
if
(
w
<
2
*
r
)
r
=
w
/
2
;
if
(
h
<
2
*
r
)
r
=
h
/
2
;
this
.
beginPath
();
this
.
moveTo
(
x
+
r
,
y
);
this
.
arcTo
(
x
+
w
,
y
,
x
+
w
,
y
+
h
,
r
);
this
.
arcTo
(
x
+
w
,
y
+
h
,
x
,
y
+
h
,
r
);
this
.
arcTo
(
x
,
y
+
h
,
x
,
y
,
r
);
this
.
arcTo
(
x
,
y
,
x
+
w
,
y
,
r
);
this
.
closePath
();
return
this
;
CanvasRenderingContext2D
.
prototype
.
roundRect
=
function
(
x
,
y
,
w
,
h
,
r
)
{
if
(
w
<
2
*
r
)
r
=
w
/
2
;
if
(
h
<
2
*
r
)
r
=
h
/
2
;
this
.
beginPath
();
this
.
moveTo
(
x
+
r
,
y
);
this
.
arcTo
(
x
+
w
,
y
,
x
+
w
,
y
+
h
,
r
);
this
.
arcTo
(
x
+
w
,
y
+
h
,
x
,
y
+
h
,
r
);
this
.
arcTo
(
x
,
y
+
h
,
x
,
y
,
r
);
this
.
arcTo
(
x
,
y
,
x
+
w
,
y
,
r
);
this
.
closePath
();
return
this
;
}
function
ShowBox
(
pheight
,
pwidth
,
up
,
right
,
height
,
width
,
count
,
example
)
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
'span'
).
hide
();
$
(
'#span'
+
count
).
show
();
// $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")");
var
Qc
=
document
.
getElementById
(
"Canvas"
);
var
Qctx
=
Qc
.
getContext
(
"2d"
);
Qctx
.
clearRect
(
0
,
0
,
Qc
.
width
,
Qc
.
height
);
Qctx
.
restore
();
var
down
=
pheight
-
(
up
+
height
);
var
scaleH
=
$
(
"Canvas"
).
height
()
/
pheight
;
var
scaleW
=
$
(
"Canvas"
).
width
()
/
pwidth
;
var
scaleDown
=
down
*
scaleH
;
var
scaleRight
=
right
*
scaleW
;
var
scalewidth
=
width
*
scaleW
;
var
scaleheight
=
height
*
scaleH
;
var
c
=
document
.
getElementById
(
"Canvas"
);
var
ctx
=
c
.
getContext
(
"2d"
);
ctx
.
save
();
ctx
.
lineWidth
=
2
;
ctx
.
strokeStyle
=
$
(
'.callout'
).
css
(
"background-color"
)
ctx
.
roundRect
(
scaleRight
,
scaleDown
,
scalewidth
,
scaleheight
,
5
).
stroke
();
});
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
'span'
).
hide
();
$
(
'#span'
+
count
).
show
();
// $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' + example + ")");
var
Qc
=
document
.
getElementById
(
"Canvas"
);
var
Qctx
=
Qc
.
getContext
(
"2d"
);
Qctx
.
clearRect
(
0
,
0
,
Qc
.
width
,
Qc
.
height
);
Qctx
.
restore
();
var
down
=
pheight
-
(
up
+
height
);
var
scaleH
=
$
(
"Canvas"
).
height
()
/
pheight
;
var
scaleW
=
$
(
"Canvas"
).
width
()
/
pwidth
;
var
scaleDown
=
down
*
scaleH
;
var
scaleRight
=
right
*
scaleW
;
var
scalewidth
=
width
*
scaleW
;
var
scaleheight
=
height
*
scaleH
;
var
c
=
document
.
getElementById
(
"Canvas"
);
var
ctx
=
c
.
getContext
(
"2d"
);
ctx
.
save
();
ctx
.
lineWidth
=
2
;
ctx
.
strokeStyle
=
$
(
'.callout'
).
css
(
"background-color"
)
ctx
.
roundRect
(
scaleRight
,
scaleDown
,
scalewidth
,
scaleheight
,
5
).
stroke
();
});
}
function
findUserInfoMatch
(
data
)
{
}
...
...
@@ -104,635 +104,637 @@ function findUserInfoMatch(data) {
function
HideBox
(
kind
)
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
'span'
).
hide
();
//console.log('hide');
var
Qc
=
document
.
getElementById
(
"Canvas"
);
var
Qctx
=
Qc
.
getContext
(
"2d"
);
Qctx
.
clearRect
(
0
,
0
,
Qc
.
width
,
Qc
.
height
);
Qctx
.
restore
();
if
(
kind
!=
'file'
)
{
document
.
getElementById
(
"preview"
).
checked
=
true
;
$
(
'#changes'
).
trigger
(
'submit'
);
}
});
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
'span'
).
hide
();
//console.log('hide');
var
Qc
=
document
.
getElementById
(
"Canvas"
);
var
Qctx
=
Qc
.
getContext
(
"2d"
);
Qctx
.
clearRect
(
0
,
0
,
Qc
.
width
,
Qc
.
height
);
Qctx
.
restore
();
if
(
kind
!=
'file'
)
{
document
.
getElementById
(
"preview"
).
checked
=
true
;
$
(
'#changes'
).
trigger
(
'submit'
);
}
});
}
function
HideBoxwithdate
()
{
jQuery
(
document
).
ready
(
function
(
$
)
{
var
Qc
=
document
.
getElementById
(
"Canvas"
);
var
Qctx
=
Qc
.
getContext
(
"2d"
);
Qctx
.
clearRect
(
0
,
0
,
Qc
.
width
,
Qc
.
height
);
Qctx
.
restore
();
});
jQuery
(
document
).
ready
(
function
(
$
)
{
var
Qc
=
document
.
getElementById
(
"Canvas"
);
var
Qctx
=
Qc
.
getContext
(
"2d"
);
Qctx
.
clearRect
(
0
,
0
,
Qc
.
width
,
Qc
.
height
);
Qctx
.
restore
();
});
}
function
fullScreen
()
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
'#bbox'
).
toggleClass
(
'fullscreen'
);
//$('#bbox').animate({ width: "100%", height: "100%", position: "fixed", top: "0", left: "0" });
function
fullScreen
()
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
(
'#bbox'
).
toggleClass
(
'fullscreen'
);
//$('#bbox').animate({ width: "100%", height: "100%", position: "fixed", top: "0", left: "0" });
});
}
});
}
function
getJson
(
user_id
)
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
.
getJSON
(
""
+
pdf_customizer
+
"/api/v1/get-list/"
+
user_id
,
function
(
data
)
{
// Get the element with id summary and set the inner text to the result.
var
json
=
JSON
.
stringify
(
data
);
pickPdfFromList
(
json
);
jQuery
(
document
).
ready
(
function
(
$
)
{
$
.
getJSON
(
""
+
pdf_customizer
+
"/api/v1/get-list/"
+
user_id
,
function
(
data
)
{
// Get the element with id summary and set the inner text to the result.
var
json
=
JSON
.
stringify
(
data
);
pickPdfFromList
(
json
);
});
});
});
}
function
getOneJson
(
id
)
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
.
getJSON
(
""
+
pdf_customizer
+
"/api/v1/get-pdf-google/"
+
id
,
function
(
data
)
{
// Get the element with id summary and set the inner text to the result.
var
json
=
JSON
.
stringify
(
data
);
edit
=
false
;
changePdfOptions
(
json
,
edit
);
jQuery
(
document
).
ready
(
function
(
$
)
{
$
.
getJSON
(
""
+
pdf_customizer
+
"/api/v1/get-pdf-google/"
+
id
,
function
(
data
)
{
// Get the element with id summary and set the inner text to the result.
var
json
=
JSON
.
stringify
(
data
);
edit
=
false
;
changePdfOptions
(
json
,
edit
);
});
});
});
}
function
getBackOneJson
(
id
)
{
jQuery
(
document
).
ready
(
function
(
$
)
{
$
.
getJSON
(
""
+
pdf_customizer
+
"/api/v1/get-pdf/"
+
id
,
function
(
data
)
{
// Get the element with id summary and set the inner text to the result.
var
json
=
JSON
.
stringify
(
data
);
//$('#google_drive').show();
edit
=
true
;
changePdfOptions
(
json
,
edi
);
jQuery
(
document
).
ready
(
function
(
$
)
{
$
.
getJSON
(
""
+
pdf_customizer
+
"/api/v1/get-pdf/"
+
id
,
function
(
data
)
{
// Get the element with id summary and set the inner text to the result.
var
json
=
JSON
.
stringify
(
data
);
//$('#google_drive').show();
edit
=
true
;
changePdfOptions
(
json
,
edi
);
});
});
});
}
function
pickPdfFromList
(
json
)
{
jQuery
(
document
).
ready
(
function
(
$
)
{
json
=
JSON
.
parse
(
json
);
var
strVar
=
""
;
var
i
;
var
pdflist
=
""
;
for
(
i
=
0
;
i
<
json
.
length
;
++
i
)
{
pdflist
+=
'<div class="column">'
;
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>'
;
pdflist
+=
" <h5>"
+
json
[
i
].
name
+
"</h5>"
;
pdflist
+=
"</div>"
;
}
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>'
;
strVar
+=
'</div></div></div><div id="contentAreaOver"></div> '
;
document
.
getElementById
(
'contentArea'
).
innerHTML
=
strVar
;
});
jQuery
(
document
).
ready
(
function
(
$
)
{
json
=
JSON
.
parse
(
json
);
var
strVar
=
""
;
var
i
;
var
pdflist
=
""
;
for
(
i
=
0
;
i
<
json
.
length
;
++
i
)
{
pdflist
+=
'<div class="column">'
;
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>'
;
pdflist
+=
" <h5>"
+
json
[
i
].
name
+
"</h5>"
;
pdflist
+=
"</div>"
;
}
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>'
;
strVar
+=
'</div></div></div><div id="contentAreaOver"></div> '
;
document
.
getElementById
(
'contentArea'
).
innerHTML
=
strVar
;
});
}
function
changePdfOptions
(
json
,
edit
)
{
jQuery
(
function
(
$
)
{
if
(
edit
==
false
){
$
(
'#contentAreaOver'
).
hide
();
}
json
=
JSON
.
parse
(
json
);
$
(
document
).
ready
(
function
()
{
$
(
"#changescontentdate"
).
datepicker
({
plugins
:
"tabfocus"
,
changeMonth
:
true
,
changeYear
:
true
,
yearRange
:
'2015:2025'
,
dateFormat
:
'DD MM dd yy'
,
minDate
:
0
,
defaultDate
:
null
}).
on
(
'change'
,
function
()
{
$
(
this
).
valid
();
// triggers the validation test
document
.
getElementById
(
"preview"
).
checked
=
true
;
$
(
'#changes'
).
trigger
(
'submit'
);
});
$
(
"#changes"
).
validate
({
errorPlacement
:
function
(
error
,
element
)
{
var
isFile
=
$
(
element
).
attr
(
'type'
)
==
'file'
;
if
(
isFile
)
{
error
.
insertAfter
(
$
(
element
).
parent
(
'label'
));
}
else
{
error
.
insertAfter
(
element
);
}
}
});
});
jQuery
(
function
(
$
)
{
if
(
edit
==
false
)
{
$
(
'#contentAreaOver'
).
hide
();
}
var
strVar2
=
""
;
var
pdflist
=
""
;
var
pdfChange
=
""
;
var
f
=
0
;
var
windowWidth
=
0.90
*
$
(
".layout-grid"
).
width
();
var
windowHeight
=
0.90
*
$
(
".layout-grid"
).
height
();
var
windowHBG
=
0.923
*
$
(
window
).
height
();
var
pwidth
=
parseInt
(
json
[
0
].
pwidth
);
var
pheight
=
parseInt
(
json
[
0
].
pheight
);
//console.log( windowWidth+' '+windowHeight);
//console.log( pwidth+' '+pheight);
if
(
pwidth
>
pheight
){
//console.log('wide')
var
scaleImage
=
windowWidth
/
pwidth
;
var
imageHeight
=
pheight
*
scaleImage
;
var
imageWidth
=
windowWidth
;
var
imgLeft
=
0
;
var
imgTop
=
40
;
}
else
{
var
scaleImage
=
windowHeight
/
pheight
;
var
imageHeight
=
windowHeight
;
var
imageWidth
=
pwidth
*
scaleImage
;
var
imgLeft
=
30
;
var
imgTop
=
2
;
}
// console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight);
pdflist
+=
'<div id="pdfPreview" style="" class="column">'
;
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>'
;
pdfChange
+=
'<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>'
+
json
[
0
].
name
+
'</h4>'
;
pdfChange
+=
'<input type="hidden" id="id" name="id" value="'
+
json
[
0
].
idPDF
+
'">'
;
for
(
i
=
0
;
i
<
json
.
length
;
++
i
)
{
var
example
=
json
[
0
].
folder
+
'/'
+
json
[
i
].
example
;
if
(
json
[
i
].
change_type
==
"textflow"
)
{
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>'
;
++
f
;
pdfChange
+=
'<span id="span'
+
i
+
'">'
+
json
[
i
].
tips
+
'</span><br/>'
;
}
if
(
json
[
i
].
change_type
==
"text"
)
{
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
+
'"">'
;
pdfChange
+=
'<span class="tip" id="span'
+
i
+
'">'
+
json
[
i
].
tips
+
'</span><br/>'
;
}
if
(
json
[
i
].
change_type
==
"img"
)
{
if
(
edit
==
true
){
pdfChange
+=
'<input value="'
+
json
[
i
].
content
+
'" tabindex="-1" class="required" id="hiddenchangescontent['
+
i
+
']" type="hidden" name="content['
+
i
+
']" >'
;
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>'
;
}
else
{
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>'
;
}
pdfChange
+=
'<span class="tip" id="span'
+
i
+
'">'
+
json
[
i
].
tips
+
'</span><br/>'
;
}
if
(
json
[
i
].
change_type
==
"date"
)
{
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
+
'"">'
;
pdfChange
+=
'<span class="tip" id="span'
+
i
+
'"> </span><br/>'
;
}
if
(
json
[
i
].
change_type
==
"user"
)
{
var
str
=
json
[
i
].
content
;
if
(
str
.
startsWith
(
'*'
)){
var
s
=
json
[
i
].
content
.
substr
(
1
);
//findUserInfoMatch(s);
var
content_string
=
eval
(
s
);
}
else
{
var
content_string
=
json
[
i
].
content
;
}
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
+
'"">'
;
pdfChange
+=
'<span class="tip" id="span'
+
i
+
'">'
+
json
[
i
].
tips
+
'</span><br/>'
;
}
}
pdfChange
+=
'<input type="checkbox" id="preview" name="preview" style="display: none;">'
;
pdfChange
+=
'<input type="submit" value="Save and Continue">'
;
pdfChange
+=
'</form>'
;
strVar2
+=
''
;
strVar2
+=
''
;
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>'
;
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>'
;
document
.
getElementById
(
'contentAreaOver'
).
innerHTML
=
strVar2
;
if
(
edit
==
false
){
$
(
"#contentAreaOver"
).
slideToggle
();
$
(
'#google_drive'
).
slideToggle
();
//document.getElementById('google_drive').innerHTML = " ";
}
var
tinymces
=
tinymce
.
init
({
selector
:
'.textarea'
,
entity_encoding
:
"raw"
,
menubar
:
false
,
toolbar
:
' bold italic'
,
remove_linebreaks
:
false
,
remove_trailing_brs
:
false
,
init_instance_callback
:
function
(
editor
)
{
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"0px solid #131212"
;
editorDocContent
.
body
.
style
.
backgroundColor
=
"#131212"
;
editorDocContent
.
body
.
style
.
color
=
"#ccc"
;
},
setup
:
function
(
editor
)
{
editor
.
on
(
'focus'
,
function
(
e
)
{
//console.log(editor.id);
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"2px solid #F7A800"
;
$
(
'#'
+
editor
.
id
).
trigger
(
"onfocus"
);
//$(this).css('border', '2px solid #F7A800 !important');
});
editor
.
on
(
'blur'
,
function
(
e
)
{
//console.log('out' + editor.id);
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"2px solid #131212"
;
//$(this).css('border', '0px solid #F7A800 !important');
HideBox
();
});
}
});
$
(
'.closeEditer'
).
click
(
function
()
{
$
(
"#contentAreaOver"
).
slideToggle
(
function
(){
edit
=
false
;
tinyMCE
.
remove
();
json
=
JSON
.
parse
(
json
);
$
(
document
).
ready
(
function
()
{
$
(
"#changescontentdate"
).
datepicker
({
plugins
:
"tabfocus"
,
changeMonth
:
true
,
changeYear
:
true
,
yearRange
:
'2015:2025'
,
dateFormat
:
'DD MM dd yy'
,
minDate
:
0
,
defaultDate
:
null
}).
on
(
'change'
,
function
()
{
$
(
this
).
valid
();
// triggers the validation test
document
.
getElementById
(
"preview"
).
checked
=
true
;
$
(
'#changes'
).
trigger
(
'submit'
);
});
$
(
"#changes"
).
validate
({
errorPlacement
:
function
(
error
,
element
)
{
var
isFile
=
$
(
element
).
attr
(
'type'
)
==
'file'
;
if
(
isFile
)
{
error
.
insertAfter
(
$
(
element
).
parent
(
'label'
));
}
else
{
error
.
insertAfter
(
element
);
}
}
});
});
$
(
'#google_drive'
).
slideToggle
();
});
var
files
;
var
imagefiles
=
[];
$
(
".fileupload"
).
change
(
function
(
e
)
{
var
target
=
e
.
target
;
files
=
e
.
target
.
files
;
// console.log(files);
if
(
files
.
length
>=
1
)
{
for
(
var
i
=
0
,
file
;
file
=
files
[
i
];
i
++
)
{
var
fileName
=
file
.
name
;
// insert file name
if
(
fileName
)
{
$
(
target
).
parent
(
'label'
).
find
(
'.file-name'
).
text
(
fileName
);
}
else
{
$
(
target
).
parent
(
'label'
).
find
(
'.file-name'
).
text
(
''
);
}
imagefiles
.
push
(
file
);
// console.log(imagefiles);
var
strVar2
=
""
;
var
pdflist
=
""
;
var
pdfChange
=
""
;
var
f
=
0
;
var
windowWidth
=
0.90
*
$
(
".layout-grid"
).
width
();
var
windowHeight
=
0.90
*
$
(
".layout-grid"
).
height
();
var
windowHBG
=
0.923
*
$
(
window
).
height
();
var
pwidth
=
parseInt
(
json
[
0
].
pwidth
);
var
pheight
=
parseInt
(
json
[
0
].
pheight
);
//console.log( windowWidth+' '+windowHeight);
//console.log( pwidth+' '+pheight);
if
(
pwidth
>
pheight
)
{
//console.log('wide')
var
scaleImage
=
windowWidth
/
pwidth
;
var
imageHeight
=
pheight
*
scaleImage
;
var
imageWidth
=
windowWidth
;
var
imgLeft
=
0
;
var
imgTop
=
40
;
}
else
{
var
scaleImage
=
windowHeight
/
pheight
;
var
imageHeight
=
windowHeight
;
var
imageWidth
=
pwidth
*
scaleImage
;
var
imgLeft
=
30
;
var
imgTop
=
2
;
}
}
else
{
$
(
target
).
parent
(
'label'
).
find
(
'.file-name'
).
text
(
''
);
}
$
(
target
).
parent
(
'label'
).
trigger
(
'focus'
);
if
(
$
(
target
).
val
()){
document
.
getElementById
(
"preview"
).
checked
=
true
;
$
(
'#changes'
).
trigger
(
'submit'
);
}
});
$
(
'.custom-file-input'
).
keypress
(
function
(
event
)
{
if
(
event
.
which
==
13
)
{
$
(
this
).
trigger
(
'click'
);
}
});
$
(
"#changes"
).
submit
(
function
(
e
)
{
// console.log('windowWidth'+windowWidth ,'windowHeight'+windowHeight,'pheight'+json[0].pheight,'pwidth'+json[0].pwidth,'imageWidth'+imageWidth, 'imageHeight'+imageHeight);
pdflist
+=
'<div id="pdfPreview" style="" class="column">'
;
// pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">';
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>'
;
pdfChange
+=
'<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>'
+
json
[
0
].
name
+
'</h4>'
;
pdfChange
+=
'<input type="hidden" id="id" name="id" value="'
+
json
[
0
].
idPDF
+
'">'
;
for
(
i
=
0
;
i
<
json
.
length
;
++
i
)
{
var
example
=
json
[
0
].
folder
+
'/'
+
json
[
i
].
example
;
if
(
json
[
i
].
change_type
==
"textflow"
)
{
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>'
;
++
f
;
pdfChange
+=
'<span id="span'
+
i
+
'">'
+
json
[
i
].
tips
+
'</span><br/>'
;
}
if
(
json
[
i
].
change_type
==
"text"
)
{
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
+
'"">'
;
pdfChange
+=
'<span class="tip" id="span'
+
i
+
'">'
+
json
[
i
].
tips
+
'</span><br/>'
;
}
if
(
json
[
i
].
change_type
==
"img"
)
{
if
(
edit
==
true
)
{
pdfChange
+=
'<input value="'
+
json
[
i
].
content
+
'" tabindex="-1" class="required" id="hiddenchangescontent['
+
i
+
']" type="hidden" name="content['
+
i
+
']" >'
;
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>'
;
}
else
{
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>'
;
}
pdfChange
+=
'<span class="tip" id="span'
+
i
+
'">'
+
json
[
i
].
tips
+
'</span><br/>'
;
}
if
(
json
[
i
].
change_type
==
"date"
)
{
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
+
'"">'
;
pdfChange
+=
'<span class="tip" id="span'
+
i
+
'"> </span><br/>'
;
}
if
(
json
[
i
].
change_type
==
"user"
)
{
var
str
=
json
[
i
].
content
;
if
(
str
.
startsWith
(
'*'
))
{
var
s
=
json
[
i
].
content
.
substr
(
1
);
//findUserInfoMatch(s);
var
content_string
=
eval
(
s
);
}
else
{
var
content_string
=
json
[
i
].
content
;
}
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
+
'"">'
;
pdfChange
+=
'<span class="tip" id="span'
+
i
+
'">'
+
json
[
i
].
tips
+
'</span><br/>'
;
}
}
pdfChange
+=
'<input type="checkbox" id="preview" name="preview" style="display: none;">'
;
pdfChange
+=
'<input type="submit" value="Save and Continue">'
;
pdfChange
+=
'</form>'
;
strVar2
+=
''
;
strVar2
+=
''
;
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>'
;
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>'
;
document
.
getElementById
(
'contentAreaOver'
).
innerHTML
=
strVar2
;
e
.
preventDefault
();
if
(
$
(
'#preview'
).
prop
(
'checked'
)
==
true
){
$
(
tinymce
.
get
()).
each
(
function
(
i
,
el
)
{
if
(
el
.
id
)
document
.
getElementById
(
el
.
id
).
value
=
el
.
getContent
();
//$('#changes').hide();
tinymce
.
get
(
el
.
id
).
remove
();
if
(
edit
==
false
)
{
$
(
"#contentAreaOver"
).
slideToggle
();
$
(
'#google_drive'
).
slideToggle
();
//document.getElementById('google_drive').innerHTML = " ";
}
var
tinymces
=
tinymce
.
init
({
selector
:
'.textarea'
,
entity_encoding
:
"raw"
,
menubar
:
false
,
toolbar
:
' bold italic'
,
remove_linebreaks
:
false
,
remove_trailing_brs
:
false
,
init_instance_callback
:
function
(
editor
)
{
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"0px solid #131212"
;
editorDocContent
.
body
.
style
.
backgroundColor
=
"#131212"
;
editorDocContent
.
body
.
style
.
color
=
"#ccc"
;
},
setup
:
function
(
editor
)
{
editor
.
on
(
'focus'
,
function
(
e
)
{
//console.log(editor.id);
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"2px solid #F7A800"
;
$
(
'#'
+
editor
.
id
).
trigger
(
"onfocus"
);
//$(this).css('border', '2px solid #F7A800 !important');
});
editor
.
on
(
'blur'
,
function
(
e
)
{
//console.log('out' + editor.id);
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"2px solid #131212"
;
//$(this).css('border', '0px solid #F7A800 !important');
HideBox
();
});
}
});
var
ids
=
[];
if
(
edit
==
true
){
$
(
"#changes input[type=file]"
).
each
(
function
()
{
if
(
$
(
this
).
get
(
0
).
files
.
length
==
0
){
document
.
getElementById
(
this
.
id
).
remove
();
}
else
{
console
.
log
(
"hidden"
+
this
.
id
);
document
.
getElementById
(
"hidden"
+
this
.
id
).
remove
();
}
});}
var
form
=
$
(
"#changes"
);
//console.log(form);
returnfileOptions
(
imagefiles
,
form
,
preview
=
true
);
var
tinymces
=
tinymce
.
init
({
selector
:
'.textarea'
,
entity_encoding
:
"raw"
,
menubar
:
false
,
toolbar
:
' bold italic'
,
remove_linebreaks
:
false
,
remove_trailing_brs
:
false
,
init_instance_callback
:
function
(
editor
)
{
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"0px solid #131212"
;
editorDocContent
.
body
.
style
.
backgroundColor
=
"#131212"
;
editorDocContent
.
body
.
style
.
color
=
"#ccc"
;
},
setup
:
function
(
editor
)
{
editor
.
on
(
'focus'
,
function
(
e
)
{
//console.log(editor.id);
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"2px solid #F7A800"
;
$
(
'#'
+
editor
.
id
).
trigger
(
"onfocus"
);
//$(this).css('border', '2px solid #F7A800 !important');
$
(
'.closeEditer'
).
click
(
function
()
{
$
(
"#contentAreaOver"
).
slideToggle
(
function
()
{
edit
=
false
;
tinyMCE
.
remove
();
});
$
(
'#google_drive'
).
slideToggle
();
});
editor
.
on
(
'blur'
,
function
(
e
)
{
//console.log('out' + editor.id);
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"2px solid #131212"
;
//$(this).css('border', '0px solid #F7A800 !important');
HideBox
();
var
files
;
var
imagefiles
=
[];
$
(
".fileupload"
).
change
(
function
(
e
)
{
var
target
=
e
.
target
;
files
=
e
.
target
.
files
;
// console.log(files);
if
(
files
.
length
>=
1
)
{
for
(
var
i
=
0
,
file
;
file
=
files
[
i
];
i
++
)
{
var
fileName
=
file
.
name
;
// insert file name
if
(
fileName
)
{
$
(
target
).
parent
(
'label'
).
find
(
'.file-name'
).
text
(
fileName
);
}
else
{
$
(
target
).
parent
(
'label'
).
find
(
'.file-name'
).
text
(
''
);
}
imagefiles
.
push
(
file
);
// console.log(imagefiles);
}
}
else
{
$
(
target
).
parent
(
'label'
).
find
(
'.file-name'
).
text
(
''
);
}
$
(
target
).
parent
(
'label'
).
trigger
(
'focus'
);
if
(
$
(
target
).
val
())
{
document
.
getElementById
(
"preview"
).
checked
=
true
;
$
(
'#changes'
).
trigger
(
'submit'
);
}
});
}
});
$
(
"#changes"
).
validate
().
cancelSubmit
=
true
;
$
(
'.custom-file-input'
).
keypress
(
function
(
event
)
{
if
(
event
.
which
==
13
)
{
$
(
this
).
trigger
(
'click'
);
}
else
{
}
});
$
(
"#changes"
).
submit
(
function
(
e
)
{
e
.
preventDefault
();
if
(
$
(
'#preview'
).
prop
(
'checked'
)
==
true
)
{
$
(
tinymce
.
get
()).
each
(
function
(
i
,
el
)
{
if
(
$
(
"#changes"
).
valid
())
{
if
(
el
.
id
)
document
.
getElementById
(
el
.
id
).
value
=
el
.
getContent
();
//$('#changes').hide();
tinymce
.
get
(
el
.
id
).
remove
();
});
$
(
tinymce
.
get
()).
each
(
function
(
i
,
el
)
{
if
(
el
.
id
)
document
.
getElementById
(
el
.
id
).
value
=
el
.
getContent
();
$
(
'#changes'
).
hide
();
tinymce
.
get
(
el
.
id
).
remove
();
var
ids
=
[];
if
(
edit
==
true
)
{
$
(
"#changes input[type=file]"
).
each
(
function
()
{
if
(
$
(
this
).
get
(
0
).
files
.
length
==
0
)
{
document
.
getElementById
(
this
.
id
).
remove
();
}
else
{
console
.
log
(
"hidden"
+
this
.
id
);
document
.
getElementById
(
"hidden"
+
this
.
id
).
remove
();
}
});
}
var
form
=
$
(
"#changes"
);
//console.log(form);
returnfileOptions
(
imagefiles
,
form
,
preview
=
true
);
var
tinymces
=
tinymce
.
init
({
selector
:
'.textarea'
,
entity_encoding
:
"raw"
,
menubar
:
false
,
toolbar
:
' bold italic'
,
remove_linebreaks
:
false
,
remove_trailing_brs
:
false
,
init_instance_callback
:
function
(
editor
)
{
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"0px solid #131212"
;
editorDocContent
.
body
.
style
.
backgroundColor
=
"#131212"
;
editorDocContent
.
body
.
style
.
color
=
"#ccc"
;
},
setup
:
function
(
editor
)
{
editor
.
on
(
'focus'
,
function
(
e
)
{
//console.log(editor.id);
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"2px solid #F7A800"
;
$
(
'#'
+
editor
.
id
).
trigger
(
"onfocus"
);
//$(this).css('border', '2px solid #F7A800 !important');
});
editor
.
on
(
'blur'
,
function
(
e
)
{
//console.log('out' + editor.id);
var
editorDoc
=
document
.
getElementById
(
editor
.
id
+
'_ifr'
);
var
editorDocContent
=
editorDoc
.
contentDocument
;
editorDoc
.
style
.
border
=
"2px solid #131212"
;
//$(this).css('border', '0px solid #F7A800 !important');
HideBox
();
});
}
});
$
(
"#changes"
).
validate
().
cancelSubmit
=
true
;
}
else
{
if
(
$
(
"#changes"
).
valid
())
{
$
(
tinymce
.
get
()).
each
(
function
(
i
,
el
)
{
if
(
el
.
id
)
document
.
getElementById
(
el
.
id
).
value
=
el
.
getContent
();
$
(
'#changes'
).
hide
();
tinymce
.
get
(
el
.
id
).
remove
();
});
var
ids
=
[];
if
(
edit
==
true
)
{
$
(
"#changes input[type=file]"
).
each
(
function
()
{
if
(
$
(
this
).
get
(
0
).
files
.
length
==
0
)
{
document
.
getElementById
(
this
.
id
).
remove
();
}
else
{
//console.log("hidden"+this.id);
document
.
getElementById
(
"hidden"
+
this
.
id
).
remove
();
}
});
}
var
form
=
$
(
"#changes"
);
//console.log(form);
returnfileOptions
(
imagefiles
,
form
,
preview
=
false
);
return
false
;
}
else
{
return
false
;
}
}
});
var
ids
=
[];
if
(
edit
==
true
){
$
(
"#changes input[type=file]"
).
each
(
function
()
{
if
(
$
(
this
).
get
(
0
).
files
.
length
==
0
){
document
.
getElementById
(
this
.
id
).
remove
();
}
else
{
//console.log("hidden"+this.id);
document
.
getElementById
(
"hidden"
+
this
.
id
).
remove
();
}
});}
var
form
=
$
(
"#changes"
);
//console.log(form);
returnfileOptions
(
imagefiles
,
form
,
preview
=
false
);
return
false
;
}
else
{
return
false
;
}
}
});
});
});
}
function
returnfileOptions
(
files
,
form
,
preview
)
{
jQuery
(
function
(
$
)
{
jQuery
(
function
(
$
)
{
var
data
=
new
FormData
();
$
.
each
(
files
,
function
(
key
,
value
)
{
data
.
append
(
key
,
value
);
var
data
=
new
FormData
();
$
.
each
(
files
,
function
(
key
,
value
)
{
data
.
append
(
key
,
value
);
});
});
$
.
ajax
({
url
:
''
+
pluginUrl
+
'/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files'
,
type
:
'POST'
,
data
:
data
,
cache
:
false
,
dataType
:
'json'
,
processData
:
false
,
// Don't process the files
contentType
:
false
,
// Set content type to false as jQuery will tell the server its a query string request
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
if
(
typeof
data
.
error
===
'undefined'
)
{
returnOptions
(
form
,
preview
);
}
else
{
// Handle errors here
$
.
ajax
({
url
:
''
+
pluginUrl
+
'/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files'
,
type
:
'POST'
,
data
:
data
,
cache
:
false
,
dataType
:
'json'
,
processData
:
false
,
// Don't process the files
contentType
:
false
,
// Set content type to false as jQuery will tell the server its a query string request
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
if
(
typeof
data
.
error
===
'undefined'
)
{
returnOptions
(
form
,
preview
);
}
else
{
// Handle errors here
console
.
log
(
'ERRORS: '
+
data
.
error
);
}
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
// Handle errors here
console
.
log
(
'ERRORS: '
+
textStatus
);
// STOP LOADING SPINNER
}
});
console
.
log
(
'ERRORS: '
+
data
.
error
);
}
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
// Handle errors here
console
.
log
(
'ERRORS: '
+
textStatus
);
// STOP LOADING SPINNER
}
});
});
}
function
returnOptions
(
form
,
preview
)
{
jQuery
(
function
(
$
)
{
jQuery
(
function
(
$
)
{
$
.
getJSON
(
pdf_customizer
+
"/api/v1/get-pdf/"
+
id
.
value
,
function
(
dataReturnd
)
{
// Get the element with id summary and set the inner text to the result.
var
json
=
dataReturnd
;
$
.
getJSON
(
pdf_customizer
+
"/api/v1/get-pdf/"
+
id
.
value
,
function
(
dataReturnd
)
{
// Get the element with id summary and set the inner text to the result.
var
json
=
dataReturnd
;
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":['
var
e
=
1
;
var
o
=
1
;
for
(
i
=
0
;
i
<
json
.
length
;
++
i
)
{
var
style
=
JSON
.
stringify
(
json
[
i
].
style
);
var
content
=
JSON
.
stringify
(
form
[
0
][
e
].
value
);
//console.log(form[0][e].value);
//console.log(json[i].label+' '+json[i].order);
if
(
content
!=
'""'
)
{
if
(
o
!==
1
)
{
jsonReturn
+=
','
;
}
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":['
var
e
=
1
;
var
o
=
1
;
for
(
i
=
0
;
i
<
json
.
length
;
++
i
)
{
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/"}'
;
++
o
};
++
e
}
jsonReturn
+=
' ]}'
;
var
windowWidth
=
0.90
*
$
(
".layout-grid"
).
width
();
var
windowHeight
=
0.90
*
$
(
".layout-grid"
).
height
();
var
windowHBG
=
0.923
*
$
(
window
).
height
();
var
pwidth
=
parseInt
(
json
[
0
].
pwidth
);
var
pheight
=
parseInt
(
json
[
0
].
pheight
);
//console.log( windowWidth+' '+windowHeight);
//console.log( pwidth+' '+pheight);
if
(
pwidth
>
pheight
){
//console.log('wide')
var
scaleImage
=
windowWidth
/
pwidth
;
var
imageHeight
=
pheight
*
scaleImage
;
var
imageWidth
=
windowWidth
;
var
imgLeft
=
0
;
var
imgTop
=
40
;
}
else
{
var
scaleImage
=
windowHeight
/
pheight
;
var
imageHeight
=
windowHeight
;
var
imageWidth
=
pwidth
*
scaleImage
;
var
imgLeft
=
30
;
var
imgTop
=
2
;
var
url
;
}
// console.log(jsonReturn);
if
(
preview
==
false
){
$
(
"#Canvas"
).
css
(
'z-index'
,
'0'
);
$
(
'#changes'
).
hide
();
$
(
'#controls'
).
show
();
url
=
'update'
;
}
else
{
$
(
"#changes"
).
validate
().
cancelSubmit
=
false
;
document
.
getElementById
(
"preview"
).
checked
=
false
;
url
=
'preview'
;
}
$
(
'#controls'
).
hide
();
$
(
'#pdfPreviewInner'
).
show
();
$
.
ajax
({
url
:
""
+
pdf_customizer
+
"/api/"
+
url
,
type
:
"POST"
,
dataType
:
'json'
,
data
:
jsonReturn
,
contentType
:
"application/json"
,
CrossDomain
:
true
,
success
:
function
(
data
)
{
var
strVar2
=
""
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>'
;
document
.
getElementById
(
'pdfPreviewInner'
).
innerHTML
=
strVar2
;
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>'
;
document
.
getElementById
(
'controls'
).
innerHTML
=
strVar3
;
$
.
LoadingOverlaySetup
({
color
:
"rgba(0, 0, 0, 0.9)"
});
$
(
'#Canvas'
).
LoadingOverlay
(
"show"
);
$
(
'#Canvas'
).
delay
(
600
).
queue
(
function
()
{
$
(
this
).
css
(
"background-image"
,
""
);
});
setTimeout
(
function
(){
$
(
'#Canvas'
).
LoadingOverlay
(
"hide"
,
true
);
},
600
);
if
(
preview
==
false
){
$
(
'#controls'
).
show
();
}
$
(
'#editMe'
).
click
(
function
()
{
$
(
"#google_drive"
).
hide
();
$
(
'#controls'
).
hide
();
$
(
'#changes'
).
show
();
$
(
"#Canvas"
).
show
();
$
(
"#Canvas"
).
css
(
'z-index'
,
'10'
);
});
$
(
'#downloadMe'
).
click
(
function
()
{
$
(
".closeEditer"
).
click
();
});
},
error
:
function
(
xhr
,
ajaxOptions
,
thrownError
)
{
//Add these parameters to display the required response
alert
(
xhr
.
status
);
document
.
getElementById
(
'pdfPreview'
).
innerHTML
=
xhr
.
responseText
;
}
});
var
style
=
JSON
.
stringify
(
json
[
i
].
style
);
var
content
=
JSON
.
stringify
(
form
[
0
][
e
].
value
);
//console.log(form[0][e].value);
//console.log(json[i].label+' '+json[i].order);
if
(
content
!=
'""'
)
{
if
(
o
!==
1
)
{
jsonReturn
+=
','
;
}
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/"}'
;
++
o
};
++
e
}
jsonReturn
+=
' ]}'
;
var
windowWidth
=
0.90
*
$
(
".layout-grid"
).
width
();
var
windowHeight
=
0.90
*
$
(
".layout-grid"
).
height
();
var
windowHBG
=
0.923
*
$
(
window
).
height
();
var
pwidth
=
parseInt
(
json
[
0
].
pwidth
);
var
pheight
=
parseInt
(
json
[
0
].
pheight
);
//console.log( windowWidth+' '+windowHeight);
//console.log( pwidth+' '+pheight);
if
(
pwidth
>
pheight
)
{
//console.log('wide')
var
scaleImage
=
windowWidth
/
pwidth
;
var
imageHeight
=
pheight
*
scaleImage
;
var
imageWidth
=
windowWidth
;
var
imgLeft
=
0
;
var
imgTop
=
40
;
}
else
{
var
scaleImage
=
windowHeight
/
pheight
;
var
imageHeight
=
windowHeight
;
var
imageWidth
=
pwidth
*
scaleImage
;
var
imgLeft
=
30
;
var
imgTop
=
2
;
var
url
;
}
// console.log(jsonReturn);
if
(
preview
==
false
)
{
$
(
"#Canvas"
).
css
(
'z-index'
,
'0'
);
$
(
'#changes'
).
hide
();
$
(
'#controls'
).
show
();
url
=
'update'
;
}
else
{
$
(
"#changes"
).
validate
().
cancelSubmit
=
false
;
document
.
getElementById
(
"preview"
).
checked
=
false
;
url
=
'preview'
;
}
$
(
'#controls'
).
hide
();
$
(
'#pdfPreviewInner'
).
show
();
$
.
ajax
({
url
:
""
+
pdf_customizer
+
"/api/"
+
url
,
type
:
"POST"
,
dataType
:
'json'
,
data
:
jsonReturn
,
contentType
:
"application/json"
,
CrossDomain
:
true
,
success
:
function
(
data
)
{
var
strVar2
=
""
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>'
;
document
.
getElementById
(
'pdfPreviewInner'
).
innerHTML
=
strVar2
;
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>'
;
document
.
getElementById
(
'controls'
).
innerHTML
=
strVar3
;
$
.
LoadingOverlaySetup
({
color
:
"rgba(0, 0, 0, 0.9)"
});
$
(
'#Canvas'
).
LoadingOverlay
(
"show"
);
$
(
'#Canvas'
).
delay
(
600
).
queue
(
function
()
{
$
(
this
).
css
(
"background-image"
,
""
);
});
setTimeout
(
function
()
{
$
(
'#Canvas'
).
LoadingOverlay
(
"hide"
,
true
);
},
600
);
if
(
preview
==
false
)
{
$
(
'#controls'
).
show
();
}
$
(
'#editMe'
).
click
(
function
()
{
$
(
"#google_drive"
).
hide
();
$
(
'#controls'
).
hide
();
$
(
'#changes'
).
show
();
$
(
"#Canvas"
).
show
();
$
(
"#Canvas"
).
css
(
'z-index'
,
'10'
);
});
$
(
'#downloadMe'
).
click
(
function
()
{
$
(
".closeEditer"
).
click
();
});
},
error
:
function
(
xhr
,
ajaxOptions
,
thrownError
)
{
//Add these parameters to display the required response
alert
(
xhr
.
status
);
document
.
getElementById
(
'pdfPreview'
).
innerHTML
=
xhr
.
responseText
;
}
});
});
});
});
}
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment