Skip to content

Commit f4abfe8

Browse files
committed
Revert "Append if infinite scroll"
This reverts commit ade7558.
1 parent ade7558 commit f4abfe8

File tree

1 file changed

+43
-48
lines changed

1 file changed

+43
-48
lines changed

unbxdSearch.js

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//uglifyjs unbxdSearch.js -o unbxdSearch.min.js && gzip -c unbxdSearch.min.js > unbxdSearch.min.js.gz && aws s3 cp unbxdSearch.min.js.gz s3://unbxd/unbxdSearch.js --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-encoding gzip --cache-control max-age=3600
2-
var unbxdSearchInit = function(jQuery, Handlebars){
2+
var unbxdSearchInit = function(jQuery, Handlebars){
33
window.Unbxd = window.Unbxd || {};
44

55
// Production steps of ECMA-262, Edition 5, 15.4.4.14
@@ -67,7 +67,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
6767
return -1;
6868
};
6969
}
70-
70+
7171
/**
7272
* Shim for "fixing" IE's lack of support (IE < 9) for applying slice
7373
* on host objects like NamedNodeMap, NodeList, and HTMLCollection
@@ -80,7 +80,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
8080
(function () {
8181
'use strict';
8282
var _slice = Array.prototype.slice;
83-
83+
8484
try {
8585
// Can't be used with DOM elements in IE < 9
8686
_slice.call(document.documentElement);
@@ -242,7 +242,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
242242
return A;
243243
};
244244
}
245-
245+
246246
if (!Array.prototype.filter) {
247247
Array.prototype.filter = function(fun/*, thisArg*/) {
248248
'use strict';
@@ -277,7 +277,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
277277
return res;
278278
};
279279
}
280-
280+
281281
// Production steps of ECMA-262, Edition 5, 15.4.4.21
282282
// Reference: http://es5.github.io/#x15.4.4.21
283283
if (!Array.prototype.reduce) {
@@ -633,15 +633,15 @@ var unbxdSearchInit = function(jQuery, Handlebars){
633633
(e.currentTarget === e.target) ? $t : undefined,
634634
field = $selected && $selected.attr('unbxdsortfield'),
635635
value = $selected && $selected.attr('unbxdsortvalue');
636-
636+
637637
if($selected){
638638
self
639639
.resetSort()
640640
.setPage(1);
641-
641+
642642
if(field && value)
643643
self.addSort(field, value);
644-
644+
645645
self.callResults(self.paintOnlyResultSet, true);
646646
}
647647
};
@@ -795,7 +795,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
795795
,checkbox_sel = self.options.facetCheckBoxSelector + "[unbxdParam_facetName='"+ name +"'][unbxdParam_facetValue='" + val + "']";
796796

797797
jQuery(checkbox_sel).removeAttr("checked");
798-
798+
799799
if(typeof self.options.facetOnDeselect == "function"){
800800
self.options.facetOnDeselect(jQuery(checkbox_sel).parents(self.options.facetElementSelector));
801801
}
@@ -857,7 +857,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
857857
}
858858
self.callResults(self.paintOnlyResultSet, true);
859859
}
860-
860+
861861
});
862862
}
863863

