refactoring. send commands to desktop app

This commit is contained in:
Maxim Kadushkin 2018-02-13 11:23:53 +03:00
parent b5a5c97735
commit 753afc350d
4 changed files with 54 additions and 16 deletions

View file

@ -55,7 +55,12 @@
height: '100%', height: '100%',
documentType: urlParams['doctype'] || 'text', documentType: urlParams['doctype'] || 'text',
document: doc, document: doc,
editorConfig: cfg editorConfig: cfg,
events: {
onInternalMessage: onInternalMessage,
onDocumentReady: onDocumentReady
}
}); });
@ -92,7 +97,7 @@
function getEditorConfig(urlParams) { function getEditorConfig(urlParams) {
return { return {
customization : { customization : {
goback: { url:"https://onlyoffice.com" } goback: { url: "callback" }
}, },
mode : urlParams["mode"] || 'edit', mode : urlParams["mode"] || 'edit',
lang : urlParams["lang"] || 'en', lang : urlParams["lang"] || 'en',
@ -147,6 +152,21 @@
} }
}; };
function onInternalMessage(event) {
let info = event.data;
if ( info.type == 'goback' ) {
if ( window.AscDesktopEditor ) {
window.AscDesktopEditor.execCommand('go:folder', info.data.status);
}
}
};
function onDocumentReady() {
if ( window.AscDesktopEditor ) {
window.AscDesktopEditor.execCommand('doc:onready', '');
}
}
if (isMobile()){ if (isMobile()){
window.addEventListener('load', fixSize); window.addEventListener('load', fixSize);
window.addEventListener('resize', fixSize); window.addEventListener('resize', fixSize);

View file

@ -582,11 +582,17 @@ define([
}, },
goBack: function(blank) { goBack: function(blank) {
var href = this.appOptions.customization.goback.url; var me = this;
if (blank) { if ( me.appOptions.customization.goback.url == 'callback' ) {
window.open(href, "_blank"); Common.Gateway.internalMessage( 'goback',
{status: me.appOptions.isOffline ? 'offline' : 'online'} );
} else { } else {
parent.location.href = href; var href = this.appOptions.customization.goback.url;
if (blank) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
} }
}, },

View file

@ -393,12 +393,18 @@ define([
}, },
goBack: function(blank) { goBack: function(blank) {
var href = this.appOptions.customization.goback.url; var me = this;
if (blank) { if ( me.appOptions.customization.goback.url == 'callback' ) {
window.open(href, "_blank"); Common.Gateway.internalMessage( 'goback',
} else { {status: me.appOptions.isOffline ? 'offline' : 'online'} );
parent.location.href = href; } else {
} var href = me.appOptions.customization.goback.url;
if (blank) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
}
}, },
onEditComplete: function(cmp) { onEditComplete: function(cmp) {

View file

@ -428,11 +428,17 @@ define([
}, },
goBack: function(blank) { goBack: function(blank) {
var href = this.appOptions.customization.goback.url; var me = this;
if (blank) { if ( me.appOptions.customization.goback.url == 'callback' ) {
window.open(href, "_blank"); Common.Gateway.internalMessage( 'goback',
{status: me.appOptions.isOffline ? 'offline' : 'online'} );
} else { } else {
parent.location.href = href; var href = me.appOptions.customization.goback.url;
if (blank) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
} }
}, },