Fix(SideContainerToggler.js): Check if the component exists on init

This commit is contained in:
yanas 2017-04-06 13:25:11 -05:00 committed by Lyubo Marinov
parent 8be85de6ef
commit cb0eef9edd
1 changed files with 17 additions and 7 deletions

View File

@ -16,17 +16,27 @@ const SideContainerToggler = {
init(eventEmitter) { init(eventEmitter) {
this.eventEmitter = eventEmitter; this.eventEmitter = eventEmitter;
// Adds a listener for the animation end event that would take care // We may not have a side toolbar container, for example, in
// of hiding all internal containers when the extendedToolbarPanel is // filmstrip-only mode.
const sideToolbarContainer
= document.getElementById("sideToolbarContainer");
if (!sideToolbarContainer)
return;
// Adds a listener for the animationend event that would take care of
// hiding all internal containers when the extendedToolbarPanel is
// closed. // closed.
document.getElementById("sideToolbarContainer") sideToolbarContainer.addEventListener(
.addEventListener("animationend", function(e) { "animationend",
if(e.animationName === "slideOutExt") function(e) {
if (e.animationName === "slideOutExt")
$("#sideToolbarContainer").children().each(function() { $("#sideToolbarContainer").children().each(function() {
if ($(this).hasClass("show")) if ($(this).hasClass("show"))
SideContainerToggler.hideInnerContainer($(this)); SideContainerToggler.hideInnerContainer($(this));
}); });
}, false); },
false);
}, },
/** /**
@ -134,4 +144,4 @@ const SideContainerToggler = {
} }
}; };
export default SideContainerToggler; export default SideContainerToggler;