Wopi: change config parameters and post messages
This commit is contained in:
parent
f8ee00314a
commit
59c658ecab
|
@ -68,6 +68,7 @@ div {
|
||||||
var documentChanged;
|
var documentChanged;
|
||||||
var sendNotificationTimer;
|
var sendNotificationTimer;
|
||||||
var sessionId;
|
var sessionId;
|
||||||
|
var fileInfo;
|
||||||
|
|
||||||
var innerAlert = function (message) {
|
var innerAlert = function (message) {
|
||||||
if (console && console.log)
|
if (console && console.log)
|
||||||
|
@ -165,15 +166,24 @@ div {
|
||||||
};
|
};
|
||||||
|
|
||||||
var onRequestClose = function () {
|
var onRequestClose = function () {
|
||||||
_postMessage('UI_Close', {});
|
if (fileInfo.ClosePostMessage)
|
||||||
|
_postMessage('UI_Close', {});
|
||||||
|
else if (fileInfo.CloseUrl)
|
||||||
|
window.parent.location.href = fileInfo.CloseUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
var onRequestEditRights = function () {
|
var onRequestEditRights = function () {
|
||||||
_postMessage('UI_Edit', {});
|
if (fileInfo.EditModePostMessage)
|
||||||
|
_postMessage('UI_Edit', {});
|
||||||
|
else if (fileInfo.HostEditUrl)
|
||||||
|
window.open(fileInfo.HostEditUrl, "_blank");
|
||||||
};
|
};
|
||||||
|
|
||||||
var requestSharingSettings = function (event) {
|
var requestSharingSettings = function (event) {
|
||||||
_postMessage('UI_Sharing', {});
|
if (fileInfo.FileSharingPostMessage)
|
||||||
|
_postMessage('UI_Sharing', {});
|
||||||
|
else if (fileInfo.FileSharingUrl)
|
||||||
|
window.open(fileInfo.FileSharingUrl, "_blank");
|
||||||
};
|
};
|
||||||
|
|
||||||
var onError = function (event) {
|
var onError = function (event) {
|
||||||
|
@ -182,9 +192,10 @@ div {
|
||||||
};
|
};
|
||||||
|
|
||||||
var connectEditor = function () {
|
var connectEditor = function () {
|
||||||
|
|
||||||
|
fileInfo = <%- JSON.stringify(fileInfo) %>;
|
||||||
|
|
||||||
var key = "<%- key %>";
|
var key = "<%- key %>";
|
||||||
var fileInfo = <%- JSON.stringify(fileInfo) %>;
|
|
||||||
var userAuth = <%- JSON.stringify(userAuth) %>;
|
var userAuth = <%- JSON.stringify(userAuth) %>;
|
||||||
var token = "<%- token %>";
|
var token = "<%- token %>";
|
||||||
var queryParams = <%- JSON.stringify(queryParams) %>;
|
var queryParams = <%- JSON.stringify(queryParams) %>;
|
||||||
|
@ -208,7 +219,7 @@ div {
|
||||||
"edit": !fileInfo.ReadOnly && fileInfo.UserCanWrite,
|
"edit": !fileInfo.ReadOnly && fileInfo.UserCanWrite,
|
||||||
"review": (fileInfo.SupportsReviewing===false) ? false : (fileInfo.UserCanReview===false ? false : fileInfo.UserCanReview),
|
"review": (fileInfo.SupportsReviewing===false) ? false : (fileInfo.UserCanReview===false ? false : fileInfo.UserCanReview),
|
||||||
"copy": fileInfo.CopyPasteRestrictions!=="CurrentDocumentOnly" && fileInfo.CopyPasteRestrictions!=="BlockAll",
|
"copy": fileInfo.CopyPasteRestrictions!=="CurrentDocumentOnly" && fileInfo.CopyPasteRestrictions!=="BlockAll",
|
||||||
"print": !fileInfo.DisablePrint
|
"print": !fileInfo.DisablePrint && !fileInfo.HidePrintOption
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"editorConfig": {
|
"editorConfig": {
|
||||||
|
@ -216,7 +227,6 @@ div {
|
||||||
"lang": queryParams.lang || queryParams.ui || "en-US",
|
"lang": queryParams.lang || queryParams.ui || "en-US",
|
||||||
"region": queryParams.rs,
|
"region": queryParams.rs,
|
||||||
"callbackUrl": JSON.stringify(userAuth),
|
"callbackUrl": JSON.stringify(userAuth),
|
||||||
"sharingSettingsUrl": fileInfo.FileSharingUrl,
|
|
||||||
"user": {
|
"user": {
|
||||||
"id": fileInfo.UserId,
|
"id": fileInfo.UserId,
|
||||||
"name": fileInfo.IsAnonymousUser ? "" : fileInfo.UserFriendlyName
|
"name": fileInfo.IsAnonymousUser ? "" : fileInfo.UserFriendlyName
|
||||||
|
@ -244,11 +254,11 @@ div {
|
||||||
"events": {
|
"events": {
|
||||||
"onAppReady": onAppReady,
|
"onAppReady": onAppReady,
|
||||||
"onDocumentStateChange": fileInfo.EditNotificationPostMessage ? onDocumentStateChange : undefined,
|
"onDocumentStateChange": fileInfo.EditNotificationPostMessage ? onDocumentStateChange : undefined,
|
||||||
'onRequestEditRights': fileInfo.EditModePostMessage ? onRequestEditRights : undefined,
|
'onRequestEditRights': fileInfo.EditModePostMessage || fileInfo.HostEditUrl ? onRequestEditRights : undefined,
|
||||||
"onError": onError,
|
"onError": onError,
|
||||||
"onRequestClose": fileInfo.ClosePostMessage ? onRequestClose : undefined,
|
"onRequestClose": fileInfo.ClosePostMessage || fileInfo.CloseUrl ? onRequestClose : undefined,
|
||||||
"onRequestRename": fileInfo.SupportsRename && fileInfo.UserCanRename ? onRequestRename : undefined,
|
"onRequestRename": fileInfo.SupportsRename && fileInfo.UserCanRename ? onRequestRename : undefined,
|
||||||
"onRequestSharingSettings": fileInfo.FileSharingPostMessage ? requestSharingSettings : undefined
|
"onRequestSharingSettings": fileInfo.FileSharingPostMessage || fileInfo.FileSharingUrl ? requestSharingSettings : undefined
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -905,21 +905,17 @@ define([
|
||||||
if (this.appConfig.canRequestSharingSettings) {
|
if (this.appConfig.canRequestSharingSettings) {
|
||||||
Common.Gateway.requestSharingSettings();
|
Common.Gateway.requestSharingSettings();
|
||||||
} else {
|
} else {
|
||||||
if (this.appConfig.wopi) {
|
var me = this;
|
||||||
window.open(this.appConfig.sharingSettingsUrl, "_blank");
|
me._docAccessDlg = new Common.Views.DocumentAccessDialog({
|
||||||
} else {
|
settingsurl: this.appConfig.sharingSettingsUrl
|
||||||
var me = this;
|
});
|
||||||
me._docAccessDlg = new Common.Views.DocumentAccessDialog({
|
me._docAccessDlg.on('accessrights', function(obj, rights){
|
||||||
settingsurl: this.appConfig.sharingSettingsUrl
|
me.setSharingSettings({sharingSettings: rights});
|
||||||
});
|
}).on('close', function(obj){
|
||||||
me._docAccessDlg.on('accessrights', function(obj, rights){
|
me._docAccessDlg = undefined;
|
||||||
me.setSharingSettings({sharingSettings: rights});
|
});
|
||||||
}).on('close', function(obj){
|
|
||||||
me._docAccessDlg = undefined;
|
|
||||||
});
|
|
||||||
|
|
||||||
me._docAccessDlg.show();
|
me._docAccessDlg.show();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue