Skip to content

Commit d38f8a3

Browse files
author
Praveen
committed
take searchQueryParam from config options for read/update of browser url, default will be q
1 parent f6d4b6f commit d38f8a3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

unbxdSearch.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
477477
'</li>',
478478
'{{/options}}'
479479
].join('')
480+
,searchQueryParam:"q"
480481
};
481482

482483
jQuery.extend(Unbxd.setSearch.prototype,{
@@ -1045,7 +1046,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
10451046
var nonhistoryPath = "";
10461047

10471048
if(this.options.type == "search" && this.params['query'] != undefined){
1048-
url += '&q=' + encodeURIComponent(this.params.query);
1049+
url += '&'+ this.options.searchQueryParam +'='+ encodeURIComponent(this.params.query);
10491050
}else if(this.options.type == "browse" && this.params['categoryId'] != undefined){
10501051
url += '&category-id=' + encodeURIComponent(this.params.categoryId);
10511052
}
@@ -1189,7 +1190,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
11891190
}
11901191

11911192
this.ajaxCall = jQuery.ajax({
1192-
url: urlobj.url
1193+
url: urlobj.url.replace(this.options.searchQueryParam+"=", "q=")
11931194
,dataType: "jsonp"
11941195
,jsonp: 'json.wrf'
11951196
,success: cb.bind(self)
@@ -1300,8 +1301,8 @@ var unbxdSearchInit = function(jQuery, Handlebars){
13001301
params.extra.rows = this.options.pageSize;
13011302

13021303
//lets get query
1303-
if("q" in obj)
1304-
params.query = obj.q;
1304+
if(this.options.searchQueryParam in obj)
1305+
params.query = obj[this.options.searchQueryParam];
13051306

13061307
//lets get category-id
13071308
if("category-id" in obj)
@@ -1356,7 +1357,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
13561357

13571358
}else{
13581359

1359-
this.params.query = obj.searchMetaData.queryParams.q; //obj.didYouMean[0].suggestion;
1360+
this.params.query = obj.searchMetaData.queryParams[this.options.searchQueryParam]; //obj.didYouMean[0].suggestion;
13601361

13611362
if(!this.compiledSpellCheckTemp)
13621363
this.compiledSpellCheckTemp = Handlebars.compile(this.options.spellCheckTemp);
@@ -1412,7 +1413,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
14121413
this.totalPages = Math.ceil(obj.response.numberOfProducts/this.getPageSize());
14131414

14141415
jQuery(this.options.searchQueryDisplay).html(this.compiledSearchQueryTemp({
1415-
query : obj.searchMetaData.queryParams.q
1416+
query : obj.searchMetaData.queryParams[this.options.searchQueryParam]
14161417
,numberOfProducts : obj.response.numberOfProducts
14171418
,start: this.productStartIdx
14181419
,end: this.productEndIdx

0 commit comments

Comments
 (0)