From f4e9b605e2efa00b479874ac2722e19493152c93 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 21 Sep 2015 18:34:04 -0400 Subject: [PATCH] fix notifs loading on slide out --- lib/persona.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/persona.js b/lib/persona.js index 1222b7b..bfd56f2 100644 --- a/lib/persona.js +++ b/lib/persona.js @@ -173,14 +173,6 @@ $(document).ready(function() { $('#mobile-menu').on('click', function() { $('#menu').show(); - - if (!slideout.isOpen()) { - require(['chat', 'notifications'], function(chat, notifications) { - chat.loadChatsDropdown($('#menu [data-section="chats"] ul')); - notifications.loadNotifications($('#menu [data-section="notifications"] ul')); - }); - } - slideout.toggle(); }); @@ -196,18 +188,32 @@ $(document).ready(function() { slideout.close(); }); - function onOpeningMenu() { + function openingMenuAndLoad() { + openingMenu(); + loadNotificationsAndChat(); + } + + function openingMenu() { $('#menu').show(); $('#header-menu').css({ 'top': $(window).scrollTop() + 'px', 'position': 'absolute' }); + + loadNotificationsAndChat(); + } + + function loadNotificationsAndChat() { + require(['chat', 'notifications'], function(chat, notifications) { + chat.loadChatsDropdown($('#menu [data-section="chats"] ul')); + notifications.loadNotifications($('#menu [data-section="notifications"] ul')); + }); } - slideout.on('beforeopen', onOpeningMenu); - slideout.on('open', onOpeningMenu); - slideout.on('translate', onOpeningMenu); + slideout.on('beforeopen', openingMenuAndLoad); + slideout.on('open', openingMenuAndLoad); + slideout.on('translate', openingMenu); slideout.on('close', function() { $('#header-menu').css({