mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
hooks: allow to set the duration of the gritter notification when a new chat message arrives
This is done adding a new "duration" parameter to the chatNewMessage() client side hook.
This commit is contained in:
parent
8a01a5e437
commit
7a999ee398
2 changed files with 5 additions and 3 deletions
|
@ -223,6 +223,7 @@ Things in context:
|
||||||
4. sticky (boolean) - if you want the gritter notification bubble to fade out on its own or just sit there
|
4. sticky (boolean) - if you want the gritter notification bubble to fade out on its own or just sit there
|
||||||
5. timestamp - the timestamp of the chat message
|
5. timestamp - the timestamp of the chat message
|
||||||
6. timeStr - the timestamp as a formatted string
|
6. timeStr - the timestamp as a formatted string
|
||||||
|
7. duration - for how long in milliseconds should the gritter notification appear (0 to disable)
|
||||||
|
|
||||||
This hook is called on the client side whenever a chat message is received from the server. It can be used to create different notifications for chat messages.
|
This hook is called on the client side whenever a chat message is received from the server. It can be used to create different notifications for chat messages.
|
||||||
|
|
||||||
|
|
7
src/static/js/chat.js
Normal file → Executable file
7
src/static/js/chat.js
Normal file → Executable file
|
@ -149,7 +149,8 @@ var chat = (function()
|
||||||
"text" : text,
|
"text" : text,
|
||||||
"sticky" : false,
|
"sticky" : false,
|
||||||
"timestamp" : msg.time,
|
"timestamp" : msg.time,
|
||||||
"timeStr" : timeStr
|
"timeStr" : timeStr,
|
||||||
|
"duration" : 4000
|
||||||
}
|
}
|
||||||
|
|
||||||
// is the users focus already in the chatbox?
|
// is the users focus already in the chatbox?
|
||||||
|
@ -186,7 +187,7 @@ var chat = (function()
|
||||||
count++;
|
count++;
|
||||||
$("#chatcounter").text(count);
|
$("#chatcounter").text(count);
|
||||||
|
|
||||||
if(!chatOpen) {
|
if(!chatOpen && ctx.duration > 0) {
|
||||||
$.gritter.add({
|
$.gritter.add({
|
||||||
// (string | mandatory) the heading of the notification
|
// (string | mandatory) the heading of the notification
|
||||||
title: ctx.authorName,
|
title: ctx.authorName,
|
||||||
|
@ -195,7 +196,7 @@ var chat = (function()
|
||||||
// (bool | optional) if you want it to fade out on its own or just sit there
|
// (bool | optional) if you want it to fade out on its own or just sit there
|
||||||
sticky: ctx.sticky,
|
sticky: ctx.sticky,
|
||||||
// (int | optional) the time you want it to be alive for before fading out
|
// (int | optional) the time you want it to be alive for before fading out
|
||||||
time: '4000'
|
time: ctx.duration
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue