reworked zoom to list of values

This commit is contained in:
nikita_bartoshuk
2026-02-12 23:57:18 +03:00
committed by Maxim Kadushkin
parent 6ed4fef78c
commit 3b79481aba
2 changed files with 27 additions and 25 deletions

View File

@ -1728,12 +1728,23 @@ define([
(item.value!==null) && Common.UI.Themes.setTheme(item.value);
},
onApiZoomChange: function(percent, type) {
var me = this;
var correspondingZoomFound = false;
this.view.mnuZoom.items[0].setChecked(type == 2, true);
this.view.mnuZoom.items[1].setChecked(type == 1, true);
this.view.mnuZoom.options.value = percent;
if ( this.view.mnuZoom.$el )
$('.menu-zoom label.zoom', this.view.mnuZoom.$el).html(percent + '%');
this.view.mnuZoom.items.forEach(function (item, index) {
if (percent === item.value) {
me.view.mnuZoom.items[index].setChecked(true);
correspondingZoomFound = true;
};
});
if (!correspondingZoomFound)
for (var i = 2; i < this.view.mnuZoom.items.length; i++) {
this.view.mnuZoom.items[i].setChecked(false);
};
},
onMenuZoomClick: function(menu, item, e){
@ -1744,12 +1755,9 @@ define([
case 'zoom:width':
item.isChecked() ? this.api.zoomFitToWidth() : this.api.zoomCustomMode();
break;
default:
this.api.zoom(item.value);
}
},
onBtnZoom: function (btn, e) {
btn == 'up' ? this.api.zoomIn() : this.api.zoomOut();
e.stopPropagation();
},
onDarkModeClick: function(item) {
@ -1933,8 +1941,6 @@ define([
// zoom
$('#id-btn-zoom-in').on('click', this.api.zoomIn.bind(this.api));
$('#id-btn-zoom-out').on('click', this.api.zoomOut.bind(this.api));
$('#id-menu-zoom-in').on('click', _.bind(this.onBtnZoom, this,'up'));
$('#id-menu-zoom-out').on('click', _.bind(this.onBtnZoom, this,'down'));
this.view.btnOptions.menu.on('item:click', _.bind(this.onOptionsClick, this));
this.view.mnuZoom.on('item:click', _.bind(this.onMenuZoomClick, this));

View File

@ -76,21 +76,17 @@ define([
items: [
{caption: this.textFitToPage, value: 'zoom:page', toggleGroup: 'view-zoom', checkable: true},
{caption: this.textFitToWidth, value: 'zoom:width', toggleGroup: 'view-zoom', checkable: true},
(new Common.UI.MenuItem({
template: _.template([
'<div id="id-menu-zoom" class="menu-zoom" style="height: 26px;" ',
'<% if(!_.isUndefined(options.stopPropagation)) { %>',
'data-stopPropagation="true"',
'<% } %>', '>',
'<label class="title">' + this.textZoom + '</label>',
'<button id="id-menu-zoom-in" type="button" style="float:right; margin: 2px 5px 0 0;" class="btn btn-toolbar"><i class="mi-icon svg-icon zoom-in">&nbsp;</i></button>',
'<label class="zoom"><%= options.value %>%</label>',
'<button id="id-menu-zoom-out" type="button" style="float:right; margin-top: 2px;" class="btn btn-toolbar"><i class="mi-icon svg-icon zoom-out">&nbsp;</i></button>',
'</div>'
].join('')),
stopPropagation: true,
value: 30
}))
{caption: '--'},
{caption: '50%', value: 50, toggleGroup: 'zoom-list', checkable: true},
{caption: '75%', value: 75, toggleGroup: 'zoom-list', checkable: true},
{caption: '100%', value: 100, toggleGroup: 'zoom-list', checkable: true},
{caption: '125%', value: 125, toggleGroup: 'zoom-list', checkable: true},
{caption: '150%', value: 150, toggleGroup: 'zoom-list', checkable: true},
{caption: '175%', value: 175, toggleGroup: 'zoom-list', checkable: true},
{caption: '200%', value: 200, toggleGroup: 'zoom-list', checkable: true},
{caption: '300%', value: 300, toggleGroup: 'zoom-list', checkable: true},
{caption: '400%', value: 400, toggleGroup: 'zoom-list', checkable: true},
{caption: '500%', value: 500, toggleGroup: 'zoom-list', checkable: true},
]
})
},