Skip to content

Commit

Permalink
[PE SSE] Add plugins in right panel
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaSvinareva committed Dec 4, 2023
1 parent 96ff136 commit 914d898
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 17 deletions.
44 changes: 42 additions & 2 deletions apps/presentationeditor/main/app/controller/RightMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ define([

this.addListeners({
'RightMenu': {
'rightmenuclick': this.onRightMenuClick
'rightmenuclick': this.onRightMenuClick,
'button:click': _.bind(this.onBtnCategoryClick, this)
},
'ViewTab': {
'rightmenu:hide': _.bind(this.onRightMenuHide, this)
},
'Common.Views.Plugins': {
'plugins:addtoright': _.bind(this.addNewPlugin, this),
'pluginsright:open': _.bind(this.openPlugin, this),
'pluginsright:close': _.bind(this.closePlugin, this),
'pluginsright:hide': _.bind(this.onHidePlugins, this)
}
});
},
Expand Down Expand Up @@ -440,6 +447,39 @@ define([

Common.NotificationCenter.trigger('layout:changed', 'main');
Common.NotificationCenter.trigger('edit:complete', this.rightmenu);
}
},

addNewPlugin: function (button, $button, $panel) {
this.rightmenu.insertButton(button, $button);
this.rightmenu.insertPanel($panel);
},

openPlugin: function (guid) {
this.rightmenu.openPlugin(guid);
},

closePlugin: function (guid) {
this.rightmenu.closePlugin(guid);
this.rightmenu.onBtnMenuClick();
Common.NotificationCenter.trigger('layout:changed', 'rightmenu');
this.rightmenu.fireEvent('editcomplete', this.rightmenu);
},

onHidePlugins: function() {
Common.NotificationCenter.trigger('layout:changed', 'rightmenu');
},

onBtnCategoryClick: function (btn) {
if (btn.options.type === 'plugin' && !btn.isDisabled()) {
this.rightmenu.onBtnMenuClick(btn);
if (btn.pressed) {
this.rightmenu.fireEvent('plugins:showpanel', [btn.options.value]); // show plugin panel
} else {
this.rightmenu.fireEvent('plugins:hidepanel', [btn.options.value]);
}
Common.NotificationCenter.trigger('layout:changed', 'rightmenu');
this.rightmenu.fireEvent('editcomplete', this.rightmenu);
}
},
});
});
18 changes: 11 additions & 7 deletions apps/presentationeditor/main/app/view/RightMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,14 @@ define([
},

onBtnMenuClick: function(btn, e) {
var target_pane = $("#" + this._settings[btn.options.asctype].panel);
var target_pane_parent = target_pane.parent();
var isPlugin = btn && btn.options.type === 'plugin',
target_pane_parent = $(this.el).find('.right-panel'),
target_pane;
if (btn && !isPlugin) {
target_pane = $("#" + this._settings[btn.options.asctype].panel);
}

if (btn.pressed) {
if (btn && btn.pressed) {
if ( this.minimizedMode ) {
$(this.el).width(MENU_SCALE_PART);
target_pane_parent.css("display", "inline-block" );
Expand All @@ -262,12 +266,11 @@ define([
Common.Utils.InternalSettings.set("pe-hide-right-settings", false);
}
target_pane_parent.find('> .active').removeClass('active');
target_pane.addClass("active");
target_pane && target_pane.addClass("active");

if (this.scroller) {
this.scroller.scrollTop(0);
}
this._settings[Common.Utils.documentSettingsType.Slide].isCurrent = (btn.options.asctype==Common.Utils.documentSettingsType.Slide);
} else {
target_pane_parent.css("display", "none" );
$(this.el).width(SCALE_MIN);
Expand All @@ -276,7 +279,7 @@ define([
Common.Utils.InternalSettings.set("pe-hide-right-settings", true);
}

this.fireEvent('rightmenuclick', [this, btn.options.asctype, this.minimizedMode, e]);
btn && !isPlugin && this.fireEvent('rightmenuclick', [this, btn.options.asctype, this.minimizedMode, e]);
},

SetActivePane: function(type, open) {
Expand All @@ -301,7 +304,8 @@ define([
},

GetActivePane: function() {
return (this.minimizedMode) ? null : this.$el.find(".settings-panel.active")[0].id;
var active = this.$el.find(".settings-panel.active");
return (this.minimizedMode || active.length === 0) ? null : active[0].id;
},

clearSelection: function() {
Expand Down
44 changes: 42 additions & 2 deletions apps/spreadsheeteditor/main/app/controller/RightMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ define([
'inserttable': this.onInsertTable.bind(this)
},
'RightMenu': {
'rightmenuclick': this.onRightMenuClick
'rightmenuclick': this.onRightMenuClick,
'button:click': _.bind(this.onBtnCategoryClick, this)
},
'PivotTable': {
'insertpivot': this.onInsertPivot
},
'ViewTab': {
'rightmenu:hide': this.onRightMenuHide.bind(this)
},
'Common.Views.Plugins': {
'plugins:addtoright': _.bind(this.addNewPlugin, this),
'pluginsright:open': _.bind(this.openPlugin, this),
'pluginsright:close': _.bind(this.closePlugin, this),
'pluginsright:hide': _.bind(this.onHidePlugins, this)
}
});

Expand Down Expand Up @@ -520,6 +527,39 @@ define([

Common.NotificationCenter.trigger('layout:changed', 'main');
Common.NotificationCenter.trigger('edit:complete', this.rightmenu);
}
},

addNewPlugin: function (button, $button, $panel) {
this.rightmenu.insertButton(button, $button);
this.rightmenu.insertPanel($panel);
},

openPlugin: function (guid) {
this.rightmenu.openPlugin(guid);
},

closePlugin: function (guid) {
this.rightmenu.closePlugin(guid);
this.rightmenu.onBtnMenuClick();
Common.NotificationCenter.trigger('layout:changed', 'rightmenu');
this.rightmenu.fireEvent('editcomplete', this.rightmenu);
},

onHidePlugins: function() {
Common.NotificationCenter.trigger('layout:changed', 'rightmenu');
},

onBtnCategoryClick: function (btn) {
if (btn.options.type === 'plugin' && !btn.isDisabled()) {
this.rightmenu.onBtnMenuClick(btn);
if (btn.pressed) {
this.rightmenu.fireEvent('plugins:showpanel', [btn.options.value]); // show plugin panel
} else {
this.rightmenu.fireEvent('plugins:hidepanel', [btn.options.value]);
}
Common.NotificationCenter.trigger('layout:changed', 'rightmenu');
this.rightmenu.fireEvent('editcomplete', this.rightmenu);
}
},
});
});
17 changes: 11 additions & 6 deletions apps/spreadsheeteditor/main/app/view/RightMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,14 @@ define([
},

onBtnMenuClick: function(btn, e) {
var target_pane = $("#" + this._settings[btn.options.asctype].panel);
var target_pane_parent = target_pane.parent();
var isPlugin = btn && btn.options.type === 'plugin',
target_pane_parent = $(this.el).find('.right-panel'),
target_pane;
if (btn && !isPlugin) {
target_pane = $("#" + this._settings[btn.options.asctype].panel);
}

if (btn.pressed) {
if (btn && btn.pressed) {
if ( this.minimizedMode ) {
$(this.el).width(MENU_SCALE_PART);
target_pane_parent.css("display", "inline-block" );
Expand All @@ -301,7 +305,7 @@ define([
Common.Utils.InternalSettings.set("sse-hide-right-settings", false);
}
target_pane_parent.find('> .active').removeClass('active');
target_pane.addClass("active");
target_pane && target_pane.addClass("active");

if (this.scroller) {
this.scroller.scrollTop(0);
Expand All @@ -314,7 +318,7 @@ define([
Common.Utils.InternalSettings.set("sse-hide-right-settings", true);
}

this.fireEvent('rightmenuclick', [this, btn.options.asctype, this.minimizedMode, e]);
btn && !isPlugin && this.fireEvent('rightmenuclick', [this, btn.options.asctype, this.minimizedMode, e]);
},

SetActivePane: function(type, open) {
Expand All @@ -339,7 +343,8 @@ define([
},

GetActivePane: function() {
return (this.minimizedMode) ? null : this.$el.find(".settings-panel.active")[0].id;
var active = this.$el.find(".settings-panel.active");
return (this.minimizedMode || active.length === 0) ? null : active[0].id;
},

clearSelection: function() {
Expand Down

0 comments on commit 914d898

Please sign in to comment.