Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#3028] Followee dropdown on dashboard is now searchable via ajax
- Loading branch information
1 parent
6ef49b7
commit 90b176e
Showing
2 changed files
with
39 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,54 @@ | ||
this.ckan.module('dashboard', function ($, _) { | ||
|
||
return { | ||
button: null, | ||
popover: null, | ||
searchTimeout: null, | ||
initialize: function () { | ||
$.proxyAll(this, /_on/); | ||
|
||
var popover = $('#followee-filter .btn') | ||
.on('click', function() { | ||
var $this = $(this); | ||
$this.toggleClass('active'); | ||
if ($this.hasClass('active')) { | ||
setTimeout(function() { | ||
$('input', $this.data('popover').tip()).focus(); | ||
}, 100); | ||
} | ||
return false; | ||
}). | ||
this.button = $('#followee-filter .btn'). | ||
on('click', this._onShowFolloweeDropdown). | ||
popover({ | ||
placement: 'bottom', | ||
title: 'Filter', | ||
html: true, | ||
content: $('#followee-popover').html() | ||
}). | ||
data('popover').tip().addClass('popover-followee'); | ||
|
||
}); | ||
this.popover = this.button.data('popover').tip().addClass('popover-followee'); | ||
if ($('.new', this.el)) { | ||
setTimeout(function() { | ||
$('.masthead .notifications').removeClass('notifications-important').html('0'); | ||
}, 1000); | ||
} | ||
}, | ||
_onInitSearch: function() { | ||
var input = $('input', this.popover); | ||
if (!input.hasClass('inited')) { | ||
input. | ||
on('keyup', this._onSearchKeyUp). | ||
addClass('inited'); | ||
} | ||
input.focus(); | ||
}, | ||
_onSearchKeyUp: function() { | ||
clearTimeout(this.searchTimeout); | ||
this.searchTimeout = setTimeout(this._onSearchKeyUpTimeout, 300); | ||
}, | ||
_onSearchKeyUpTimeout: function(e) { | ||
var input = $('input', this.popover); | ||
var q = input.val().toLowerCase(); | ||
if (q) { | ||
$('li', this.popover).hide(); | ||
$('li.everything, [data-search^="' + q + '"]', this.popover).show(); | ||
} else { | ||
$('li', this.popover).show(); | ||
} | ||
}, | ||
_onShowFolloweeDropdown: function() { | ||
this.button.toggleClass('active'); | ||
if (this.button.hasClass('active')) { | ||
setTimeout(this._onInitSearch, 100); | ||
} | ||
return false; | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters