1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Navbar/Search.js
2013-09-23 22:27:51 -07:00

37 lines
1016 B
JavaScript

'use strict';
define(
[
'app',
'Series/SeriesCollection'
], function (App, SeriesCollection) {
$(document).on('keydown', function (e){
if ($(e.target).is('input')) {
return;
}
if (e.keyCode === 84) {
$('.x-series-search').focus();
e.preventDefault();
}
});
$.fn.bindSearch = function () {
$(this).typeahead({
source : function () {
return SeriesCollection.pluck('title');
},
sorter: function (items) {
return items.sort();
},
updater: function (item) {
var series = SeriesCollection.findWhere({ title: item });
this.$element.blur();
App.Router.navigate('/series/{0}'.format(series.get('titleSlug')), { trigger: true });
}
});
};
});