Commit c6c0ced9b9a647794d1524ff7bbce61949f38939
1 parent
b8e418aa
Exists in
master
and in
29 other branches
Filter chat-rooms
Showing
1 changed file
with
26 additions
and
0 deletions
Show diff stats
public/javascripts/chat.js
... | ... | @@ -727,4 +727,30 @@ jQuery(function($) { |
727 | 727 | $('#chat-busy').trigger('click'); |
728 | 728 | } |
729 | 729 | $('#chat #buddy-list').perfectScrollbar(); |
730 | + | |
731 | + // custom css expression for a case-insensitive contains() | |
732 | + jQuery.expr[':'].Contains = function(a,i,m){ | |
733 | + return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0; | |
734 | + }; | |
735 | + | |
736 | + $('#chat .search').change( function () { | |
737 | + var filter = $(this).val(); | |
738 | + var list = $('#buddy-list .buddies a'); | |
739 | + if(filter) { | |
740 | + // this finds all links in a list that contain the input, | |
741 | + // and hide the ones not containing the input while showing the ones that do | |
742 | + $(list).find("span:not(:Contains(" + filter + "))").parent().hide(); | |
743 | + $(list).find("span:Contains(" + filter + ")").parent().show(); | |
744 | + } else { | |
745 | + $(list).show(); | |
746 | + } | |
747 | + return false; | |
748 | + }).keyup( function () { | |
749 | + // fire the above change event after every letter | |
750 | + $(this).change(); | |
751 | + }); | |
752 | + | |
753 | + $('#chat .buddies a').live('click', function(){ | |
754 | + $('#chat .search').val('').change(); | |
755 | + }); | |
730 | 756 | }); | ... | ... |