From 24d2ac270cb558ece849d9016bc303a1fe73bb4f Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 30 Jan 2014 11:06:23 -0500 Subject: [PATCH] changed notifications code to jq - prevents crashes if notification element does not exist --- public/src/modules/notifications.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js index 43b614d339..e00f366cbd 100644 --- a/public/src/modules/notifications.js +++ b/public/src/modules/notifications.js @@ -3,12 +3,12 @@ define(function() { Notifications.prepareDOM = function() { // Notifications dropdown - var notifContainer = document.getElementsByClassName('notifications')[0], - notifTrigger = notifContainer.querySelector('a'), - notifList = document.getElementById('notif-list'), + var notifContainer = $('.notifications'), + notifTrigger = notifContainer.children('a'), + notifList = $('#notif-list'), notifIcon = $('.notifications a i'); - notifTrigger.addEventListener('click', function(e) { + notifTrigger.on('click', function(e) { e.preventDefault(); if (notifContainer.className.indexOf('open') === -1) { socket.emit('notifications.get', null, function(err, data) { @@ -58,7 +58,7 @@ define(function() { } }); - notifList.addEventListener('click', function(e) { + notifList.on('click', function(e) { var target; switch (e.target.nodeName) { case 'SPAN':