diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js
index f4072183b..6cd666fca 100644
--- a/apps/documenteditor/mobile/app/controller/Main.js
+++ b/apps/documenteditor/mobile/app/controller/Main.js
@@ -638,9 +638,9 @@ define([
$(document).on('contextmenu', _.bind(me.onContextMenu, me));
if (!me.appOptions.canReview) {
- var canViewReview = me.appOptions.isEdit || me.api.asc_HaveRevisionsChanges(true);
- DE.getController('Common.Controllers.Collaboration').setCanViewReview(canViewReview);
- if (canViewReview) {
+ me.appOptions.canViewReview = me.appOptions.isEdit || me.api.asc_HaveRevisionsChanges(true);
+ DE.getController('Common.Controllers.Collaboration').setCanViewReview(me.appOptions.canViewReview);
+ if (me.appOptions.canViewReview) {
var viewReviewMode = Common.localStorage.getItem("de-view-review-mode");
if (viewReviewMode===null)
viewReviewMode = me.appOptions.customization && /^(original|final|markup)$/i.test(me.appOptions.customization.reviewDisplay) ? me.appOptions.customization.reviewDisplay.toLocaleLowerCase() : 'original';
@@ -648,6 +648,7 @@ define([
DE.getController('Common.Controllers.Collaboration').turnDisplayMode(viewReviewMode);
}
}
+ DE.getController('Toolbar').displayCollaboration();
Common.Gateway.documentReady();
diff --git a/apps/documenteditor/mobile/app/controller/Toolbar.js b/apps/documenteditor/mobile/app/controller/Toolbar.js
index 9821de2ce..da1b50097 100644
--- a/apps/documenteditor/mobile/app/controller/Toolbar.js
+++ b/apps/documenteditor/mobile/app/controller/Toolbar.js
@@ -52,6 +52,7 @@ define([
DE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
// private
var stateDisplayMode = false;
+ var _users = [];
return {
models: [],
@@ -78,12 +79,14 @@ define([
this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo'));
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this));
- this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.displayCollaboration, this));
- this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.displayCollaboration, this));
+ this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this));
+ this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onUsersChanged, this));
+ this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
},
setMode: function (mode) {
+ this.mode = mode;
this.getView('Toolbar').setMode(mode);
},
@@ -191,19 +194,38 @@ define([
DE.getController('Settings').hideModal();
},
- displayCollaboration: function(users) {
- if(users !== undefined) {
+ displayCollaboration: function() {
+ if(_users !== undefined) {
var length = 0;
- _.each(users, function (item) {
- if (!item.asc_getView())
+ _.each(_users, function (item) {
+ if ((item.asc_getState()!==false) && !item.asc_getView())
length++;
});
- if (length > 0) {
- $('#toolbar-collaboration').show();
- } else {
+ if (length < 1 && this.mode && !this.mode.canViewComments && !this.mode.canReview && !this.mode.canViewReview)
$('#toolbar-collaboration').hide();
+ else
+ $('#toolbar-collaboration').show();
+ }
+ },
+
+ onUsersChanged: function(users) {
+ _users = users;
+ this.displayCollaboration();
+ },
+
+ onUserConnection: function(change){
+ var changed = false;
+ for (var uid in _users) {
+ if (undefined !== uid) {
+ var user = _users[uid];
+ if (user && user.asc_getId() == change.asc_getId()) {
+ _users[uid] = change;
+ changed = true;
+ }
}
}
+ !changed && change && (_users[change.asc_getId()] = change);
+ this.displayCollaboration();
},
dlgLeaveTitleText : 'You leave the application',
diff --git a/apps/presentationeditor/mobile/app/controller/Toolbar.js b/apps/presentationeditor/mobile/app/controller/Toolbar.js
index cb9b42416..2d1c9f527 100644
--- a/apps/presentationeditor/mobile/app/controller/Toolbar.js
+++ b/apps/presentationeditor/mobile/app/controller/Toolbar.js
@@ -51,6 +51,7 @@ define([
PE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
// private
+ var _users = [];
return {
models: [],
@@ -77,13 +78,15 @@ define([
this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo'));
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this));
- this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.displayCollaboration, this));
- this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.displayCollaboration, this));
+ this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this));
+ this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onUsersChanged, this));
+ this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this));
},
setMode: function (mode) {
+ this.mode = mode;
this.getView('Toolbar').setMode(mode);
},
@@ -200,19 +203,38 @@ define([
PE.getController('Settings').hideModal();
},
- displayCollaboration: function(users) {
- if(users !== undefined) {
+ displayCollaboration: function() {
+ if(_users !== undefined) {
var length = 0;
- _.each(users, function (item) {
- if (!item.asc_getView())
+ _.each(_users, function (item) {
+ if ((item.asc_getState()!==false) && !item.asc_getView())
length++;
});
- if (length > 0) {
- $('#toolbar-collaboration').show();
- } else {
+ if (length < 1 && this.mode && !this.mode.canViewComments)
$('#toolbar-collaboration').hide();
+ else
+ $('#toolbar-collaboration').show();
+ }
+ },
+
+ onUsersChanged: function(users) {
+ _users = users;
+ this.displayCollaboration();
+ },
+
+ onUserConnection: function(change){
+ var changed = false;
+ for (var uid in _users) {
+ if (undefined !== uid) {
+ var user = _users[uid];
+ if (user && user.asc_getId() == change.asc_getId()) {
+ _users[uid] = change;
+ changed = true;
+ }
}
}
+ !changed && change && (_users[change.asc_getId()] = change);
+ this.displayCollaboration();
},
dlgLeaveTitleText : 'You leave the application',
diff --git a/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js b/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js
index 46328b544..74a778ffb 100644
--- a/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js
+++ b/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js
@@ -55,6 +55,7 @@ define([
book: false,
sheet: false
};
+ var _users = [];
return {
models: [],
@@ -84,14 +85,16 @@ define([
this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onApiWorksheetLocked, this));
this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onApiActiveSheetChanged, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this));
- this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.displayCollaboration, this));
- this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.displayCollaboration, this));
+ this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this));
+ this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onUsersChanged, this));
+ this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('sheet:active', this.onApiActiveSheetChanged.bind(this));
},
setMode: function (mode) {
+ this.mode = mode;
this.getView('Toolbar').setMode(mode);
},
@@ -219,19 +222,38 @@ define([
SSE.getController('Settings').hideModal();
},
- displayCollaboration: function(users) {
- if(users !== undefined) {
+ displayCollaboration: function() {
+ if(_users !== undefined) {
var length = 0;
- _.each(users, function (item) {
- if (!item.asc_getView())
+ _.each(_users, function (item) {
+ if ((item.asc_getState()!==false) && !item.asc_getView())
length++;
});
- if (length > 0) {
- $('#toolbar-collaboration').show();
- } else {
+ if (length < 1 && this.mode && !this.mode.canViewComments)
$('#toolbar-collaboration').hide();
+ else
+ $('#toolbar-collaboration').show();
+ }
+ },
+
+ onUsersChanged: function(users) {
+ _users = users;
+ this.displayCollaboration();
+ },
+
+ onUserConnection: function(change){
+ var changed = false;
+ for (var uid in _users) {
+ if (undefined !== uid) {
+ var user = _users[uid];
+ if (user && user.asc_getId() == change.asc_getId()) {
+ _users[uid] = change;
+ changed = true;
+ }
}
}
+ !changed && change && (_users[change.asc_getId()] = change);
+ this.displayCollaboration();
},
dlgLeaveTitleText : 'You leave the application',