1
1
//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 ) {
3
3
window . Unbxd = window . Unbxd || { } ;
4
4
5
5
// Production steps of ECMA-262, Edition 5, 15.4.4.14
@@ -67,7 +67,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
67
67
return - 1 ;
68
68
} ;
69
69
}
70
-
70
+
71
71
/**
72
72
* Shim for "fixing" IE's lack of support (IE < 9) for applying slice
73
73
* on host objects like NamedNodeMap, NodeList, and HTMLCollection
@@ -80,7 +80,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
80
80
( function ( ) {
81
81
'use strict' ;
82
82
var _slice = Array . prototype . slice ;
83
-
83
+
84
84
try {
85
85
// Can't be used with DOM elements in IE < 9
86
86
_slice . call ( document . documentElement ) ;
@@ -242,7 +242,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
242
242
return A ;
243
243
} ;
244
244
}
245
-
245
+
246
246
if ( ! Array . prototype . filter ) {
247
247
Array . prototype . filter = function ( fun /*, thisArg*/ ) {
248
248
'use strict' ;
@@ -277,7 +277,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
277
277
return res ;
278
278
} ;
279
279
}
280
-
280
+
281
281
// Production steps of ECMA-262, Edition 5, 15.4.4.21
282
282
// Reference: http://es5.github.io/#x15.4.4.21
283
283
if ( ! Array . prototype . reduce ) {
@@ -633,15 +633,15 @@ var unbxdSearchInit = function(jQuery, Handlebars){
633
633
( e . currentTarget === e . target ) ? $t : undefined ,
634
634
field = $selected && $selected . attr ( 'unbxdsortfield' ) ,
635
635
value = $selected && $selected . attr ( 'unbxdsortvalue' ) ;
636
-
636
+
637
637
if ( $selected ) {
638
638
self
639
639
. resetSort ( )
640
640
. setPage ( 1 ) ;
641
-
641
+
642
642
if ( field && value )
643
643
self . addSort ( field , value ) ;
644
-
644
+
645
645
self . callResults ( self . paintOnlyResultSet , true ) ;
646
646
}
647
647
} ;
@@ -795,7 +795,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
795
795
, checkbox_sel = self . options . facetCheckBoxSelector + "[unbxdParam_facetName='" + name + "'][unbxdParam_facetValue='" + val + "']" ;
796
796
797
797
jQuery ( checkbox_sel ) . removeAttr ( "checked" ) ;
798
-
798
+
799
799
if ( typeof self . options . facetOnDeselect == "function" ) {
800
800
self . options . facetOnDeselect ( jQuery ( checkbox_sel ) . parents ( self . options . facetElementSelector ) ) ;
801
801
}
@@ -857,7 +857,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
857
857
}
858
858
self . callResults ( self . paintOnlyResultSet , true ) ;
859
859
}
860
-
860
+
861
861
} ) ;
862
862
}
863
863
@@ -968,16 +968,16 @@ var unbxdSearchInit = function(jQuery, Handlebars){
968
968
}
969
969
, addRangeFilter : function ( field , lb , ub ) {
970
970
if ( ! ( field in this . params . ranges ) )
971
- this . params . ranges [ field ] = { } ;
972
-
971
+ this . params . ranges [ field ] = { } ;
972
+
973
973
this . params . ranges [ field ] [ lb + ' TO ' + ub ] = { lb : lb || '*' , ub : ub || '*' } ;
974
974
975
975
return this ;
976
976
}
977
977
, removeRangeFilter : function ( field , lb , ub ) {
978
978
if ( ! lb && ! ub && field in this . params . ranges )
979
979
delete this . params . ranges [ field ] ;
980
-
980
+
981
981
if ( lb && ub && field in this . params . ranges && ( lb + ' TO ' + ub in this . params . ranges [ field ] ) )
982
982
delete this . params . ranges [ field ] [ lb + ' TO ' + ub ] ;
983
983
@@ -1088,7 +1088,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1088
1088
else if ( b . length > 0 )
1089
1089
nonhistoryPath += '&filter=' + b . join ( ' OR ' ) ;
1090
1090
}
1091
-
1091
+
1092
1092
var a = [ ] ;
1093
1093
var b = [ ] ;
1094
1094
for ( var field in this . params . sort ) {
@@ -1142,7 +1142,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1142
1142
1143
1143
if ( this . options . facetMultiSelect )
1144
1144
nonhistoryPath += '&facet.multiselect=true' ;
1145
-
1145
+
1146
1146
nonhistoryPath += '&indent=off' ;
1147
1147
1148
1148
return {
@@ -1155,26 +1155,26 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1155
1155
if ( this . isLoading ) {
1156
1156
this . ajaxCall . abort ( ) ;
1157
1157
}
1158
-
1158
+
1159
1159
this . isLoading = true ;
1160
1160
1161
1161
if ( this . options . loaderSelector . length > 0 )
1162
1162
jQuery ( this . options . loaderSelector ) . show ( ) ;
1163
-
1163
+
1164
1164
var self = this
1165
1165
, modifiedCB = callback . bind ( self )
1166
1166
, cb = function ( data ) {
1167
1167
this . isLoading = false ;
1168
1168
if ( this . options . loaderSelector . length > 0 )
1169
1169
jQuery ( this . options . loaderSelector ) . hide ( ) ;
1170
-
1170
+
1171
1171
if ( "error" in data )
1172
1172
return false ;
1173
1173
1174
1174
modifiedCB ( data ) ;
1175
1175
}
1176
1176
, urlobj = self . url ( ) ;
1177
-
1177
+
1178
1178
if ( doPush ) {
1179
1179
var finalquery = this . options . noEncoding ? urlobj . query : this . encode ( urlobj . query ) ;
1180
1180
if ( this . isHistory ) {
@@ -1199,7 +1199,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1199
1199
jQuery ( this . options . searchQueryDisplay ) . empty ( ) ;
1200
1200
if ( this . options . deferInitRender . indexOf ( 'search' ) === - 1 )
1201
1201
jQuery ( this . options . searchResultContainer ) . empty ( ) ;
1202
-
1202
+
1203
1203
jQuery ( this . options . facetContainerSelector ) . empty ( ) ;
1204
1204
1205
1205
this . options . selectedFacetHolderSelector && jQuery ( this . options . selectedFacetHolderSelector ) . hide ( ) ;
@@ -1227,7 +1227,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1227
1227
}
1228
1228
, setDefaultParams : function ( params ) {
1229
1229
this . options . setDefaultFilters . call ( this ) ;
1230
-
1230
+
1231
1231
if ( Object . keys ( this . defaultParams ) . length === 0 )
1232
1232
this . defaultParams = jQuery . extend ( true , { } , this . params ) ;
1233
1233
}
@@ -1263,7 +1263,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1263
1263
if ( vals . length > 1 ) {
1264
1264
if ( ! ( arr [ 0 ] in params . ranges ) )
1265
1265
params . ranges [ arr [ 0 ] ] = { } ;
1266
-
1266
+
1267
1267
params . ranges [ arr [ 0 ] ] [ arr [ 1 ] ] = { lb : isNaN ( parseFloat ( vals [ 0 ] ) ) ? '*' : parseFloat ( vals [ 0 ] ) , ub : isNaN ( parseFloat ( vals [ 1 ] ) ) ? '*' : parseFloat ( vals [ 1 ] ) } ;
1268
1268
} else {
1269
1269
if ( ! ( arr [ 0 ] in params . filters ) )
@@ -1324,7 +1324,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1324
1324
, _internalPaintResultSet : function ( obj , facetsAlso ) {
1325
1325
if ( "error" in obj )
1326
1326
return false ;
1327
-
1327
+
1328
1328
this . totalNumberOfProducts = 0 ;
1329
1329
1330
1330
this . currentNumberOfProducts = 0 ;
@@ -1342,18 +1342,18 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1342
1342
this . params . extra . page = this . params . extra . page - 1 ;
1343
1343
1344
1344
this . params . query = obj . didYouMean [ 0 ] . suggestion ;
1345
-
1345
+
1346
1346
if ( ! this . compiledSpellCheckTemp )
1347
1347
this . compiledSpellCheckTemp = Handlebars . compile ( this . options . spellCheckTemp ) ;
1348
-
1348
+
1349
1349
jQuery ( this . options . spellCheck ) . html ( this . compiledSpellCheckTemp ( { suggestion : obj . didYouMean [ 0 ] . suggestion } ) ) . show ( ) ;
1350
-
1350
+
1351
1351
facetsAlso ? this . callResults ( this . paintAfterSpellCheck ) : this . callResults ( this . paintOnlyResultSet ) ;
1352
1352
1353
1353
} else {
1354
-
1354
+
1355
1355
this . params . query = obj . searchMetaData . queryParams . q ; //obj.didYouMean[0].suggestion;
1356
-
1356
+
1357
1357
if ( ! this . compiledSpellCheckTemp )
1358
1358
this . compiledSpellCheckTemp = Handlebars . compile ( this . options . spellCheckTemp ) ;
1359
1359
@@ -1434,18 +1434,13 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1434
1434
this . compiledResultTemp [ val ] = Handlebars . compile ( this . options . searchResultSetTemp [ val ] ) ;
1435
1435
} . bind ( this ) ) ;
1436
1436
}
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 ) ) ;
1443
1438
} else {
1444
1439
if ( ! this . compiledResultTemp )
1445
1440
this . compiledResultTemp = Handlebars . compile ( this . options . searchResultSetTemp ) ;
1446
1441
1447
1442
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 ) ) ;
1449
1444
}
1450
1445
}
1451
1446
@@ -1562,8 +1557,8 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1562
1557
return obj . page > 0 && obj . page <= this . totalPages ;
1563
1558
} . bind ( this ) )
1564
1559
1565
-
1566
-
1560
+
1561
+
1567
1562
jQuery ( this . options . paginationContainerSelector ) . html ( this . compiledPaginationTemp ( {
1568
1563
hasFirst : this . getPage ( ) > 1 ? true : false ,
1569
1564
hasPrev : this . getPage ( ) > 1 ? true : false ,
@@ -1595,9 +1590,9 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1595
1590
}
1596
1591
) ) ;
1597
1592
} . bind ( this ) , [ ] ) ;
1598
-
1593
+
1599
1594
jQuery ( this . options . bannerSelector ) . html ( bannersToDraw . join ( '' ) ) ;
1600
-
1595
+
1601
1596
}
1602
1597
, paintFacets : function ( obj ) {
1603
1598
if ( "error" in obj )
@@ -1642,7 +1637,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1642
1637
}
1643
1638
1644
1639
if ( ( singlefacet . unordered . length ) > 0 ) textfacets . push ( singlefacet ) ;
1645
-
1640
+
1646
1641
} else {
1647
1642
for ( var i = 0 , len = facets [ x ] [ 'values' ] [ 'counts' ] . length / 2 ; i < len ; i ++ ) {
1648
1643
facetValStart = parseFloat ( facets [ x ] [ 'values' ] [ 'counts' ] [ 2 * i ] ) . toString ( ) ;
@@ -1674,15 +1669,15 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1674
1669
if ( this . options . deferInitRender . indexOf ( 'search' ) > - 1 ) {
1675
1670
this . options . deferInitRender = [ ] ;
1676
1671
}
1677
-
1672
+
1678
1673
if ( typeof this . options . onFacetLoad == "function" ) {
1679
1674
this . options . onFacetLoad . call ( this , obj ) ;
1680
1675
}
1681
1676
1682
1677
if ( this . options . getFacetStats . length &&
1683
1678
typeof this . options . processFacetStats == "function" &&
1684
1679
"stats" in obj && obj . stats [ this . options . getFacetStats ] != null ) {
1685
-
1680
+
1686
1681
obj . stats [ this . options . getFacetStats ] . values = {
1687
1682
min : obj . stats [ this . options . getFacetStats ] . min ,
1688
1683
max : obj . stats [ this . options . getFacetStats ] . max
@@ -1698,7 +1693,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1698
1693
obj . stats [ this . options . getFacetStats ] . max
1699
1694
} ;
1700
1695
}
1701
-
1696
+
1702
1697
}
1703
1698
1704
1699
this . options . processFacetStats . call ( this , obj . stats ) ;
@@ -1708,15 +1703,15 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1708
1703
var selFacetKeysLength = Math . max ( Object . keys ( this . params . filters ) . length ,
1709
1704
Object . keys ( this . params . ranges ) . length ) ;
1710
1705
var selectedFacets = { } ;
1711
-
1706
+
1712
1707
if ( selFacetKeysLength ) {
1713
1708
selectedFacets . filters = this . params . filters ;
1714
1709
selectedFacets . ranges = { } ;
1715
1710
1716
1711
for ( var x in this . params . ranges ) {
1717
1712
if ( ! selectedFacets . ranges . hasOwnProperty ( x ) )
1718
1713
selectedFacets . ranges [ x ] = { } ;
1719
-
1714
+
1720
1715
for ( var y in this . params . ranges [ x ] ) {
1721
1716
selectedFacets . ranges [ x ] [ y ] = x ;
1722
1717
}
@@ -1750,7 +1745,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1750
1745
while ( e = r . exec ( q ) ) {
1751
1746
var e1 = e [ 1 ] . indexOf ( "[" )
1752
1747
//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 )
1754
1749
, i = e1 != "-1" ? d ( e [ 1 ] . slice ( e1 + 1 , e [ 1 ] . indexOf ( "]" , e1 ) ) ) : ""
1755
1750
, v = d ( e [ 2 ] ) ;
1756
1751
@@ -1859,11 +1854,11 @@ var unbxdSearchInit = function(jQuery, Handlebars){
1859
1854
} ) ;
1860
1855
} ;
1861
1856
1862
- if ( ! window . jQuery || ! window . Handlebars )
1857
+ if ( ! window . jQuery || ! window . Handlebars )
1863
1858
throw "Please include jQuery & Handlebars libraries before loading unbxdSearch.js" ;
1864
1859
1865
1860
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 ) )
1867
1862
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)" ;
1868
1863
1869
1864
0 commit comments