Skip to content

Commit

Permalink
refactor: some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Nov 10, 2024
1 parent 7be761c commit c1c62b9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cms/static/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ function(
$('.nav-dd .nav-item .wrapper-nav-sub').removeClass('is-shown');
$('.nav-dd .nav-item .title').removeClass('is-selected');
$('.custom-dropdown .dropdown-options').hide();

try {
window.parent.postMessage(
{
type: 'toggleDropdownMenu',
message: 'Sends a message when the dropdown menu is closed',
payload: {
subMenuHeight: 0,
}
}, document.referrer
);
} catch (e) {
console.error(e);
}
});

$('.nav-dd .nav-item, .filterable-column .nav-item').click(function(e) {
Expand Down
16 changes: 16 additions & 0 deletions cms/static/js/views/pages/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,22 @@ function($, _, Backbone, gettext, BasePage,
// Code in 'base.js' normally handles toggling these dropdowns but since this one is
// not present yet during the domReady event, we have to handle displaying it ourselves.
subMenu.classList.toggle('is-shown');

try {
if (this.options.isIframeEmbed) {
window.parent.postMessage(
{
type: 'toggleDropdownMenu',
message: 'Sends a message when the dropdown menu is toggled',
payload: {
subMenuHeight: subMenu.offsetHeight,
}
}, document.referrer
);
}
} catch (e) {
console.error(e);
}
// if propagation is not stopped, the event will bubble up to the
// body element, which will close the dropdown.
event.stopPropagation();
Expand Down
2 changes: 1 addition & 1 deletion cms/static/js/views/pages/container_subviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ function($, _, gettext, BaseView, ViewUtils, XBlockViewUtils, MoveXBlockUtils, H
tagValueElement.className = 'tagging-label-value';

tagContentElement.appendChild(tagValueElement);
parentElement.appendChild(tagContentElement);
parentElement?.appendChild(tagContentElement);

if (tag.children.length > 0) {
var tagIconElement = document.createElement('span'),
Expand Down

0 comments on commit c1c62b9

Please sign in to comment.