diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index ab783a36b..17408b32e 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -45,6 +45,53 @@ define([ var config = {}; var app = window.AscDesktopEditor; + if ( !!app ) { + window.on_native_message = function (cmd, param) { + if (/^style:change/.test(cmd)) { + var obj = JSON.parse(param); + + if ( obj.element == 'toolbar' ) { + if ( obj.action == 'off' && obj.style == 'native-color' ) { + $('.toolbar').removeClass('editor-native-color'); + } + } else + if ( obj.element == 'body' ) { + if ( obj.action == 'merge' ) { + var style = document.createElement('style'); + style.innerHTML = obj.style; + document.body.appendChild(style); + } + } + } else + if (/window:features/.test(cmd)) { + var obj = JSON.parse(param); + + if ( obj.canUndock == 'true' ) { + if ( !config.canUndock ) { + config.canUndock = true; + + if ( !_.isEmpty(config) ) + Common.NotificationCenter.trigger('app:config', {canUndock:true}); + } + } + } else + if (/window:status/.test(cmd)) { + var obj = JSON.parse(param); + + if ( obj.action == 'undocking' ) { + Common.NotificationCenter.trigger('undock:status', {status:obj.status=='undocked'?'undocked':'docked'}); + } + } else + if (/editor:config/.test(cmd)) { + if ( param == 'request' ) + app.execCommand('editor:config', JSON.stringify({user: config.user, 'extraleft': $('#box-document-title #slot-btn-dt-save').parent().width()})); + } + }; + + app.execCommand('webapps:events', 'loading'); + app.execCommand('window:features', 'request'); + } + return { init: function (opts) { _.extend(config, opts); @@ -57,25 +104,15 @@ define([ $('.toolbar').addClass('editor-native-color'); }); - if ( !!app ) { - if ( !config.isOffline ) { - if ( config.customization.goback && config.customization.goback.url ) { - app.execCommand('webapps:config', JSON.stringify({'goback': config.customization.goback.url})); - } + Common.NotificationCenter.on('action:undocking', function (opts) { + app.execCommand('editor:event', JSON.stringify({action:'undocking', state: opts == 'dock' ? 'dock' : 'undock'})); + }); + + Common.NotificationCenter.on('app:face', function (mode) { + if ( config.canUndock ) { + Common.NotificationCenter.trigger('app:config', {canUndock: true}); } - - app.on_native_message = function (cmd, param) { - if (/^style:change/.test(cmd)) { - var obj = JSON.parse(param); - - if ( obj.element == 'toolbar' ) { - if ( obj.action == 'off' && obj.style == 'native-color' ) { - $('.toolbar').removeClass('editor-native-color'); - } - } - } - }; - } + }); } }, process: function (opts) { @@ -95,7 +132,7 @@ define([ }, requestClose: function () { if ( config.isDesktopApp && !!app ) { - app.execCommand('editor:request', JSON.stringify({action:'close', url: config.customization.goback.url})); + app.execCommand('editor:event', JSON.stringify({action:'close', url: config.customization.goback.url})); } } }; diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 7c2873269..3827c4a8f 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -97,6 +97,7 @@ define([ ''+ '' + '
' + + '
' + '
' + '
' + '
' + @@ -309,6 +310,24 @@ define([ me.btnOptions.updateHint(me.tipViewSettings); } + function onAppConfig(config) { + var me = this; + if ( config.canUndock ) { + me.btnUndock = new Common.UI.Button({ + cls: 'btn-header no-caret', + iconCls: 'svgicon svg-btn-undock', + hint: me.tipUndock, + split: true + }); + + me.btnUndock.on('click', function (e) { + Common.NotificationCenter.trigger('action:undocking', 'undock'); + }); + + me.btnUndock.render($('#toolbar .box-tabs #slot-btn-undock')); + } + } + function onDocNameKeyDown(e) { var me = this; @@ -343,6 +362,13 @@ define([ } } + function onAppUndocked(c) { + var me = this; + if ( me.btnUndock ) { + c.status == 'undocked' ? me.btnUndock.hide() : me.btnUndock.show(); + } + } + return { options: { branding: {}, @@ -390,11 +416,11 @@ define([ me.mnuZoom = {options: {value: 100}}; - Common.NotificationCenter.on('app:ready', function(mode) { - Common.Utils.asyncCall(onAppReady, me, mode); - }); - Common.NotificationCenter.on('app:face', function(mode) { - Common.Utils.asyncCall(onAppShowed, me, mode); + Common.NotificationCenter.on({ + 'app:ready': function(mode) {Common.Utils.asyncCall(onAppReady, me, mode);}, + 'app:face': function(mode) {Common.Utils.asyncCall(onAppShowed, me, mode);}, + 'app:config' : function (c) {Common.Utils.asyncCall(onAppConfig, me, c);}, + 'undock:status': onAppUndocked.bind(this) }); Common.NotificationCenter.on('collaboration:sharingdeny', onLostEditRights); }, @@ -700,6 +726,7 @@ define([ tipSave: 'Save', tipUndo: 'Undo', tipRedo: 'Redo', + tipUndock: 'Undock', textCompactView: 'Hide Toolbar', textHideStatusBar: 'Hide Status Bar', textHideLines: 'Hide Rulers', diff --git a/apps/common/main/resources/img/header/buttons.svg b/apps/common/main/resources/img/header/buttons.svg index ff98b557d..75fe9b409 100644 --- a/apps/common/main/resources/img/header/buttons.svg +++ b/apps/common/main/resources/img/header/buttons.svg @@ -67,4 +67,10 @@ + + + + + + diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index df2b6d052..4d158c05b 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -167,6 +167,7 @@ "Common.Views.Header.tipViewUsers": "View users and manage document access rights", "Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtRename": "Rename", + "Common.Views.Header.tipUndock": "Undock into separate window", "Common.Views.History.textCloseHistory": "Close History", "Common.Views.History.textHide": "Collapse", "Common.Views.History.textHideAll": "Hide detailed changes", diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 95820d8a2..59ac33b4a 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -100,6 +100,7 @@ "Common.Views.Header.tipViewUsers": "View users and manage document access rights", "Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtRename": "Rename", + "Common.Views.Header.tipUndock": "Undock into separate window", "Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel", "Common.Views.ImageFromUrlDialog.okButtonText": "OK", "Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:", diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index c863a2eb6..832fc77c5 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -92,6 +92,7 @@ "Common.Views.Header.tipUndo": "Undo", "Common.Views.Header.tipViewSettings": "View settings", "Common.Views.Header.tipViewUsers": "View users and manage document access rights", + "Common.Views.Header.tipUndock": "Undock into separate window", "Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtRename": "Rename", "Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel",