3.1.0 • Published 6 years ago

avanti-search v3.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Avanti Search

Install

  1. $ bower install avanti-search --save.
  2. Install JS-Cookie.
  3. Insert avanti-search.js in your store.
  4. Insert avanti-search.css in your store.
  5. Insert VTEX search result tag <vtex.cmc:searchResult/> in your template.
  6. Insert below script in your template at the bottom. Inside <body> tag:
<script>
  /**
   * Avoid VTEX animation
   */
  function goToTopPage() { }

  var $childrenResult = $('.resultItemsWrapper').children('script')

  if ($childrenResult.length !== 0) {
    var scriptContent = $childrenResult.html();
    eval('window.' + /(PageClick_)([0-9]+)/g.exec(scriptContent)[0] + ' = function () {}');
  }
</script>
  1. Call plugin in your JavaScript:
(function() {
  $('.resultItemsWrapper div[id^="ResultItems"]').avantiSearch();
})();

Options

Elements
OptionTypeDefault
$resultItemsWrapperElement$('.resultItemsWrapper')
$scriptElement$('.resultItemsWrapper').children('script')
$totalItemsElement$('.searchResultsTime:first .resultado-busca-numero .value')
$selectOrderElement$('#O')
$filtersElement$('.search-multiple-navigator label')
Classes
OptionTypeDefault
classFilterActiveStringfilter--active
classItemPreLoadStringshelf-item--preload
classLoadBtnHideStringload-btn--hide
classLoadLessStringload-less
classLoadMoreStringload-more
classPaginationStringpagination
Texts
OptionTypeDefault
textLoadLessStringLoad less
textLoadMoreStringLoad more
textPaginationFirstStringFirst
textPaginationPrevStringPrev
textPaginationNextStringNext
textPaginationLastStringLast
textEmptyResultStringNo product found
Pagination
OptionTypeDefault
paginationBooleanfalse
paginationRangeButtonsNumber3
Others
OptionTypeDefault
cookieNameStringAvantiSearchQuery
defaultParamsObject{}Pass default params to request.Example: { 'query': { 'O': 'OrderByPriceASC' } }
attemptsNumber1

Example:

(function() {
  $('.resultItemsWrapper div[id^="ResultItems"]').avantiSearch({
    cookieName: 'AvantiSearchQuery',
    defaultParams: {
      'query': {
        'O': 'OrderByPriceASC'
      }
    }
  });
})();

Events

Event nameArguments
avantisearch.initevent, options, request
avantisearch.initWithCookieevent, options, request
avantisearch.initWithoutCookieevent, options, request
avantisearch.beforeSearchevent, options, request
avantisearch.afterSearchevent, options, request
avantisearch.beforeChangeOrderevent, options, request, element
avantisearch.afterChangeOrderevent, options, request, element
avantisearch.beforeFilterevent, options, request, element
avantisearch.afterFilterevent, options, request, element
avantisearch.beforeChangePageevent, options, request
avantisearch.afterChangePageevent, options, request
avantisearch.beforeShowItemsevent, options, request, page
avantisearch.afterShowItemsevent, options, request, page

Example:

(function() {
  var $resultItems = $('.resultItemsWrapper div[id^="ResultItems"]');

  $resultItems
    .on('avantisearch.init', function (event, options, request) {
      console.log(event);
      console.log(options);
      console.log(request);
    });

  $resultItems.avantiSearch();
})();

Tips and Tricks

  1. Call the events: avantisearch.init, avantisearch.initWithCookie, avantisearch.initWithoutCookie or avantisearch.beforeSearch before the plugin start.

Dependencies

Contributing

3.1.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.0

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago