[DE] Show File and Plugins tabs in view mode

This commit is contained in:
Julia Radzhabova 2018-05-15 15:37:26 +03:00
parent 52029b5d19
commit 869bc1a7a6
9 changed files with 1156 additions and 1078 deletions

View file

@ -94,7 +94,7 @@ define([
$(document.body).on('click', onClickDocument.bind(this));
Common.NotificationCenter.on('tab:visible', _.bind(function(action, visible){
this.setVisible(action, visible)
this.setVisible(action, visible);
}, this));
},
@ -120,7 +120,7 @@ define([
return t.length && t.data('tab') == tag;
},
setFolded: function(value) {
setFolded: function(value, defNum) {
this.isFolded = value;
var me = this;
@ -178,6 +178,9 @@ define([
if ( active_panel.length ) {
var tab = active_panel.data('tab');
me.$tabs.find('> a[data-tab=' + tab + ']').parent().toggleClass('active', true);
} else if (defNum!==undefined && defNum<me.$tabs.length) {
var t = $(me.$tabs[defNum]).find('> a');
t.length && me.setTab(t.data('tab'));
}
}
},
@ -278,6 +281,8 @@ define([
if ($target.length) {
$target.after(panel);
} else {
panel.appendTo(this.$layout.find('.box-panels'));
}
}

View file

@ -59,7 +59,7 @@ define([
'render:before' : function (toolbar) {
var appOptions = me.getApplication().getController('Main').appOptions;
if ( appOptions.isEdit && !appOptions.isEditMailMerge && !appOptions.isEditDiagram ) {
if ( !appOptions.isEditMailMerge && !appOptions.isEditDiagram ) {
var tab = {action: 'plugins', caption: me.panelPlugins.groupCaption};
me.$toolbarPanelPlugins = me.panelPlugins.getPanel();

View file

@ -484,9 +484,8 @@ define([
if ( config.canEdit && config.canRequestEditRights )
this.btnEdit = createTitleButton('svg-btn-edit', $html.find('#slot-hbtn-edit'));
} else {
me.btnOptions.render($html.find('#slot-btn-options'));
}
me.btnOptions.render($html.find('#slot-btn-options'));
$userList = $html.find('.cousers-list');
$panelUsers = $html.find('.box-cousers');

View file

@ -622,7 +622,7 @@ define([
}
application.getController('DocumentHolder').getView().focus();
if (this.api && !toolbarView._state.previewmode) {
if (this.api && this.appOptions.isEdit && !toolbarView._state.previewmode) {
var cansave = this.api.asc_isDocumentCanSave(),
forcesave = this.appOptions.forcesave,
isSyncButton = (toolbarView.btnCollabChanges.rendered) ? toolbarView.btnCollabChanges.$icon.hasClass('btn-synch') : false,
@ -1140,7 +1140,8 @@ define([
viewport = app.getController('Viewport').getView('Viewport'),
// headerView = app.getController('Viewport').getView('Common.Views.Header'),
statusbarView = app.getController('Statusbar').getView('Statusbar'),
documentHolder = app.getController('DocumentHolder').getView();
documentHolder = app.getController('DocumentHolder').getView(),
toolbarController = app.getController('Toolbar');
// if (headerView) {
// headerView.setHeaderCaption(this.appOptions.isEdit ? 'Document Editor' : 'Document Viewer');
@ -1149,7 +1150,7 @@ define([
viewport && viewport.setMode(this.appOptions);
statusbarView && statusbarView.setMode(this.appOptions);
toolbarController.setMode(this.appOptions);
documentHolder.setMode(this.appOptions);
this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this));
@ -1187,20 +1188,17 @@ define([
viewport.applyEditorMode();
var toolbarView = (toolbarController) ? toolbarController.getView() : null;
_.each([
toolbarView,
rightmenuController.getView('RightMenu')
], function(view) {
if (view) {
view.setApi(me.api);
view.on('editcomplete', _.bind(me.onEditComplete, me));
view.setMode(me.appOptions);
var rightmenuView = rightmenuController.getView('RightMenu');
if (rightmenuView) {
rightmenuView.setApi(me.api);
rightmenuView.on('editcomplete', _.bind(me.onEditComplete, me));
rightmenuView.setMode(me.appOptions);
}
});
var toolbarView = (toolbarController) ? toolbarController.getView() : null;
if (toolbarView) {
toolbarView.setApi(me.api);
toolbarView.on('editcomplete', _.bind(me.onEditComplete, me));
toolbarView.on('insertimage', _.bind(me.onInsertImage, me));
toolbarView.on('inserttable', _.bind(me.onInsertTable, me));
toolbarView.on('insertshape', _.bind(me.onInsertShape, me));

View file

@ -226,6 +226,11 @@ define([
Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me));
},
setMode: function(mode) {
this.mode = mode;
this.toolbar.applyLayout(mode);
},
attachUIEvents: function(toolbar) {
/**
* UI Events
@ -359,7 +364,7 @@ define([
},
onChangeCompactView: function(view, compact) {
this.toolbar.setFolded(compact);
this.toolbar.setFolded(compact, 1);
this.toolbar.fireEvent('view:compact', [this, compact]);
Common.localStorage.setBool('de-compact-toolbar', compact);
@ -2700,6 +2705,8 @@ define([
me.toolbar.render(_.extend({isCompactView: compactview}, config));
if ( config.isEdit ) {
me.toolbar.setMode(config);
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration};
var $panel = this.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel();

View file

@ -195,6 +195,14 @@ define([
checkable: true,
value: 'toolbar'
});
if (!config.isEdit) {
me.header.mnuitemCompactToolbar.hide();
Common.NotificationCenter.on('tab:visible', _.bind(function(action, visible){
if (action=='plugins' && visible) {
me.header.mnuitemCompactToolbar.show();
}
}, this));
}
var mnuitemHideStatusBar = new Common.UI.MenuItem({
caption: me.header.textHideStatusBar,

View file

@ -0,0 +1,26 @@
<div class="toolbar">
<div class="box-tabs">
<div class="extra left"></div>
<section class="tabs">
<a class="scroll left">
<i class="icon">&lt;</i>
</a>
<ul>
<% for(var i in tabs) { %>
<li class="ribtab<% if (tabs[i].extcls) print(' ' + tabs[i].extcls) %>">
<a data-tab="<%= tabs[i].action %>" data-title="<%= tabs[i].caption %>"><%= tabs[i].caption %></a>
</li>
<% } %>
</ul>
<a class="scroll right">
<i class="icon">&gt;</i>
</a>
</section>
<div class="extra right">
</div>
</div>
<section class="box-controls">
<section class="box-panels">
</section>
</section>
</div>

View file

@ -183,7 +183,7 @@ define([
} else {
btn.panel['hide']();
}
if (this.mode.isEdit) DE.getController('Toolbar').DisableToolbar(state==true);
DE.getController('Toolbar').DisableToolbar(state==true);
if (!this.supressEvents)
Common.NotificationCenter.trigger('layout:changed', 'leftmenu');
},

View file

@ -45,6 +45,7 @@ define([
'underscore',
'backbone',
'text!documenteditor/main/app/template/Toolbar.template',
'text!documenteditor/main/app/template/ToolbarView.template',
'common/main/lib/collection/Fonts',
'common/main/lib/component/Button',
'common/main/lib/component/ComboBox',
@ -58,7 +59,7 @@ define([
'common/main/lib/component/ComboDataView'
,'common/main/lib/component/SynchronizeTip'
,'common/main/lib/component/Mixtbar'
], function ($, _, Backbone, template) {
], function ($, _, Backbone, template, template_view) {
'use strict';
DE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend((function(){
@ -77,17 +78,6 @@ define([
initialize: function () {
var me = this;
Common.UI.Mixtbar.prototype.initialize.call(this, {
template: _.template(template),
tabs: [
{ caption: me.textTabFile, action: 'file', extcls: 'canedit'},
{ caption: me.textTabHome, action: 'home', extcls: 'canedit'},
{ caption: me.textTabInsert, action: 'ins', extcls: 'canedit'},
{ caption: me.textTabLayout, action: 'layout', extcls: 'canedit'},
{ caption: me.textTabLinks, action: 'links', extcls: 'canedit'}
]}
);
/**
* UI Components
*/
@ -107,6 +97,27 @@ define([
hasCollaborativeChanges: undefined,
previewmode: false
};
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(this));
return this;
},
applyLayout: function (config) {
var me = this;
if ( config.isEdit ) {
Common.UI.Mixtbar.prototype.initialize.call(this, {
template: _.template(template),
tabs: [
{caption: me.textTabFile, action: 'file', extcls: 'canedit'},
{caption: me.textTabHome, action: 'home', extcls: 'canedit'},
{caption: me.textTabInsert, action: 'ins', extcls: 'canedit'},
{caption: me.textTabLayout, action: 'layout', extcls: 'canedit'},
{caption: me.textTabLinks, action: 'links', extcls: 'canedit'}
]
}
);
this.btnSaveCls = 'btn-save';
this.btnSaveTip = this.tipSave + Common.Utils.String.platformKey('Ctrl+S');
@ -681,8 +692,8 @@ define([
toggleGroup: 'menuColumns',
value: 4
},
{ caption: '--' },
{ caption: this.textColumnsCustom, value: 'advanced' }
{caption: '--'},
{caption: this.textColumnsCustom, value: 'advanced'}
]
})
});
@ -977,7 +988,7 @@ define([
caption: me.capImgWrapping,
menu: true
});
me.toolbarControls.push( me.btnImgAlign,
me.toolbarControls.push(me.btnImgAlign,
me.btnImgGroup, me.btnImgForward, me.btnImgBackward, me.btnImgWrapping);
//
@ -1132,9 +1143,31 @@ define([
}
this.on('render:after', _.bind(this.onToolbarAfterRender, this));
} else {
Common.UI.Mixtbar.prototype.initialize.call(this, {
template: _.template(template_view),
tabs: [
{caption: me.textTabFile, action: 'file', extcls: ''}
]
}
);
Common.NotificationCenter.on('tab:visible', _.bind(function(action, visible){
if (action=='plugins' && visible) {
var compactview = false;
if ( Common.localStorage.itemExists("de-compact-toolbar") ) {
compactview = Common.localStorage.getBool("de-compact-toolbar");
} else if ( config.customization && config.customization.compactToolbar )
compactview = true;
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(this));
if (!compactview) {
me.setFolded(false, 1);
me.setTab('plugins');
me.fireEvent('view:compact', [me, compactview]);
Common.NotificationCenter.trigger('layout:changed', 'toolbar');
}
}
}, this));
}
return this;
},
@ -1153,27 +1186,25 @@ define([
} else {
me.$layout.find('.canedit').hide();
me.$layout.addClass('folded');
me.$el.html(me.$layout);
}
this.fireEvent('render:after', [this]);
Common.UI.Mixtbar.prototype.afterRender.call(this);
/** coauthoring begin **/
this.showSynchTip = !Common.localStorage.getBool("de-hide-synch");
this.needShowSynchTip = false;
/** coauthoring end **/
Common.NotificationCenter.on({
'window:resize': function() {
Common.UI.Mixtbar.prototype.onResize.apply(me, arguments);
}
});
if ( mode.isEdit ) {
/** coauthoring begin **/
this.showSynchTip = !Common.localStorage.getBool("de-hide-synch");
this.needShowSynchTip = false;
/** coauthoring end **/
me.setTab('home');
if ( me.isCompactView )
me.setFolded(true);
var top = Common.localStorage.getItem("de-pgmargins-top"),
left = Common.localStorage.getItem("de-pgmargins-left"),
@ -1186,6 +1217,10 @@ define([
$(mnu.el).html(mnu.template({id: Common.UI.getId(), caption : mnu.caption, options : mnu.options}));
} else
this.btnPageMargins.menu.items[0].setVisible(false);
}
if ( me.isCompactView )
me.setFolded(true);
return this;
},