diff --git a/src/scripts/searchtab.js b/src/scripts/searchtab.js index 538770e42e..c0852bfc77 100644 --- a/src/scripts/searchtab.js +++ b/src/scripts/searchtab.js @@ -1,30 +1,54 @@ -define(["searchFields", "searchResults", "events"], function(SearchFields, SearchResults, events) { +define(["searchFields", "searchResults", "events"], function (SearchFields, SearchResults, events) { "use strict"; function init(instance, tabContent, options) { - tabContent.innerHTML = '
', instance.searchFields = new SearchFields({ + tabContent.innerHTML = '
'; + instance.searchFields = new SearchFields({ element: tabContent.querySelector(".searchFields") - }), instance.searchResults = new SearchResults({ + }); + instance.searchResults = new SearchResults({ element: tabContent.querySelector(".searchResults"), serverId: ApiClient.serverId(), parentId: options.parentId, collectionType: options.collectionType - }), events.on(instance.searchFields, "search", function(e, value) { - instance.searchResults.search(value) - }) + }); + events.on(instance.searchFields, "search", function (e, value) { + instance.searchResults.search(value); + }); } function SearchTab(view, tabContent, options) { var self = this; - options = options || {}, init(this, tabContent, options), self.preRender = function() {}, self.renderTab = function() { + options = options || {}; + init(this, tabContent, options); + + self.preRender = function () {}; + + self.renderTab = function () { var searchFields = this.searchFields; - searchFields && searchFields.focus() - } + + if (searchFields) { + searchFields.focus(); + } + }; } - return SearchTab.prototype.destroy = function() { + + SearchTab.prototype.destroy = function () { var searchFields = this.searchFields; - searchFields && searchFields.destroy(), this.searchFields = null; + + if (searchFields) { + searchFields.destroy(); + } + + this.searchFields = null; var searchResults = this.searchResults; - searchResults && searchResults.destroy(), this.searchResults = null - }, SearchTab -}); \ No newline at end of file + + if (searchResults) { + searchResults.destroy(); + } + + this.searchResults = null; + }; + + return SearchTab; +});