mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
changed notifications code to jq - prevents crashes if notification element does not exist
This commit is contained in:
@@ -3,12 +3,12 @@ define(function() {
|
|||||||
|
|
||||||
Notifications.prepareDOM = function() {
|
Notifications.prepareDOM = function() {
|
||||||
// Notifications dropdown
|
// Notifications dropdown
|
||||||
var notifContainer = document.getElementsByClassName('notifications')[0],
|
var notifContainer = $('.notifications'),
|
||||||
notifTrigger = notifContainer.querySelector('a'),
|
notifTrigger = notifContainer.children('a'),
|
||||||
notifList = document.getElementById('notif-list'),
|
notifList = $('#notif-list'),
|
||||||
notifIcon = $('.notifications a i');
|
notifIcon = $('.notifications a i');
|
||||||
|
|
||||||
notifTrigger.addEventListener('click', function(e) {
|
notifTrigger.on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (notifContainer.className.indexOf('open') === -1) {
|
if (notifContainer.className.indexOf('open') === -1) {
|
||||||
socket.emit('notifications.get', null, function(err, data) {
|
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;
|
var target;
|
||||||
switch (e.target.nodeName) {
|
switch (e.target.nodeName) {
|
||||||
case 'SPAN':
|
case 'SPAN':
|
||||||
|
|||||||
Reference in New Issue
Block a user