/** * jQuery NavToSelect v0.5.2 * https://github.com/amazingSurge/jquery-navToSelect * * Copyright (c) amazingSurge * Released under the LGPL-3.0 license */ (function(global, factory) { if (typeof define === 'function' && define.amd) { define(['jquery'], factory); } else if (typeof exports !== 'undefined') { factory(require('jquery')); } else { var mod = { exports: {} }; factory(global.jQuery); global.jqueryNavToSelectEs = mod.exports; } })(this, function(_jquery) { 'use strict'; var _jquery2 = _interopRequireDefault(_jquery); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 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; }; })(); /* eslint no-unused-vars: "off" */ var DEFAULTS = { maxLevel: 4, prependTo: null, activeClass: 'active', linkSelector: 'a:first', indentString: '–', indentSpace: true, placeholder: 'Navigate to...', useOptgroup: false, namespace: 'navToSelect', itemFilter: function itemFilter($li) { return true; }, getItemLabel: function getItemLabel($li) { return $li.find(this.options.linkSelector).text(); }, getItemsFromList: function getItemsFromList($list, level) { var that = this; var _items = []; $list.children('li').each(function() { var $li = $(this); if (!that.options.itemFilter($li)) { return; } var item = { value: that.getItemValue($li), label: that.options.getItemLabel.call(that, $li), linkable: that.isLinkable($li), actived: that.isActived($li) }; if ($li.children('ul, ol').length) { item.items = []; $li.children('ul, ol').each(function() { item.items = item.items.concat( that.options.getItemsFromList.call(that, $(this), level + 1) ); }); } _items.push(item); }); return _items; }, onChange: function onChange() { if ($(this).data('linkable') !== false) { document.location.href = this.value; } } }; var NAMESPACE$1 = 'navToSelect'; /** * Plugin constructor **/ var navToSelect = (function() { function navToSelect(element, options) { _classCallCheck(this, navToSelect); this.element = element; this.$element = (0, _jquery2.default)(element); this._isBuilded = false; this.options = _jquery2.default.extend({}, DEFAULTS, options); this.init(); } _createClass( navToSelect, [ { key: 'init', value: function init() { var _this = this; var items = this.getItems(); this.build(items); this.$select.on('change', this.options.onChange); /* fix orientation change issue */ (0, _jquery2.default)(window).on('orientationchange', function() { if (_this.$select.is(':hidden') && _this.$select.is(':focus')) { _this.$select.blur(); } }); this.trigger('ready'); } }, { key: 'build', value: function build(items) { this.$select = (0, _jquery2.default)('