Fix wopi messages
This commit is contained in:
parent
9a1c2a0b91
commit
c14408bd9c
|
@ -689,6 +689,22 @@
|
|||
});
|
||||
};
|
||||
|
||||
var _grabFocus = function(data) {
|
||||
setTimeout(function(){
|
||||
_sendCommand({
|
||||
command: 'grabFocus',
|
||||
data: data
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
||||
var _blurFocus = function(data) {
|
||||
_sendCommand({
|
||||
command: 'blurFocus',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
var _serviceCommand = function(command, data) {
|
||||
_sendCommand({
|
||||
command: 'internalCommand',
|
||||
|
@ -721,7 +737,9 @@
|
|||
setMailMergeRecipients: _setMailMergeRecipients,
|
||||
setRevisedFile : _setRevisedFile,
|
||||
setFavorite : _setFavorite,
|
||||
requestClose : _requestClose
|
||||
requestClose : _requestClose,
|
||||
grabFocus : _grabFocus,
|
||||
blurFocus : _blurFocus
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@ div {
|
|||
var postMessageOrigin;
|
||||
var lang = "en-US";
|
||||
var startTime;
|
||||
var editNotificationPostMessage;
|
||||
var documentChanged;
|
||||
var sendNotificationTimer;
|
||||
|
||||
var innerAlert = function (message) {
|
||||
if (console && console.log)
|
||||
|
@ -75,11 +76,11 @@ div {
|
|||
var commandMap = {
|
||||
'Blur_Focus': function (data) {
|
||||
innerAlert('Blur_Focus');
|
||||
// docEditor.blurFocus();
|
||||
docEditor.blurFocus();
|
||||
},
|
||||
'Grab_Focus': function (data) {
|
||||
innerAlert('Grab_Focus');
|
||||
// docEditor.grabFocus();
|
||||
docEditor.grabFocus();
|
||||
},
|
||||
'Host_PostmessageReady': function (data) {
|
||||
innerAlert('Host_PostmessageReady');
|
||||
|
@ -101,7 +102,6 @@ div {
|
|||
};
|
||||
|
||||
var _onMessage = function(msg) {
|
||||
// TODO: check message origin
|
||||
if (msg.origin !== postMessageOrigin) return;
|
||||
|
||||
var data = msg.data;
|
||||
|
@ -118,9 +118,9 @@ div {
|
|||
}
|
||||
|
||||
if (cmd) {
|
||||
handler = commandMap[cmd.command];
|
||||
handler = commandMap[cmd.MessageId];
|
||||
if (handler) {
|
||||
handler.call(this, cmd.data);
|
||||
handler.call(this, cmd);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -140,9 +140,18 @@ div {
|
|||
innerAlert("App ready");
|
||||
};
|
||||
|
||||
var sendEditNotification = function () {
|
||||
documentChanged && _postMessage('Edit_Notification', {});
|
||||
documentChanged = false;
|
||||
};
|
||||
|
||||
var onDocumentStateChange = function (event) {
|
||||
if (editNotificationPostMessage && event.data) {
|
||||
_postMessage('Edit_Notification', {});
|
||||
if (event.data) {
|
||||
documentChanged = true;
|
||||
if (sendNotificationTimer===undefined) {
|
||||
sendNotificationTimer = setInterval(sendEditNotification, 30000);
|
||||
sendEditNotification();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -226,7 +235,7 @@ div {
|
|||
},
|
||||
events: {
|
||||
"onAppReady": onAppReady,
|
||||
"onDocumentStateChange": onDocumentStateChange,
|
||||
"onDocumentStateChange": fileInfo.EditNotificationPostMessage ? onDocumentStateChange : undefined,
|
||||
'onRequestEditRights': fileInfo.EditModePostMessage ? onRequestEditRights : undefined,
|
||||
"onError": onError,
|
||||
"onRequestClose": fileInfo. ClosePostMessage ? onRequestClose : undefined,
|
||||
|
@ -236,8 +245,9 @@ div {
|
|||
};
|
||||
|
||||
postMessageOrigin = fileInfo.PostMessageOrigin;
|
||||
if (postMessageOrigin && (typeof postMessageOrigin === 'string') && postMessageOrigin.charAt(postMessageOrigin.length-1)=='/')
|
||||
postMessageOrigin = postMessageOrigin.substring(0, postMessageOrigin.length - 1);
|
||||
lang = config.editorConfig.lang;
|
||||
editNotificationPostMessage = fileInfo.EditNotificationPostMessage;
|
||||
|
||||
startTime = Date.now();
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
|
||||
|
|
|
@ -130,6 +130,14 @@ if (window.Common === undefined) {
|
|||
|
||||
'requestClose': function(data) {
|
||||
$me.trigger('requestclose', data);
|
||||
},
|
||||
|
||||
'blurFocus': function(data) {
|
||||
$me.trigger('blurfocus', data);
|
||||
},
|
||||
|
||||
'grabFocus': function(data) {
|
||||
$me.trigger('grabfocus', data);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -223,6 +223,7 @@ define([
|
|||
Common.Gateway.on('init', _.bind(this.loadConfig, this));
|
||||
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
|
||||
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
|
||||
Common.Gateway.on('grabfocus', _.bind(this.onGrabFocus, this));
|
||||
Common.Gateway.appReady();
|
||||
|
||||
// $(window.top).resize(_.bind(this.onDocumentResize, this));
|
||||
|
@ -2530,6 +2531,10 @@ define([
|
|||
this._renameDialog.show(Common.Utils.innerWidth() - this._renameDialog.options.width - 15, 30);
|
||||
},
|
||||
|
||||
onGrabFocus: function() {
|
||||
this.getApplication().getController('DocumentHolder').getView().focus();
|
||||
},
|
||||
|
||||
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.',
|
||||
criticalErrorTitle: 'Error',
|
||||
notcriticalErrorTitle: 'Warning',
|
||||
|
|
|
@ -199,6 +199,7 @@ define([
|
|||
Common.Gateway.on('init', _.bind(this.loadConfig, this));
|
||||
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
|
||||
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
|
||||
Common.Gateway.on('grabfocus', _.bind(this.onGrabFocus, this));
|
||||
Common.Gateway.appReady();
|
||||
|
||||
this.getApplication().getController('Viewport').setApi(this.api);
|
||||
|
@ -2327,6 +2328,10 @@ define([
|
|||
return"#"+("000000"+color.toString(16)).substr(-6);
|
||||
},
|
||||
|
||||
onGrabFocus: function() {
|
||||
this.getApplication().getController('DocumentHolder').getView().focus();
|
||||
},
|
||||
|
||||
// Translation
|
||||
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.',
|
||||
criticalErrorTitle: 'Error',
|
||||
|
|
|
@ -226,6 +226,7 @@ define([
|
|||
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
|
||||
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
|
||||
Common.Gateway.on('internalcommand', _.bind(this.onInternalCommand, this));
|
||||
Common.Gateway.on('grabfocus', _.bind(this.onGrabFocus, this));
|
||||
Common.Gateway.appReady();
|
||||
|
||||
this.getApplication().getController('Viewport').setApi(this.api);
|
||||
|
@ -2524,6 +2525,10 @@ define([
|
|||
this._renameDialog.show(Common.Utils.innerWidth() - this._renameDialog.options.width - 15, 30);
|
||||
},
|
||||
|
||||
onGrabFocus: function() {
|
||||
this.getApplication().getController('DocumentHolder').getView().focus();
|
||||
},
|
||||
|
||||
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.',
|
||||
criticalErrorTitle: 'Error',
|
||||
notcriticalErrorTitle: 'Warning',
|
||||
|
|
Loading…
Reference in a new issue