1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/scripts/searchtab.js

55 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-10-08 01:03:29 +03:00
define(["searchFields", "searchResults", "events"], function (SearchFields, SearchResults, events) {
2018-10-23 01:05:09 +03:00
"use strict";
function init(instance, tabContent, options) {
2019-10-08 01:03:29 +03:00
tabContent.innerHTML = '<div class="padded-left padded-right searchFields"></div><div class="searchResults padded-top" style="padding-top:1.5em;"></div>';
instance.searchFields = new SearchFields({
2018-10-23 01:05:09 +03:00
element: tabContent.querySelector(".searchFields")
2019-10-08 01:03:29 +03:00
});
instance.searchResults = new SearchResults({
2018-10-23 01:05:09 +03:00
element: tabContent.querySelector(".searchResults"),
serverId: ApiClient.serverId(),
parentId: options.parentId,
collectionType: options.collectionType
2019-10-08 01:03:29 +03:00
});
events.on(instance.searchFields, "search", function (e, value) {
instance.searchResults.search(value);
});
2018-10-23 01:05:09 +03:00
}
function SearchTab(view, tabContent, options) {
var self = this;
2019-10-08 01:03:29 +03:00
options = options || {};
init(this, tabContent, options);
self.preRender = function () {};
self.renderTab = function () {
2018-10-23 01:05:09 +03:00
var searchFields = this.searchFields;
2019-10-08 01:03:29 +03:00
if (searchFields) {
searchFields.focus();
}
};
2018-10-23 01:05:09 +03:00
}
2019-10-08 01:03:29 +03:00
SearchTab.prototype.destroy = function () {
2018-10-23 01:05:09 +03:00
var searchFields = this.searchFields;
2019-10-08 01:03:29 +03:00
if (searchFields) {
searchFields.destroy();
}
this.searchFields = null;
2018-10-23 01:05:09 +03:00
var searchResults = this.searchResults;
2019-10-08 01:03:29 +03:00
if (searchResults) {
searchResults.destroy();
}
this.searchResults = null;
};
return SearchTab;
});