mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
moved refreshTitle into app.js, messaging someone now invokes an alternating title, hehe
This commit is contained in:
@@ -119,7 +119,7 @@ var ajaxify = {};
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.refreshTitle(url);
|
app.refreshTitle(url);
|
||||||
|
|
||||||
}, url, template);
|
}, url, template);
|
||||||
|
|
||||||
|
|||||||
@@ -396,7 +396,44 @@ var socket,
|
|||||||
$('body,html').animate({
|
$('body,html').animate({
|
||||||
scrollTop: $('html').height() - 100
|
scrollTop: $('html').height() - 100
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var titleObj = {
|
||||||
|
active: false,
|
||||||
|
interval: undefined,
|
||||||
|
titles: []
|
||||||
|
};
|
||||||
|
app.alternatingTitle = function (title) {
|
||||||
|
if (typeof title !== 'string') return;
|
||||||
|
|
||||||
|
if (title.length > 0) {
|
||||||
|
titleObj.titles[1] = title;
|
||||||
|
if (titleObj.interval) {
|
||||||
|
clearInterval(titleObj.interval);
|
||||||
}
|
}
|
||||||
|
titleObj.interval = setInterval(function() {
|
||||||
|
window.document.title = titleObj.titles[titleObj.titles.indexOf(window.document.title) ^ 1];
|
||||||
|
}, 2000);
|
||||||
|
} else {
|
||||||
|
if (titleObj.interval) {
|
||||||
|
clearInterval(titleObj.interval);
|
||||||
|
}
|
||||||
|
if (titleObj.titles[0]) window.document.title = titleObj.titles[0];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
app.refreshTitle = function(url) {
|
||||||
|
if (!url) {
|
||||||
|
var a = document.createElement('a');
|
||||||
|
a.href = document.location;
|
||||||
|
url = a.pathname.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.emit('api:meta.buildTitle', url, function(title, numNotifications) {
|
||||||
|
titleObj.titles[0] = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
|
||||||
|
app.alternatingTitle('');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
jQuery('document').ready(function () {
|
jQuery('document').ready(function () {
|
||||||
$('#search-form').on('submit', function () {
|
$('#search-form').on('submit', function () {
|
||||||
@@ -410,5 +447,5 @@ var socket,
|
|||||||
showWelcomeMessage = location.href.indexOf('loggedin') !== -1;
|
showWelcomeMessage = location.href.indexOf('loggedin') !== -1;
|
||||||
|
|
||||||
app.loadConfig();
|
app.loadConfig();
|
||||||
|
app.alternatingTitle('');
|
||||||
}());
|
}());
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
|
|
||||||
socket.emit('api:notifications.mark_all_read', null, function() {
|
socket.emit('api:notifications.mark_all_read', null, function() {
|
||||||
notifIcon.toggleClass('active', false);
|
notifIcon.toggleClass('active', false);
|
||||||
utils.refreshTitle();
|
app.refreshTitle();
|
||||||
|
|
||||||
// Update favicon + local count
|
// Update favicon + local count
|
||||||
Tinycon.setBubble(0);
|
Tinycon.setBubble(0);
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
type: 'warning',
|
type: 'warning',
|
||||||
timeout: 2000
|
timeout: 2000
|
||||||
});
|
});
|
||||||
utils.refreshTitle();
|
app.refreshTitle();
|
||||||
|
|
||||||
// Update the favicon + local storage
|
// Update the favicon + local storage
|
||||||
var savedCount = parseInt(localStorage.getItem('notifications:count'),10) || 0;
|
var savedCount = parseInt(localStorage.getItem('notifications:count'),10) || 0;
|
||||||
@@ -209,7 +209,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('chatMessage', function(data) {
|
socket.on('chatMessage', function(data) {
|
||||||
|
|
||||||
require(['chat'], function(chat) {
|
require(['chat'], function(chat) {
|
||||||
var modal = null;
|
var modal = null;
|
||||||
if (chat.modalExists(data.fromuid)) {
|
if (chat.modalExists(data.fromuid)) {
|
||||||
@@ -220,10 +219,12 @@
|
|||||||
chat.load(modal.attr('UUID'));
|
chat.load(modal.attr('UUID'));
|
||||||
} else {
|
} else {
|
||||||
chat.toggleNew(modal.attr('UUID'), true);
|
chat.toggleNew(modal.attr('UUID'), true);
|
||||||
|
app.alternatingTitle(data.username + ' has messaged you');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
modal = chat.createModal(data.username, data.fromuid);
|
modal = chat.createModal(data.username, data.fromuid);
|
||||||
chat.toggleNew(modal.attr('UUID'), true);
|
chat.toggleNew(modal.attr('UUID'), true);
|
||||||
|
app.alternatingTitle(data.username + ' has messaged you');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ define(function() {
|
|||||||
taskbar.minimizeAll();
|
taskbar.minimizeAll();
|
||||||
module.load(uuid);
|
module.load(uuid);
|
||||||
taskbar.toggleNew(uuid, false);
|
taskbar.toggleNew(uuid, false);
|
||||||
|
app.alternatingTitle('');
|
||||||
|
|
||||||
// Highlight the button
|
// Highlight the button
|
||||||
$(taskbar.tasklist).removeClass('active');
|
$(taskbar.tasklist).removeClass('active');
|
||||||
|
|||||||
@@ -169,23 +169,6 @@
|
|||||||
return tags;
|
return tags;
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshTitle: function(url) {
|
|
||||||
if (!url) {
|
|
||||||
var a = document.createElement('a');
|
|
||||||
a.href = document.location;
|
|
||||||
url = a.pathname.slice(1);
|
|
||||||
}
|
|
||||||
var notificationIcon;
|
|
||||||
|
|
||||||
socket.emit('api:meta.buildTitle', url, function(title, numNotifications) {
|
|
||||||
document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
|
|
||||||
notificationIcon = notificationIcon || document.querySelector('.notifications a i');
|
|
||||||
if (numNotifications > 0 && notificationIcon) {
|
|
||||||
notificationIcon.className = 'fa fa-circle active';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
isRelativeUrl: function(url) {
|
isRelativeUrl: function(url) {
|
||||||
var firstChar = url.slice(0, 1);
|
var firstChar = url.slice(0, 1);
|
||||||
return (firstChar === '.' || firstChar === '/');
|
return (firstChar === '.' || firstChar === '/');
|
||||||
|
|||||||
@@ -1159,5 +1159,3 @@ websockets.init = function(io) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(module.exports);
|
})(module.exports);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user