/* eslint-disable */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.droplab = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0){ if(!listItems[currentIndex-1]){ currentIndex = currentIndex-1; } listItems[currentIndex-1].classList.add('dropdown-active'); } }; var mousedown = function mousedown(e) { var list = e.detail.hook.list; removeHighlight(list); list.show(); currentIndex = 0; isUpArrow = false; isDownArrow = false; }; var selectItem = function selectItem(list) { var listItems = removeHighlight(list); var currentItem = listItems[currentIndex-1]; var listEvent = new CustomEvent('click.dl', { detail: { list: list, selected: currentItem, data: currentItem.dataset, }, }); list.list.dispatchEvent(listEvent); list.hide(); } var keydown = function keydown(e){ var typedOn = e.target; isUpArrow = false; isDownArrow = false; if(e.detail.which){ currentKey = e.detail.which; if(currentKey === 13){ selectItem(e.detail.hook.list); return; } if(currentKey === 38) { isUpArrow = true; } if(currentKey === 40) { isDownArrow = true; } } else if(e.detail.key) { currentKey = e.detail.key; if(currentKey === 'Enter'){ selectItem(e.detail.hook.list); return; } if(currentKey === 'ArrowUp') { isUpArrow = true; } if(currentKey === 'ArrowDown') { isDownArrow = true; } } if(isUpArrow){ currentIndex--; } if(isDownArrow){ currentIndex++; } if(currentIndex < 0){ currentIndex = 0; } setMenuForArrows(e.detail.hook.list); }; w.addEventListener('mousedown.dl', mousedown); w.addEventListener('keydown.dl', keydown); }; }); },{"./window":11}],10:[function(require,module,exports){ var DATA_TRIGGER = require('./constants').DATA_TRIGGER; var DATA_DROPDOWN = require('./constants').DATA_DROPDOWN; var toDataCamelCase = function(attr){ return this.camelize(attr.split('-').slice(1).join(' ')); }; // the tiniest damn templating I can do var t = function(s,d){ for(var p in d) s=s.replace(new RegExp('{{'+p+'}}','g'), d[p]); return s; }; var camelize = function(str) { return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(letter, index) { return index == 0 ? letter.toLowerCase() : letter.toUpperCase(); }).replace(/\s+/g, ''); }; var closest = function(thisTag, stopTag) { while(thisTag !== null && thisTag.tagName !== stopTag && thisTag.tagName !== 'HTML'){ thisTag = thisTag.parentNode; } return thisTag; }; var isDropDownParts = function(target) { if(target.tagName === 'HTML') { return false; } return ( target.hasAttribute(DATA_TRIGGER) || target.hasAttribute(DATA_DROPDOWN) ); }; module.exports = { toDataCamelCase: toDataCamelCase, t: t, camelize: camelize, closest: closest, isDropDownParts: isDropDownParts, }; },{"./constants":1}],11:[function(require,module,exports){ module.exports = function(callback) { return (function() { callback(this); }).call(null); }; },{}]},{},[8])(8) });