mirror of https://github.com/lidarr/Lidarr
30 lines
902 B
JavaScript
30 lines
902 B
JavaScript
|
'use strict';
|
||
|
define(
|
||
|
[
|
||
|
'app',
|
||
|
'Series/SeriesCollection'
|
||
|
], function (App, SeriesCollection) {
|
||
|
$.fn.bindSearch = function () {
|
||
|
$(this).typeahead({
|
||
|
source : function () {
|
||
|
return SeriesCollection.map(function (model) {
|
||
|
return model.get('title');
|
||
|
});
|
||
|
},
|
||
|
|
||
|
sorter: function (items) {
|
||
|
return items.sort();
|
||
|
},
|
||
|
|
||
|
updater: function (item) {
|
||
|
var series = SeriesCollection.find(function (model) {
|
||
|
return model.get('title') === item;
|
||
|
});
|
||
|
|
||
|
this.$element.blur();
|
||
|
App.Router.navigate('/series/{0}'.format(series.get('titleSlug')), { trigger: true });
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
});
|