Skip to content

Commit

Permalink
[DE PE SSE] Fix background plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaSvinareva committed Sep 20, 2023
1 parent b996bfb commit 7bd9a2f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 30 deletions.
59 changes: 33 additions & 26 deletions apps/common/main/lib/controller/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,23 +265,34 @@ define([
},

turnOffBackgroundPlugin: function (guid) {
var switcher;
this.backgroundPluginsSwitchers.forEach(function (item) {
if (item.options.pluginGuid === guid) {
switcher = item;
if (this.backgroundPluginsSwitchers) {
var switcher;
this.backgroundPluginsSwitchers.forEach(function (item) {
if (item.options.pluginGuid === guid) {
switcher = item;
}
});
if (switcher) {
switcher.updateHint(this.viewPlugins.textStart);
switcher.setValue(false);
return true;
}
});
if (switcher) {
switcher.updateHint(this.viewPlugins.textStart);
switcher.setValue(false);
return true;
return false;
}
return false;
},

onShowBeforeBackgroundPlugins: function (menu) {
var me = this;
me.clickInsideMenu = false;
var hideActiveMenu = function () {
var activeMenu = menu.cmpEl.find('.dropdown-toggle.active');
for (var i=0; i<activeMenu.length; i++) {
var m = activeMenu[i],
b = $(m).parent();
b.toggleClass('open', false);
$(m).trigger($.Event('hide.bs.dropdown'));
}
};
this.backgroundPluginsSwitchers = [];
this.backgroundPlugins.forEach(function (model) {
var modes = model.get('variations'),
Expand Down Expand Up @@ -345,24 +356,26 @@ define([
btn.menu.on('item:click', function (menu, item, e) {
Common.UI.Menu.Manager.hideAll();
me.viewPlugins.fireEvent('plugin:select', [menu.options.pluginGuid, item.value]);
}).on('keydown:before', function (menu, e) {
me.clickInsideMenu = false;
});
btn.menu.on('keydown:before', function (menu, e) {
if (e.keyCode == Common.UI.Keys.ESC) {
var btn = menu.cmpEl.parent();
if (btn.hasClass('open')) {
btn.toggleClass('open', false);
$(menu.el).trigger($.Event('hide.bs.dropdown'));
_.delay(function(){
btn.closest('.btn-group.open').find('[data-toggle=dropdown]:first').focus();
}, 10);
}
hideActiveMenu();
_.delay(function(){
btn.cmpEl.closest('.btn-group.open').find('[data-toggle=dropdown]:first').focus();
}, 10);
}
});
btn.menu.cmpEl.find('li').on('mousedown', function () {
me.clickInsideMenu = true;
});
btn.cmpEl.on('mousedown', function () {
me.clickInsideMenu = true;
});
btn.on('click', function () {
var btnGroup = btn.$el.find('.btn-group'),
isOpen = btnGroup.hasClass('open');
if (!isOpen) hideActiveMenu();
btnGroup.toggleClass('open', !isOpen);
$(btn.menu.el).trigger($.Event(!isOpen ? 'show.bs.dropdown' : 'hide.bs.dropdown'));
me.clickInsideMenu = false;
Expand All @@ -371,13 +384,7 @@ define([
});
menu.cmpEl.find('li').on('mousedown', function () {
if (me.clickInsideMenu) return;
var activeMenu = menu.cmpEl.find('.dropdown-toggle.active');
for (var i=0; i<activeMenu.length; i++) {
var m = activeMenu[i],
btn = $(m).parent();
btn.toggleClass('open', false);
$(m).trigger($.Event('hide.bs.dropdown'));
}
hideActiveMenu();
});
},

Expand Down
6 changes: 4 additions & 2 deletions apps/common/main/lib/view/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ define([
},

createBackgroundPluginsButton: function () {
var _set = Common.enumLock;
var btn = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-background-plugins',
Expand All @@ -325,10 +326,11 @@ define([
template: _.template('<div class="menu-header">' + this.textTheListOfBackgroundPlugins + '</div>'),
stopPropagation: true
}
]
],
restoreHeight: true
}),
hint: this.textBackgroundPlugins,
//lock: model.get('isDisplayedInViewer') ? [_set.viewMode, _set.previewReviewMode, _set.viewFormMode, _set.selRangeEdit, _set.editFormula] : [_set.viewMode, _set.previewReviewMode, _set.viewFormMode, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.selRangeEdit, _set.editFormula ],
lock: [_set.viewMode, _set.previewReviewMode, _set.viewFormMode, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.selRangeEdit, _set.editFormula],
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
Expand Down
6 changes: 4 additions & 2 deletions apps/common/main/resources/less/toolbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -999,12 +999,12 @@ section .field-styles {
.menu-header {
display: block;
font-weight: bold;
padding: 10px 20px;
padding: 10px 16px;
}
> li > .menu-item {
display: flex;
align-items: center;
padding: 10px 20px;
padding: 8px 16px;
.menu-item-icon {
float: none;
margin: 0;
Expand All @@ -1014,10 +1014,12 @@ section .field-styles {
}
.plugin-caption {
flex-basis: 100%;
padding-top: 3px;
}
.plugin-tools {
display: flex;
.float-right();
padding-top: 2px;
.plugin-toggle {
display: flex;
align-items: center;
Expand Down
1 change: 1 addition & 0 deletions apps/presentationeditor/main/resources/less/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
@import "../../../../common/main/resources/less/scroller.less";
@import "../../../../common/main/resources/less/synchronize-tip.less";
@import "../../../../common/main/resources/less/common.less";
@import "../../../../common/main/resources/less/switcher.less";
@import "../../../../common/main/resources/less/opendialog.less";
@import "../../../../common/main/resources/less/plugins.less";
@import "../../../../common/main/resources/less/toolbar.less";
Expand Down
1 change: 1 addition & 0 deletions apps/spreadsheeteditor/main/resources/less/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
@import "../../../../common/main/resources/less/synchronize-tip.less";
@import "../../../../common/main/resources/less/tabbar.less";
@import "../../../../common/main/resources/less/common.less";
@import "../../../../common/main/resources/less/switcher.less";
@import "../../../../common/main/resources/less/opendialog.less";
@import "../../../../common/main/resources/less/plugins.less";
@import "../../../../common/main/resources/less/toolbar.less";
Expand Down

0 comments on commit 7bd9a2f

Please sign in to comment.