-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathOnlyOffice.js
More file actions
110 lines (90 loc) · 3.7 KB
/
Copy pathOnlyOffice.js
File metadata and controls
110 lines (90 loc) · 3.7 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
(function() {
var throttle = function(type, name, obj) {
obj = obj || window;
var running = false;
var func = function() {
if (running) { return; }
running = true;
requestAnimationFrame(function() {
obj.dispatchEvent(new CustomEvent(name));
running = false;
});
};
obj.addEventListener(type, func);
};
/* init - you can init any event */
throttle("resize", "optimizedResize");
Alfresco.WebPreview.prototype.Plugins.OnlyOffice = function(wp, attributes)
{
this.wp = wp;
this.attributes = YAHOO.lang.merge(Alfresco.util.deepCopy(this.attributes), attributes);
return this;
};
Alfresco.WebPreview.prototype.Plugins.OnlyOffice.prototype =
{
attributes: {},
report: function() {
return null;
},
display: function() {
var aboveThreshold = this.attributes.abovePreviewThreshold;
if (aboveThreshold) {
var messageAbovePreviewThreshold = Alfresco.messages.global["label.onlyoffice.abovePreviewThreshold"];
if (!messageAbovePreviewThreshold) {
messageAbovePreviewThreshold = "This document cannot be viewed or edited in OnlyOffice. Please edit using Microsoft Office.";
}
return '<div class="message">' + messageAbovePreviewThreshold + '</div>';
} else {
var docEditor = new DocsAPI.DocEditor(this.wp.id + "-body", this.getAttributes());
this.updateHeight();
//Update the height of the document preview
window.addEventListener("optimizedResize", this.updateHeight.bind(this));
}
},
updateHeight: function() {
var iFrames = document.getElementById(this.wp.id).getElementsByTagName("iframe");
var height = this.wp.options.proxy == "alfresco-noauth" ? 260 : 200;
if(iFrames[0]) {
iFrames[0].style.height = (window.innerHeight - height) + "px";
}
},
/*getDocumentType: function(ext) {
if (".docm.dotm.docx.doc.odt.rtf.txt.html.htm.mht.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
if (".xlsm.xltm.xlam.xlsb.xls.xlsx.ods.csv".indexOf(ext) != -1) return "spreadsheet";
if (".pptm.potm.ppsm.ppam.sldm.pps.ppsx.ppt.pptx.odp".indexOf(ext) != -1) return "presentation";
return null;
},*/
getAttributes: function() {
var docName = this.attributes.docTitle;
var docType = docName.substring(docName.lastIndexOf(".") + 1).trim().toLowerCase();
var config = {
type: getEditorType(),
width: "100%",
height: "100%",
documentType: getDocumentType(docType),
document: {
title: docName,
url: this.attributes.docUrl,
fileType: translateDocumentType(docType),
key: this.attributes.key,
permissions: {
edit: true,
comment: false
}
},
editorConfig: {
mode: "view",
lang: this.attributes.lang,
callbackUrl: this.attributes.callbackUrl,
user: this.attributes.user,
customization: {
zoom: -2,
chat: false,
comments: false
}
}
};
return config;
}
};
})();