diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index 8b4481f5e..41fa95d7c 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -91,19 +91,26 @@ define([ } else if (/editor:config/.test(cmd)) { if ( param == 'request' ) { - var opts = { - user: config.user, - title: { buttons: [] } - }; + if ( !!titlebuttons ) { + var opts = { + user: config.user, + title: { buttons: [] } + }; - var header = webapp.getController('Viewport').getView('Common.Views.Header'); - if ( header ) { - for (var i in titlebuttons) { - opts.title.buttons.push(_serializeHeaderButton(i, titlebuttons[i])); + var header = webapp.getController('Viewport').getView('Common.Views.Header'); + if ( header ) { + for (var i in titlebuttons) { + opts.title.buttons.push(_serializeHeaderButton(i, titlebuttons[i])); + } + } + + app.execCommand('editor:config', JSON.stringify(opts)); + } else + if ( !config.callback_editorconfig ) { + config.callback_editorconfig = function() { + setTimeout(function(){window.on_native_message(cmd, param);},0); } } - - app.execCommand('editor:config', JSON.stringify(opts)); } } else if (/button:click/.test(cmd)) { @@ -114,6 +121,12 @@ define([ } }; + if ( !!window.native_message_cmd ) { + for ( var c in window.native_message_cmd ) { + window.on_native_message(c, window.native_message_cmd[c]); + } + } + // app.execCommand('window:features', {version: config.version, action: 'request'}); app.execCommand('webapps:features', {version: config.version, eventloading:true, titlebuttons:true}); } @@ -190,6 +203,11 @@ define([ var iconname = /\s?([^\s]+)$/.exec(titlebuttons.save.btn.$icon.attr('class')); !!iconname && iconname.length && (titlebuttons.save.icon = btnsave_icons[iconname]); + + if ( !!config.callback_editorconfig ) { + config.callback_editorconfig(); + delete config.callback_editorconfig; + } }); Common.NotificationCenter.on({ diff --git a/apps/documenteditor/main/index.html.deploy b/apps/documenteditor/main/index.html.deploy index 5a11eb7c6..8bb439d43 100644 --- a/apps/documenteditor/main/index.html.deploy +++ b/apps/documenteditor/main/index.html.deploy @@ -212,6 +212,13 @@ logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null; window.frameEditorId = params["frameEditorId"]; + + if ( window.AscDesktopEditor ) { + window.on_native_message = function (cmd, param) { + !window.native_message_cmd && (window.native_message_cmd = []); + window.native_message_cmd[cmd] = param; + } + } diff --git a/apps/presentationeditor/main/index.html.deploy b/apps/presentationeditor/main/index.html.deploy index 5225cc248..56d2c45a2 100644 --- a/apps/presentationeditor/main/index.html.deploy +++ b/apps/presentationeditor/main/index.html.deploy @@ -249,6 +249,13 @@ logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null; window.frameEditorId = params["frameEditorId"]; + + if ( window.AscDesktopEditor ) { + window.on_native_message = function (cmd, param) { + !window.native_message_cmd && (window.native_message_cmd = []); + window.native_message_cmd[cmd] = param; + } + } diff --git a/apps/spreadsheeteditor/main/index.html.deploy b/apps/spreadsheeteditor/main/index.html.deploy index e8e17a25b..c112c666e 100644 --- a/apps/spreadsheeteditor/main/index.html.deploy +++ b/apps/spreadsheeteditor/main/index.html.deploy @@ -227,6 +227,13 @@ logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null; window.frameEditorId = params["frameEditorId"]; + + if ( window.AscDesktopEditor ) { + window.on_native_message = function (cmd, param) { + !window.native_message_cmd && (window.native_message_cmd = []); + window.native_message_cmd[cmd] = param; + } + }