From bb8a9f57eecf99b61fefe6b1443f5673e44042ff Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 11 Jun 2015 14:10:36 -0400 Subject: [PATCH] Search will now create results container automatically, and add category search classname --- src/definitions/modules/search.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index aa7764142..f6cb91559 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -62,6 +62,8 @@ $.fn.search = function(parameters) { module.verbose('Initializing module'); module.determine.searchFields(); module.bind.events(); + module.set.type(); + module.create.results(); module.instantiate(); }, instantiate: function() { @@ -272,7 +274,7 @@ $.fn.search = function(parameters) { debug : settings.debug, on : false, action : 'search', - onFailure : module.error + onError : module.error }, searchHTML ; @@ -369,6 +371,12 @@ $.fn.search = function(parameters) { .val(value) ; }, + type: function(type) { + type || settings.type; + if(settings.type == 'category') { + $module.addClass(settings.type) + } + }, buttonPressed: function() { $searchButton.addClass(className.pressed); } @@ -444,6 +452,9 @@ $.fn.search = function(parameters) { onSuccess : function(response) { module.parse.response.call(element, response, searchTerm); }, + onFailure: function() { + module.displayMessage(error.serverError); + }, urlData: { query: searchTerm } @@ -630,6 +641,14 @@ $.fn.search = function(parameters) { ; module.verbose('Creating unique id', id); return id; + }, + results: function() { + if($results.length === 0) { + $results = $('
') + .addClass(className.results) + .appendTo($module) + ; + } } }, @@ -998,7 +1017,7 @@ $.fn.search = function(parameters) { $.fn.search.settings = { - name : 'Search Module', + name : 'Search', namespace : 'search', debug : false, @@ -1061,6 +1080,7 @@ $.fn.search.settings = { empty : 'empty', focus : 'focus', loading : 'loading', + results : 'results', pressed : 'down' }, @@ -1070,7 +1090,7 @@ $.fn.search.settings = { logging : 'Error in debug logging, exiting.', noEndpoint : 'No search endpoint was specified', noTemplate : 'A valid template name was not specified.', - serverError : 'There was an issue with querying the server.', + serverError : 'There was an issue querying the server.', maxResults : 'Results must be an array to use maxResults setting', method : 'The method you called is not defined.' },