diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 898b5671d8..438aa42348 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -851,7 +851,7 @@ define([ comment.set('initials', Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()))); comment.set('parsedName', AscCommon.UserInfoParser.getParsedName(data.asc_getUserName())); comment.set('parsedGroups', AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName())); - comment.set('usercolor', (user) ? user.get('color') : null); + comment.set('usercolor', (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(userid || data.asc_getUserName())); comment.set('avatar', avatar); comment.set('resolved', data.asc_getSolved()); comment.set('quote', data.asc_getQuoteText()); @@ -890,7 +890,7 @@ define([ username : data.asc_getReply(i).asc_getUserName(), initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName())), parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName()), - usercolor : (user) ? user.get('color') : null, + usercolor : (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(userid || data.asc_getReply(i).asc_getUserName()), avatar : avatar, date : t.dateToLocaleTimeString(dateReply), reply : data.asc_getReply(i).asc_getText(), @@ -1300,7 +1300,7 @@ define([ var users = this.userCollection, hasGroup = false, updateCommentData = function(comment, user, isNotReply) { - var color = (user) ? user.get('color') : null, + var color = (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(comment.get('userid')), needrender = false; if (color !== comment.get('usercolor')) { needrender = true; @@ -1395,7 +1395,7 @@ define([ initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getUserName())), parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()), parsedGroups : AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName()), - usercolor : (user) ? user.get('color') : null, + usercolor : (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(userid || data.asc_getUserName()), avatar : avatar, date : this.dateToLocaleTimeString(date), quote : data.asc_getQuoteText(), @@ -1456,7 +1456,7 @@ define([ username : data.asc_getReply(i).asc_getUserName(), initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName())), parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName()), - usercolor : (user) ? user.get('color') : null, + usercolor : (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(userid || data.asc_getReply(i).asc_getUserName()), avatar : avatar, date : this.dateToLocaleTimeString(date), reply : data.asc_getReply(i).asc_getText(), @@ -1501,7 +1501,7 @@ define([ avatar: Common.UI.ExternalUsers.getImage(this.currentUserId), initials: Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName())), parsedName: AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName()), - usercolor: (user) ? user.get('color') : null, + usercolor: (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(this.currentUserId), editTextInPopover: true, showReplyInPopover: false, hideAddReply: true, diff --git a/apps/common/main/lib/controller/ExternalUsers.js b/apps/common/main/lib/controller/ExternalUsers.js index 317e77a99f..84d05058a1 100644 --- a/apps/common/main/lib/controller/ExternalUsers.js +++ b/apps/common/main/lib/controller/ExternalUsers.js @@ -49,7 +49,9 @@ Common.UI.ExternalUsers = new( function() { isUsersLoading = false, externalUsersInfo = [], isUsersInfoLoading = false, - stackUsersInfoResponse = []; + stackUsersInfoResponse = [], + api, + userColors = []; var _get = function(type, ids) { if (type==='info') { @@ -114,9 +116,9 @@ Common.UI.ExternalUsers = new( function() { _onUsersInfo(stackUsersInfoResponse.shift()); }; - var _init = function(canRequestUsers) { + var _init = function(canRequestUsers, _api) { Common.Gateway.on('setusers', _onUsersInfo); - + api = _api; if (!canRequestUsers) return; Common.Gateway.on('setusers', function(data) { @@ -137,10 +139,20 @@ Common.UI.ExternalUsers = new( function() { }); }; + var _getColor = function(id, intValue) { + if (!userColors[id]) { + var color = api.asc_getUserColorById(id); + userColors[id] = ["#"+("000000"+color.toString(16)).substr(-6), color]; + } + + return intValue ? userColors[id][1] : userColors[id][0]; + }; + return { init: _init, get: _get, getImage: _getImage, - setImage: _setImage + setImage: _setImage, + getColor: _getColor } })(); diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 4da7eb56e6..10c2442b5a 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -522,7 +522,7 @@ define([ uid : Common.UI.getId(), userid : item.get_UserId(), username : item.get_UserName(), - usercolor : (user) ? user.get('color') : null, + usercolor : (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(item.get_UserId() || item.get_UserName()), initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(item.get_UserName())), avatar : avatar, date : me.dateToLocaleTimeString(date), @@ -1091,7 +1091,7 @@ define([ var users = this.userCollection; this.popoverChanges && this.popoverChanges.each(function (model) { var user = users.findOriginalUser(model.get('userid')); - model.set('usercolor', (user) ? user.get('color') : null); + model.set('usercolor', (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(model.get('userid'))); user && user.get('avatar') && model.set('avatar', user.get('avatar')); }); }, diff --git a/apps/common/main/lib/view/Chat.js b/apps/common/main/lib/view/Chat.js index e2896967e5..96bffc8f68 100644 --- a/apps/common/main/lib/view/Chat.js +++ b/apps/common/main/lib/view/Chat.js @@ -229,7 +229,7 @@ define([ var user = this.storeUsers.findOriginalUser(m.get('userid')), avatar = Common.UI.ExternalUsers.getImage(m.get('userid')); m.set({ - usercolor : user ? user.get('color') : null, + usercolor : user ? user.get('color') : Common.UI.ExternalUsers.getColor(m.get('userid')), avatar : avatar, initials : user ? user.get('initials') : Common.Utils.getUserInitials(m.get('parsedName')), message : this._pickLink(m.get('message')) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 445639e526..6763f5bcb4 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -718,11 +718,12 @@ define([ docIdPrev = (ver>0 && versions[ver-1]) ? versions[ver-1].key : version.key + '0'; user = usersStore.findUser(version.user.id); if (!user) { + var color = Common.UI.ExternalUsers.getColor(version.user.id || version.user.name || this.textAnonymous, true); user = new Common.Models.User({ id : version.user.id, username : version.user.name || this.textAnonymous, - colorval : Asc.c_oAscArrUserColors[usersCnt], - color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) + colorval : color, + color : this.generateUserColor(color) }); usersStore.add(user); } @@ -770,11 +771,12 @@ define([ user = usersStore.findUser(change.user.id); if (!user) { + var color = Common.UI.ExternalUsers.getColor(change.user.id || change.user.name || this.textAnonymous, true); user = new Common.Models.User({ id : change.user.id, username : change.user.name || this.textAnonymous, - colorval : Asc.c_oAscArrUserColors[usersCnt], - color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) + colorval : color, + color : this.generateUserColor(color) }); usersStore.add(user); } @@ -1662,7 +1664,7 @@ define([ this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api); this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt); this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt); - Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers); + Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers, this.api); this.appOptions.user.image ? Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image) : Common.UI.ExternalUsers.get('info', this.appOptions.user.id); if (this.appOptions.canComments) @@ -1714,10 +1716,8 @@ define([ } } fastCoauth = (value===null || parseInt(value) == 1); - - value = Common.localStorage.getItem((fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict"); - if (value == null) value = fastCoauth ? 'none' : 'last'; - Common.Utils.InternalSettings.set((fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", value); + Common.Utils.InternalSettings.set("de-settings-showchanges-fast", Common.localStorage.getItem("de-settings-showchanges-fast") || 'none'); + Common.Utils.InternalSettings.set("de-settings-showchanges-strict", Common.localStorage.getItem("de-settings-showchanges-strict") || 'last'); } else if (!this.appOptions.isEdit && this.appOptions.isRestrictedEdit) { fastCoauth = true; } else if (this.appOptions.canLiveView && !this.appOptions.isOffline) { // viewer diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 4348889f26..6d3d63f974 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -611,9 +611,11 @@ define([ dataHintDirection: 'left', dataHintOffset: 'small' }); - this.rbCoAuthModeFast.on('change', function(){ - me.chAutosave.setValue(1); - me.onChangeCoAuthMode(1); + this.rbCoAuthModeFast.on('change', function(field, newValue, eOpts){ + if (newValue) { + me.chAutosave.setValue(1); + me.onChangeCoAuthMode(1); + } }); this.rbCoAuthModeFast.$el.parent().on('click', function (){me.rbCoAuthModeFast.setValue(true);}); @@ -624,7 +626,9 @@ define([ dataHintDirection: 'left', dataHintOffset: 'small' }); - this.rbCoAuthModeStrict.on('change', _.bind(this.onChangeCoAuthMode, this,0)); + this.rbCoAuthModeStrict.on('change', function(field, newValue, eOpts){ + newValue && me.onChangeCoAuthMode(0); + }); this.rbCoAuthModeStrict.$el.parent().on('click', function (){me.rbCoAuthModeStrict.setValue(true);}); this.rbChangesBallons = new Common.UI.RadioBox({ diff --git a/apps/pdfeditor/main/app/controller/Main.js b/apps/pdfeditor/main/app/controller/Main.js index b6e1b39695..d309368296 100644 --- a/apps/pdfeditor/main/app/controller/Main.js +++ b/apps/pdfeditor/main/app/controller/Main.js @@ -1272,7 +1272,7 @@ define([ this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api); this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt); this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt); - Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers); + Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers, this.api); this.appOptions.user.image ? Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image) : Common.UI.ExternalUsers.get('info', this.appOptions.user.id); if (this.appOptions.canComments) @@ -1320,10 +1320,8 @@ define([ } } fastCoauth = (value===null || parseInt(value) == 1); - - value = Common.localStorage.getItem((fastCoauth) ? "pdfe-settings-showchanges-fast" : "pdfe-settings-showchanges-strict"); - if (value == null) value = fastCoauth ? 'none' : 'last'; - Common.Utils.InternalSettings.set((fastCoauth) ? "pdfe-settings-showchanges-fast" : "pdfe-settings-showchanges-strict", value); + Common.Utils.InternalSettings.set("pdfe-settings-showchanges-fast", Common.localStorage.getItem("pdfe-settings-showchanges-fast") || 'none'); + Common.Utils.InternalSettings.set("pdfe-settings-showchanges-strict", Common.localStorage.getItem("pdfe-settings-showchanges-strict") || 'last'); } else { fastCoauth = false; autosave = 0; diff --git a/apps/pdfeditor/main/app/view/FileMenuPanels.js b/apps/pdfeditor/main/app/view/FileMenuPanels.js index 0ebf70e3fd..bbb229c969 100644 --- a/apps/pdfeditor/main/app/view/FileMenuPanels.js +++ b/apps/pdfeditor/main/app/view/FileMenuPanels.js @@ -494,9 +494,11 @@ define([ dataHintDirection: 'left', dataHintOffset: 'small' }); - this.rbCoAuthModeFast.on('change', function(){ - me.chAutosave.setValue(1); - me.onChangeCoAuthMode(1); + this.rbCoAuthModeFast.on('change', function(field, newValue, eOpts){ + if (newValue) { + me.chAutosave.setValue(1); + me.onChangeCoAuthMode(1); + } }); this.rbCoAuthModeFast.$el.parent().on('click', function (){me.rbCoAuthModeFast.setValue(true);}); @@ -507,7 +509,9 @@ define([ dataHintDirection: 'left', dataHintOffset: 'small' }); - this.rbCoAuthModeStrict.on('change', _.bind(this.onChangeCoAuthMode, this,0)); + this.rbCoAuthModeStrict.on('change', function(field, newValue, eOpts){ + newValue && me.onChangeCoAuthMode(0); + }); this.rbCoAuthModeStrict.$el.parent().on('click', function (){me.rbCoAuthModeStrict.setValue(true);}); this.rbShowChangesNone = new Common.UI.RadioBox({ diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 1edf480844..6f7f72e6b0 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1300,7 +1300,7 @@ define([ this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt); this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt); - Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers); + Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers, this.api); this.appOptions.user.image ? Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image) : Common.UI.ExternalUsers.get('info', this.appOptions.user.id); // change = true by default in editor @@ -2649,11 +2649,12 @@ define([ docIdPrev = (ver>0 && versions[ver-1]) ? versions[ver-1].key : version.key + '0'; user = usersStore.findUser(version.user.id); if (!user) { + var color = Common.UI.ExternalUsers.getColor(version.user.id || version.user.name || this.textAnonymous, true); user = new Common.Models.User({ id : version.user.id, username : version.user.name, - colorval : Asc.c_oAscArrUserColors[usersCnt], - color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) + colorval : color, + color : this.generateUserColor(color) }); usersStore.add(user); } @@ -2701,11 +2702,12 @@ define([ user = usersStore.findUser(change.user.id); if (!user) { + var color = Common.UI.ExternalUsers.getColor(change.user.id || change.user.name || this.textAnonymous, true); user = new Common.Models.User({ id : change.user.id, username : change.user.name, - colorval : Asc.c_oAscArrUserColors[usersCnt], - color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) + colorval : color, + color : this.generateUserColor(color) }); usersStore.add(user); } diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index dce2cf57ff..f533ebdcdd 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -466,8 +466,8 @@ define([ dataHint : '2', dataHintDirection: 'left', dataHintOffset: 'small' - }).on('change', function () { - me.chAutosave.setValue(1); + }).on('change', function (field, newValue, eOpts) { + newValue && me.chAutosave.setValue(1); }); this.rbCoAuthModeFast.$el.parent().on('click', function (){me.rbCoAuthModeFast.setValue(true);}); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 0cd027529c..4f6496d7e4 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1417,7 +1417,7 @@ define([ this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt); this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt); - Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers); + Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers, this.api); this.appOptions.user.image ? Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image) : Common.UI.ExternalUsers.get('info', this.appOptions.user.id); } @@ -3297,11 +3297,12 @@ define([ docIdPrev = (ver>0 && versions[ver-1]) ? versions[ver-1].key : version.key + '0'; user = usersStore.findUser(version.user.id); if (!user) { + var color = Common.UI.ExternalUsers.getColor(version.user.id || version.user.name || this.textAnonymous, true); user = new Common.Models.User({ id : version.user.id, username : version.user.name, - colorval : Asc.c_oAscArrUserColors[usersCnt], - color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) + colorval : color, + color : this.generateUserColor(color) }); usersStore.add(user); } @@ -3349,11 +3350,12 @@ define([ user = usersStore.findUser(change.user.id); if (!user) { + var color = Common.UI.ExternalUsers.getColor(change.user.id || change.user.name || this.textAnonymous, true); user = new Common.Models.User({ id : change.user.id, username : change.user.name, - colorval : Asc.c_oAscArrUserColors[usersCnt], - color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) + colorval : color, + color : this.generateUserColor(color) }); usersStore.add(user); } diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 576572c4e2..09368b1e24 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -466,8 +466,8 @@ define([ dataHint : '2', dataHintDirection: 'left', dataHintOffset: 'small' - }).on('change', function () { - me.chAutosave.setValue(1); + }).on('change', function (field, newValue, eOpts) { + newValue && me.chAutosave.setValue(1); }); this.rbCoAuthModeFast.$el.parent().on('click', function (){me.rbCoAuthModeFast.setValue(true);});