[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);
// 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
});

View file

@ -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();