|
@@ -244,40 +244,43 @@ $(function() {
|
|
|
|
|
|
// channel list filter
|
|
|
|
|
|
- if ($('#channel-list').length) {
|
|
|
+ function update_filtered() {
|
|
|
+ var filter = $('#filter').val().trim().toLowerCase();
|
|
|
+ if (filter === '') {
|
|
|
+ $('#archived-channels').show();
|
|
|
+ } else {
|
|
|
+ $('#archived-channels').hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ var filter_words = filter.split(/ +/);
|
|
|
+ $('#active-channels li').each(function() {
|
|
|
+ var $this = $(this);
|
|
|
+ var this_text = $this.data('text');
|
|
|
+ var match = true;
|
|
|
+ for (var i = 0, l = filter_words.length; i < l; i++) {
|
|
|
+ if (this_text.indexOf(filter_words[i]) === -1) {
|
|
|
+ match = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (match) {
|
|
|
+ $this.show();
|
|
|
+ } else {
|
|
|
+ $this.hide();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if ($('#active-channels li:visible').length === 0) {
|
|
|
+ $('#no-results').show();
|
|
|
+ } else {
|
|
|
+ $('#no-results').hide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($('body').hasClass('list')) {
|
|
|
$('#filter')
|
|
|
.focus()
|
|
|
.select()
|
|
|
- .keyup(function(e) {
|
|
|
- var filter = this.value.trim().toLowerCase();
|
|
|
- if (filter === '') {
|
|
|
- $('#archived-channels').show();
|
|
|
- } else {
|
|
|
- $('#archived-channels').hide();
|
|
|
- }
|
|
|
- var filter_words = filter.split(/ +/);
|
|
|
- $('#active-channels li').each(function() {
|
|
|
- var $this = $(this);
|
|
|
- var this_text = $this.data('text');
|
|
|
- var match = true;
|
|
|
- for (var i = 0, l = filter_words.length; i < l; i++) {
|
|
|
- if (this_text.indexOf(filter_words[i]) === -1) {
|
|
|
- match = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (match) {
|
|
|
- $this.show();
|
|
|
- } else {
|
|
|
- $this.hide();
|
|
|
- }
|
|
|
- });
|
|
|
- if ($('#active-channels li:visible').length === 0) {
|
|
|
- $('#no-results').show();
|
|
|
- } else {
|
|
|
- $('#no-results').hide();
|
|
|
- }
|
|
|
- })
|
|
|
+ .keyup(update_filtered)
|
|
|
.keypress(function(e) {
|
|
|
if (e.which === 13) {
|
|
|
e.preventDefault();
|
|
@@ -286,6 +289,11 @@ $(function() {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ $(window).on('pageshow', function(e) {
|
|
|
+ update_filtered();
|
|
|
+ $('#filter').focus();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
// highlight
|