Source: components/filter/filter-result/filter-result-element/product-limit.js

import jQ from "jquery";
import BaseComponent from "../../../base-component";
import Selector from "../../../../helpers/selector";
import FilterApi from "../../../../api/filter-api";

/**
 * Product limit select box
 * @extends BaseComponent
 */
class ProductLimit extends BaseComponent {
	/**
	 * @constructs
	 */
	constructor () {
		super();
	}

	/**
	 * Replace the brackets in raw html template with proper values
	 * @returns {String} HTML string
	 */
	compileTemplate() {
		// Override this method by buildFilterShowLimit
	}

	/**
	 * Render product limit select box
	 */
	render() {
		jQ(Selector.topShowLimit).html(this.compileTemplate());
		var $topLimitSelect = jQ(Selector.topShowLimit + ' select');
		if ($topLimitSelect.length) {
			$topLimitSelect.val(Globals.queryParams.limit);
		}
	}

	/**
	 * Bind the events on Sorting select box
	 */
	bindEvents() {
		jQ(Selector.topShowLimit + ' select').change(function(e) {
			FilterApi.setParam('limit', jQ(this).val());
			FilterApi.applyFilter();
		})
	}
}

export default ProductLimit;