Browse Source

Possible solve #1899 Issues with blank string results evaluating as undefined when minCharacters = 0, issue with saved results not being retrieved when response pulled from cache

pull/1785/merge
jlukic 9 years ago
parent
commit
2ed793a351
5 changed files with 77 additions and 44 deletions
  1. 37
      dist/components/search.js
  2. 4
      dist/components/search.min.js
  3. 39
      dist/semantic.js
  4. 6
      dist/semantic.min.js
  5. 35
      src/definitions/modules/search.js

37
dist/components/search.js

@ -1,5 +1,5 @@
/*!
* # Semantic UI 1.10.4 - Search
* # Semantic UI 1.11.0 - Search
* http://github.com/semantic-org/semantic-ui/
*
*
@ -68,6 +68,7 @@ $.fn.search = function(parameters) {
if(settings.automatic) {
$prompt
.on(inputEvent + eventNamespace, module.throttle)
.attr('autocomplete', 'off')
;
}
$prompt
@ -356,11 +357,13 @@ $.fn.search = function(parameters) {
query: function() {
var
searchTerm = module.get.value(),
cachedHTML = module.read.cachedHTML(searchTerm)
cache = module.read.cache(searchTerm)
;
if(cachedHTML) {
if(cache) {
module.debug('Reading result for ' + searchTerm + ' from cache');
module.addResults(cachedHTML);
module.save.results(cache.results);
module.addResults(cache.html);
}
else {
module.debug('Querying for ' + searchTerm);
@ -376,6 +379,9 @@ $.fn.search = function(parameters) {
module.debug('Searching with default search API endpoint');
module.search.remote(searchTerm);
}
else {
module.error(error.noEndpoint);
}
}
else {
module.error(error.source);
@ -398,7 +404,10 @@ $.fn.search = function(parameters) {
results: searchResults
});
module.remove.loading();
module.write.cachedHTML(searchTerm, searchHTML);
module.write.cache(searchTerm, {
html : searchHTML,
results : searchResults
});
module.addResults(searchHTML);
},
remote: function(searchTerm) {
@ -470,13 +479,14 @@ $.fn.search = function(parameters) {
;
module.verbose('Parsing server response', response);
if(response !== undefined) {
if(searchTerm) {
module.write.cachedHTML(searchTerm, searchHTML);
if(response.results !== undefined) {
module.save.results(response.results);
}
if(searchTerm !== undefined && response.results !== undefined) {
module.write.cache(searchTerm, {
html : searchHTML,
results : response.results
});
module.save.results(response.results);
module.addResults(searchHTML);
}
module.addResults(searchHTML);
}
}
},
@ -510,7 +520,7 @@ $.fn.search = function(parameters) {
},
read: {
cachedHTML: function(name) {
cache: function(name) {
var
cache = $module.data(metadata.cache)
;
@ -533,7 +543,7 @@ $.fn.search = function(parameters) {
},
write: {
cachedHTML: function(name, value) {
cache: function(name, value) {
var
cache = ($module.data(metadata.cache) !== undefined)
? $module.data(metadata.cache)
@ -878,6 +888,7 @@ $.fn.search.settings = {
source : 'Cannot search. No source used, and Semantic API module was not included',
noResults : 'Your search returned no results',
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.',
maxResults : 'Results must be an array to use maxResults setting',

4
dist/components/search.min.js
File diff suppressed because it is too large
View File

39
dist/semantic.js

@ -1,5 +1,5 @@
/*
* # Semantic UI - 1.10.4
* # Semantic UI - 1.11.0
* https://github.com/Semantic-Org/Semantic-UI
* http://www.semantic-ui.com/
*
@ -8858,7 +8858,7 @@ $.fn.rating.settings = {
})( jQuery, window , document );
/*!
* # Semantic UI 1.10.4 - Search
* # Semantic UI 1.11.0 - Search
* http://github.com/semantic-org/semantic-ui/
*
*
@ -8927,6 +8927,7 @@ $.fn.search = function(parameters) {
if(settings.automatic) {
$prompt
.on(inputEvent + eventNamespace, module.throttle)
.attr('autocomplete', 'off')
;
}
$prompt
@ -9215,11 +9216,13 @@ $.fn.search = function(parameters) {
query: function() {
var
searchTerm = module.get.value(),
cachedHTML = module.read.cachedHTML(searchTerm)
cache = module.read.cache(searchTerm)
;
if(cachedHTML) {
if(cache) {
module.debug('Reading result for ' + searchTerm + ' from cache');
module.addResults(cachedHTML);
module.save.results(cache.results);
module.addResults(cache.html);
}
else {
module.debug('Querying for ' + searchTerm);
@ -9235,6 +9238,9 @@ $.fn.search = function(parameters) {
module.debug('Searching with default search API endpoint');
module.search.remote(searchTerm);
}
else {
module.error(error.noEndpoint);
}
}
else {
module.error(error.source);
@ -9257,7 +9263,10 @@ $.fn.search = function(parameters) {
results: searchResults
});
module.remove.loading();
module.write.cachedHTML(searchTerm, searchHTML);
module.write.cache(searchTerm, {
html : searchHTML,
results : searchResults
});
module.addResults(searchHTML);
},
remote: function(searchTerm) {
@ -9329,13 +9338,14 @@ $.fn.search = function(parameters) {
;
module.verbose('Parsing server response', response);
if(response !== undefined) {
if(searchTerm) {
module.write.cachedHTML(searchTerm, searchHTML);
if(response.results !== undefined) {
module.save.results(response.results);
}
if(searchTerm !== undefined && response.results !== undefined) {
module.write.cache(searchTerm, {
html : searchHTML,
results : response.results
});
module.save.results(response.results);
module.addResults(searchHTML);
}
module.addResults(searchHTML);
}
}
},
@ -9369,7 +9379,7 @@ $.fn.search = function(parameters) {
},
read: {
cachedHTML: function(name) {
cache: function(name) {
var
cache = $module.data(metadata.cache)
;
@ -9392,7 +9402,7 @@ $.fn.search = function(parameters) {
},
write: {
cachedHTML: function(name, value) {
cache: function(name, value) {
var
cache = ($module.data(metadata.cache) !== undefined)
? $module.data(metadata.cache)
@ -9737,6 +9747,7 @@ $.fn.search.settings = {
source : 'Cannot search. No source used, and Semantic API module was not included',
noResults : 'Your search returned no results',
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.',
maxResults : 'Results must be an array to use maxResults setting',

6
dist/semantic.min.js
File diff suppressed because it is too large
View File

35
src/definitions/modules/search.js

@ -68,6 +68,7 @@ $.fn.search = function(parameters) {
if(settings.automatic) {
$prompt
.on(inputEvent + eventNamespace, module.throttle)
.attr('autocomplete', 'off')
;
}
$prompt
@ -356,11 +357,13 @@ $.fn.search = function(parameters) {
query: function() {
var
searchTerm = module.get.value(),
cachedHTML = module.read.cachedHTML(searchTerm)
cache = module.read.cache(searchTerm)
;
if(cachedHTML) {
if(cache) {
module.debug('Reading result for ' + searchTerm + ' from cache');
module.addResults(cachedHTML);
module.save.results(cache.results);
module.addResults(cache.html);
}
else {
module.debug('Querying for ' + searchTerm);
@ -376,6 +379,9 @@ $.fn.search = function(parameters) {
module.debug('Searching with default search API endpoint');
module.search.remote(searchTerm);
}
else {
module.error(error.noEndpoint);
}
}
else {
module.error(error.source);
@ -398,7 +404,10 @@ $.fn.search = function(parameters) {
results: searchResults
});
module.remove.loading();
module.write.cachedHTML(searchTerm, searchHTML);
module.write.cache(searchTerm, {
html : searchHTML,
results : searchResults
});
module.addResults(searchHTML);
},
remote: function(searchTerm) {
@ -470,13 +479,14 @@ $.fn.search = function(parameters) {
;
module.verbose('Parsing server response', response);
if(response !== undefined) {
if(searchTerm) {
module.write.cachedHTML(searchTerm, searchHTML);
if(response.results !== undefined) {
module.save.results(response.results);
}
if(searchTerm !== undefined && response.results !== undefined) {
module.write.cache(searchTerm, {
html : searchHTML,
results : response.results
});
module.save.results(response.results);
module.addResults(searchHTML);
}
module.addResults(searchHTML);
}
}
},
@ -510,7 +520,7 @@ $.fn.search = function(parameters) {
},
read: {
cachedHTML: function(name) {
cache: function(name) {
var
cache = $module.data(metadata.cache)
;
@ -533,7 +543,7 @@ $.fn.search = function(parameters) {
},
write: {
cachedHTML: function(name, value) {
cache: function(name, value) {
var
cache = ($module.data(metadata.cache) !== undefined)
? $module.data(metadata.cache)
@ -878,6 +888,7 @@ $.fn.search.settings = {
source : 'Cannot search. No source used, and Semantic API module was not included',
noResults : 'Your search returned no results',
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.',
maxResults : 'Results must be an array to use maxResults setting',

Loading…
Cancel
Save