diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js index 00fe47dc7..33c5f0dc2 100644 --- a/modules/UI/side_pannels/chat/Chat.js +++ b/modules/UI/side_pannels/chat/Chat.js @@ -315,7 +315,7 @@ var Chat = { * Indicates if the chat is currently visible. */ isVisible () { - return $('#chatspace').is(":visible"); + return UIUtil.isVisible(document.getElementById("chatspace")); }, /** * Shows and hides the window with the smileys diff --git a/modules/UI/side_pannels/contactlist/ContactList.js b/modules/UI/side_pannels/contactlist/ContactList.js index aa743afa9..267b78d7e 100644 --- a/modules/UI/side_pannels/contactlist/ContactList.js +++ b/modules/UI/side_pannels/contactlist/ContactList.js @@ -1,6 +1,7 @@ /* global $, APP */ import Avatar from '../../avatar/Avatar'; import UIEvents from '../../../../service/UI/UIEvents'; +import UIUtil from '../../util/UIUtil'; let numberOfContacts = 0; let notificationInterval; @@ -87,7 +88,7 @@ var ContactList = { * otherwise */ isVisible () { - return $('#contactlist').is(":visible"); + return UIUtil.isVisible(document.getElementById("contactlist")); }, /** diff --git a/modules/UI/side_pannels/settings/SettingsMenu.js b/modules/UI/side_pannels/settings/SettingsMenu.js index 266f10e78..ffebeaf20 100644 --- a/modules/UI/side_pannels/settings/SettingsMenu.js +++ b/modules/UI/side_pannels/settings/SettingsMenu.js @@ -161,7 +161,7 @@ export default { * @returns {boolean} */ isVisible () { - return $('#settingsmenu').is(':visible'); + return UIUtil.isVisible(document.getElementById("settingsmenu")); }, /** diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.js index ab284805f..4e3e381e3 100644 --- a/modules/UI/util/UIUtil.js +++ b/modules/UI/util/UIUtil.js @@ -155,7 +155,18 @@ return Object.keys(attrs).map( key => ` ${key}="${attrs[key]}"` ).join(' '); - } + }, + + /** + * Checks if the given DOM element is currently visible. The offsetParent + * will be null if the "display" property of the element or any of its + * parent containers is set to "none". This method will NOT check the + * visibility property though. + * @param {el} The DOM element we'd like to check for visibility + */ + isVisible(el) { + return (el.offsetParent !== null); + } }; export default UIUtil;