2016-04-01 13:17:09 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 13:05:03 +00:00
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
2016-04-01 13:17:09 +00:00
|
|
|
*
|
|
|
|
* This program is a free software product. You can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
|
|
* of any third-party rights.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
*
|
2019-01-17 13:00:34 +00:00
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
2016-04-01 13:17:09 +00:00
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions
|
|
|
|
* of the Program must display Appropriate Legal Notices, as required under
|
|
|
|
* Section 5 of the GNU AGPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7(b) of the License you must retain the original Product
|
|
|
|
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
|
|
|
* grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
* All the Product's GUI elements, including illustrations and icon sets, as
|
|
|
|
* well as technical writing content are licensed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
|
|
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
*
|
|
|
|
*/
|
2016-03-11 00:48:53 +00:00
|
|
|
/**
|
|
|
|
* Statusbar.js
|
|
|
|
*
|
|
|
|
* Statusbar controller
|
|
|
|
*
|
|
|
|
* Created by Alexander Yuzhin on 1/15/14
|
2018-03-01 12:16:38 +00:00
|
|
|
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
|
2016-03-11 00:48:53 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'core',
|
|
|
|
'documenteditor/main/app/view/Statusbar',
|
2017-04-05 09:11:15 +00:00
|
|
|
'common/main/lib/util/LanguageInfo'
|
2016-03-11 00:48:53 +00:00
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
DE.Controllers.Statusbar = Backbone.Controller.extend(_.extend({
|
|
|
|
models: [],
|
|
|
|
collections: [],
|
|
|
|
views: [
|
|
|
|
'Statusbar'
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize: function() {
|
2018-03-21 11:28:28 +00:00
|
|
|
var me = this;
|
2016-03-11 00:48:53 +00:00
|
|
|
this.addListeners({
|
|
|
|
'Statusbar': {
|
2017-03-29 11:19:57 +00:00
|
|
|
'langchanged': this.onLangMenu,
|
|
|
|
'zoom:value': function(value) {
|
|
|
|
this.api.zoom(value);
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.statusbar);
|
|
|
|
}.bind(this)
|
2018-03-21 11:28:28 +00:00
|
|
|
},
|
|
|
|
'Common.Views.Header': {
|
|
|
|
'statusbar:hide': function (view, status) {
|
|
|
|
me.statusbar.setVisible(!status);
|
|
|
|
Common.localStorage.setBool('de-hidden-status', status);
|
|
|
|
|
|
|
|
Common.NotificationCenter.trigger('layout:changed', 'status');
|
2021-02-27 09:43:32 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.statusbar);
|
2018-03-21 11:28:28 +00:00
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
events: function() {
|
|
|
|
return {
|
|
|
|
'click #btn-zoom-down': _.bind(this.zoomDocument,this,'down'),
|
|
|
|
'click #btn-zoom-up': _.bind(this.zoomDocument,this,'up'),
|
2017-03-29 09:47:57 +00:00
|
|
|
'click #btn-zoom-topage': _.bind(this.onBtnZoomTo, this, 'topage'),
|
2017-04-04 15:22:02 +00:00
|
|
|
'click #btn-zoom-towidth': _.bind(this.onBtnZoomTo, this, 'towidth')
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onLaunch: function() {
|
|
|
|
this.statusbar = this.createView('Statusbar', {
|
2017-03-29 11:19:57 +00:00
|
|
|
// storeUsers: this.getApplication().getCollection('Common.Collections.Users')
|
|
|
|
});
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
Common.NotificationCenter.on('app:face', function (cfg) {
|
2017-04-10 13:39:03 +00:00
|
|
|
me.statusbar.render(cfg);
|
2017-03-29 11:19:57 +00:00
|
|
|
me.statusbar.$el.css('z-index', 1);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2017-11-10 09:00:47 +00:00
|
|
|
$('.statusbar #label-zoom').css('min-width', 80);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2017-04-05 09:11:15 +00:00
|
|
|
if ( cfg.isEdit ) {
|
2019-07-15 13:22:34 +00:00
|
|
|
var review = me.getApplication().getController('Common.Controllers.ReviewChanges').getView();
|
2017-04-10 13:39:03 +00:00
|
|
|
if (cfg.canReview) {
|
|
|
|
me.btnTurnReview = review.getButton('turn', 'statusbar');
|
|
|
|
me.btnTurnReview.render(me.statusbar.$layout.find('#btn-doc-review'));
|
|
|
|
} else {
|
|
|
|
me.statusbar.$el.find('.el-review').hide();
|
|
|
|
}
|
|
|
|
|
2017-04-05 09:11:15 +00:00
|
|
|
me.btnSpelling = review.getButton('spelling', 'statusbar');
|
|
|
|
me.btnSpelling.render( me.statusbar.$layout.find('#btn-doc-spell') );
|
2017-10-09 12:03:50 +00:00
|
|
|
me.btnDocLang = review.getButton('doclang', 'statusbar');
|
|
|
|
me.btnDocLang.render( me.statusbar.$layout.find('#btn-doc-lang') );
|
2017-04-05 09:11:15 +00:00
|
|
|
} else {
|
2017-04-10 13:39:03 +00:00
|
|
|
me.statusbar.$el.find('.el-edit, .el-review').hide();
|
2017-03-29 11:19:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-04-25 08:54:45 +00:00
|
|
|
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me));
|
2017-03-29 11:19:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onAppReady: function (config) {
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
(new Promise(function(resolve) {
|
|
|
|
resolve();
|
|
|
|
})).then(function () {
|
|
|
|
me.bindViewEvents(me.statusbar, me.events);
|
|
|
|
|
|
|
|
var statusbarIsHidden = Common.localStorage.getBool("de-hidden-status");
|
|
|
|
if ( config.canReview && !statusbarIsHidden ) {
|
2017-04-04 15:14:47 +00:00
|
|
|
var _process_changestip = function() {
|
|
|
|
var showTrackChangesTip = !Common.localStorage.getBool("de-track-changes-tip");
|
|
|
|
if ( showTrackChangesTip ) {
|
|
|
|
me.btnTurnReview.updateHint('');
|
|
|
|
if (me.changesTooltip === undefined)
|
2021-02-10 10:09:21 +00:00
|
|
|
me.changesTooltip = me.createChangesTip(me.textTrackChanges, 'de-track-changes-tip');
|
2017-04-04 15:14:47 +00:00
|
|
|
|
2021-02-27 09:43:32 +00:00
|
|
|
me.hideTips();
|
2017-04-04 15:14:47 +00:00
|
|
|
me.changesTooltip.show();
|
|
|
|
} else {
|
|
|
|
me.btnTurnReview.updateHint(me.tipReview);
|
|
|
|
}
|
|
|
|
}
|
2017-03-29 11:19:57 +00:00
|
|
|
|
2021-02-10 10:09:21 +00:00
|
|
|
var trackRevisions = me.api.asc_IsTrackRevisions(),
|
|
|
|
trackChanges = typeof (config.customization) == 'object' ? config.customization.trackChanges : undefined;
|
|
|
|
if ( config.isReviewOnly || trackChanges===true || (trackChanges!==false) && trackRevisions) {
|
2017-03-29 11:19:57 +00:00
|
|
|
_process_changestip();
|
2021-02-10 10:09:21 +00:00
|
|
|
} else if ( trackRevisions ) {
|
2018-09-12 11:52:13 +00:00
|
|
|
var showNewChangesTip = !Common.localStorage.getBool("de-new-changes");
|
|
|
|
if ( me.api.asc_HaveRevisionsChanges() && showNewChangesTip ) {
|
|
|
|
me.btnTurnReview.updateHint('');
|
2017-03-29 11:19:57 +00:00
|
|
|
|
2018-09-12 11:52:13 +00:00
|
|
|
if (me.newChangesTooltip === undefined)
|
2021-02-10 10:09:21 +00:00
|
|
|
me.newChangesTooltip = me.createChangesTip(me.textHasChanges, 'de-new-changes');
|
2017-03-29 11:19:57 +00:00
|
|
|
|
2021-02-27 09:43:32 +00:00
|
|
|
me.hideTips();
|
2018-09-12 11:52:13 +00:00
|
|
|
me.newChangesTooltip.show();
|
|
|
|
} else
|
|
|
|
me.btnTurnReview.updateHint(me.tipReview);
|
2017-03-29 11:19:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
2021-02-27 09:43:32 +00:00
|
|
|
onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) {
|
|
|
|
var global = (localFlag===null),
|
|
|
|
state = global ? globalFlag : localFlag;
|
|
|
|
if (this.btnTurnReview) {
|
|
|
|
if (!state) {
|
|
|
|
this.hideTips();
|
|
|
|
this.btnTurnReview.updateHint(this.tipReview);
|
|
|
|
} else if (userId && state && global ) {
|
|
|
|
if (this.globalChangesTooltip === undefined)
|
|
|
|
this.globalChangesTooltip = this.createChangesTip(this.textSetTrackChanges);
|
|
|
|
if (!this.globalChangesTooltip.isVisible()) {
|
|
|
|
this.hideTips();
|
|
|
|
this.globalChangesTooltip.show();
|
|
|
|
}
|
|
|
|
}
|
2017-04-25 08:54:45 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
|
|
|
this.api.asc_registerCallback('asc_onZoomChange', _.bind(this._onZoomChange, this));
|
|
|
|
this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this._onTextLanguage, this));
|
2021-02-27 09:43:32 +00:00
|
|
|
this.api.asc_registerCallback('asc_onOnTrackRevisionsChange', _.bind(this.onApiTrackRevisionsChange, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.statusbar.setApi(api);
|
|
|
|
},
|
|
|
|
|
2017-03-29 11:19:57 +00:00
|
|
|
onBtnZoomTo: function(d, e) {
|
|
|
|
var _btn, _func;
|
|
|
|
if ( d == 'topage' ) {
|
|
|
|
_btn = 'btnZoomToPage';
|
|
|
|
_func = 'zoomFitToPage';
|
|
|
|
} else {
|
|
|
|
_btn = 'btnZoomToWidth';
|
|
|
|
_func = 'zoomFitToWidth';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !this.statusbar[ _btn ].pressed )
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.zoomCustomMode(); else
|
2017-03-29 11:19:57 +00:00
|
|
|
this.api[ _func ]();
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.statusbar);
|
|
|
|
},
|
|
|
|
|
|
|
|
zoomDocument: function(d,e) {
|
|
|
|
switch (d) {
|
|
|
|
case 'up': this.api.zoomIn(); break;
|
|
|
|
case 'down': this.api.zoomOut(); break;
|
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.statusbar);
|
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* api events
|
|
|
|
* */
|
|
|
|
|
|
|
|
_onZoomChange: function(percent, type) {
|
|
|
|
this.statusbar.btnZoomToPage.toggle(type == 2, true);
|
|
|
|
this.statusbar.btnZoomToWidth.toggle(type == 1, true);
|
|
|
|
|
|
|
|
$('.statusbar #label-zoom').text(Common.Utils.String.format(this.zoomText, percent));
|
|
|
|
},
|
|
|
|
|
|
|
|
_onTextLanguage: function(langId) {
|
|
|
|
var info = Common.util.LanguageInfo.getLocalLanguageName(langId);
|
|
|
|
this.statusbar.setLanguage({
|
2019-01-28 13:51:07 +00:00
|
|
|
value: info[0],
|
|
|
|
displayValue: info[1],
|
2016-03-11 00:48:53 +00:00
|
|
|
code: langId
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-02-07 15:16:17 +00:00
|
|
|
setLanguages: function(langs) {
|
|
|
|
this.langs = langs;
|
2016-03-11 00:48:53 +00:00
|
|
|
this.statusbar.reloadLanguages(langs);
|
|
|
|
},
|
|
|
|
|
2017-04-11 13:40:01 +00:00
|
|
|
setStatusCaption: function(text, force, delay) {
|
|
|
|
if (this.timerCaption && ( ((new Date()) < this.timerCaption) || text.length==0 ) && !force )
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.timerCaption = undefined;
|
|
|
|
if (text.length) {
|
|
|
|
this.statusbar.showStatusMessage(text);
|
|
|
|
if (delay>0)
|
|
|
|
this.timerCaption = (new Date()).getTime() + delay;
|
|
|
|
} else
|
2016-03-11 00:48:53 +00:00
|
|
|
this.statusbar.clearStatusMessage();
|
|
|
|
},
|
|
|
|
|
|
|
|
createDelayedElements: function() {
|
|
|
|
this.statusbar.$el.css('z-index', '');
|
|
|
|
},
|
|
|
|
|
|
|
|
onLangMenu: function(obj, langid, title) {
|
|
|
|
this.api.put_TextPrLang(langid);
|
|
|
|
},
|
|
|
|
|
|
|
|
synchronizeChanges: function() {
|
|
|
|
this.setStatusCaption('');
|
|
|
|
},
|
|
|
|
|
2021-02-27 09:43:32 +00:00
|
|
|
hideTips: function () {
|
|
|
|
this.changesTooltip && this.changesTooltip.isVisible() && this.changesTooltip.hide();
|
|
|
|
this.newChangesTooltip && this.newChangesTooltip.isVisible() && this.newChangesTooltip.hide();
|
|
|
|
this.globalChangesTooltip && this.globalChangesTooltip.isVisible() && this.globalChangesTooltip.hide();
|
|
|
|
},
|
|
|
|
|
2021-02-10 10:09:21 +00:00
|
|
|
createChangesTip: function (text, storage) {
|
2017-03-29 11:19:57 +00:00
|
|
|
var me = this;
|
2016-03-11 00:48:53 +00:00
|
|
|
var tip = new Common.UI.SynchronizeTip({
|
2017-03-29 11:19:57 +00:00
|
|
|
target : me.btnTurnReview.$el,
|
2016-03-11 00:48:53 +00:00
|
|
|
text : text,
|
2021-02-19 17:35:56 +00:00
|
|
|
placement: 'top-left',
|
2021-02-10 10:09:21 +00:00
|
|
|
showLink: !!storage
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
2017-03-29 11:19:57 +00:00
|
|
|
tip.on({
|
|
|
|
'dontshowclick': function() {
|
|
|
|
Common.localStorage.setItem(storage, 1);
|
|
|
|
|
|
|
|
tip.hide();
|
2017-04-19 11:22:31 +00:00
|
|
|
me.btnTurnReview.updateHint(me.tipReview);
|
2017-03-29 11:19:57 +00:00
|
|
|
},
|
|
|
|
'closeclick': function() {
|
|
|
|
tip.hide();
|
2017-04-19 11:22:31 +00:00
|
|
|
me.btnTurnReview.updateHint(me.tipReview);
|
2017-03-29 11:19:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
return tip;
|
|
|
|
},
|
|
|
|
|
|
|
|
zoomText : 'Zoom {0}%',
|
|
|
|
textHasChanges : 'New changes have been tracked',
|
2017-04-19 12:09:44 +00:00
|
|
|
textTrackChanges: 'The document is opened with the Track Changes mode enabled',
|
2021-02-10 10:09:21 +00:00
|
|
|
tipReview : 'Review',
|
|
|
|
textSetTrackChanges: 'You are in Track Changes mode'
|
2016-03-11 00:48:53 +00:00
|
|
|
}, DE.Controllers.Statusbar || {}));
|
|
|
|
});
|