mirror of
https://github.com/thelounge/thelounge
synced 2024-11-27 14:30:57 +00:00
Merge pull request #308 from thelounge/xpaw/fix-badge-format
Fix unread counter not being formatted on page load
This commit is contained in:
commit
dc6c36401b
3 changed files with 12 additions and 3 deletions
9
client/js/libs/handlebars/roundBadgeNumber.js
Normal file
9
client/js/libs/handlebars/roundBadgeNumber.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
Handlebars.registerHelper(
|
||||
"roundBadgeNumber", function(count) {
|
||||
if (count < 1000) {
|
||||
return count;
|
||||
}
|
||||
|
||||
return (count / 1000).toFixed(2).slice(0, -1) + "k";
|
||||
}
|
||||
);
|
|
@ -670,7 +670,7 @@ $(function() {
|
|||
self.addClass("active")
|
||||
.find(".badge")
|
||||
.removeClass("highlight")
|
||||
.data("count", "")
|
||||
.data("count", 0)
|
||||
.empty();
|
||||
|
||||
if (sidebar.find(".highlight").length === 0) {
|
||||
|
@ -845,7 +845,7 @@ $(function() {
|
|||
if (badge.length !== 0) {
|
||||
var i = (badge.data("count") || 0) + 1;
|
||||
badge.data("count", i);
|
||||
badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i);
|
||||
badge.html(Handlebars.helpers.roundBadgeNumber(i));
|
||||
if (msg.highlight) {
|
||||
badge.addClass("highlight");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{#each channels}}
|
||||
<div data-id="{{id}}" data-target="#chan-{{id}}" data-title="{{name}}" class="chan {{type}}">
|
||||
<span class="badge{{#if highlight}} highlight{{/if}}" data-count="{{unread}}">{{#if unread}}{{unread}}{{/if}}</span>
|
||||
<span class="badge{{#if highlight}} highlight{{/if}}" data-count="{{unread}}">{{#if unread}}{{roundBadgeNumber unread}}{{/if}}</span>
|
||||
<button class="close" aria-label="Close"></button>
|
||||
<span class="name" title="{{name}}">{{name}}</span>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue