From: Jack Allnutt Date: Sun, 4 Sep 2011 16:22:22 +0000 (+0100) Subject: Re-clicking a nick will now collapse the userbox X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ef885bffe8e010ba327a5884c6a8de7239c80340;p=KiwiIRC.git Re-clicking a nick will now collapse the userbox --- diff --git a/js/front.js b/js/front.js index 7f46057..6b48ecc 100644 --- a/js/front.js +++ b/js/front.js @@ -959,27 +959,27 @@ var front = { userClick: function (item) { + var li = $(item).parent(); + // Remove any existing userboxes $('#kiwi .userbox').remove(); - - var li = $(item).parent(); - /*var html = '
\ - \ - Message\ - Info\ -
'; - li.append(html);*/ - $('#tmpl_user_box').tmpl({nick: front.nickStripPrefix($(item).text())}).appendTo(li); - - $('#kiwi .userbox .userbox_query').click(function (ev) { - var nick = $('#kiwi .userbox_nick').val(); - front.run('/query ' + nick); - }); - - $('#kiwi .userbox .userbox_whois').click(function (ev) { - var nick = $('#kiwi .userbox_nick').val(); - front.run('/whois ' + nick); - }); + + if ($(li).data('userbox') === item) { + $(li).removeData('userbox'); + } else { + $('#tmpl_user_box').tmpl({nick: front.nickStripPrefix($(item).text())}).appendTo(li); + + $('#kiwi .userbox .userbox_query').click(function (ev) { + var nick = $('#kiwi .userbox_nick').val(); + front.run('/query ' + nick); + }); + + $('#kiwi .userbox .userbox_whois').click(function (ev) { + var nick = $('#kiwi .userbox_nick').val(); + front.run('/whois ' + nick); + }); + $(li).data('userbox', item); + } },