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%',
documentType: urlParams['doctype'] || 'text',
document: doc,
editorConfig: cfg
editorConfig: cfg,
events: {
onInternalMessage: onInternalMessage,
onDocumentReady: onDocumentReady
}
});
@ -92,7 +97,7 @@
function getEditorConfig(urlParams) {
return {
customization : {
goback: { url:"https://onlyoffice.com" }
goback: { url: "callback" }
},
mode : urlParams["mode"] || 'edit',
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()){
window.addEventListener('load', fixSize);
window.addEventListener('resize', fixSize);

View file

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

View file

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

View file

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