diff --git a/apps/common/main/lib/component/Button.js b/apps/common/main/lib/component/Button.js
index 78ee15724..12eb656b7 100644
--- a/apps/common/main/lib/component/Button.js
+++ b/apps/common/main/lib/component/Button.js
@@ -575,6 +575,13 @@ define([
this.trigger('toggle', this, state);
},
+ click: function(opts) {
+ if ( !this.disabled ) {
+ this.doToggle();
+ this.trigger('click', this, opts);
+ }
+ },
+
isActive: function() {
if (this.enableToggle)
return this.pressed;
@@ -643,6 +650,24 @@ define([
btnIconEl.addClass(cls || '');
},
+ changeIcon: function(opts) {
+ var me = this;
+ if ( opts && (opts.curr || opts.next)) {
+ !!opts.curr && (me.$icon.removeClass(opts.curr));
+ !!opts.next && !me.$icon.hasClass(opts.next) && (me.$icon.addClass(opts.next));
+
+ if ( !!me.options.signals ) {
+ if ( !(me.options.signals.indexOf('icon:changed') < 0) ) {
+ me.trigger('icon:changed', me, opts);
+ }
+ }
+ }
+ },
+
+ hasIcon: function(iconcls) {
+ return this.$icon.hasClass(iconcls);
+ },
+
setVisible: function(visible) {
if (this.cmpEl) this.cmpEl.toggleClass('hidden', !visible);
this.visible = visible;
diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js
index ba7bd7336..41fa95d7c 100644
--- a/apps/common/main/lib/controller/Desktop.js
+++ b/apps/common/main/lib/controller/Desktop.js
@@ -42,8 +42,15 @@ define([
'use strict';
var Desktop = function () {
- var config = {};
- var app = window.AscDesktopEditor;
+ var config = {version:'{{PRODUCT_VERSION}}'};
+ var app = window.AscDesktopEditor,
+ webapp = window.DE || window.PE || window.SSE;
+ var titlebuttons;
+ var btnsave_icons = {
+ 'btn-save': 'save',
+ 'btn-save-coauth': 'coauth',
+ 'btn-synch': 'synch' };
+
if ( !!app ) {
window.on_native_message = function (cmd, param) {
@@ -83,15 +90,80 @@ define([
}
} 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()}));
+ if ( param == 'request' ) {
+ 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]));
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+ } else
+ if (/button:click/.test(cmd)) {
+ var obj = JSON.parse(param);
+ if ( !!obj.action ) {
+ titlebuttons[obj.action].btn.click();
+ }
}
};
- app.execCommand('webapps:events', 'loading');
- app.execCommand('window:features', 'request');
+ 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});
}
+ var _serializeHeaderButton = function(action, config) {
+ return {
+ action: action,
+ icon: config.icon || undefined,
+ hint: config.btn.options.hint,
+ disabled: config.disabled
+ };
+ };
+
+ var _onTitleButtonDisabled = function (action, e, status) {
+ titlebuttons[action].disabled = status;
+ var _buttons = {};
+ _buttons[action] = status;
+ app.execCommand('title:button', JSON.stringify({disabled: _buttons}));
+ };
+
+ var _onSaveIconChanged = function (e, opts) {
+ app.execCommand('title:button', JSON.stringify({'icon:changed': {'save': btnsave_icons[opts.next]}}));
+ };
+
+ var _onModalDialog = function (status) {
+ if ( status == 'open' ) {
+ app.execCommand('title:button', JSON.stringify({disabled: {'all':true}}));
+ } else {
+ var _buttons = {};
+ for (var i in titlebuttons) {
+ _buttons[i] = titlebuttons[i].disabled;
+ }
+
+ app.execCommand('title:button', JSON.stringify({'disabled': _buttons}));
+ }
+ };
+
return {
init: function (opts) {
_.extend(config, opts);
@@ -112,6 +184,35 @@ define([
if ( config.canUndock ) {
Common.NotificationCenter.trigger('app:config', {canUndock: true});
}
+
+ var header = webapp.getController('Viewport').getView('Common.Views.Header');
+ titlebuttons = {
+ 'save': {btn: header.btnSave, disabled:false},
+ 'print': {btn: header.btnPrint, disabled:false},
+ 'undo': {btn: header.btnUndo, disabled:false},
+ 'redo': {btn: header.btnRedo, disabled:false}
+ };
+
+ for (var i in titlebuttons) {
+ titlebuttons[i].btn.options.signals = ['disabled'];
+ titlebuttons[i].btn.on('disabled', _onTitleButtonDisabled.bind(this, i));
+ }
+
+ header.btnSave.options.signals.push('icon:changed');
+ header.btnSave.on('icon:changed', _onSaveIconChanged.bind(this));
+
+ 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({
+ 'modal:show': _onModalDialog.bind(this, 'open'),
+ 'modal:close': _onModalDialog.bind(this, 'close')
});
}
},
diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js
index 42fa0071e..a56d5cfcd 100644
--- a/apps/common/main/lib/view/Header.js
+++ b/apps/common/main/lib/view/Header.js
@@ -527,7 +527,7 @@ define([
me.btnRedo = createTitleButton('toolbar__icon icon--inverse btn-redo', $html.findById('#slot-btn-dt-redo'), true);
if ( me.btnSave.$icon.is('svg') ) {
- me.btnSave.$icon.addClass('icon-save');
+ me.btnSave.$icon.addClass('icon-save btn-save');
var _create_use = function (extid, intid) {
var _use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
_use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', extid);
diff --git a/apps/common/main/resources/img/header/buttons.svg b/apps/common/main/resources/img/header/buttons.svg
index 7b8046f07..e4adbca6e 100644
--- a/apps/common/main/resources/img/header/buttons.svg
+++ b/apps/common/main/resources/img/header/buttons.svg
@@ -21,8 +21,8 @@
-
-
+
+
@@ -30,9 +30,9 @@
c0.391,0.391,0.391,1.023,0,1.414L15.273,8.598z"/>
-
-
-
+
+
+
diff --git a/apps/documenteditor/main/index.html.deploy b/apps/documenteditor/main/index.html.deploy
index fd10155b5..8748c4255 100644
--- a/apps/documenteditor/main/index.html.deploy
+++ b/apps/documenteditor/main/index.html.deploy
@@ -199,6 +199,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 969493a9f..f542da26a 100644
--- a/apps/presentationeditor/main/index.html.deploy
+++ b/apps/presentationeditor/main/index.html.deploy
@@ -236,6 +236,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 93957563b..9a2b64c74 100644
--- a/apps/spreadsheeteditor/main/index.html.deploy
+++ b/apps/spreadsheeteditor/main/index.html.deploy
@@ -204,6 +204,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/build/Gruntfile.js b/build/Gruntfile.js
index 931c30e25..f94736a74 100644
--- a/build/Gruntfile.js
+++ b/build/Gruntfile.js
@@ -264,7 +264,7 @@ module.exports = function(grunt) {
src: ['<%= pkg.main.js.requirejs.options.out %>'],
overwrite: true,
replacements: [{
- from: /\{\{PRODUCT_VERSION\}\}/,
+ from: /\{\{PRODUCT_VERSION\}\}/g,
to: packageFile.version
}]
},