-
-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Search] Inject id and class attr into individual result #3142
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -220,9 +220,7 @@ | |||||
var | ||||||
$result = $(this), | ||||||
$title = $result.find(selector.title).eq(0), | ||||||
$link = $result.is('a[href]') | ||||||
? $result | ||||||
: $result.find('a[href]').eq(0), | ||||||
$link = $result.is('a[href]') ? $result : $(), | ||||||
href = $link.attr('href') || false, | ||||||
target = $link.attr('target') || false, | ||||||
// title is used for result lookup | ||||||
|
@@ -1459,6 +1457,8 @@ | |||||
results: 'results', // array of results (standard) | ||||||
title: 'title', // result title | ||||||
url: 'url', // result url | ||||||
id: 'id', // HTML 'id' attribute | ||||||
classes: 'classes', // Classes specific to each result to add to the HTML 'class' attribute. | ||||||
action: 'action', // "view more" object name | ||||||
actionText: 'text', // "view more" text | ||||||
actionURL: 'url', // "view more" url | ||||||
|
@@ -1538,8 +1538,17 @@ | |||||
html += '<div class="results">'; | ||||||
$.each(category.results, function (index, result) { | ||||||
html += result[fields.url] | ||||||
? '<a class="result" href="' + result[fields.url].replace(/"/g, '') + '">' | ||||||
: '<a class="result">'; | ||||||
? '<a href="' + result[fields.url].replace(/"/g, '') + '" ' | ||||||
: html += '<div '; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed and a breaking change, keep using the anchor tag |
||||||
|
||||||
html += result[fields.id] !== undefined | ||||||
? ' id="' + result[fields.id] + '" ' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be sanitzed (double quotes removed
Suggested change
|
||||||
: ''; | ||||||
|
||||||
html += result[fields.classes] !== undefined | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should rename the fields property to |
||||||
? ' class="result ' + result[fields.classes] + '">' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs to be sanitized (double quotes removed)
Suggested change
|
||||||
: ' class="result">'; | ||||||
|
||||||
if (result[fields.image] !== undefined) { | ||||||
html += '' | ||||||
+ '<div class="image">' | ||||||
|
@@ -1558,7 +1567,10 @@ | |||||
} | ||||||
html += '' | ||||||
+ '</div>'; | ||||||
html += '</a>'; | ||||||
|
||||||
html += result[fields.url] | ||||||
? '</a>' | ||||||
: '</div>'; | ||||||
Comment on lines
+1570
to
+1573
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above and revert. Keep using the anchor tag |
||||||
}); | ||||||
html += '</div>'; | ||||||
html += '' | ||||||
|
@@ -1591,8 +1603,17 @@ | |||||
// each result | ||||||
$.each(response[fields.results], function (index, result) { | ||||||
html += result[fields.url] | ||||||
? '<a class="result" href="' + result[fields.url].replace(/"/g, '') + '">' | ||||||
: '<a class="result">'; | ||||||
? '<a href="' + result[fields.url].replace(/"/g, '') + '" ' | ||||||
: '<div '; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change as existing projects could rely on always assuming an |
||||||
|
||||||
html += result[fields.id] !== undefined | ||||||
? ' id="' + result[fields.id] + '" ' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be sanitized (double quotes removed)
Suggested change
|
||||||
: ''; | ||||||
|
||||||
html += result[fields.classes] !== undefined | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should rename the fields property to |
||||||
? ' class="result ' + result[fields.classes] + '">' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to be sanitized (double quotes removed) |
||||||
: ' class="result">'; | ||||||
|
||||||
if (result[fields.image] !== undefined) { | ||||||
html += '' | ||||||
+ '<div class="image">' | ||||||
|
@@ -1611,7 +1632,10 @@ | |||||
} | ||||||
html += '' | ||||||
+ '</div>'; | ||||||
html += '</a>'; | ||||||
|
||||||
html += result[fields.url] | ||||||
? '</a>' | ||||||
: '</div>'; | ||||||
Comment on lines
+1635
to
+1638
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above, this should be reverted to always create an achor |
||||||
}); | ||||||
if (response[fields.action]) { | ||||||
html += fields.actionURL === false | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should name the property
class
instead ofclasses