[DE, PE] refactoring

This commit is contained in:
Maxim Kadushkin 2017-04-20 17:45:47 +03:00
parent 60e0feecfc
commit ada56664f3
4 changed files with 18 additions and 46 deletions

View file

@ -105,7 +105,6 @@ define([
this.addListeners({
'Toolbar': {
'view:compact' : this.onChangeCompactView,
'insert:break' : this.onClickPageBreak
},
'FileMenu': {
@ -268,9 +267,9 @@ define([
toolbar.listStyles.on('click', _.bind(this.onListStyleSelect, this));
toolbar.listStyles.on('contextmenu', _.bind(this.onListStyleContextMenu, this));
toolbar.styleMenu.on('hide:before', _.bind(this.onListStyleBeforeHide, this));
// toolbar.mnuitemHideTitleBar.on('toggle', _.bind(this.onHideTitleBar, this));
toolbar.mnuitemHideStatusBar.on('toggle', _.bind(this.onHideStatusBar, this));
toolbar.mnuitemHideRulers.on('toggle', _.bind(this.onHideRulers, this));
toolbar.mnuitemCompactToolbar.on('toggle', _.bind(this.onChangeCompactView, this));
toolbar.btnFitPage.on('toggle', _.bind(this.onZoomToPageToggle, this));
toolbar.btnFitWidth.on('toggle', _.bind(this.onZoomToWidthToggle, this));
toolbar.mnuZoomIn.on('click', _.bind(this.onZoomInClick, this));
@ -330,6 +329,7 @@ define([
onChangeCompactView: function(view, compact) {
this.toolbar.setFolded(compact);
this.toolbar.fireEvent('view:compact', [this, compact]);
Common.localStorage.setBool('de-compact-toolbar', compact);
Common.NotificationCenter.trigger('layout:changed', 'toolbar');
@ -2741,10 +2741,16 @@ define([
onAppShowed: function (config) {
var me = this;
var isCompactView = Common.localStorage.getItem("de-compact-toolbar");
isCompactView = !config.isEdit || !!(isCompactView !== null && parseInt(isCompactView) == 1 || isCompactView === null && config.customization && config.customization.compactToolbar);
var compactview = !config.isEdit;
if ( config.isEdit ) {
if ( Common.localStorage.itemExists("de-compact-toolbar") ) {
compactview = Common.localStorage.getBool("de-compact-toolbar");
} else
if ( config.customization && config.customization.compactToolbar )
compactview = true;
}
me.toolbar.render(_.extend(config, {isCompactView: isCompactView}));
me.toolbar.render(_.extend({isCompactView: compactview}, config));
if ( config.isEdit ) {
var tab = {action: 'review', caption: me.toolbar.textTabReview};
@ -2754,7 +2760,6 @@ define([
me.toolbar.addTab(tab, $panel, 3);
}
}
this.toolbar.mnuitemCompactToolbar.setChecked(true, true);
},
onAppReady: function (config) {

View file

@ -1322,20 +1322,18 @@ define([
this.fireEvent('render:before', [this]);
me.isCompactView = mode.isCompactView;
if ( mode.isEdit ) {
me.isCompactView = Common.localStorage.getBool("de-compact-toolbar");
me.$el.html(me.rendererComponents(config.$dom));
} else {
config.$dom.find('.canedit').hide();
config.$dom.addClass('folded');
me.isCompactView = true;
me.$el.html(config.$dom);
}
this.fireEvent('render:after', [this]);
me.isCompactView = mode.isCompactView;
/** coauthoring begin **/
this.showSynchTip = !Common.localStorage.getBool("de-hide-synch");
this.needShowSynchTip = false;
@ -1704,18 +1702,17 @@ define([
items: [
this.mnuitemCompactToolbar = new Common.UI.MenuItem({
caption: this.textCompactView,
checked: me.isCompactView,
checkable: true
}),
// this.mnuitemHideTitleBar = new Common.UI.MenuItem({
// caption: this.textHideTitleBar,
// checkable: true
// }),
this.mnuitemHideStatusBar = new Common.UI.MenuItem({
caption: this.textHideStatusBar,
checked: Common.localStorage.getBool("de-hidden-status"),
checkable: true
}),
this.mnuitemHideRulers = new Common.UI.MenuItem({
caption: this.textHideLines,
checked: Common.localStorage.getBool("de-hidden-rulers"),
checkable: true
}),
{caption: '--'},
@ -2144,19 +2141,6 @@ define([
maxRows: 8,
maxColumns: 10
});
/**/
var mode = this.mode;
// value = Common.localStorage.getItem("de-compact-toolbar");
// var valueCompact = !!(value !== null && parseInt(value) == 1 || value === null && this.mode.customization && this.mode.customization.compactToolbar);
this.mnuitemCompactToolbar.setChecked(this.isCompactView, true);
this.mnuitemCompactToolbar.on('toggle', _.bind(this.changeViewMode, this));
// this.mnuitemHideTitleBar.setChecked( Common.localStorage.getBool("de-hidden-title"), true );
this.mnuitemHideStatusBar.setChecked( Common.localStorage.getBool("de-hidden-status"), true );
this.mnuitemHideRulers.setChecked( Common.localStorage.getBool("de-hidden-rulers"), true );
/**/
},
updateMetricUnit: function () {
@ -2262,10 +2246,6 @@ define([
this.listStylesAdditionalMenuItem.setVisible(mode.canEditStyles);
},
changeViewMode: function (item, compact) {
this.fireEvent('view:compact', [this, compact]);
},
onSendThemeColorSchemes: function (schemas) {
var me = this;
@ -2692,7 +2672,7 @@ define([
textTabHome: 'Home',
textTabInsert: 'Insert',
textTabLayout: 'Page Layout',
textTabReview: 'Review'
textTabReview: 'Review',
capBtnInsShape: 'Shape',
capBtnInsTextbox: 'Text',
capBtnInsDropcap: 'Drop Cap',

View file

@ -114,7 +114,6 @@ define([
this.addListeners({
'Toolbar': {
'view:compact' : this.onChangeCompactView,
'insert:image' : this.onInsertImageClick.bind(this),
'insert:text' : this.onInsertText.bind(this),
'insert:textart' : this.onInsertTextart.bind(this),
@ -259,9 +258,9 @@ define([
toolbar.btnSlideSize.menu.on('item:click', _.bind(this.onSlideSize, this));
toolbar.mnuInsertChartPicker.on('item:click', _.bind(this.onSelectChart, this));
toolbar.listTheme.on('click', _.bind(this.onListThemeSelect, this));
toolbar.mnuitemHideTitleBar.on('toggle', _.bind(this.onHideTitleBar, this));
toolbar.mnuitemHideStatusBar.on('toggle', _.bind(this.onHideStatusBar, this));
toolbar.mnuitemHideRulers.on('toggle', _.bind(this.onHideRulers, this));
toolbar.mnuitemCompactToolbar.on('toggle', _.bind(this.onChangeCompactView, this));
toolbar.btnFitPage.on('toggle', _.bind(this.onZoomToPageToggle, this));
toolbar.btnFitWidth.on('toggle', _.bind(this.onZoomToWidthToggle, this));
toolbar.mnuZoomIn.on('click', _.bind(this.onZoomInClick, this));
@ -317,6 +316,7 @@ define([
onChangeCompactView: function(view, compact) {
this.toolbar.setFolded(compact);
this.toolbar.fireEvent('view:compact', [this.toolbar, compact]);
Common.localStorage.setBool('pe-compact-toolbar', compact);
Common.NotificationCenter.trigger('layout:changed', 'toolbar');

View file

@ -1331,10 +1331,6 @@ define([
checkable: true,
checked: me.isCompactView
}),
this.mnuitemHideTitleBar = new Common.UI.MenuItem({
caption: this.textHideTitleBar,
checkable: true
}),
this.mnuitemHideStatusBar = new Common.UI.MenuItem({
caption: this.textHideStatusBar,
checkable: true
@ -1373,8 +1369,6 @@ define([
]
})
);
if (this.mode.isDesktopApp || this.mode.canBrandingExt && this.mode.customization && this.mode.customization.header === false)
this.mnuitemHideTitleBar.hide();
if (this.mode.canBrandingExt && this.mode.customization && this.mode.customization.statusBar === false)
this.mnuitemHideStatusBar.hide();
@ -1520,9 +1514,6 @@ define([
me.mnuChangeSlidePicker._needRecalcSlideLayout = true;
});
this.mnuitemCompactToolbar.on('toggle', _.bind(this.changeViewMode, this));
this.mnuitemHideTitleBar.setChecked(Common.localStorage.getBool('pe-hidden-title'), true);
this.mnuitemHideStatusBar.setChecked(Common.localStorage.getBool('pe-hidden-status'), true);
this.mnuitemHideRulers.setChecked(Common.localStorage.getItem("pe-hidden-rulers"), true);
@ -1575,10 +1566,6 @@ define([
this.lockToolbar(PE.enumLock.cantPrint, !mode.canPrint || mode.disableDownload, {array: [this.btnPrint]});
},
changeViewMode: function (item, compact) {
this.fireEvent('view:compact', [this, compact]);
},
onSendThemeColorSchemes: function (schemas) {
var me = this,
mnuColorSchema = me.btnColorSchemas.menu;