From 4a44c1f34450b589d2b88a5a24dba0d07938b7c5 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 4 Apr 2017 18:14:47 +0300 Subject: [PATCH] [DE] refactoring --- apps/common/main/lib/view/ReviewChanges.js | 101 ++++++++++-------- .../main/app/controller/Statusbar.js | 25 +++-- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index f6e66808d..e33efd63b 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -477,7 +477,7 @@ define([ Common.UI.BaseView.prototype.initialize.call(this, options); // this.store = this.options.store; - this.popoverChanges = this.options.popoverChanges; + // this.popoverChanges = this.options.popoverChanges; this.btnPrev = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', @@ -513,53 +513,10 @@ define([ }); this.btnsTurnReview = [this.btnTurnOn]; - var me = this; - var promise = new Promise( function(resolve) { resolve(); }); - Common.NotificationCenter.on('app:ready', function (cfg) { - promise.then(function(){ - me.appConfig = cfg; - - me.btnPrev.updateHint(me.hintPrev); - me.btnNext.updateHint(me.hintNext); - me.btnTurnOn.updateHint(me.textChangesOn); - - me.btnAccept.setMenu( - new Common.UI.Menu({ - items: [ - { - caption: me.txtAcceptCurrent, - value: 'current' - }, - { - caption: me.txtAcceptAll, - value: 'all' - } - ] - }) - ); - - me.btnReject.setMenu( - new Common.UI.Menu({ - items: [ - { - caption: me.txtRejectCurrent, - value: 'current' - }, - { - caption: me.txtRejectAll, - value: 'all' - } - ] - }) - ); - - me.btnAccept.setDisabled(cfg.isReviewOnly); - me.btnReject.setDisabled(cfg.isReviewOnly); - - setEvents.call(me); - }); }); + + Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, render: function (el) { @@ -569,6 +526,56 @@ define([ return this; }, + onAppReady: function (config) { + var me = this; + (new Promise(function (accept, reject) { + accept(); + })).then(function(){ + me.appConfig = config; + + me.btnPrev.updateHint(me.hintPrev); + me.btnNext.updateHint(me.hintNext); + me.btnTurnOn.updateHint(me.textChangesOn); + me.btnDocLang.updateHint(me.tipSetDocLang); + me.btnSetSpelling.updateHint(me.tipSetSpelling); + + me.btnAccept.setMenu( + new Common.UI.Menu({ + items: [ + { + caption: me.txtAcceptCurrent, + value: 'current' + }, + { + caption: me.txtAcceptAll, + value: 'all' + } + ] + }) + ); + + me.btnReject.setMenu( + new Common.UI.Menu({ + items: [ + { + caption: me.txtRejectCurrent, + value: 'current' + }, + { + caption: me.txtRejectAll, + value: 'all' + } + ] + }) + ); + + me.btnAccept.setDisabled(config.isReviewOnly); + me.btnReject.setDisabled(config.isReviewOnly); + + setEvents.call(me); + }); + }, + getPanel: function () { var _html = $(_.template( template, {} )); @@ -589,7 +596,7 @@ define([ getPopover: function (sdkViewName) { if (_.isUndefined(this.popover)) { this.popover = new Common.Views.ReviewChangesPopover({ - store: this.popoverChanges, + store: this.options.popoverChanges, delegate: this, renderTo: sdkViewName }); diff --git a/apps/documenteditor/main/app/controller/Statusbar.js b/apps/documenteditor/main/app/controller/Statusbar.js index dd9c9e02d..89483c1ee 100644 --- a/apps/documenteditor/main/app/controller/Statusbar.js +++ b/apps/documenteditor/main/app/controller/Statusbar.js @@ -118,21 +118,20 @@ define([ })).then(function () { me.bindViewEvents(me.statusbar, me.events); - function _process_changestip() { - var showTrackChangesTip = !Common.localStorage.getBool("de-track-changes-tip"); - if ( showTrackChangesTip ) { - me.btnTurnReview.updateHint(''); - if (me.changesTooltip === undefined) - me.changesTooltip = me.createChangesTip(me.textTrackChanges, 'de-track-changes-tip', false); - - me.changesTooltip.show(); - } else { - me.btnTurnReview.updateHint(me.tipReview); - } - } - var statusbarIsHidden = Common.localStorage.getBool("de-hidden-status"); if ( config.canReview && !statusbarIsHidden ) { + var _process_changestip = function() { + var showTrackChangesTip = !Common.localStorage.getBool("de-track-changes-tip"); + if ( showTrackChangesTip ) { + me.btnTurnReview.updateHint(''); + if (me.changesTooltip === undefined) + me.changesTooltip = me.createChangesTip(me.textTrackChanges, 'de-track-changes-tip', false); + + me.changesTooltip.show(); + } else { + me.btnTurnReview.updateHint(me.tipReview); + } + } if ( config.isReviewOnly ) { _process_changestip();