-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobile.js
More file actions
125 lines (112 loc) · 3.35 KB
/
mobile.js
File metadata and controls
125 lines (112 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
let router;
let editViewer = null;
let browseViewer = null;
let groupUid = "uniqueID";
class MyMobileViewer extends MyViewer {
constructor(options) {
super();
this.initViewers();
}
initViewers(){
initBrowseViewer();
initEditViewer();
bindEvents();
}
// override
getDocument() {
let doc = editViewer.currentDocument;
if (!doc) {
doc = Dynamsoft.DDV.documentManager.createDocument();
editViewer.openDocument(doc.uid);
}
return doc;
}
async saveToPng(index, settings) {
const doc = this.getDocument();
const file = await doc?.saveToPng(index, settings);
return await MyViewerApp.fileToBase64(file);
}
async saveCurrentToPng(settings) {
if (editViewer.getPageCount() <= 0) {
return "";
}
return await this.saveToPng(editViewer.getCurrentPageIndex(), settings);
}
}
function initEditViewer(){
const config = {
type: Dynamsoft.DDV.Elements.Layout,
flexDirection: "column",
className: "ddv-edit-viewer-mobile",
children: [
{
type: Dynamsoft.DDV.Elements.Layout,
className: "ddv-edit-viewer-header-mobile",
children: [
{
// Add a "Back" buttom to header and bind click event to go back to the perspective viewer
// The event will be registered later.
type: Dynamsoft.DDV.Elements.Button,
className: "ddv-button-back",
events:{
click: "back"
}
},
Dynamsoft.DDV.Elements.Pagination
],
},
Dynamsoft.DDV.Elements.MainView,
{
type: Dynamsoft.DDV.Elements.Layout,
className: "ddv-edit-viewer-footer-mobile",
children: [
Dynamsoft.DDV.Elements.DisplayMode,
Dynamsoft.DDV.Elements.RotateLeft,
Dynamsoft.DDV.Elements.Crop,
Dynamsoft.DDV.Elements.Filter,
Dynamsoft.DDV.Elements.Undo,
Dynamsoft.DDV.Elements.Delete,
{
// Bind event for "PerspectiveAll" button to show the edit viewer
// The event will be registered later.
type: Dynamsoft.DDV.Elements.Button,
className: "ddv-load-image",
events:{
click: "loadFile"
}
},
],
},
],
};
editViewer = new Dynamsoft.DDV.EditViewer({
groupUid: groupUid,
container: "container",
uiConfig: config,
});
editViewer.hide();
}
function initBrowseViewer(){
browseViewer = new Dynamsoft.DDV.BrowseViewer({
groupUid: groupUid,
container: "container"
});
}
function bindEvents(){
editViewer.on("back",() => {
switchViewer(0,1);
});
editViewer.on("loadFile",() => {
MyViewerApp.invokeDotNet('loadFile', 'true', '');
});
}
function showEditor(){
switchViewer(1,0);
}
// Define a function to control the viewers' visibility
function switchViewer(e,b) {
editViewer.hide();
browseViewer.hide();
if(e) editViewer.show();
if(b) browseViewer.show();
};