@@ -968,16 +968,16 @@ var unbxdSearchInit = function(jQuery, Handlebars){
968968
}
969969
,addRangeFilter : function(field, lb, ub){
970970
if(!(field in this.params.ranges))
971-
this.params.ranges[field] = {};
972-
971+
this.params.ranges[field] = {};
972+
973973
this.params.ranges[field][lb + ' TO ' + ub] = {lb : lb || '*', ub : ub || '*'};
974974

975975
return this;
976976
}
977977
,removeRangeFilter : function(field, lb, ub){
978978
if(!lb && !ub && field in this.params.ranges)
979979
delete this.params.ranges[field];
980-
980+
981981
if(lb && ub && field in this.params.ranges && (lb + ' TO ' + ub in this.params.ranges[field]))
982982
delete this.params.ranges[field][lb + ' TO ' + ub];
983983

@@ -1088,7 +1088,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
10881088
else if(b.length > 0)
10891089
nonhistoryPath += '&filter='+b.join(' OR ');
10901090
}
1091-
1091+
10921092
var a = [];
10931093
var b = [];
10941094
for(var field in this.params.sort){
@@ -1142,7 +1142,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
11421142

11431143
if(this.options.facetMultiSelect)
11441144
nonhistoryPath += '&facet.multiselect=true';
1145-
1145+
11461146
nonhistoryPath += '&indent=off';
11471147

11481148
return {
@@ -1155,26 +1155,26 @@ var unbxdSearchInit = function(jQuery, Handlebars){
11551155
if(this.isLoading){
11561156
this.ajaxCall.abort();
11571157
}
1158-
1158+
11591159
this.isLoading = true;
11601160

11611161
if(this.options.loaderSelector.length > 0)
11621162
jQuery(this.options.loaderSelector).show();
1163-
1163+
11641164
var self = this
11651165
,modifiedCB = callback.bind(self)
11661166
,cb = function(data){
11671167
this.isLoading = false;
11681168
if(this.options.loaderSelector.length > 0)
11691169
jQuery(this.options.loaderSelector).hide();
1170-
1170+
11711171
if("error" in data)
11721172
return false;
11731173

11741174
modifiedCB(data);
11751175
}
11761176
,urlobj = self.url();
1177-
1177+
11781178
if(doPush){
11791179
var finalquery = this.options.noEncoding ? urlobj.query : this.encode( urlobj.query );
11801180
if(this.isHistory){
@@ -1199,7 +1199,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
11991199
jQuery(this.options.searchQueryDisplay).empty();
12001200
if(this.options.deferInitRender.indexOf('search') === -1)
12011201
jQuery(this.options.searchResultContainer).empty();
1202-
1202+
12031203
jQuery(this.options.facetContainerSelector).empty();
12041204

12051205
this.options.selectedFacetHolderSelector && jQuery(this.options.selectedFacetHolderSelector).hide();
@@ -1227,7 +1227,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
12271227
}
12281228
,setDefaultParams: function(params){
12291229
this.options.setDefaultFilters.call(this);
1230-
1230+
12311231
if(Object.keys(this.defaultParams).length === 0)
12321232
this.defaultParams = jQuery.extend(true, {}, this.params);
12331233
}
@@ -1263,7 +1263,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
12631263
if(vals.length > 1){
12641264
if(!(arr[0] in params.ranges))
12651265
params.ranges[arr[0]] = {};
1266-
1266+
12671267
params.ranges[arr[0]][arr[1]] = {lb : isNaN(parseFloat(vals[0])) ? '*' : parseFloat(vals[0]), ub : isNaN(parseFloat(vals[1])) ? '*' : parseFloat(vals[1])};
12681268
} else {
12691269
if(!(arr[0] in params.filters))
@@ -1324,7 +1324,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
13241324
,_internalPaintResultSet: function(obj, facetsAlso){
13251325
if("error" in obj)
13261326
return false;
1327-
1327+
13281328
this.totalNumberOfProducts = 0;
13291329

13301330
this.currentNumberOfProducts = 0;
@@ -1342,18 +1342,18 @@ var unbxdSearchInit = function(jQuery, Handlebars){
13421342
this.params.extra.page = this.params.extra.page - 1;
13431343

13441344
this.params.query = obj.didYouMean[0].suggestion;
1345-
1345+
13461346
if(!this.compiledSpellCheckTemp)
13471347
this.compiledSpellCheckTemp = Handlebars.compile(this.options.spellCheckTemp);
1348-
1348+
13491349
jQuery(this.options.spellCheck).html(this.compiledSpellCheckTemp({suggestion : obj.didYouMean[0].suggestion})).show();
1350-
1350+
13511351
facetsAlso ? this.callResults(this.paintAfterSpellCheck) : this.callResults(this.paintOnlyResultSet) ;
13521352

13531353
}else{
1354-
1354+
13551355
this.params.query = obj.searchMetaData.queryParams.q; //obj.didYouMean[0].suggestion;
1356-
1356+
13571357
if(!this.compiledSpellCheckTemp)
13581358
this.compiledSpellCheckTemp = Handlebars.compile(this.options.spellCheckTemp);
13591359

@@ -1434,18 +1434,13 @@ var unbxdSearchInit = function(jQuery, Handlebars){
14341434
this.compiledResultTemp[val] = Handlebars.compile(this.options.searchResultSetTemp[val]);
14351435
}.bind(this));
14361436
}
1437-
if (this.options.deferInitRender.indexOf('search') === -1 || !this.isUsingPagination()) {
1438-
jQuery(this.options.searchResultContainer).append(this.compiledResultTemp[currentViewType](obj.response));
1439-
} else {
1440-
jQuery(this.options.searchResultContainer).html(this.compiledResultTemp[currentViewType](obj.response));
1441-
}
1442-
1437+
jQuery(this.options.searchResultContainer).html(this.compiledResultTemp[currentViewType](obj.response));
14431438
}else{
14441439
if(!this.compiledResultTemp)
14451440
this.compiledResultTemp = Handlebars.compile(this.options.searchResultSetTemp);
14461441

14471442
if(this.options.deferInitRender.indexOf('search') === -1 || !this.isUsingPagination()){
1448-
jQuery(this.options.searchResultContainer).append(this.compiledResultTemp(obj.response));
1443+
jQuery(this.options.searchResultContainer).append(this.compiledResultTemp(obj.response));
14491444
}
14501445
}
14511446

@@ -1562,8 +1557,8 @@ var unbxdSearchInit = function(jQuery, Handlebars){
15621557
return obj.page > 0 && obj.page <= this.totalPages;
15631558
}.bind(this))
15641559

1565-
1566-
1560+
1561+
15671562
jQuery(this.options.paginationContainerSelector).html(this.compiledPaginationTemp({
15681563
hasFirst: this.getPage() > 1 ? true : false,
15691564
hasPrev: this.getPage() > 1 ? true : false,
@@ -1595,9 +1590,9 @@ var unbxdSearchInit = function(jQuery, Handlebars){
15951590
}
15961591
));
15971592
}.bind(this), []);
1598-
1593+
15991594
jQuery(this.options.bannerSelector).html(bannersToDraw.join(''));
1600-
1595+
16011596
}
16021597
,paintFacets: function(obj){
16031598
if("error" in obj)
@@ -1642,7 +1637,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
16421637
}
16431638

16441639
if((singlefacet.unordered.length) > 0) textfacets.push(singlefacet);
1645-
1640+
16461641
} else {
16471642
for(var i = 0, len = facets[x]['values']['counts'].length/2; i < len; i++){
16481643
facetValStart = parseFloat(facets[x]['values']['counts'][2 * i]).toString();
@@ -1674,15 +1669,15 @@ var unbxdSearchInit = function(jQuery, Handlebars){
16741669
if (this.options.deferInitRender.indexOf('search') > -1){
16751670
this.options.deferInitRender = [];
16761671
}
1677-
1672+
16781673
if (typeof this.options.onFacetLoad == "function") {
16791674
this.options.onFacetLoad.call(this, obj);
16801675
}
16811676

16821677
if(this.options.getFacetStats.length &&
16831678
typeof this.options.processFacetStats == "function" &&
16841679
"stats" in obj && obj.stats[this.options.getFacetStats] != null){
1685-
1680+
16861681
obj.stats[this.options.getFacetStats].values = {
16871682
min: obj.stats[this.options.getFacetStats].min,
16881683
max: obj.stats[this.options.getFacetStats].max
@@ -1698,7 +1693,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
16981693
obj.stats[this.options.getFacetStats].max
16991694
};
17001695
}
1701-
1696+
17021697
}
17031698

17041699
this.options.processFacetStats.call(this,obj.stats);
@@ -1708,15 +1703,15 @@ var unbxdSearchInit = function(jQuery, Handlebars){
17081703
var selFacetKeysLength = Math.max(Object.keys(this.params.filters).length,
17091704
Object.keys(this.params.ranges).length);
17101705
var selectedFacets = {};
1711-
1706+
17121707
if(selFacetKeysLength){
17131708
selectedFacets.filters = this.params.filters;
17141709
selectedFacets.ranges = {};
17151710

17161711
for (var x in this.params.ranges){
17171712
if(!selectedFacets.ranges.hasOwnProperty(x))
17181713
selectedFacets.ranges[x] = {};
1719-
1714+
17201715
for (var y in this.params.ranges[x]){
17211716
selectedFacets.ranges[x][y] = x;
17221717
}
@@ -1750,7 +1745,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
17501745
while (e = r.exec(q)) {
17511746
var e1 = e[1].indexOf("[")
17521747
//first group of regex match
1753-
,k = e1 == "-1" ? e[1] : e[1].slice(0, e1)
1748+
,k = e1 == "-1" ? e[1] : e[1].slice(0, e1)
17541749
,i = e1 != "-1" ? d(e[1].slice(e1+1, e[1].indexOf("]", e1))) : ""
17551750
,v = d(e[2]);
17561751

@@ -1859,11 +1854,11 @@ var unbxdSearchInit = function(jQuery, Handlebars){
18591854
});
18601855
};
18611856

1862-
if(!window.jQuery || !window.Handlebars)
1857+
if(!window.jQuery || !window.Handlebars)
18631858
throw "Please include jQuery & Handlebars libraries before loading unbxdSearch.js";
18641859

18651860
var arr = jQuery.fn.jquery.split('.');
1866-
if( arr[0] < 1 || (arr[0] == 1 && arr[1] < 7) )
1861+
if( arr[0] < 1 || (arr[0] == 1 && arr[1] < 7) )
18671862
throw "jQuery version needs to be greater than 1.7 to use unbxdSearch.js. You can pass custom jQuery & Handlebars by calling unbxdSeachInit(jQuery, Handlebars)";
18681863

18691864

0 commit comments

Comments
 (0)