[SE PE] absract 'save' button

This commit is contained in:
Maxim Kadushkin 2018-02-28 16:17:53 +03:00
parent 09b9947051
commit 6cf3ee7fb9
4 changed files with 36 additions and 34 deletions

View file

@ -902,7 +902,7 @@ define([
var toolbar = this.toolbar;
if (this.api && this.api.asc_isDocumentCanSave) {
var isModified = this.api.asc_isDocumentCanSave();
var isSyncButton = this.toolbar.btnSave.$icon.hasClass('btn-synch');
var isSyncButton = this.toolbar.btnCollabChanges.$icon.hasClass('btn-synch');
if (!isModified && !isSyncButton && !this.toolbar.mode.forcesave)
return;

View file

@ -173,6 +173,7 @@ define([
lock : [_set.lostConnect],
signals : ['disabled']
});
me.btnCollabChanges = me.btnSave;
me.btnUndo = new Common.UI.Button({
id : 'id-toolbar-btn-undo',
@ -1467,7 +1468,7 @@ define([
/** coauthoring begin **/
onCollaborativeChanges: function () {
if (this._state.hasCollaborativeChanges) return;
if (!this.btnSave.rendered) {
if (!this.btnCollabChanges.rendered) {
this.needShowSynchTip = true;
return;
}
@ -1479,15 +1480,15 @@ define([
}
this._state.hasCollaborativeChanges = true;
this.btnSave.$icon.removeClass(this.btnSaveCls).addClass('btn-synch');
this.btnCollabChanges.$icon.removeClass(this.btnSaveCls).addClass('btn-synch');
if (this.showSynchTip) {
this.btnSave.updateHint('');
this.btnCollabChanges.updateHint('');
if (this.synchTooltip === undefined)
this.createSynchTip();
this.synchTooltip.show();
} else {
this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
}
this.btnSave.setDisabled(false);
@ -1496,29 +1497,29 @@ define([
createSynchTip: function () {
this.synchTooltip = new Common.UI.SynchronizeTip({
target: $('#id-toolbar-btn-save')
target: this.btnCollabChanges.$el
});
this.synchTooltip.on('dontshowclick', function () {
this.showSynchTip = false;
this.synchTooltip.hide();
this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
Common.localStorage.setItem("pe-hide-synch", 1);
}, this);
this.synchTooltip.on('closeclick', function () {
this.synchTooltip.hide();
this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
}, this);
},
synchronizeChanges: function () {
if (this.btnSave.rendered) {
if (this.btnCollabChanges.rendered) {
var me = this;
if ( me.btnSave.$icon.hasClass('btn-synch') ) {
me.btnSave.$icon.removeClass('btn-synch').addClass(this.btnSaveCls);
if ( me.btnCollabChanges.$icon.hasClass('btn-synch') ) {
me.btnCollabChanges.$icon.removeClass('btn-synch').addClass(this.btnSaveCls);
if (this.synchTooltip)
this.synchTooltip.hide();
this.btnSave.updateHint(this.btnSaveTip);
this.btnCollabChanges.updateHint(this.btnSaveTip);
this.btnSave.setDisabled(!me.mode.forcesave);
this._state.hasCollaborativeChanges = false;
@ -1535,12 +1536,12 @@ define([
var length = _.size(editusers);
var cls = (length > 1) ? 'btn-save-coauth' : 'btn-save';
if (cls !== this.btnSaveCls && this.btnSave.rendered) {
if (cls !== this.btnSaveCls && this.btnCollabChanges.rendered) {
this.btnSaveTip = ((length > 1) ? this.tipSaveCoauth : this.tipSave ) + Common.Utils.String.platformKey('Ctrl+S');
if ( !this.btnSave.$icon.hasClass('btn-synch') ) {
this.btnSave.$icon.removeClass(this.btnSaveCls).addClass(cls);
this.btnSave.updateHint(this.btnSaveTip);
if ( !this.btnCollabChanges.$icon.hasClass('btn-synch') ) {
this.btnCollabChanges.$icon.removeClass(this.btnSaveCls).addClass(cls);
this.btnCollabChanges.updateHint(this.btnSaveTip);
}
this.btnSaveCls = cls;
}

View file

@ -386,7 +386,7 @@ define([
onSave: function(e) {
if (this.api) {
var isModified = this.api.asc_isDocumentCanSave();
var isSyncButton = this.toolbar.btnSave.$icon.hasClass('btn-synch');
var isSyncButton = this.toolbar.btnCollabChanges.$icon.hasClass('btn-synch');
if (!isModified && !isSyncButton && !this.toolbar.mode.forcesave)
return;

View file

@ -375,6 +375,7 @@ define([
iconCls : 'no-mask ' + me.btnSaveCls,
signals : ['disabled']
});
me.btnCollabChanges = me.btnSave;
me.btnIncFontSize = new Common.UI.Button({
id : 'id-toolbar-btn-incfont',
@ -1221,7 +1222,7 @@ define([
var hidetip = Common.localStorage.getItem("sse-hide-synch");
me.showSynchTip = !(hidetip && parseInt(hidetip) == 1);
me.needShowSynchTip = false;
// me.needShowSynchTip = false;
}
me.lockControls = [
@ -1822,22 +1823,22 @@ define([
onApiCollaborativeChanges: function() {
if (this._state.hasCollaborativeChanges) return;
if (!this.btnSave.rendered) {
this.needShowSynchTip = true;
if (!this.btnCollabChanges.rendered) {
// this.needShowSynchTip = true;
return;
}
this._state.hasCollaborativeChanges = true;
this.btnSave.$icon.removeClass(this.btnSaveCls).addClass('btn-synch');
this.btnCollabChanges.$icon.removeClass(this.btnSaveCls).addClass('btn-synch');
if (this.showSynchTip){
this.btnSave.updateHint('');
this.btnCollabChanges.updateHint('');
if (this.synchTooltip===undefined)
this.createSynchTip();
this.synchTooltip.show();
} else {
this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
}
this.btnSave.setDisabled(false);
@ -1846,29 +1847,29 @@ define([
createSynchTip: function () {
this.synchTooltip = new Common.UI.SynchronizeTip({
target : $('#id-toolbar-btn-save')
target: this.btnCollabChanges.$el
});
this.synchTooltip.on('dontshowclick', function() {
this.showSynchTip = false;
this.synchTooltip.hide();
this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
Common.localStorage.setItem('sse-hide-synch', 1);
}, this);
this.synchTooltip.on('closeclick', function() {
this.synchTooltip.hide();
this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
this.btnCollabChanges.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S'));
}, this);
},
synchronizeChanges: function() {
if (this.btnSave.rendered) {
if (this.btnCollabChanges.rendered) {
var me = this;
if ( me.btnSave.$icon.hasClass('btn-synch') ) {
me.btnSave.$icon.removeClass('btn-synch').addClass(this.btnSaveCls);
if ( me.btnCollabChanges.$icon.hasClass('btn-synch') ) {
me.btnCollabChanges.$icon.removeClass('btn-synch').addClass(this.btnSaveCls);
if (this.synchTooltip)
this.synchTooltip.hide();
this.btnSave.updateHint(this.btnSaveTip);
this.btnCollabChanges.updateHint(this.btnSaveTip);
this.btnSave.setDisabled(!me.mode.forcesave);
this._state.hasCollaborativeChanges = false;
@ -1885,12 +1886,12 @@ define([
var length = _.size(editusers);
var cls = (length>1) ? 'btn-save-coauth' : 'btn-save';
if (cls !== this.btnSaveCls && this.btnSave.rendered) {
if (cls !== this.btnSaveCls && this.btnCollabChanges.rendered) {
this.btnSaveTip = ((length>1) ? this.tipSaveCoauth : this.tipSave )+ Common.Utils.String.platformKey('Ctrl+S');
if ( !this.btnSave.$icon.hasClass('btn-synch') ) {
this.btnSave.$icon.removeClass(this.btnSaveCls).addClass(cls);
this.btnSave.updateHint(this.btnSaveTip);
if ( !this.btnCollabChanges.$icon.hasClass('btn-synch') ) {
this.btnCollabChanges.$icon.removeClass(this.btnSaveCls).addClass(cls);
this.btnCollabChanges.updateHint(this.btnSaveTip);
}
this.btnSaveCls = cls;
}