[DE] refactoring

This commit is contained in:
Maxim Kadushkin 2017-04-04 18:14:47 +03:00
parent 3784eb0717
commit 4a44c1f344
2 changed files with 66 additions and 60 deletions

View file

@ -477,7 +477,7 @@ define([
Common.UI.BaseView.prototype.initialize.call(this, options); Common.UI.BaseView.prototype.initialize.call(this, options);
// this.store = this.options.store; // this.store = this.options.store;
this.popoverChanges = this.options.popoverChanges; // this.popoverChanges = this.options.popoverChanges;
this.btnPrev = new Common.UI.Button({ this.btnPrev = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
@ -513,16 +513,31 @@ define([
}); });
this.btnsTurnReview = [this.btnTurnOn]; 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; Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
render: function (el) {
this.boxSdk = $('#editor_sdk');
if ( el ) el.html( this.getPanel() );
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.btnPrev.updateHint(me.hintPrev);
me.btnNext.updateHint(me.hintNext); me.btnNext.updateHint(me.hintNext);
me.btnTurnOn.updateHint(me.textChangesOn); me.btnTurnOn.updateHint(me.textChangesOn);
me.btnDocLang.updateHint(me.tipSetDocLang);
me.btnSetSpelling.updateHint(me.tipSetSpelling);
me.btnAccept.setMenu( me.btnAccept.setMenu(
new Common.UI.Menu({ new Common.UI.Menu({
@ -554,19 +569,11 @@ define([
}) })
); );
me.btnAccept.setDisabled(cfg.isReviewOnly); me.btnAccept.setDisabled(config.isReviewOnly);
me.btnReject.setDisabled(cfg.isReviewOnly); me.btnReject.setDisabled(config.isReviewOnly);
setEvents.call(me); setEvents.call(me);
}); });
});
},
render: function (el) {
this.boxSdk = $('#editor_sdk');
if ( el ) el.html( this.getPanel() );
return this;
}, },
getPanel: function () { getPanel: function () {
@ -589,7 +596,7 @@ define([
getPopover: function (sdkViewName) { getPopover: function (sdkViewName) {
if (_.isUndefined(this.popover)) { if (_.isUndefined(this.popover)) {
this.popover = new Common.Views.ReviewChangesPopover({ this.popover = new Common.Views.ReviewChangesPopover({
store: this.popoverChanges, store: this.options.popoverChanges,
delegate: this, delegate: this,
renderTo: sdkViewName renderTo: sdkViewName
}); });

View file

@ -118,7 +118,9 @@ define([
})).then(function () { })).then(function () {
me.bindViewEvents(me.statusbar, me.events); me.bindViewEvents(me.statusbar, me.events);
function _process_changestip() { 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"); var showTrackChangesTip = !Common.localStorage.getBool("de-track-changes-tip");
if ( showTrackChangesTip ) { if ( showTrackChangesTip ) {
me.btnTurnReview.updateHint(''); me.btnTurnReview.updateHint('');
@ -131,9 +133,6 @@ define([
} }
} }
var statusbarIsHidden = Common.localStorage.getBool("de-hidden-status");
if ( config.canReview && !statusbarIsHidden ) {
if ( config.isReviewOnly ) { if ( config.isReviewOnly ) {
_process_changestip(); _process_changestip();
} else } else