-
Notifications
You must be signed in to change notification settings - Fork 44
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 #11 from bigcommerce/searcher
Renderable AJAX
- Loading branch information
Showing
6 changed files
with
101 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import BaseEvents from './base'; | ||
|
||
export default class SearchEvents extends BaseEvents { | ||
|
||
/** | ||
* @Constructor | ||
* @param {object} options | ||
*/ | ||
constructor(options) { | ||
this.options = options || {}; | ||
|
||
this.dataMap = { | ||
'[data-quick-search]': { | ||
eventName: 'search-quick', | ||
trigger: ['input'] | ||
} | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import RemoteBC from './remote'; | ||
import RemoteCountry from './countries'; | ||
import RemoteProduct from './product'; | ||
import RemoteProductAttributes from './product-attributes'; | ||
import Search from './search'; | ||
|
||
export default RemoteBC; | ||
export { RemoteCountry, RemoteProductAttributes }; | ||
export { | ||
RemoteCountry, | ||
RemoteProductAttributes, | ||
RemoteProduct, | ||
Search | ||
}; |
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,33 @@ | ||
import RemoteBC from './remote'; | ||
import $ from 'jquery'; | ||
|
||
export default class RemoteProduct extends RemoteBC | ||
{ | ||
/** | ||
* @Constructor | ||
*/ | ||
constructor() { | ||
// call parent | ||
super(); | ||
|
||
this.endPoint = '/product/'; | ||
} | ||
|
||
/** | ||
* | ||
* @param productId | ||
* @param params | ||
* @param callback | ||
*/ | ||
getById(productId, params, callback) | ||
{ | ||
let url = this.endPoint + productId; | ||
|
||
if (typeof params === 'function') { | ||
callback = params; | ||
params = {}; | ||
} | ||
|
||
this.makeRequest(url, 'GET', params, callback); | ||
} | ||
} |
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,28 @@ | ||
import RemoteBC from './remote'; | ||
import _ from 'lodash'; | ||
|
||
export default class Search extends RemoteBC | ||
{ | ||
/** | ||
* @Constructor | ||
*/ | ||
constructor() { | ||
// call parent | ||
super(); | ||
|
||
// set up class variables | ||
this.endPoint = '/search'; | ||
} | ||
|
||
/** | ||
* Get search results | ||
* @param {String} query | ||
* @param {Object} params | ||
* @param {Function} callback | ||
*/ | ||
search(query, params, callback) { | ||
params.search_query = encodeURIComponent(query); | ||
|
||
this.makeRequest(this.endPoint, 'GET', params, callback); | ||
} | ||
} |