[DE, PE] refactoring

This commit is contained in:
Maxim Kadushkin 2017-04-21 16:36:06 +03:00
parent 40e6a62fd1
commit 679af22f14
6 changed files with 55 additions and 59 deletions

View file

@ -183,6 +183,10 @@
.separator { .separator {
margin-left: 12px; margin-left: 12px;
&.close {
margin-left: 5px;
}
&.long { &.long {
height: 46px; height: 46px;
} }

View file

@ -56,6 +56,7 @@ define([
'use strict'; 'use strict';
DE.Controllers.Main = Backbone.Controller.extend(_.extend((function() { DE.Controllers.Main = Backbone.Controller.extend(_.extend((function() {
var appHeader;
var ApplyEditRights = -255; var ApplyEditRights = -255;
var LoadingDocument = -256; var LoadingDocument = -256;
@ -269,10 +270,8 @@ define([
this.appOptions.canPlugins = false; this.appOptions.canPlugins = false;
this.plugins = this.editorConfig.plugins; this.plugins = this.editorConfig.plugins;
this.getApplication() appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header');
.getController('Viewport') appHeader.setCanBack(this.appOptions.canBackToFolder === true);
.getView('Common.Views.Header')
.setCanBack(this.appOptions.canBackToFolder === true);
if (this.editorConfig.lang) if (this.editorConfig.lang)
this.api.asc_setLocale(this.editorConfig.lang); this.api.asc_setLocale(this.editorConfig.lang);
@ -313,10 +312,7 @@ define([
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
if (data.doc) { if (data.doc) {
this.getApplication() appHeader.setDocumentCaption(data.doc.title);
.getController('Viewport')
.getView('Common.Views.Header')
.setDocumentCaption(data.doc.title);
} }
}, },
@ -391,7 +387,7 @@ define([
}); });
} else { } else {
this.api.asc_coAuthoringDisconnect(); this.api.asc_coAuthoringDisconnect();
this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); appHeader.setCanRename(false);
this.getApplication().getController('LeftMenu').getView('LeftMenu').showHistory(); this.getApplication().getController('LeftMenu').getView('LeftMenu').showHistory();
this.disableEditing(true); this.disableEditing(true);
var versions = opts.data.history, var versions = opts.data.history,
@ -519,9 +515,6 @@ define([
app.getController('Toolbar').DisableToolbar(disable, disable); app.getController('Toolbar').DisableToolbar(disable, disable);
app.getController('RightMenu').SetDisabled(disable, false); app.getController('RightMenu').SetDisabled(disable, false);
app.getController('Statusbar').getView('Statusbar').SetDisabled(disable); app.getController('Statusbar').getView('Statusbar').SetDisabled(disable);
var tooltip = app.getController('Toolbar').getView('Toolbar').synchTooltip;
if (tooltip) tooltip.hide();
} }
app.getController('LeftMenu').SetDisabled(disable, true); app.getController('LeftMenu').SetDisabled(disable, true);
}, },
@ -539,7 +532,7 @@ define([
// this.getMainMenu().closeFullScaleMenu(); // this.getMainMenu().closeFullScaleMenu();
var application = this.getApplication(), var application = this.getApplication(),
toolbarController = application.getController('Toolbar'), toolbarController = application.getController('Toolbar'),
toolbarView = toolbarController.getView('Toolbar'); toolbarView = toolbarController.getView();
if (this.appOptions.isEdit && toolbarView && (toolbarView.btnInsertShape.pressed || toolbarView.btnInsertText.pressed) && if (this.appOptions.isEdit && toolbarView && (toolbarView.btnInsertShape.pressed || toolbarView.btnInsertText.pressed) &&
( !_.isObject(arguments[1]) || arguments[1].id !== 'tlb-btn-insshape')) { // TODO: Event from api is needed to clear btnInsertShape state ( !_.isObject(arguments[1]) || arguments[1].id !== 'tlb-btn-insshape')) { // TODO: Event from api is needed to clear btnInsertShape state
@ -577,11 +570,7 @@ define([
var action = {id: id, type: type}; var action = {id: id, type: type};
this.stackLongActions.pop(action); this.stackLongActions.pop(action);
this.getApplication() appHeader.setDocumentCaption(this.api.asc_getDocumentName());
.getController('Viewport')
.getView('Common.Views.Header')
.setDocumentCaption(this.api.asc_getDocumentName());
this.updateWindowTitle(true); this.updateWindowTitle(true);
action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.Information}); action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.Information});
@ -592,11 +581,11 @@ define([
if (this._state.fastCoauth && this._state.usersCount>1) { if (this._state.fastCoauth && this._state.usersCount>1) {
var me = this; var me = this;
me._state.timerSave = setTimeout(function () { me._state.timerSave = setTimeout(function () {
me.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('end'); appHeader.setSaveStatus('end');
delete me._state.timerSave; delete me._state.timerSave;
}, 500); }, 500);
} else } else
this.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('end'); appHeader.setSaveStatus('end');
} else } else
this.getApplication().getController('Statusbar').setStatusCaption(''); this.getApplication().getController('Statusbar').setStatusCaption('');
} }
@ -713,7 +702,7 @@ define([
this.loadMask.show(); this.loadMask.show();
} else } else
if ( action.id == Asc.c_oAscAsyncAction.Save || action.id == Asc.c_oAscAsyncAction['ForceSaveButton']) { if ( action.id == Asc.c_oAscAsyncAction.Save || action.id == Asc.c_oAscAsyncAction['ForceSaveButton']) {
this.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('begin'); appHeader.setSaveStatus('begin');
} else { } else {
this.getApplication().getController('Statusbar').setStatusCaption(text); this.getApplication().getController('Statusbar').setStatusCaption(text);
} }
@ -785,11 +774,7 @@ define([
me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(me.onCoAuthoringDisconnect, me)); me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(me.onCoAuthoringDisconnect, me));
me.api.asc_registerCallback('asc_onPrint', _.bind(me.onPrint, me)); me.api.asc_registerCallback('asc_onPrint', _.bind(me.onPrint, me));
var application = me.getApplication(); appHeader.setDocumentCaption(me.api.asc_getDocumentName());
application.getController('Viewport')
.getView('Common.Views.Header')
.setDocumentCaption(me.api.asc_getDocumentName());
me.updateWindowTitle(true); me.updateWindowTitle(true);
me.api.SetTextBoxInputMode(Common.localStorage.getBool("de-settings-inputmode")); me.api.SetTextBoxInputMode(Common.localStorage.getBool("de-settings-inputmode"));
@ -817,6 +802,7 @@ define([
} }
/** coauthoring end **/ /** coauthoring end **/
var application = me.getApplication();
var toolbarController = application.getController('Toolbar'), var toolbarController = application.getController('Toolbar'),
statusbarController = application.getController('Statusbar'), statusbarController = application.getController('Statusbar'),
documentHolderController = application.getController('DocumentHolder'), documentHolderController = application.getController('DocumentHolder'),
@ -1008,12 +994,11 @@ define([
this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view';
var headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header');
this.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof this.editorConfig.customization == 'object'); this.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof this.editorConfig.customization == 'object');
if (this.appOptions.canBranding) if (this.appOptions.canBranding)
headerView.setBranding(this.editorConfig.customization); appHeader.setBranding(this.editorConfig.customization);
this.appOptions.canRename && headerView.setCanRename(true); this.appOptions.canRename && appHeader.setCanRename(true);
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
if (this.appOptions.canBrandingExt) if (this.appOptions.canBrandingExt)
@ -1097,7 +1082,7 @@ define([
viewport.applyEditorMode(); viewport.applyEditorMode();
var toolbarView = (toolbarController) ? toolbarController.getView('Toolbar') : null; var toolbarView = (toolbarController) ? toolbarController.getView() : null;
_.each([ _.each([
toolbarView, toolbarView,
@ -1331,7 +1316,7 @@ define([
onCoAuthoringDisconnect: function() { onCoAuthoringDisconnect: function() {
this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true}); this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true});
this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); appHeader.setCanRename(false);
this.appOptions.canRename = false; this.appOptions.canRename = false;
this._state.isDisconnected = true; this._state.isDisconnected = true;
}, },
@ -1352,7 +1337,7 @@ define([
if (!this.tooltip) { if (!this.tooltip) {
this.tooltip = new Common.UI.Tooltip({ this.tooltip = new Common.UI.Tooltip({
owner: this.getApplication().getController('Toolbar').getView('Toolbar'), owner: this.getApplication().getController('Toolbar').getView(),
hideonclick: true, hideonclick: true,
placement: 'bottom', placement: 'bottom',
cls: 'main-info', cls: 'main-info',
@ -1373,12 +1358,8 @@ define([
if (this._state.isDocModified !== isModified || force) { if (this._state.isDocModified !== isModified || force) {
var title = this.defaultTitleText; var title = this.defaultTitleText;
var headerView = this.getApplication() if (!_.isEmpty(appHeader.getDocumentCaption()))
.getController('Viewport') title = appHeader.getDocumentCaption() + ' - ' + title;
.getView('Common.Views.Header');
if (!_.isEmpty(headerView.getDocumentCaption()))
title = headerView.getDocumentCaption() + ' - ' + title;
if (isModified) { if (isModified) {
clearTimeout(this._state.timerCaption); clearTimeout(this._state.timerCaption);
@ -1407,9 +1388,9 @@ define([
this.updateWindowTitle(); this.updateWindowTitle();
this.api.isDocumentModified() && this.api.isDocumentModified() &&
this.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('changed'); appHeader.setSaveStatus('changed');
var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar'); var toolbarView = this.getApplication().getController('Toolbar').getView();
if (toolbarView) { if (toolbarView) {
var isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), var isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'),
@ -1427,7 +1408,7 @@ define([
onDocumentCanSaveChanged: function (isCanSave) { onDocumentCanSaveChanged: function (isCanSave) {
var application = this.getApplication(), var application = this.getApplication(),
toolbarController = application.getController('Toolbar'), toolbarController = application.getController('Toolbar'),
toolbarView = toolbarController.getView('Toolbar'); toolbarView = toolbarController.getView();
if (toolbarView && this.api) { if (toolbarView && this.api) {
var isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), var isSyncButton = $('.icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'),
@ -1552,7 +1533,7 @@ define([
this.getApplication().getController('Common.Controllers.ReviewChanges').synchronizeChanges(); this.getApplication().getController('Common.Controllers.ReviewChanges').synchronizeChanges();
this.getApplication().getController('DocumentHolder').getView().hideTips(); this.getApplication().getController('DocumentHolder').getView().hideTips();
/** coauthoring begin **/ /** coauthoring begin **/
this.getApplication().getController('Toolbar').getView('Toolbar').synchronizeChanges(); this.getApplication().getController('Toolbar').getView().synchronizeChanges();
/** coauthoring end **/ /** coauthoring end **/
this._state.hasCollaborativeChanges = false; this._state.hasCollaborativeChanges = false;
}, },
@ -1721,7 +1702,7 @@ define([
Common.Utils.Metric.setCurrentMetric(value); Common.Utils.Metric.setCurrentMetric(value);
this.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); this.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter));
this.getApplication().getController('RightMenu').updateMetricUnit(); this.getApplication().getController('RightMenu').updateMetricUnit();
this.getApplication().getController('Toolbar').getView('Toolbar').updateMetricUnit(); this.getApplication().getController('Toolbar').getView().updateMetricUnit();
}, },
onAdvancedOptions: function(advOptions) { onAdvancedOptions: function(advOptions) {
@ -1810,16 +1791,16 @@ define([
}, },
onDocumentName: function(name) { onDocumentName: function(name) {
this.getApplication().getController('Viewport').getView('Common.Views.Header').setDocumentCaption(name); appHeader.setDocumentCaption(name);
this.updateWindowTitle(true); this.updateWindowTitle(true);
}, },
onMeta: function(meta) { onMeta: function(meta) {
var app = this.getApplication(), appHeader.setDocumentCaption(meta.title);
filemenu = app.getController('LeftMenu').getView('LeftMenu').getMenu('file');
app.getController('Viewport').getView('Common.Views.Header').setDocumentCaption(meta.title);
this.updateWindowTitle(true); this.updateWindowTitle(true);
this.document.title = meta.title; this.document.title = meta.title;
var filemenu = this.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file');
filemenu.loadDocument({doc:this.document}); filemenu.loadDocument({doc:this.document});
filemenu.panels['info'].updateInfo(this.document); filemenu.panels['info'].updateInfo(this.document);
Common.Gateway.metaChange(meta); Common.Gateway.metaChange(meta);

View file

@ -2710,6 +2710,9 @@ define([
mask.remove(); mask.remove();
Common.util.Shortcuts.resumeEvents('alt+h'); Common.util.Shortcuts.resumeEvents('alt+h');
} }
if ( toolbar.synchTooltip )
toolbar.synchTooltip.hide();
}, },
onSelectRecepientsClick: function() { onSelectRecepientsClick: function() {
@ -2809,6 +2812,10 @@ define([
}); });
}, },
getView: function (name) {
return !name ? this.toolbar : Backbone.Controller.prototype.getView.apply(this, arguments);
},
textEmptyImgUrl : 'You need to specify image URL.', textEmptyImgUrl : 'You need to specify image URL.',
textWarning : 'Warning', textWarning : 'Warning',
textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 100', textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 100',

View file

@ -231,9 +231,7 @@
} }
.lang-flag { .lang-flag {
&:not(.dasble) {
background-position: -16px -108px; background-position: -16px -108px;
}
&.ca, &.ca-ES {background-position: 0 0;} &.ca, &.ca-ES {background-position: 0 0;}
&.cs, &.cs-CZ {background-position: -16px 0;} &.cs, &.cs-CZ {background-position: -16px 0;}

View file

@ -72,17 +72,17 @@
</div> </div>
<div class="separator long"></div> <div class="separator long"></div>
<div class="group"> <div class="group">
<div class="elset" style="width:202px;"> <div class="elset" style="width:195px;">
<span class="btn-slot" style="float: left; width: 148px;" id="slot-field-fontname"></span> <span class="btn-slot" style="float: left; width: 148px;" id="slot-field-fontname"></span>
<span class="btn-slot" style="float: left; width: 45px; margin-left: 2px;" id="slot-field-fontsize"></span> <span class="btn-slot" style="float: left; width: 45px; margin-left: 2px;" id="slot-field-fontsize"></span>
</div> </div>
<div class="elset"> <div class="elset font-attr">
<span class="btn-slot split" id="slot-btn-bold"></span> <span class="btn-slot" id="slot-btn-bold"></span>
<span class="btn-slot split" id="slot-btn-italic"></span> <span class="btn-slot" id="slot-btn-italic"></span>
<span class="btn-slot split" id="slot-btn-underline"></span> <span class="btn-slot" id="slot-btn-underline"></span>
<span class="btn-slot split" id="slot-btn-strikeout"></span> <span class="btn-slot" id="slot-btn-strikeout"></span>
<span class="btn-slot split" id="slot-btn-fontcolor"></span> <span class="btn-slot" id="slot-btn-fontcolor"></span>
<span class="btn-slot split" id="slot-btn-superscript"></span> <span class="btn-slot" id="slot-btn-superscript"></span>
<span class="btn-slot" id="slot-btn-subscript"></span> <span class="btn-slot" id="slot-btn-subscript"></span>
</div> </div>
</div> </div>
@ -100,7 +100,7 @@
<span class="btn-slot split" id="slot-btn-linespace"></span> <span class="btn-slot split" id="slot-btn-linespace"></span>
</div> </div>
</div> </div>
<div class="separator long"></div> <div class="separator long close"></div>
<div class="group"> <div class="group">
<div class="elset"> <div class="elset">
<span class="btn-slot" id="slot-btn-clearstyle"></span> <span class="btn-slot" id="slot-btn-clearstyle"></span>

View file

@ -13,6 +13,12 @@
opacity: 0.4; opacity: 0.4;
} }
} }
.font-attr {
> .btn-slot:not(:last-child) {
margin-right: 8px;
}
}
} }
.toolbar-mask { .toolbar-mask {