This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocument-loader.js
More file actions
52 lines (52 loc) · 2.17 KB
/
document-loader.js
File metadata and controls
52 lines (52 loc) · 2.17 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
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Document editor - Document loader
*/
var DocumentLoader = (function () {
function DocumentLoader(documentEditor) {
this.hostUrl = 'https://ej2services.syncfusion.com/production/web-services/';
this.documentEditor = undefined;
this.documentEditor = documentEditor;
}
DocumentLoader.prototype.loadDefault = function (defaultDocument) {
this.documentEditor.open(JSON.stringify(defaultDocument));
};
DocumentLoader.prototype.loadFile = function (path) {
var _this = this;
var baseUrl = this.hostUrl + 'api/documenteditor/import';
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', baseUrl, true);
var waitingPopUp = document.getElementById('waiting-popup');
var inActiveDiv = document.getElementById('popup-overlay');
this.documentEditor.isReadOnly = true;
waitingPopUp.style.display = 'block';
inActiveDiv.style.display = 'block';
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200 || httpRequest.status === 304) {
_this.documentEditor.open(httpRequest.responseText);
_this.documentEditor.isReadOnly = false;
waitingPopUp.style.display = 'none';
inActiveDiv.style.display = 'none';
}
else {
waitingPopUp.style.display = 'none';
inActiveDiv.style.display = 'none';
_this.documentEditor.isReadOnly = false;
console.error(httpRequest.response);
}
}
};
var formData = new FormData();
formData.append('files', path);
this.documentEditor.documentName = path.name.substr(0, path.name.lastIndexOf('.'));
httpRequest.send(formData);
};
DocumentLoader.prototype.destroy = function () {
this.documentEditor = undefined;
this.hostUrl = undefined;
};
return DocumentLoader;
}());
exports.DocumentLoader = DocumentLoader;