[SSE] Add customize statusbar menu

This commit is contained in:
JuliaSvinareva 2020-06-17 17:39:13 +03:00
parent a9850f64b3
commit 36034c4043
2 changed files with 81 additions and 8 deletions

View file

@ -353,6 +353,20 @@ define([
}); });
}); });
this.customizeStatusBarMenu = new Common.UI.Menu({
style: 'margin-top: -14px; margin-left: -7px;',
menuAlign: 'bl-tl',
items: [
{template: _.template('<div style="padding-left: 6px; padding-top: 2px;">' + this.textCustomizeStatusBar + '</div>')},
{caption: '--'},
{caption: this.itemAverage, value: 'average', checkable: true, checked: true},
{caption: this.itemCount, value: 'count', checkable: true, checked: true},
{caption: this.itemMinimum, value: 'min', checkable: true, checked: true},
{caption: this.itemMaximum, value: 'max', checkable: true, checked: true},
{caption: this.itemSum, value: 'sum', checkable: true, checked: true}
]
});
this.tabbar.$el.append('<div class="dropdown-toggle" data-toggle="dropdown" style="width:0; height:0;"></div>'); this.tabbar.$el.append('<div class="dropdown-toggle" data-toggle="dropdown" style="width:0; height:0;"></div>');
this.tabMenu.render(this.tabbar.$el); this.tabMenu.render(this.tabbar.$el);
this.tabMenu.cmpEl.attr({tabindex: -1}); this.tabMenu.cmpEl.attr({tabindex: -1});
@ -375,6 +389,28 @@ define([
this.boxZoom = $('#status-zoom-box', this.el); this.boxZoom = $('#status-zoom-box', this.el);
this.boxZoom.find('.separator').css('border-left-color','transparent'); this.boxZoom.find('.separator').css('border-left-color','transparent');
this.$el.append('<div id="statusbar-menu" style="width:0; height:0;"></div>');
this.$customizeStatusBarMenu = this.$el.find('#statusbar-menu');
this.$customizeStatusBarMenu.on({
'show.bs.dropdown': function () {
_.defer(function(){
me.$customizeStatusBarMenu.find('ul').focus();
}, 100);
},
'hide.bs.dropdown': function () {
_.defer(function(){
me.api.asc_enableKeyEvents(true);
}, 100);
}
});
this.$customizeStatusBarMenu.append('<div class="dropdown-toggle" data-toggle="dropdown" style="width:0; height:0;"></div>');
this.customizeStatusBarMenu.render(this.$customizeStatusBarMenu);
this.customizeStatusBarMenu.cmpEl.attr({tabindex: -1});
this.customizeStatusBarMenu.on('show:after', _.bind(this.onCustomizeStatusBarAfterShow, this));
this.customizeStatusBarMenu.on('hide:after', _.bind(this.onCustomizeStatusBarAfterHide, this));
this.customizeStatusBarMenu.on('item:click', _.bind(this.onCustomizeStatusBarClick, this));
this.boxMath.on('contextmenu', _.bind(this.showCustomizeStatusBar, this));
return this; return this;
}, },
@ -641,6 +677,38 @@ define([
this.editMode = edit; this.editMode = edit;
}, },
showCustomizeStatusBar: function (e) {
var rect = e.target.getBoundingClientRect();
this.customizeStatusBarMenu.atposition = {
left: rect.left,
top: rect.top
};
this.customizeStatusBarMenu.show();
},
onCustomizeStatusBarAfterShow: function (obj) {
if (obj.atposition) {
obj.setOffset(obj.atposition.left);
}
this.enableKeyEvents = true;
},
onCustomizeStatusBarAfterHide: function () {
if (!_.isUndefined(this.enableKeyEvents)) {
if (this.api) {
this.api.asc_enableKeyEvents(this.enableKeyEvents);
}
this.enableKeyEvents = undefined;
}
},
onCustomizeStatusBarClick: function (o, item) {
var value = item.value,
checked = item.checked;
this.boxMath.find('#status-math-' + value)[checked ? 'removeClass' : 'addClass']('hide');
},
tipZoomIn : 'Zoom In', tipZoomIn : 'Zoom In',
tipZoomOut : 'Zoom Out', tipZoomOut : 'Zoom Out',
tipZoomFactor : 'Magnification', tipZoomFactor : 'Magnification',
@ -668,7 +736,13 @@ define([
filteredRecordsText : '{0} of {1} records filtered', filteredRecordsText : '{0} of {1} records filtered',
filteredText : 'Filter mode', filteredText : 'Filter mode',
selectAllSheets : 'Select All Sheets', selectAllSheets : 'Select All Sheets',
ungroupSheets : 'Ungroup Sheets' ungroupSheets : 'Ungroup Sheets',
textCustomizeStatusBar: 'Customize status bar',
itemAverage : 'Average',
itemCount : 'Count',
itemMinimum : 'Minimum',
itemMaximum : 'Maximum',
itemSum : 'Sum'
}, SSE.Views.Statusbar || {})); }, SSE.Views.Statusbar || {}));
SSE.Views.Statusbar.RenameDialog = Common.UI.Window.extend(_.extend({ SSE.Views.Statusbar.RenameDialog = Common.UI.Window.extend(_.extend({

View file

@ -122,17 +122,16 @@
#status-math-box, #status-math-box,
#status-filtered-box { #status-filtered-box {
float: right; float: right;
padding-top: 6px;
padding-right: 14px;
label { label {
padding-top: 6px;
height: 25px;
&:not(:last-child) { &:not(:last-child) {
margin-right: 10px; padding-right: 10px;
}
&:last-child {
padding-right: 14px;
} }
}
.separator {
margin-top: -6px;
} }
} }