|
|
@ -633,14 +633,22 @@ $.fn.search = function(parameters) { |
|
|
|
create: { |
|
|
|
id: function(resultIndex, categoryIndex) { |
|
|
|
var |
|
|
|
firstLetterCharCode = 97, |
|
|
|
categoryID = (categoryIndex !== undefined) |
|
|
|
? String.fromCharCode(firstLetterCharCode + categoryIndex) |
|
|
|
: '', |
|
|
|
resultID = resultIndex, |
|
|
|
id = categoryID + resultID |
|
|
|
resultID = (resultIndex + 1), // not zero indexed
|
|
|
|
categoryID = (categoryIndex + 1), |
|
|
|
firstCharCode, |
|
|
|
letterID, |
|
|
|
id |
|
|
|
; |
|
|
|
module.verbose('Creating unique id', id); |
|
|
|
if(categoryIndex !== undefined) { |
|
|
|
// start char code for "A"
|
|
|
|
letterID = String.fromCharCode(97 + categoryIndex); |
|
|
|
id = letterID + resultID; |
|
|
|
module.verbose('Creating category result id', id); |
|
|
|
} |
|
|
|
else { |
|
|
|
id = resultID; |
|
|
|
module.verbose('Creating result id', id); |
|
|
|
} |
|
|
|
return id; |
|
|
|
}, |
|
|
|
results: function() { |
|
|
@ -654,17 +662,15 @@ $.fn.search = function(parameters) { |
|
|
|
}, |
|
|
|
|
|
|
|
inject: { |
|
|
|
result: function(result, resultID, categoryID) { |
|
|
|
result: function(result, resultIndex, categoryIndex) { |
|
|
|
module.verbose('Injecting result into results'); |
|
|
|
var |
|
|
|
resultIndex = (resultID - 1), |
|
|
|
categoryIndex = (categoryID - 1), |
|
|
|
$selectedResult = (categoryID !== undefined) |
|
|
|
$selectedResult = (categoryIndex !== undefined) |
|
|
|
? $results |
|
|
|
.children().eq(categoryIndex) |
|
|
|
.children().eq(resultIndex) |
|
|
|
.children(selector.result).eq(resultIndex) |
|
|
|
: $results |
|
|
|
.children().eq(resultIndex) |
|
|
|
.children(selector.result).eq(resultIndex) |
|
|
|
; |
|
|
|
module.verbose('Injecting results metadata', $selectedResult); |
|
|
|
$selectedResult |
|
|
@ -675,13 +681,13 @@ $.fn.search = function(parameters) { |
|
|
|
module.debug('Injecting unique ids into results'); |
|
|
|
var |
|
|
|
// since results may be object, we must use counters
|
|
|
|
categoryIndex = 1, |
|
|
|
resultIndex = 1 |
|
|
|
categoryIndex = 0, |
|
|
|
resultIndex = 0 |
|
|
|
; |
|
|
|
if(settings.type === 'category') { |
|
|
|
// iterate through each category result
|
|
|
|
resultIndex = 1; |
|
|
|
$.each(results, function(index, category) { |
|
|
|
resultIndex = 0; |
|
|
|
$.each(category.results, function(index, value) { |
|
|
|
var |
|
|
|
result = category.results[index] |
|
|
|