/**

* Carousel Materialize wrapper.
*
* @author Htmlstream
* @version 1.0
* @requires
*
*/

;(function ($) {

'use strict';

$.HSCore.components.HSCarouselMaterialize = {
  /**
   *
   *
   * @var Object _baseConfig
   */
  _baseConfig: {
    dist: -50
  },

  /**
   *
   *
   * @var jQuery pageCollection
   */
  pageCollection: $(),

  /**
   * Initialization of Carousel wrapper.
   *
   * @param String selector (optional)
   * @param Object config (optional)
   *
   * @return jQuery pageCollection - collection of initialized items.
   */

  init: function (selector, config) {

    this.collection = selector && $(selector).length ? $(selector) : $();
    if (!$(selector).length) return;

    this.config = config && $.isPlainObject(config) ?
        $.extend({}, this._baseConfig, config) : this._baseConfig;

    this.config.itemSelector = selector;

    this.initCarouselMaterialize();

    return this.pageCollection;

  },

  initCarouselMaterialize: function () {
    //Variables
    var $self = this,
        config = $self.config,
        collection = $self.pageCollection;

    //Actions
    this.collection.each(function (i, el) {
      //Variables
      var $this = $(el);

      $this.materializeCarousel({
        dist: -50
      });

      //Actions
      collection = collection.add($this);
    });
  }
}

})(jQuery);