(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict';

var _pagination = require('./pagination');

// initialize all elements
var componentsList = document.querySelectorAll(_pagination.Pagination.getSelector()); // Import all components

for (var i = 0; i < componentsList.length; i++) {
	new _pagination.Pagination(componentsList[i]);
}
},{"./pagination":2}],2:[function(require,module,exports){
'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

/**
 * pagination.js
 * Script to resize pagination when it contains three digits
 */

/**
* Declare constants
*/
var attributeBase = 'data-rs-pagination';

var Pagination = exports.Pagination = function () {
	function Pagination(element) {
		_classCallCheck(this, Pagination);

		this.element = element;
		this.paginationList = this.element.querySelector('[' + this.attributes.paginationList + ']');
		this.listItems = [].concat(_toConsumableArray(this.paginationList.getElementsByTagName('li')));
		this.handleNextPreviousElements();
		this.handleListItems();
	}

	/**
 * Declare attributes
 */


	_createClass(Pagination, [{
		key: 'handleListItems',


		/**
   * Handle list items - check for three digits, if length of one of the list items is at least three digits, add pagination__list--s class to element
   */
		value: function handleListItems() {
			var containsThreeDigits = false;

			if (this.listItems.length > 0) {
				// check first item in item list
				if (this.listItems[0].innerText.trim().length > 2) {
					containsThreeDigits = true;
				}
				// check last item in item list
				else if (this.listItems[this.listItems.length - 1].innerText.trim().length > 2) {
						containsThreeDigits = true;
					}
			}
			if (containsThreeDigits) {
				this.paginationList.classList.add(this.classes.paginationListSmall);
			}
		}

		/**
   * Handle next previous elements - check if list items contain a pagination control ('<-' or '->'), if so remove these from list items
   */

	}, {
		key: 'handleNextPreviousElements',
		value: function handleNextPreviousElements() {
			var firstListItem = this.listItems[0];
			if (firstListItem.getAttribute(this.attributes.paginationControl) !== 'undefined' && firstListItem.getAttribute(this.attributes.paginationControl) !== null) {
				// shift: remove first item from list
				this.listItems.shift();
			}

			var lastListItem = this.listItems[this.listItems.length - 1];
			if (lastListItem.getAttribute(this.attributes.paginationControl) !== 'undefined' && lastListItem.getAttribute(this.attributes.paginationControl) !== null) {
				// pop: remove last item from list
				this.listItems.pop();
			}
		}

		/**
   * Get selector
   */

	}, {
		key: 'attributes',
		get: function get() {
			return {
				paginationControl: attributeBase + '-control',
				paginationList: attributeBase + '-list'
			};
		}

		/**
  * Declare classes
  */

	}, {
		key: 'classes',
		get: function get() {
			return {
				paginationListSmall: 'pagination__list--s'
			};
		}
	}], [{
		key: 'getSelector',
		value: function getSelector() {
			return '[' + attributeBase + ']';
		}
	}]);

	return Pagination;
}();
},{}]},{},[1]);
