Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2577 from rehandalal/product-search-mobile
[bug 1172603] [bug 1172604] Search on mobile product pages
- Loading branch information
Showing
7 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(function($) { | ||
var $body = $('body'); | ||
var locale = $('html').attr('lang'); | ||
var search = k.InstantSearchSettings.searchClient; | ||
|
||
if ($body.is('.product-landing') || $body.is('.documents')) { | ||
k.InstantSearchSettings.hideContent = function() { | ||
$('#content').hide(); | ||
}; | ||
|
||
k.InstantSearchSettings.showContent = function() { | ||
$('#content').show(); | ||
$('#instant-search-content').remove(); | ||
}; | ||
|
||
k.InstantSearchSettings.render = function(data) { | ||
var context = $.extend({}, data); | ||
var base_url = '/' + locale + '/search?q=' + search.lastQuery; | ||
base_url += '&' + search.serializeParams(); | ||
context['base_url'] = base_url; | ||
|
||
if ($('#instant-search-content').length) { | ||
var $searchContent = $('#instant-search-content'); | ||
} else { | ||
var $searchContent = $('<div />').attr('id', 'instant-search-content'); | ||
$('#content').after($searchContent); | ||
} | ||
|
||
$searchContent.html(k.nunjucksEnv.render('mobile-product-search-results.html', context)); | ||
}; | ||
} | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
kitsune/sumo/static/sumo/tpl/mobile-product-search-results.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="search-header">{{ 'Search results'|gettext }}</div> | ||
<ul class="document-list"> | ||
{% if num_results > 0 %} | ||
{% for doc in results %} | ||
<li> | ||
<a href="{{ doc.url }}">{{ doc.title }}</a> | ||
</li> | ||
{% endfor %} | ||
{% else %} | ||
<li><a href="#">{{ 'No results found.'|gettext }}</a></li> | ||
{% endif %} | ||
</ul> |