diff --git a/assets/scripts/dist/choices.min.js b/assets/scripts/dist/choices.min.js index 5409f4b..3b67db5 100644 --- a/assets/scripts/dist/choices.min.js +++ b/assets/scripts/dist/choices.min.js @@ -1,2 +1,2 @@ -!function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var i={};return e.m=t,e.c=i,e.p="/assets/scripts/dist/",e(0)}([function(t,e,i){t.exports=i(1)},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Choices=void 0;var o=function(){function t(t,e){for(var i=0;i1)for(var o=1;o=1){var t=e.store.getOptionsFiltedBySelectable(),i=e.input.value,n=new c.default(t,{keys:["label","value"],shouldSort:!0,include:"score"}),s=n.search(i);e.highlightPosition=0,e.isSearching=!0,e.store.dispatch((0,r.filterOptions)(s))}};u()}else l&&(this.isSearching=!1,this.store.dispatch((0,r.activateOptions)()))}}}},{key:"onInput",value:function(t){"select-one"!==this.passedElement.type&&(this.input.style.width=(0,a.getWidthOfInput)(this.input))}},{key:"onMouseDown",value:function(t){var e=this;if(2!==t.button){var i=this.store.getItemsFilteredByActive();if(this.containerOuter.contains(t.target))!function(){t.preventDefault();var n=!!t.shiftKey;"text"===e.passedElement.type||e.dropdown.classList.contains(e.options.classNames.activeState)||e.showDropdown(),e.input!==document.activeElement&&e.input.focus(),t.target.hasAttribute("data-button")?e.options.removeItems&&e.options.removeButton&&!function(){var n=t.target.parentNode.getAttribute("data-id"),s=i.find(function(t){return t.id===parseInt(n)});e.removeItem(s)}():t.target.hasAttribute("data-item")?e.options.removeItems&&!function(){var s=t.target.getAttribute("data-id");i.forEach(function(t){t.id!==parseInt(s)||t.selected?n||e.deselectItem(t):e.selectItem(t)})}():t.target.hasAttribute("data-option")&&!function(){var i=e.store.getOptionsFilteredByActive(),n=t.target.getAttribute("data-id"),s=i.find(function(t){return t.id===parseInt(n)});s.selected||s.disabled||(e.addItem(s.value,s.label,s.id),"select-one"===e.passedElement.type&&e.toggleDropdown())}()}();else{var n=this.dropdown.classList.contains(this.options.classNames.activeState),s=i.some(function(t){return t.selected===!0});s&&this.deselectAll(),this.containerOuter.classList.remove(this.options.classNames.focusState),n&&this.toggleDropdown()}}}},{key:"onPaste",value:function(t){t.target===this.input&&(this.options.allowPaste||t.preventDefault())}},{key:"onMouseOver",value:function(t){(t.target===this.dropdown||(0,a.findAncestor)(t.target,this.options.classNames.listDropdown))&&t.target.hasAttribute("data-option")&&this.highlightOption(t.target)}},{key:"onFocus",value:function(t){var e=this.dropdown.classList.contains(this.options.classNames.activeState);t.target!==this.input||e||(this.containerOuter.classList.add(this.options.classNames.focusState),"select-one"!==this.passedElement.type&&"select-multiple"!==this.passedElement.type||this.showDropdown())}},{key:"onBlur",value:function(t){var e=this.dropdown.classList.contains(this.options.classNames.activeState);t.target!==this.input||e?this.hideDropdown():this.containerOuter.classList.remove(this.options.classNames.focusState)}},{key:"clearInput",value:function(){this.input.value&&(this.input.value=""),"select-one"!==this.passedElement.type&&(this.input.style.width=(0,a.getWidthOfInput)(this.input))}},{key:"regexFilter",value:function(t){if(t){var e=new RegExp(this.options.regexFilter,"i");return e.test(t)}}},{key:"scrollToOption",value:function(t,e){var i=this;if(t){var n=this.dropdown.offsetHeight,s=t.offsetHeight,o=t.offsetTop+s,r=this.dropdown.scrollTop+n,a=void 0,l=function c(t,e,n){var s=!1,o=void 0,r=void 0,a=4;n>0?(o=(e-i.dropdown.scrollTop)/a,r=o>1?o:1,i.dropdown.scrollTop=i.dropdown.scrollTop+r,i.dropdown.scrollTop1?o:1,i.dropdown.scrollTop=i.dropdown.scrollTop-r,i.dropdown.scrollTop>e&&(s=!0)),s&&requestAnimationFrame(function(t){c(t,e,n)})};e>0?(a=this.dropdown.scrollTop+o-r,requestAnimationFrame(function(t){l(t,a,1)})):(a=t.offsetTop,requestAnimationFrame(function(t){l(t,a,-1)}))}}},{key:"highlightOption",value:function(t){var e=this,i=Array.from(this.dropdown.querySelectorAll("[data-option-selectable]"));if(i.length){var n=Array.from(this.dropdown.querySelectorAll("."+this.options.classNames.highlightedState));if(n.forEach(function(t){t.classList.remove(e.options.classNames.highlightedState)}),t)t.classList.add(this.options.classNames.highlightedState),this.highlightPosition=i.indexOf(t);else{var s=void 0;s=i.length>this.highlightPosition?i[this.highlightPosition]:i[i.length-1],s||(s=i[0]),s.classList.add(this.options.classNames.highlightedState)}}}},{key:"selectItem",value:function(t){if(t){var e=t.id;this.store.dispatch((0,r.selectItem)(e,!0))}}},{key:"deselectItem",value:function(t){if(t){var e=t.id;this.store.dispatch((0,r.selectItem)(e,!1))}}},{key:"selectAll",value:function(){var t=this,e=this.store.getItems();e.forEach(function(e){t.selectItem(e)})}},{key:"deselectAll",value:function(){var t=this,e=this.store.getItems();e.forEach(function(e){t.deselectItem(e)})}},{key:"addItem",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?-1:arguments[2],n=arguments.length<=3||void 0===arguments[3]?this.options.callbackOnAddItem:arguments[3],s=this.store.getItems(),o=t.trim(),l=e||o,c=i||-1;this.options.prependValue&&(o=this.options.prependValue+o.toString()),this.options.appendValue&&(o+=this.options.appendValue.toString());var u=s?s.length+1:1;this.store.dispatch((0,r.addItem)(o,l,u,c)),"select-one"===this.passedElement.type&&this.removeActiveItems(u),n&&((0,a.isType)("Function",n)?n(u,o,this.passedElement):console.error("callbackOnAddItem: Callback is not a function"))}},{key:"removeItem",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?this.options.callbackOnRemoveItem:arguments[1];if(!t||!(0,a.isType)("Object",t))return void console.error("removeItem: No item object was passed to be removed");var i=t.id,n=(t.value,t.optionId);return this.store.dispatch((0,r.removeItem)(i,n)),e?void((0,a.isType)("Function",e)||console.error("callbackOnRemoveItem: Callback is not a function")):void 0}},{key:"removeItemsByValue",value:function(t){return void(t&&(0,a.isType)("String",t)||console.error("removeItemsByValue: No value was passed to be removed"))}},{key:"removeActiveItems",value:function(t){var e=this,i=this.store.getItemsFilteredByActive();i.forEach(function(i){i.active&&t!==i.id&&e.removeItem(i)})}},{key:"removeSelectedItems",value:function(){var t=this,e=this.store.getItemsFilteredByActive();e.forEach(function(e){e.selected&&e.active&&t.removeItem(e)})}},{key:"addOption",value:function(t,e,i){var n=arguments.length<=3||void 0===arguments[3]?-1:arguments[3];if(e){i||(i=e);var s=this.store.getOptions(),o=s.length+1,a=t&&(t.disabled||t.parentNode.disabled);this.store.dispatch((0,r.addOption)(e,i,o,n,a)),t&&t.selected&&!a&&this.addItem(e,i,o)}}},{key:"addGroup",value:function(t,e,i){var n=this,s=Array.from(t.getElementsByTagName("OPTION")),o=e;s?(this.store.dispatch((0,r.addGroup)(t.label,o,!0,t.disabled)),s.forEach(function(t,e){n.addOption(t,t.value,t.innerHTML,o)})):this.store.dispatch((0,r.addGroup)(t.label,t.id,!1,t.disabled))}},{key:"showDropdown",value:function(){this.containerOuter.classList.add(this.options.classNames.openState),this.dropdown.classList.add(this.options.classNames.activeState);var t=this.dropdown.getBoundingClientRect(),e=t.top+t.height>=document.body.offsetHeight;e?this.containerOuter.classList.add(this.options.classNames.flippedState):this.containerOuter.classList.remove(this.options.classNames.flippedState)}},{key:"hideDropdown",value:function(){var t=this.containerOuter.classList.contains(this.options.classNames.flippedState);this.containerOuter.classList.remove(this.options.classNames.openState),this.dropdown.classList.remove(this.options.classNames.activeState),t&&this.containerOuter.classList.remove(this.options.classNames.flippedState)}},{key:"toggleDropdown",value:function(){var t=this.dropdown.classList.contains(this.options.classNames.activeState);t?this.hideDropdown():this.showDropdown()}},{key:"disable",value:function(){this.passedElement.disabled=!0,this.initialised&&(this.input.disabled=!0,this.containerOuter.classList.add(this.options.classNames.disabledState))}},{key:"ajax",value:function(t){var e=this;this.containerOuter.classList.add("is-loading"),this.input.placeholder=this.options.loadingText;var i=function(t,i,n){t&&t.length&&(e.containerOuter.classList.remove("is-loading"),e.input.placeholder="",t.forEach(function(t,s){0===s&&e.addItem(t[i],t[n],s),e.addOption(null,t[i],t[n])}))};t(i)}},{key:"getTemplate",value:function(t){if(t){for(var e=this.options.templates,i=arguments.length,n=Array(i>1?i-1:0),s=1;i>s;s++)n[s-1]=arguments[s];return e[t].apply(e,n)}}},{key:"createTemplates",value:function(){var t=this,e=this.options.classNames,i={containerOuter:function(){return(0,a.strToEl)('
')},containerInner:function(){return(0,a.strToEl)('
')},itemList:function(){return(0,a.strToEl)('
')},optionList:function(){return(0,a.strToEl)('
')},input:function(){return(0,a.strToEl)('')},dropdown:function(){return(0,a.strToEl)('
')},notice:function(t,i){return(0,a.strToEl)('
'+t+"
")},selectOption:function(t){return(0,a.strToEl)('")},option:function(t){return(0,a.strToEl)('\n
\n '+t.label+"\n
\n ")},optgroup:function(t){return(0,a.strToEl)('\n
\n
'+t.value+"
\n
\n ")},item:function(i){return t.options.removeButton?(0,a.strToEl)('\n
\n '+i.label+'\n \n
\n '):(0,a.strToEl)('\n
\n '+i.label+"\n
\n ")}};this.options.templates=(0,a.extend)(this.options.templates,i)}},{key:"generateInput",value:function(){var t=this,e=this.getTemplate("containerOuter"),i=this.getTemplate("containerInner"),n=this.getTemplate("itemList"),s=this.getTemplate("optionList"),o=this.getTemplate("input"),r=this.getTemplate("dropdown");if(this.containerOuter=e,this.containerInner=i,this.input=o,this.optionList=s,this.itemList=n,this.dropdown=r,this.passedElement.classList.add(this.options.classNames.input,this.options.classNames.hiddenState),this.passedElement.tabIndex="-1",this.passedElement.setAttribute("style","display:none;"),this.passedElement.setAttribute("aria-hidden","true"),this.passedElement.removeAttribute("data-choice"),(0,a.wrap)(this.passedElement,i),(0,a.wrap)(i,e),this.options.placeholder&&(this.options.placeholderValue||this.passedElement.placeholder)&&"select-one"!==this.passedElement.type){var l=this.options.placeholderValue||this.passedElement.placeholder;o.placeholder=l,o.style.width=(0,a.getWidthOfInput)(o)}if(this.options.addItems||this.disable(),e.appendChild(i),e.appendChild(r),i.appendChild(n),r.appendChild(s),"select-multiple"===this.passedElement.type||"text"===this.passedElement.type?i.appendChild(o):this.options.allowSearch&&r.insertBefore(o,r.firstChild),"select-multiple"===this.passedElement.type||"select-one"===this.passedElement.type){this.highlightPosition=0;var c=Array.from(this.passedElement.getElementsByTagName("OPTGROUP"));if(this.isSearching=!1,c&&c.length)c.forEach(function(e,i){var n=0===i;t.addGroup(e,i,n)});else{var u=Array.from(this.passedElement.options);u.forEach(function(e){t.addOption(e,e.value,e.innerHTML)})}}else"text"===this.passedElement.type&&this.presetItems.forEach(function(e){if((0,a.isType)("Object",e)){if(!e.value)return;t.addItem(e.value,e.label,e.id)}else(0,a.isType)("String",e)&&t.addItem(e)})}},{key:"renderGroups",value:function(t,e,i){var n=this,s=i||document.createDocumentFragment();return t.forEach(function(t,i){var o=e.filter(function(e){return"select-one"===n.passedElement.type?e.groupId===t.id:e.groupId===t.id&&!e.selected});if(o.length>=1){var r=n.getTemplate("optgroup",t);s.appendChild(r),n.renderOptions(o,s)}}),s}},{key:"renderOptions",value:function(t,e){var i=this,n=e||document.createDocumentFragment();return t.forEach(function(t,e){var s=i.getTemplate("option",t);"select-one"===i.passedElement.type?n.appendChild(s):t.selected||n.appendChild(s)}),n}},{key:"renderItems",value:function(t,e){var i=this,n=e||document.createDocumentFragment(),s=this.store.getItemsReducedToValues(t);"text"===this.passedElement.type?this.passedElement.setAttribute("value",s.join(this.options.delimiter)):!function(){var e=document.createDocumentFragment();t.forEach(function(t){var n=i.getTemplate("selectOption",t);e.appendChild(n)}),i.passedElement.innerHTML="",i.passedElement.appendChild(e)}(),t.forEach(function(t){var e=i.getTemplate("item",t);n.appendChild(e)}),this.itemList.innerHTML="",this.itemList.appendChild(n)}},{key:"render",value:function(){if(this.currentState=this.store.getState(),this.currentState!==this.prevState){if(!(this.currentState.options===this.prevState.options&&this.currentState.groups===this.prevState.groups||"select-multiple"!==this.passedElement.type&&"select-one"!==this.passedElement.type)){var t=this.store.getGroupsFilteredByActive(),e=this.store.getOptionsFilteredByActive(),i=document.createDocumentFragment();if(this.optionList.innerHTML="",t.length>=1&&this.isSearching!==!0?this.renderGroups(t,e,i):e.length>=1&&this.renderOptions(e,i),i.children.length)this.optionList.appendChild(i),this.highlightOption();else{var n=this.isSearching?this.getTemplate("notice","No results found"):this.getTemplate("notice","No options to select");this.optionList.appendChild(n)}}if(this.currentState.items!==this.prevState.items){var s=this.store.getItemsFilteredByActive();s&&this.renderItems(s)}this.prevState=this.currentState}}},{key:"addEventListeners",value:function(){document.addEventListener("keyup",this.onKeyUp),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("mousedown",this.onMouseDown),document.addEventListener("mouseover",this.onMouseOver),this.input.addEventListener("input",this.onInput),this.input.addEventListener("paste",this.onPaste),this.input.addEventListener("focus",this.onFocus),this.input.addEventListener("blur",this.onBlur)}},{key:"removeEventListeners",value:function(){document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("mouseover",this.onMouseOver),this.input.removeEventListener("input",this.onInput),this.input.removeEventListener("paste",this.onPaste),this.input.removeEventListener("focus",this.onFocus),this.input.removeEventListener("blur",this.onBlur)}},{key:"init",value:function(t){this.initialised!==!0&&(this.initialised=!0,this.createTemplates(),this.generateInput(),this.store.subscribe(this.render),this.render(),this.addEventListeners(),(t=this.options.callbackOnInit)&&((0,a.isType)("Function",t)?t():console.error("callbackOnInit: Callback is not a function")))}},{key:"destroy",value:function(){this.passedElement.classList.remove(this.options.classNames.input,this.options.classNames.hiddenState),this.passedElement.tabIndex="",this.passedElement.removeAttribute("style","display:none;"),this.passedElement.removeAttribute("aria-hidden"),this.containerOuter.outerHTML=this.passedElement.outerHTML,this.passedElement=null,this.userOptions=null,this.options=null,this.store=null,this.removeEventListeners()}}]),t}();window.Choices=t.exports=h},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.addItem=function(t,e,i,n){return{type:"ADD_ITEM",value:t,label:e,id:i,optionId:n}},e.removeItem=function(t,e){return{type:"REMOVE_ITEM",id:t,optionId:e}},e.selectItem=function(t,e){return{type:"SELECT_ITEM",id:t,selected:e}},e.addOption=function(t,e,i,n,s){return{type:"ADD_OPTION",value:t,label:e,id:i,groupId:n,disabled:s}},e.filterOptions=function(t){return{type:"FILTER_OPTIONS",results:t}},e.activateOptions=function(){var t=arguments.length<=0||void 0===arguments[0]?!0:arguments[0];return{type:"ACTIVATE_OPTIONS",active:t}},e.addGroup=function(t,e,i,n){return{type:"ADD_GROUP",value:t,id:e,active:i,disabled:n}}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=(e.hasClass=function(t,e){return new RegExp(" "+e+" ").test(" "+t.className+" ")},e.capitalise=function(t){return t.replace(/\w\S*/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()})},e.isType=function(t,e){var i=Object.prototype.toString.call(e).slice(8,-1);return void 0!==e&&null!==e&&i===t}),n=(e.extend=function o(){for(var t={},e=!1,n=arguments.length,s=function(n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e&&i("Object",n[s])?t[s]=o(!0,t[s],n[s]):t[s]=n[s])},r=0;n>r;r++){var a=arguments[r];i("Object",a)?s(a):console.error("Custom options must be an object")}return t},e.whichTransitionEvent=function(){var t,e=document.createElement("fakeelement"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in i)if(void 0!==e.style[t])return i[t]},e.whichAnimationEvent=function(){var t,e=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in i)if(void 0!==e.style[t])return i[t]}),s=(e.getParentsUntil=function(t,e,i){for(var n=[];t&&t!==document;t=t.parentNode){if(e){var s=e.charAt(0);if("."===s&&t.classList.contains(e.substr(1)))break;if("#"===s&&t.id===e.substr(1))break;if("["===s&&t.hasAttribute(e.substr(1,e.length-1)))break;if(t.tagName.toLowerCase()===e)break}if(i){var o=i.charAt(0);"."===o&&t.classList.contains(i.substr(1))&&n.push(t),"#"===o&&t.id===i.substr(1)&&n.push(t),"["===o&&t.hasAttribute(i.substr(1,i.length-1))&&n.push(t),t.tagName.toLowerCase()===i&&n.push(t)}else n.push(t)}return 0===n.length?null:n},e.wrap=function(t,e){return e=e||document.createElement("div"),t.nextSibling?t.parentNode.insertBefore(e,t.nextSibling):t.parentNode.appendChild(e),e.appendChild(t)},e.getSiblings=function(t){for(var e=[],i=t.parentNode.firstChild;i;i=i.nextSibling)1===i.nodeType&&i!==t&&e.push(i);return e},e.findAncestor=function(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t},e.debounce=function(t,e,i){var n;return function(){var s=this,o=arguments,r=function(){n=null,i||t.apply(s,o)},a=i&&!n;clearTimeout(n),n=setTimeout(r,e),a&&t.apply(s,o)}},e.getElemDistance=function(t){var e=0;if(t.offsetParent)do e+=t.offsetTop,t=t.offsetParent;while(t);return e>=0?e:0},e.getElementOffset=function(t,e){var i=e;return i>1&&(i=1),i>0&&(i=0),Math.max(t.offsetHeight*i)},e.getAdjacentEl=function(t,e){var i=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(t&&e){var n=t.parentNode.parentNode,s=Array.from(n.querySelectorAll(e)),o=s.indexOf(t),r=i>0?1:-1;return s[o+r]}},e.getScrollPosition=function(t){return"bottom"===t?Math.max((window.scrollY||window.pageYOffset)+(window.innerHeight||document.documentElement.clientHeight)):window.scrollY||window.pageYOffset},e.isInView=function(t,e,i){return this.getScrollPosition(e)>this.getElemDistance(t)+this.getElementOffset(t,i)},e.isScrolledIntoView=function(t,e){var i=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(t){var n=void 0;return n=i>0?e.scrollTop+e.offsetHeight>=t.offsetTop+t.offsetHeight:t.offsetTop>=e.scrollTop}},e.stripHTML=function(t){var e=document.createElement("DIV");return e.innerHTML=t,e.textContent||e.innerText||""},e.addAnimation=function(t,e){var i=n(),s=function o(){t.classList.remove(e),t.removeEventListener(i,o,!1)};t.classList.add(e),t.addEventListener(i,s,!1)},e.getRandomNumber=function(t,e){return Math.floor(Math.random()*(e-t)+t)},e.strToEl=function(){var t=document.createElement("div");return function(e){var i;for(t.innerHTML=e,i=t.children[0];t.firstChild;)t.removeChild(t.firstChild);return i}}());e.getWidthOfInput=function(t){var e=t.value||t.placeholder,i=t.offsetWidth;if(e){var n=s(""+e+"");n.style.position="absolute",n.style.padding="0",n.style.top="-9999px",n.style.left="-9999px",n.style.width="auto",n.style.whiteSpace="pre",document.body.appendChild(n),e&&n.offsetWidth!==t.offsetWidth&&(i=n.offsetWidth+4),document.body.removeChild(n)}return i+"px"}},function(t,e,i){!function(e){"use strict";function i(){console.log.apply(console,arguments)}function n(t,e){var i,n,s,o;for(this.list=t,this.options=e=e||{},i=0,o=["sort","shouldSort","verbose","tokenize"],n=o.length;n>i;i++)s=o[i],this.options[s]=s in e?e[s]:l[s];for(i=0,o=["searchFn","sortFn","keys","getFn","include"],n=o.length;n>i;i++)s=o[i],this.options[s]=e[s]||l[s]}function s(t,e,i){var n,r,a,l,c,u;if(e){if(a=e.indexOf("."),-1!==a?(n=e.slice(0,a),r=e.slice(a+1)):n=e,l=t[n],null!==l&&void 0!==l)if(r||"string"!=typeof l&&"number"!=typeof l)if(o(l))for(c=0,u=l.length;u>c;c++)s(l[c],r,i);else r&&s(l,r,i);else i.push(l)}else i.push(t);return i}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}function r(t,e){e=e||{},this.options=e,this.options.location=e.location||r.defaultOptions.location,this.options.distance="distance"in e?e.distance:r.defaultOptions.distance,this.options.threshold="threshold"in e?e.threshold:r.defaultOptions.threshold,this.options.maxPatternLength=e.maxPatternLength||r.defaultOptions.maxPatternLength,this.pattern=e.caseSensitive?t:t.toLowerCase(),this.patternLen=t.length,this.patternLen<=this.options.maxPatternLength&&(this.matchmask=1<s;s++)this.tokenSearchers.push(new i(n[s],t));this.fullSeacher=new i(e,t)},n.prototype._startSearch=function(){var t,e,i,n,s=this.options,o=s.getFn,r=this.list,a=r.length,l=this.options.keys,c=l.length,u=null;if("string"==typeof r[0])for(i=0;a>i;i++)this._analyze("",r[i],i,i);else for(this._keyMap={},i=0;a>i;i++)for(u=r[i],n=0;c>n;n++){if(t=l[n],"string"!=typeof t){if(e=1-t.weight||1,this._keyMap[t.name]={weight:e},t.weight<=0||t.weight>1)throw new Error("Key weight has to be > 0 and <= 1");t=t.name}else this._keyMap[t]={weight:1};this._analyze(t,o(u,t,[]),u,i)}},n.prototype._analyze=function(t,e,n,s){var r,l,c,u,d,h,p,f,v,m,g,y,b,w,E,I=this.options,O=!1;if(void 0!==e&&null!==e)if(l=[],"string"==typeof e){if(r=e.split(a),I.verbose&&i("---------\nKey:",t),I.verbose&&i("Record:",r),this.options.tokenize){for(c=this.tokenSearchers,u=c.length,w=0;ww;w++)h+=l[w];h/=f,I.verbose&&i("Token score average:",h)}v=this.fullSeacher.search(e),I.verbose&&i("Full text score:",v.score),p=v.score,void 0!==h&&(p=(p+h)/2),I.verbose&&i("Score average:",p),(O||v.isMatch)&&(d=this.resultMap[s],d?d.output.push({key:t,score:p,matchedIndices:v.matchedIndices}):(this.resultMap[s]={item:n,output:[{key:t,score:p,matchedIndices:v.matchedIndices}]},this.results.push(this.resultMap[s])))}else if(o(e))for(w=0;we;e++)r=s[e].score,a=u?u[s[e].key].weight:1,c=r*a,1!==a?l=Math.min(l,c):(n+=c,s[e].nScore=c);1===l?d[t].score=n/o:d[t].score=l,this.options.verbose&&i(d[t])}},n.prototype._sort=function(){var t=this.options;t.shouldSort&&(t.verbose&&i("\n\nSorting...."),this.results.sort(t.sortFn))},n.prototype._format=function(){var t,e,n,s,o,r=this.options,a=r.getFn,l=[],c=this.results,u=r.include;for(r.verbose&&i("\n\nOutput:\n\n",c),s=r.id?function(t){c[t].item=a(c[t].item,r.id,[])[0]}:function(){},o=function(t){var e,i,n,s,o,r=c[t];if(u.length>0){ -if(e={item:r.item},-1!==u.indexOf("matches"))for(n=r.output,e.matches=[],i=0;ie;e++)s(e),t=o(e),l.push(t);return l},r.defaultOptions={location:0,distance:100,threshold:.6,maxPatternLength:32},r.prototype._calculatePatternAlphabet=function(){var t={},e=0;for(e=0;eS.maxPatternLength){if(y=t.match(new RegExp(this.pattern.replace(a,"|"))),b=!!y)for(E=[],e=0,I=y.length;I>e;e++)O=y[e],E.push([t.indexOf(O),O.length-1]);return{isMatch:b,score:b?.5:1,matchedIndices:E}}for(s=S.location,n=t.length,o=S.threshold,r=t.indexOf(this.pattern,s),w=[],e=0;n>e;e++)w[e]=0;for(-1!=r&&(o=Math.min(this._bitapScore(0,r),o),r=t.lastIndexOf(this.pattern,s+this.patternLen),-1!=r&&(o=Math.min(this._bitapScore(0,r),o))),r=-1,m=1,g=[],u=this.patternLen+n,e=0;el;)this._bitapScore(e,s+c)<=o?l=c:u=c,c=Math.floor((u-l)/2+l);for(u=c,d=Math.max(1,s-c+1),h=Math.min(s+c,n)+this.patternLen,p=Array(h+2),p[h+1]=(1<=d;i--)if(v=this.patternAlphabet[t.charAt(i-1)],v&&(w[i-1]=1),0===e?p[i]=(p[i+1]<<1|1)&v:p[i]=(p[i+1]<<1|1)&v|((f[i+1]|f[i])<<1|1)|f[i+1],p[i]&this.matchmask&&(m=this._bitapScore(e,i-1),o>=m)){if(o=m,r=i-1,g.push(r),!(r>s))break;d=Math.max(1,2*s-r)}if(this._bitapScore(e+1,s)>o)break;f=p}return E=this._getMatchedIndices(w),{isMatch:r>=0,score:0===m?.001:m,matchedIndices:E}},r.prototype._getMatchedIndices=function(t){for(var e,i=[],n=-1,s=-1,o=0,r=r=t.length;r>o;o++)e=t[o],e&&-1===n?n=o:e||-1===n||(s=o-1,i.push([n,s]),n=-1);return t[o-1]&&i.push([n,o-1]),i},t.exports=n}(this)},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Store=void 0;var o=function(){function t(t,e){for(var i=0;ii;i++)e[i]=arguments[i];return function(t){return function(i,n,s){var r=t(i,n,s),l=r.dispatch,c=[],u={getState:r.getState,dispatch:function(t){return l(t)}};return c=e.map(function(t){return t(u)}),l=a.default.apply(void 0,c)(r.dispatch),o({},r,{dispatch:l})}}}var o=Object.assign||function(t){for(var e=1;ei;i++)e[i]=arguments[i];return function(){if(0===e.length)return arguments.length<=0?void 0:arguments[0];var t=e[e.length-1],i=e.slice(0,-1);return i.reduceRight(function(t,e){return e(t)},t.apply(void 0,arguments))}}e.__esModule=!0,e.default=i},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var s=i(6),o=i(18),r=n(o),a=i(19),l=n(a),c=i(20),u=n(c),d=(0,s.combineReducers)({items:r.default,groups:l.default,options:u.default});e.default=d},function(t,e){"use strict";function i(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e-1?t.map(function(t){return t.id===parseInt(e.optionId)&&(t.selected=!0),t}):t;case"REMOVE_ITEM":return e.optionId>-1?t.map(function(t){return t.id===parseInt(e.optionId)&&(t.selected=!1),t}):t;case"FILTER_OPTIONS":var n=e.results,s=t.map(function(t,e){return t.active=n.some(function(e){return e.item.id===t.id?(t.score=e.score,!0):void 0}),t}).sort(function(t,e){return t.score-e.score});return s;case"ACTIVATE_OPTIONS":return t.map(function(t){return t.active=e.active,t});default:return t}};e.default=n}]); \ No newline at end of file +!function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var i={};return e.m=t,e.c=i,e.p="/assets/scripts/dist/",e(0)}([function(t,e,i){t.exports=i(1)},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Choices=void 0;var o=function(){function t(t,e){for(var i=0;i1)for(var o=1;o=1){var t=e.store.getOptionsFiltedBySelectable(),i=e.input.value,n=new c.default(t,{keys:["label","value"],shouldSort:!0,include:"score"}),s=n.search(i);e.highlightPosition=0,e.isSearching=!0,e.store.dispatch((0,r.filterOptions)(s))}};u()}else l&&(this.isSearching=!1,this.store.dispatch((0,r.activateOptions)()))}}}},{key:"onInput",value:function(t){"select-one"!==this.passedElement.type&&(this.input.style.width=(0,a.getWidthOfInput)(this.input))}},{key:"onMouseDown",value:function(t){var e=this;if(2!==t.button){var i=this.store.getItemsFilteredByActive();if(this.containerOuter.contains(t.target))!function(){t.preventDefault();var n=!!t.shiftKey;"text"===e.passedElement.type||e.dropdown.classList.contains(e.options.classNames.activeState)||e.showDropdown(),e.input!==document.activeElement&&e.input.focus(),t.target.hasAttribute("data-button")?e.options.removeItems&&e.options.removeButton&&!function(){var n=t.target.parentNode.getAttribute("data-id"),s=i.find(function(t){return t.id===parseInt(n)});e.removeItem(s)}():t.target.hasAttribute("data-item")?e.options.removeItems&&!function(){var s=t.target.getAttribute("data-id");i.forEach(function(t){t.id!==parseInt(s)||t.selected?n||e.deselectItem(t):e.selectItem(t)})}():t.target.hasAttribute("data-option")&&!function(){var i=e.store.getOptionsFilteredByActive(),n=t.target.getAttribute("data-id"),s=i.find(function(t){return t.id===parseInt(n)});s.selected||s.disabled||(e.addItem(s.value,s.label,s.id),"select-one"===e.passedElement.type&&(e.input.value="",e.isSearching=!1,e.store.dispatch((0,r.activateOptions)(!0)),e.toggleDropdown()))}()}();else{var n=this.dropdown.classList.contains(this.options.classNames.activeState),s=i.some(function(t){return t.selected===!0});s&&this.deselectAll(),this.containerOuter.classList.remove(this.options.classNames.focusState),n&&this.toggleDropdown()}}}},{key:"onPaste",value:function(t){t.target===this.input&&(this.options.allowPaste||t.preventDefault())}},{key:"onMouseOver",value:function(t){(t.target===this.dropdown||(0,a.findAncestor)(t.target,this.options.classNames.listDropdown))&&t.target.hasAttribute("data-option")&&this.highlightOption(t.target)}},{key:"onFocus",value:function(t){var e=this.dropdown.classList.contains(this.options.classNames.activeState);t.target!==this.input||e||(this.containerOuter.classList.add(this.options.classNames.focusState),"select-one"!==this.passedElement.type&&"select-multiple"!==this.passedElement.type||this.showDropdown())}},{key:"onBlur",value:function(t){var e=this.dropdown.classList.contains(this.options.classNames.activeState);t.target!==this.input||e?this.hideDropdown():this.containerOuter.classList.remove(this.options.classNames.focusState)}},{key:"clearInput",value:function(){this.input.value&&(this.input.value=""),"select-one"!==this.passedElement.type&&(this.input.style.width=(0,a.getWidthOfInput)(this.input))}},{key:"regexFilter",value:function(t){if(t){var e=new RegExp(this.options.regexFilter,"i");return e.test(t)}}},{key:"scrollToOption",value:function(t,e){var i=this;if(t){var n=this.optionList.offsetHeight,s=t.offsetHeight,o=t.offsetTop+s,r=this.optionList.scrollTop+n,a=e>0?this.optionList.scrollTop+o-r:t.offsetTop,l=function c(t,e,n){var s=!1,o=void 0,r=void 0,a=4;n>0?(o=(e-i.optionList.scrollTop)/a,r=o>1?o:1,i.optionList.scrollTop=i.optionList.scrollTop+r,i.optionList.scrollTop1?o:1,i.optionList.scrollTop=i.optionList.scrollTop-r,i.optionList.scrollTop>e&&(s=!0)),s&&requestAnimationFrame(function(t){c(t,e,n)})};requestAnimationFrame(function(t){l(t,a,e)})}}},{key:"highlightOption",value:function(t){var e=this,i=Array.from(this.dropdown.querySelectorAll("[data-option-selectable]"));if(i.length){var n=Array.from(this.dropdown.querySelectorAll("."+this.options.classNames.highlightedState));if(n.forEach(function(t){t.classList.remove(e.options.classNames.highlightedState)}),t)t.classList.add(this.options.classNames.highlightedState),this.highlightPosition=i.indexOf(t);else{var s=void 0;s=i.length>this.highlightPosition?i[this.highlightPosition]:i[i.length-1],s||(s=i[0]),s.classList.add(this.options.classNames.highlightedState)}}}},{key:"selectItem",value:function(t){if(t){var e=t.id;this.store.dispatch((0,r.selectItem)(e,!0))}}},{key:"deselectItem",value:function(t){if(t){var e=t.id;this.store.dispatch((0,r.selectItem)(e,!1))}}},{key:"selectAll",value:function(){var t=this,e=this.store.getItems();e.forEach(function(e){t.selectItem(e)})}},{key:"deselectAll",value:function(){var t=this,e=this.store.getItems();e.forEach(function(e){t.deselectItem(e)})}},{key:"addItem",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?-1:arguments[2],n=arguments.length<=3||void 0===arguments[3]?this.options.callbackOnAddItem:arguments[3],s=this.store.getItems(),o=t.trim(),l=e||o,c=i||-1;this.options.prependValue&&(o=this.options.prependValue+o.toString()),this.options.appendValue&&(o+=this.options.appendValue.toString());var u=s?s.length+1:1;this.store.dispatch((0,r.addItem)(o,l,u,c)),"select-one"===this.passedElement.type&&this.removeActiveItems(u),n&&((0,a.isType)("Function",n)?n(u,o,this.passedElement):console.error("callbackOnAddItem: Callback is not a function"))}},{key:"removeItem",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?this.options.callbackOnRemoveItem:arguments[1];if(!t||!(0,a.isType)("Object",t))return void console.error("removeItem: No item object was passed to be removed");var i=t.id,n=(t.value,t.optionId);return this.store.dispatch((0,r.removeItem)(i,n)),e?void((0,a.isType)("Function",e)||console.error("callbackOnRemoveItem: Callback is not a function")):void 0}},{key:"removeItemsByValue",value:function(t){return void(t&&(0,a.isType)("String",t)||console.error("removeItemsByValue: No value was passed to be removed"))}},{key:"removeActiveItems",value:function(t){var e=this,i=this.store.getItemsFilteredByActive();i.forEach(function(i){i.active&&t!==i.id&&e.removeItem(i)})}},{key:"removeSelectedItems",value:function(){var t=this,e=this.store.getItemsFilteredByActive();e.forEach(function(e){e.selected&&e.active&&t.removeItem(e)})}},{key:"addOption",value:function(t,e,i){var n=arguments.length<=3||void 0===arguments[3]?-1:arguments[3];if(e){i||(i=e);var s=this.store.getOptions(),o=s.length+1,a=t&&(t.disabled||t.parentNode.disabled);this.store.dispatch((0,r.addOption)(e,i,o,n,a)),t&&t.selected&&!a&&this.addItem(e,i,o)}}},{key:"addGroup",value:function(t,e,i){var n=this,s=Array.from(t.getElementsByTagName("OPTION")),o=e;s?(this.store.dispatch((0,r.addGroup)(t.label,o,!0,t.disabled)),s.forEach(function(t,e){n.addOption(t,t.value,t.innerHTML,o)})):this.store.dispatch((0,r.addGroup)(t.label,t.id,!1,t.disabled))}},{key:"showDropdown",value:function(){this.containerOuter.classList.add(this.options.classNames.openState),this.dropdown.classList.add(this.options.classNames.activeState);var t=this.dropdown.getBoundingClientRect(),e=t.top+t.height>=document.body.offsetHeight;e?this.containerOuter.classList.add(this.options.classNames.flippedState):this.containerOuter.classList.remove(this.options.classNames.flippedState)}},{key:"hideDropdown",value:function(){var t=this.containerOuter.classList.contains(this.options.classNames.flippedState);this.containerOuter.classList.remove(this.options.classNames.openState),this.dropdown.classList.remove(this.options.classNames.activeState),t&&this.containerOuter.classList.remove(this.options.classNames.flippedState)}},{key:"toggleDropdown",value:function(){var t=this.dropdown.classList.contains(this.options.classNames.activeState);t?this.hideDropdown():this.showDropdown()}},{key:"disable",value:function(){this.passedElement.disabled=!0,this.initialised&&(this.input.disabled=!0,this.containerOuter.classList.add(this.options.classNames.disabledState))}},{key:"ajax",value:function(t){var e=this;this.containerOuter.classList.add("is-loading");var i=this.getTemplate("item",{id:-1,value:"Loading",label:this.options.loadingText,active:!0});this.itemList.appendChild(i);var n=function(t,i,n){t&&t.length&&(e.containerOuter.classList.remove("is-loading"),e.input.placeholder="",t.forEach(function(t,s){0===s&&e.addItem(t[i],t[n],s),e.addOption(null,t[i],t[n])}))};t(n)}},{key:"getTemplate",value:function(t){if(t){for(var e=this.options.templates,i=arguments.length,n=Array(i>1?i-1:0),s=1;i>s;s++)n[s-1]=arguments[s];return e[t].apply(e,n)}}},{key:"createTemplates",value:function(){var t=this,e=this.options.classNames,i={containerOuter:function(){return(0,a.strToEl)('
')},containerInner:function(){return(0,a.strToEl)('
')},itemList:function(){return(0,a.strToEl)('
')},optionList:function(){return(0,a.strToEl)('
')},input:function(){return(0,a.strToEl)('')},dropdown:function(){return(0,a.strToEl)('
')},notice:function(t,i){return(0,a.strToEl)('
'+t+"
")},selectOption:function(t){return(0,a.strToEl)('")},option:function(t){return(0,a.strToEl)('\n
\n '+t.label+"\n
\n ")},optgroup:function(t){return(0,a.strToEl)('\n
\n
'+t.value+"
\n
\n ")},item:function(i){return t.options.removeButton?(0,a.strToEl)('\n
\n '+i.label+'\n \n
\n '):(0,a.strToEl)('\n
\n '+i.label+"\n
\n ")}};this.options.templates=(0,a.extend)(this.options.templates,i)}},{key:"generateInput",value:function(){var t=this,e=this.getTemplate("containerOuter"),i=this.getTemplate("containerInner"),n=this.getTemplate("itemList"),s=this.getTemplate("optionList"),o=this.getTemplate("input"),r=this.getTemplate("dropdown");if(this.containerOuter=e,this.containerInner=i,this.input=o,this.optionList=s,this.itemList=n,this.dropdown=r,this.passedElement.classList.add(this.options.classNames.input,this.options.classNames.hiddenState),this.passedElement.tabIndex="-1",this.passedElement.setAttribute("style","display:none;"),this.passedElement.setAttribute("aria-hidden","true"),this.passedElement.removeAttribute("data-choice"),(0,a.wrap)(this.passedElement,i),(0,a.wrap)(i,e),this.options.placeholder&&(this.options.placeholderValue||this.passedElement.placeholder)){var l=this.options.placeholderValue||this.passedElement.placeholder;o.placeholder=l,"select-one"!==this.passedElement.type&&(o.style.width=(0,a.getWidthOfInput)(o))}if(this.options.addItems||this.disable(),e.appendChild(i),e.appendChild(r),i.appendChild(n),r.appendChild(s),"select-multiple"===this.passedElement.type||"text"===this.passedElement.type?i.appendChild(o):this.options.allowSearch&&r.insertBefore(o,r.firstChild),"select-multiple"===this.passedElement.type||"select-one"===this.passedElement.type){this.highlightPosition=0;var c=Array.from(this.passedElement.getElementsByTagName("OPTGROUP"));if(this.isSearching=!1,c&&c.length)c.forEach(function(e,i){var n=0===i;t.addGroup(e,i,n)});else{var u=Array.from(this.passedElement.options);u.forEach(function(e){t.addOption(e,e.value,e.innerHTML)})}}else"text"===this.passedElement.type&&this.presetItems.forEach(function(e){if((0,a.isType)("Object",e)){if(!e.value)return;t.addItem(e.value,e.label,e.id)}else(0,a.isType)("String",e)&&t.addItem(e)})}},{key:"renderGroups",value:function(t,e,i){var n=this,s=i||document.createDocumentFragment();return t.forEach(function(t,i){var o=e.filter(function(e){return"select-one"===n.passedElement.type?e.groupId===t.id:e.groupId===t.id&&!e.selected});if(o.length>=1){var r=n.getTemplate("optgroup",t);s.appendChild(r),n.renderOptions(o,s)}}),s}},{key:"renderOptions",value:function(t,e){var i=this,n=e||document.createDocumentFragment();return t.forEach(function(t,e){var s=i.getTemplate("option",t);"select-one"===i.passedElement.type?n.appendChild(s):t.selected||n.appendChild(s)}),n}},{key:"renderItems",value:function(t,e){var i=this,n=e||document.createDocumentFragment(),s=this.store.getItemsReducedToValues(t);"text"===this.passedElement.type?this.passedElement.setAttribute("value",s.join(this.options.delimiter)):!function(){var e=document.createDocumentFragment();t.forEach(function(t){var n=i.getTemplate("selectOption",t);e.appendChild(n)}),i.passedElement.innerHTML="",i.passedElement.appendChild(e)}(),t.forEach(function(t){var e=i.getTemplate("item",t);n.appendChild(e)}),this.itemList.innerHTML="",this.itemList.appendChild(n)}},{key:"render",value:function(){if(this.currentState=this.store.getState(),this.currentState!==this.prevState){if(!(this.currentState.options===this.prevState.options&&this.currentState.groups===this.prevState.groups||"select-multiple"!==this.passedElement.type&&"select-one"!==this.passedElement.type)){var t=this.store.getGroupsFilteredByActive(),e=this.store.getOptionsFilteredByActive(),i=document.createDocumentFragment();if(this.optionList.innerHTML="",t.length>=1&&this.isSearching!==!0?this.renderGroups(t,e,i):e.length>=1&&this.renderOptions(e,i),i.children.length)this.optionList.appendChild(i),this.highlightOption();else{var n=this.isSearching?this.getTemplate("notice","No results found"):this.getTemplate("notice","No options to select");this.optionList.appendChild(n)}}if(this.currentState.items!==this.prevState.items){var s=this.store.getItemsFilteredByActive();s&&this.renderItems(s)}this.prevState=this.currentState}}},{key:"addEventListeners",value:function(){document.addEventListener("keyup",this.onKeyUp),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("mousedown",this.onMouseDown),document.addEventListener("mouseover",this.onMouseOver),this.input.addEventListener("input",this.onInput),this.input.addEventListener("paste",this.onPaste),this.input.addEventListener("focus",this.onFocus),this.input.addEventListener("blur",this.onBlur)}},{key:"removeEventListeners",value:function(){document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("mouseover",this.onMouseOver),this.input.removeEventListener("input",this.onInput),this.input.removeEventListener("paste",this.onPaste),this.input.removeEventListener("focus",this.onFocus),this.input.removeEventListener("blur",this.onBlur)}},{key:"init",value:function(t){this.initialised!==!0&&(this.initialised=!0,this.createTemplates(),this.generateInput(),this.store.subscribe(this.render),this.render(),this.addEventListeners(),(t=this.options.callbackOnInit)&&((0,a.isType)("Function",t)?t():console.error("callbackOnInit: Callback is not a function")))}},{key:"destroy",value:function(){this.passedElement.classList.remove(this.options.classNames.input,this.options.classNames.hiddenState),this.passedElement.tabIndex="",this.passedElement.removeAttribute("style","display:none;"),this.passedElement.removeAttribute("aria-hidden"),this.containerOuter.outerHTML=this.passedElement.outerHTML,this.passedElement=null,this.userOptions=null,this.options=null,this.store=null,this.removeEventListeners()}}]),t}();window.Choices=t.exports=h},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.addItem=function(t,e,i,n){return{type:"ADD_ITEM",value:t,label:e,id:i,optionId:n}},e.removeItem=function(t,e){return{type:"REMOVE_ITEM",id:t,optionId:e}},e.selectItem=function(t,e){return{type:"SELECT_ITEM",id:t,selected:e}},e.addOption=function(t,e,i,n,s){return{type:"ADD_OPTION",value:t,label:e,id:i,groupId:n,disabled:s}},e.filterOptions=function(t){return{type:"FILTER_OPTIONS",results:t}},e.activateOptions=function(){var t=arguments.length<=0||void 0===arguments[0]?!0:arguments[0];return{type:"ACTIVATE_OPTIONS",active:t}},e.addGroup=function(t,e,i,n){return{type:"ADD_GROUP",value:t,id:e,active:i,disabled:n}}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=(e.hasClass=function(t,e){return new RegExp(" "+e+" ").test(" "+t.className+" ")},e.capitalise=function(t){return t.replace(/\w\S*/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()})},e.isType=function(t,e){var i=Object.prototype.toString.call(e).slice(8,-1);return void 0!==e&&null!==e&&i===t}),n=(e.extend=function o(){for(var t={},e=!1,n=arguments.length,s=function(n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e&&i("Object",n[s])?t[s]=o(!0,t[s],n[s]):t[s]=n[s])},r=0;n>r;r++){var a=arguments[r];i("Object",a)?s(a):console.error("Custom options must be an object")}return t},e.whichTransitionEvent=function(){var t,e=document.createElement("fakeelement"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in i)if(void 0!==e.style[t])return i[t]},e.whichAnimationEvent=function(){var t,e=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in i)if(void 0!==e.style[t])return i[t]}),s=(e.getParentsUntil=function(t,e,i){for(var n=[];t&&t!==document;t=t.parentNode){if(e){var s=e.charAt(0);if("."===s&&t.classList.contains(e.substr(1)))break;if("#"===s&&t.id===e.substr(1))break;if("["===s&&t.hasAttribute(e.substr(1,e.length-1)))break;if(t.tagName.toLowerCase()===e)break}if(i){var o=i.charAt(0);"."===o&&t.classList.contains(i.substr(1))&&n.push(t),"#"===o&&t.id===i.substr(1)&&n.push(t),"["===o&&t.hasAttribute(i.substr(1,i.length-1))&&n.push(t),t.tagName.toLowerCase()===i&&n.push(t)}else n.push(t)}return 0===n.length?null:n},e.wrap=function(t,e){return e=e||document.createElement("div"),t.nextSibling?t.parentNode.insertBefore(e,t.nextSibling):t.parentNode.appendChild(e),e.appendChild(t)},e.getSiblings=function(t){for(var e=[],i=t.parentNode.firstChild;i;i=i.nextSibling)1===i.nodeType&&i!==t&&e.push(i);return e},e.findAncestor=function(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t},e.debounce=function(t,e,i){var n;return function(){var s=this,o=arguments,r=function(){n=null,i||t.apply(s,o)},a=i&&!n;clearTimeout(n),n=setTimeout(r,e),a&&t.apply(s,o)}},e.getElemDistance=function(t){var e=0;if(t.offsetParent)do e+=t.offsetTop,t=t.offsetParent;while(t);return e>=0?e:0},e.getElementOffset=function(t,e){var i=e;return i>1&&(i=1),i>0&&(i=0),Math.max(t.offsetHeight*i)},e.getAdjacentEl=function(t,e){var i=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(t&&e){var n=t.parentNode.parentNode,s=Array.from(n.querySelectorAll(e)),o=s.indexOf(t),r=i>0?1:-1;return s[o+r]}},e.getScrollPosition=function(t){return"bottom"===t?Math.max((window.scrollY||window.pageYOffset)+(window.innerHeight||document.documentElement.clientHeight)):window.scrollY||window.pageYOffset},e.isInView=function(t,e,i){return this.getScrollPosition(e)>this.getElemDistance(t)+this.getElementOffset(t,i)},e.isScrolledIntoView=function(t,e){var i=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(t){var n=void 0;return n=i>0?e.scrollTop+e.offsetHeight>=t.offsetTop+t.offsetHeight:t.offsetTop>=e.scrollTop}},e.stripHTML=function(t){var e=document.createElement("DIV");return e.innerHTML=t,e.textContent||e.innerText||""},e.addAnimation=function(t,e){var i=n(),s=function o(){t.classList.remove(e),t.removeEventListener(i,o,!1)};t.classList.add(e),t.addEventListener(i,s,!1)},e.getRandomNumber=function(t,e){return Math.floor(Math.random()*(e-t)+t)},e.strToEl=function(){var t=document.createElement("div");return function(e){var i;for(t.innerHTML=e,i=t.children[0];t.firstChild;)t.removeChild(t.firstChild);return i}}());e.getWidthOfInput=function(t){var e=t.value||t.placeholder,i=t.offsetWidth;if(e){var n=s(""+e+"");n.style.position="absolute",n.style.padding="0",n.style.top="-9999px",n.style.left="-9999px",n.style.width="auto",n.style.whiteSpace="pre",document.body.appendChild(n),e&&n.offsetWidth!==t.offsetWidth&&(i=n.offsetWidth+4),document.body.removeChild(n)}return i+"px"}},function(t,e,i){!function(e){"use strict";function i(){console.log.apply(console,arguments)}function n(t,e){var i,n,s,o;for(this.list=t,this.options=e=e||{},i=0,o=["sort","shouldSort","verbose","tokenize"],n=o.length;n>i;i++)s=o[i],this.options[s]=s in e?e[s]:l[s];for(i=0,o=["searchFn","sortFn","keys","getFn","include"],n=o.length;n>i;i++)s=o[i],this.options[s]=e[s]||l[s]}function s(t,e,i){var n,r,a,l,c,u;if(e){if(a=e.indexOf("."),-1!==a?(n=e.slice(0,a),r=e.slice(a+1)):n=e,l=t[n],null!==l&&void 0!==l)if(r||"string"!=typeof l&&"number"!=typeof l)if(o(l))for(c=0,u=l.length;u>c;c++)s(l[c],r,i);else r&&s(l,r,i);else i.push(l)}else i.push(t);return i}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}function r(t,e){e=e||{},this.options=e,this.options.location=e.location||r.defaultOptions.location,this.options.distance="distance"in e?e.distance:r.defaultOptions.distance,this.options.threshold="threshold"in e?e.threshold:r.defaultOptions.threshold,this.options.maxPatternLength=e.maxPatternLength||r.defaultOptions.maxPatternLength,this.pattern=e.caseSensitive?t:t.toLowerCase(),this.patternLen=t.length,this.patternLen<=this.options.maxPatternLength&&(this.matchmask=1<s;s++)this.tokenSearchers.push(new i(n[s],t));this.fullSeacher=new i(e,t)},n.prototype._startSearch=function(){var t,e,i,n,s=this.options,o=s.getFn,r=this.list,a=r.length,l=this.options.keys,c=l.length,u=null;if("string"==typeof r[0])for(i=0;a>i;i++)this._analyze("",r[i],i,i);else for(this._keyMap={},i=0;a>i;i++)for(u=r[i],n=0;c>n;n++){if(t=l[n],"string"!=typeof t){if(e=1-t.weight||1,this._keyMap[t.name]={weight:e},t.weight<=0||t.weight>1)throw new Error("Key weight has to be > 0 and <= 1");t=t.name}else this._keyMap[t]={weight:1};this._analyze(t,o(u,t,[]),u,i)}},n.prototype._analyze=function(t,e,n,s){var r,l,c,u,d,h,p,f,v,m,g,y,b,E,w,I=this.options,O=!1;if(void 0!==e&&null!==e)if(l=[],"string"==typeof e){if(r=e.split(a),I.verbose&&i("---------\nKey:",t),I.verbose&&i("Record:",r),this.options.tokenize){for(c=this.tokenSearchers,u=c.length,E=0;EE;E++)h+=l[E];h/=f,I.verbose&&i("Token score average:",h)}v=this.fullSeacher.search(e),I.verbose&&i("Full text score:",v.score),p=v.score,void 0!==h&&(p=(p+h)/2),I.verbose&&i("Score average:",p),(O||v.isMatch)&&(d=this.resultMap[s],d?d.output.push({key:t,score:p,matchedIndices:v.matchedIndices}):(this.resultMap[s]={item:n,output:[{key:t,score:p,matchedIndices:v.matchedIndices}]},this.results.push(this.resultMap[s])))}else if(o(e))for(E=0;Ee;e++)r=s[e].score,a=u?u[s[e].key].weight:1,c=r*a,1!==a?l=Math.min(l,c):(n+=c,s[e].nScore=c);1===l?d[t].score=n/o:d[t].score=l,this.options.verbose&&i(d[t])}},n.prototype._sort=function(){var t=this.options;t.shouldSort&&(t.verbose&&i("\n\nSorting...."),this.results.sort(t.sortFn))},n.prototype._format=function(){ +var t,e,n,s,o,r=this.options,a=r.getFn,l=[],c=this.results,u=r.include;for(r.verbose&&i("\n\nOutput:\n\n",c),s=r.id?function(t){c[t].item=a(c[t].item,r.id,[])[0]}:function(){},o=function(t){var e,i,n,s,o,r=c[t];if(u.length>0){if(e={item:r.item},-1!==u.indexOf("matches"))for(n=r.output,e.matches=[],i=0;ie;e++)s(e),t=o(e),l.push(t);return l},r.defaultOptions={location:0,distance:100,threshold:.6,maxPatternLength:32},r.prototype._calculatePatternAlphabet=function(){var t={},e=0;for(e=0;eS.maxPatternLength){if(y=t.match(new RegExp(this.pattern.replace(a,"|"))),b=!!y)for(w=[],e=0,I=y.length;I>e;e++)O=y[e],w.push([t.indexOf(O),O.length-1]);return{isMatch:b,score:b?.5:1,matchedIndices:w}}for(s=S.location,n=t.length,o=S.threshold,r=t.indexOf(this.pattern,s),E=[],e=0;n>e;e++)E[e]=0;for(-1!=r&&(o=Math.min(this._bitapScore(0,r),o),r=t.lastIndexOf(this.pattern,s+this.patternLen),-1!=r&&(o=Math.min(this._bitapScore(0,r),o))),r=-1,m=1,g=[],u=this.patternLen+n,e=0;el;)this._bitapScore(e,s+c)<=o?l=c:u=c,c=Math.floor((u-l)/2+l);for(u=c,d=Math.max(1,s-c+1),h=Math.min(s+c,n)+this.patternLen,p=Array(h+2),p[h+1]=(1<=d;i--)if(v=this.patternAlphabet[t.charAt(i-1)],v&&(E[i-1]=1),0===e?p[i]=(p[i+1]<<1|1)&v:p[i]=(p[i+1]<<1|1)&v|((f[i+1]|f[i])<<1|1)|f[i+1],p[i]&this.matchmask&&(m=this._bitapScore(e,i-1),o>=m)){if(o=m,r=i-1,g.push(r),!(r>s))break;d=Math.max(1,2*s-r)}if(this._bitapScore(e+1,s)>o)break;f=p}return w=this._getMatchedIndices(E),{isMatch:r>=0,score:0===m?.001:m,matchedIndices:w}},r.prototype._getMatchedIndices=function(t){for(var e,i=[],n=-1,s=-1,o=0,r=r=t.length;r>o;o++)e=t[o],e&&-1===n?n=o:e||-1===n||(s=o-1,i.push([n,s]),n=-1);return t[o-1]&&i.push([n,o-1]),i},t.exports=n}(this)},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Store=void 0;var o=function(){function t(t,e){for(var i=0;ii;i++)e[i]=arguments[i];return function(t){return function(i,n,s){var r=t(i,n,s),l=r.dispatch,c=[],u={getState:r.getState,dispatch:function(t){return l(t)}};return c=e.map(function(t){return t(u)}),l=a.default.apply(void 0,c)(r.dispatch),o({},r,{dispatch:l})}}}e.__esModule=!0;var o=Object.assign||function(t){for(var e=1;ei;i++)e[i]=arguments[i];if(0===e.length)return function(t){return t};var n=function(){var t=e[e.length-1],i=e.slice(0,-1);return{v:function(){return i.reduceRight(function(t,e){return e(t)},t.apply(void 0,arguments))}}}();return"object"==typeof n?n.v:void 0}e.__esModule=!0,e.default=i},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var s=i(6),o=i(20),r=n(o),a=i(21),l=n(a),c=i(22),u=n(c),d=(0,s.combineReducers)({items:r.default,groups:l.default,options:u.default});e.default=d},function(t,e){"use strict";function i(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e-1?t.map(function(t){return t.id===parseInt(e.optionId)&&(t.selected=!0),t}):t;case"REMOVE_ITEM":return e.optionId>-1?t.map(function(t){return t.id===parseInt(e.optionId)&&(t.selected=!1),t}):t;case"FILTER_OPTIONS":var n=e.results,s=t.map(function(t,e){return t.active=n.some(function(e){return e.item.id===t.id?(t.score=e.score,!0):void 0}),t}).sort(function(t,e){return t.score-e.score});return s;case"ACTIVATE_OPTIONS":return t.map(function(t){return t.active=e.active,t});default:return t}};e.default=n}]); \ No newline at end of file diff --git a/assets/scripts/src/choices.js b/assets/scripts/src/choices.js index 2de643a..c775459 100644 --- a/assets/scripts/src/choices.js +++ b/assets/scripts/src/choices.js @@ -235,7 +235,6 @@ export class Choices { break; case enterKey: - if(this.passedElement.type === 'select-one') this.toggleDropdown(); // If enter key is pressed and the input has a value if(e.target.value && this.passedElement.type === 'text') { @@ -252,6 +251,12 @@ export class Choices { const id = highlighted.getAttribute('data-id'); this.addItem(value, label, id); this.clearInput(this.passedElement); + + if(this.passedElement.type === 'select-one') { + this.isSearching = false; + this.store.dispatch(activateOptions()); + this.toggleDropdown(); + } } } break; @@ -279,7 +284,7 @@ export class Choices { if(nextEl) { // We prevent default to stop the cursor moving // when pressing the arrow - if(!isScrolledIntoView(nextEl, this.dropdown, directionInt)) { + if(!isScrolledIntoView(nextEl, this.optionList, directionInt)) { this.scrollToOption(nextEl, directionInt); } this.highlightOption(nextEl); @@ -290,7 +295,7 @@ export class Choices { case backKey: case deleteKey: // If backspace or delete key is pressed and the input has no value - if(hasFocusedInput && !e.target.value) { + if(hasFocusedInput && !e.target.value && this.passedElement.type !== 'select-one') { this.handleBackspace(activeItems); e.preventDefault(); } @@ -441,6 +446,9 @@ export class Choices { if(!option.selected && !option.disabled) { this.addItem(option.value, option.label, option.id); if(this.passedElement.type === 'select-one') { + this.input.value = ""; + this.isSearching = false; + this.store.dispatch(activateOptions(true)); this.toggleDropdown(); } } @@ -551,17 +559,17 @@ export class Choices { scrollToOption(option, direction) { if(!option) return; - const dropdownHeight = this.dropdown.offsetHeight; + const dropdownHeight = this.optionList.offsetHeight; const optionHeight = option.offsetHeight; - + // Distance from bottom of element to top of parent - const optionPos = option.offsetTop + optionHeight; + const optionPos = option.offsetTop + optionHeight; // Scroll position of dropdown - const containerScrollPos = this.dropdown.scrollTop + dropdownHeight; + const containerScrollPos = this.optionList.scrollTop + dropdownHeight; // Difference between the option and scroll position - let endPoint; + let endPoint = direction > 0 ? ((this.optionList.scrollTop + optionPos) - containerScrollPos) : option.offsetTop; const animateScroll = (time, endPoint, direction) => { let continueAnimation = false; @@ -569,19 +577,19 @@ export class Choices { const strength = 4; if(direction > 0) { - easing = (endPoint - this.dropdown.scrollTop)/strength; + easing = (endPoint - this.optionList.scrollTop)/strength; distance = easing > 1 ? easing : 1; - this.dropdown.scrollTop = this.dropdown.scrollTop + distance; - if(this.dropdown.scrollTop < endPoint) { + this.optionList.scrollTop = this.optionList.scrollTop + distance; + if(this.optionList.scrollTop < endPoint) { continueAnimation = true; } } else { - easing = (this.dropdown.scrollTop - endPoint)/strength; + easing = (this.optionList.scrollTop - endPoint)/strength; distance = easing > 1 ? easing : 1; - this.dropdown.scrollTop = this.dropdown.scrollTop - distance; - if(this.dropdown.scrollTop > endPoint) { + this.optionList.scrollTop = this.optionList.scrollTop - distance; + if(this.optionList.scrollTop > endPoint) { continueAnimation = true; } } @@ -593,18 +601,9 @@ export class Choices { } }; - // Scroll dropdown to top of option - if(direction > 0) { - endPoint = (this.dropdown.scrollTop + optionPos) - containerScrollPos; - requestAnimationFrame((time) => { - animateScroll(time, endPoint, 1); - }); - } else { - endPoint = option.offsetTop; - requestAnimationFrame((time) => { - animateScroll(time, endPoint, -1); - }); - } + requestAnimationFrame((time) => { + animateScroll(time, endPoint, direction); + }); } /** @@ -910,7 +909,10 @@ export class Choices { */ ajax(fn) { this.containerOuter.classList.add('is-loading'); - this.input.placeholder = this.options.loadingText; + // this.input.placeholder = this.options.loadingText; + + const placeholderItem = this.getTemplate('item', { id: -1, value: 'Loading', label: this.options.loadingText, active: true}); + this.itemList.appendChild(placeholderItem); const callback = (results, value, label) => { if(results && results.length) { @@ -1041,9 +1043,9 @@ export class Choices { // If placeholder has been enabled and we have a value if (this.options.placeholder && (this.options.placeholderValue || this.passedElement.placeholder)) { + const placeholder = this.options.placeholderValue || this.passedElement.placeholder; + input.placeholder = placeholder; if(this.passedElement.type !== 'select-one') { - const placeholder = this.options.placeholderValue || this.passedElement.placeholder; - input.placeholder = placeholder; input.style.width = getWidthOfInput(input); } } @@ -1139,7 +1141,7 @@ export class Choices { // Create fragment to add elements to const itemListFragment = fragment || document.createDocumentFragment(); // Simplify store data to just values - const itemsFiltered = this.store.getItemsReducedToValues(items); + const itemsFiltered = this.store.getItemsReducedToValues(items); if(this.passedElement.type === 'text') { // Assign hidden input array of values diff --git a/assets/styles/css/choices.css b/assets/styles/css/choices.css index f5ce17b..e081530 100644 --- a/assets/styles/css/choices.css +++ b/assets/styles/css/choices.css @@ -72,6 +72,8 @@ h1, h2, h3, h4, h5, h6 { display: block; width: 100%; padding: 1rem; + border-bottom: 1px solid #DDDDDD; + background-color: #FFFFFF; margin: 0; } .choices[data-type*="select-one"].is-open:after { @@ -100,7 +102,7 @@ h1, h2, h3, h4, h5, h6 { border-radius: 0.25rem; font-size: 1.4rem; overflow: hidden; } - .is-focused .choices__inner { + .is-focused .choices__inner, .is-open .choices__inner { border-color: #b7b7b7; } .is-open .choices__inner { border-radius: 0.25rem 0.25rem 0 0; } @@ -113,9 +115,8 @@ h1, h2, h3, h4, h5, h6 { list-style-type: none; } .choices__list--single { - display: inline-block; } - .choices__list--single .choices__item { - padding: .4rem; } + display: inline-block; + padding: .4rem; } .choices__list--multiple { display: inline; } @@ -150,11 +151,14 @@ h1, h2, h3, h4, h5, h6 { margin-top: -1px; border-bottom-left-radius: 0.25rem; border-bottom-right-radius: 0.25rem; - max-height: 300px; - overflow: auto; - will-change: scroll-position; } + overflow: hidden; } .choices__list--dropdown.is-active { display: block; } + .choices__list--dropdown .choices__list { + position: relative; + max-height: 300px; + overflow: auto; + will-change: scroll-position; } .choices__list--dropdown .choices__item { padding: 1rem; font-size: 1.4rem; } diff --git a/assets/styles/css/choices.min.css b/assets/styles/css/choices.min.css index ee293a1..ce0908b 100644 --- a/assets/styles/css/choices.min.css +++ b/assets/styles/css/choices.min.css @@ -1 +1 @@ -*,:after,:before{box-sizing:border-box}body,html{margin:0;height:100%;widows:100%}html{font-size:62.5%}body{background-color:#333;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:1.6rem;color:#fff}hr,label{display:block}label{margin-bottom:.8rem;font-size:1.4rem;font-weight:500}hr{margin:3.6rem 0;border:0;border-bottom:1px solid #eaeaea;height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:1.2rem;font-weight:400}.container{display:block;margin:auto;max-width:35em;padding:2.4rem}.section{background-color:#fff;padding:2.4rem;color:#333}.choices{margin-bottom:2.4rem;position:relative}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices[data-type*=select-one] .choices__inner{cursor:pointer;padding-bottom:.75rem}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:1rem;margin:0}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333 transparent;margin-top:-7.5px}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:1.15rem;top:50%;margin-top:-2.5px}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices__inner{background-color:#f9f9f9;padding:.75rem .75rem .375rem;border:1px solid #ddd;border-radius:.25rem;font-size:1.4rem;overflow:hidden}.is-focused .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:.25rem .25rem 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 .25rem .25rem}.choices__list{margin:0;padding-left:0;list-style-type:none}.choices__list--single{display:inline-block}.choices__list--single .choices__item{padding:.4rem}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;border-radius:2rem;padding:.4rem 1rem;font-size:1.2rem;margin-right:.375rem;margin-bottom:.375rem;background-color:#00bcd4;border:1px solid #008fa1;color:#fff;word-break:break-all}.choices__list--multiple .choices__item[data-deletable]{padding-right:.5rem}.choices__list--multiple .choices__item.is-selected{background-color:#00a5bb;border:1px solid #007888}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:.25rem;border-bottom-right-radius:.25rem;max-height:300px;overflow:auto;will-change:scroll-position}.choices__list--dropdown.is-active{display:block}.choices__list--dropdown .choices__item{padding:1rem;font-size:1.4rem}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list--dropdown .choices__item.is-selected{opacity:.5}.choices__list--dropdown .choices__item.is-selected:hover{background-color:#fff}.choices__list--dropdown .choices__item--selectable:after{content:"Press to select";font-size:12px;opacity:0;float:right}.choices__list--dropdown .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.is-open .choices__list--dropdown{border-color:#b7b7b7}.is-flipped .choices__list--dropdown{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:.5}.choices__group .choices__heading{font-weight:600;font-size:1.2rem;padding:1rem;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-image:url(../../icons/cross.svg);background-repeat:no-repeat;background-position:center;background-size:8px;border-left:1px solid #008fa1;margin-left:4px;padding-left:6px;padding-right:6px;line-height:1;cursor:pointer}.choices__input{background-color:#f9f9f9;font-size:1.4rem;padding:0;margin-bottom:.5rem;display:inline-block;vertical-align:baseline;border:0;border-radius:0;max-width:100%;padding:.4rem 0 .4rem .2rem}.choices__input:focus{outline:0} \ No newline at end of file +*,:after,:before{box-sizing:border-box}body,html{margin:0;height:100%;widows:100%}html{font-size:62.5%}body{background-color:#333;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:1.6rem;color:#fff}hr,label{display:block}label{margin-bottom:.8rem;font-size:1.4rem;font-weight:500}hr{margin:3.6rem 0;border:0;border-bottom:1px solid #eaeaea;height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:1.2rem;font-weight:400}.container{display:block;margin:auto;max-width:35em;padding:2.4rem}.section{background-color:#fff;padding:2.4rem;color:#333}.choices{margin-bottom:2.4rem;position:relative}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices[data-type*=select-one] .choices__inner{cursor:pointer;padding-bottom:.75rem}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:1rem;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333 transparent;margin-top:-7.5px}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:1.15rem;top:50%;margin-top:-2.5px}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices__inner{background-color:#f9f9f9;padding:.75rem .75rem .375rem;border:1px solid #ddd;border-radius:.25rem;font-size:1.4rem;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:.25rem .25rem 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 .25rem .25rem}.choices__list{margin:0;padding-left:0;list-style-type:none}.choices__list--single{display:inline-block;padding:.4rem}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;border-radius:2rem;padding:.4rem 1rem;font-size:1.2rem;margin-right:.375rem;margin-bottom:.375rem;background-color:#00bcd4;border:1px solid #008fa1;color:#fff;word-break:break-all}.choices__list--multiple .choices__item[data-deletable]{padding-right:.5rem}.choices__list--multiple .choices__item.is-selected{background-color:#00a5bb;border:1px solid #007888}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:.25rem;border-bottom-right-radius:.25rem;overflow:hidden}.choices__list--dropdown.is-active{display:block}.choices__list--dropdown .choices__list{position:relative;max-height:300px;overflow:auto;will-change:scroll-position}.choices__list--dropdown .choices__item{padding:1rem;font-size:1.4rem}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list--dropdown .choices__item.is-selected{opacity:.5}.choices__list--dropdown .choices__item.is-selected:hover{background-color:#fff}.choices__list--dropdown .choices__item--selectable:after{content:"Press to select";font-size:12px;opacity:0;float:right}.choices__list--dropdown .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.is-open .choices__list--dropdown{border-color:#b7b7b7}.is-flipped .choices__list--dropdown{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:.5}.choices__group .choices__heading{font-weight:600;font-size:1.2rem;padding:1rem;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-image:url(../../icons/cross.svg);background-repeat:no-repeat;background-position:center;background-size:8px;border-left:1px solid #008fa1;margin-left:4px;padding-left:6px;padding-right:6px;line-height:1;cursor:pointer}.choices__input{background-color:#f9f9f9;font-size:1.4rem;padding:0;margin-bottom:.5rem;display:inline-block;vertical-align:baseline;border:0;border-radius:0;max-width:100%;padding:.4rem 0 .4rem .2rem}.choices__input:focus{outline:0} \ No newline at end of file diff --git a/assets/styles/scss/choices.scss b/assets/styles/scss/choices.scss index 2eb204c..0ec181a 100644 --- a/assets/styles/scss/choices.scss +++ b/assets/styles/scss/choices.scss @@ -98,6 +98,8 @@ $choices-button-icon-path: '../../icons/cross.svg'; display: block; width: 100%; padding: 1rem; + border-bottom: 1px solid $choices-keyline-color; + background-color: #FFFFFF; margin: 0; } &.is-open:after { @@ -129,7 +131,7 @@ $choices-button-icon-path: '../../icons/cross.svg'; border-radius: $choices-border-radius; font-size: 1.4rem; overflow: hidden; - .is-focused & { border-color: darken($choices-keyline-color, 15%); } + .is-focused &, .is-open & { border-color: darken($choices-keyline-color, 15%); } .is-open & { border-radius: $choices-border-radius $choices-border-radius 0 0; } .is-flipped.is-open & { border-radius: 0 0 $choices-border-radius $choices-border-radius; } } @@ -142,7 +144,7 @@ $choices-button-icon-path: '../../icons/cross.svg'; .choices__list--single { display: inline-block; - .choices__item { padding: .4rem; } + padding: .4rem; } .choices__list--multiple { @@ -181,11 +183,16 @@ $choices-button-icon-path: '../../icons/cross.svg'; margin-top: -1px; border-bottom-left-radius: $choices-border-radius; border-bottom-right-radius: $choices-border-radius; - max-height: 300px; - overflow: auto; - will-change: scroll-position; + overflow: hidden; &.is-active { display: block; } + .choices__list { + position: relative; + max-height: 300px; + overflow: auto; + will-change: scroll-position; + } + .choices__item { padding: 1rem; font-size: 1.4rem; diff --git a/build/config.gypi b/build/config.gypi new file mode 100644 index 0000000..5b92012 --- /dev/null +++ b/build/config.gypi @@ -0,0 +1,56 @@ +# Do not edit. File was generated by node-gyp's "configure" step +{ + "target_defaults": { + "cflags": [], + "default_configuration": "Release", + "defines": [], + "include_dirs": [], + "libraries": [] + }, + "variables": { + "asan": 0, + "host_arch": "x64", + "icu_data_file": "icudt57l.dat", + "icu_data_in": "../../deps/icu-small/source/data/in/icudt57l.dat", + "icu_endianness": "l", + "icu_gyp_path": "tools/icu/icu-generic.gyp", + "icu_locales": "en,root", + "icu_path": "deps/icu-small", + "icu_small": "true", + "icu_ver_major": "57", + "llvm_version": 0, + "node_byteorder": "little", + "node_enable_v8_vtunejit": "false", + "node_install_npm": "true", + "node_no_browser_globals": "false", + "node_prefix": "/", + "node_release_urlbase": "https://nodejs.org/download/release/", + "node_shared_cares": "false", + "node_shared_http_parser": "false", + "node_shared_libuv": "false", + "node_shared_openssl": "false", + "node_shared_zlib": "false", + "node_tag": "", + "node_use_dtrace": "true", + "node_use_etw": "false", + "node_use_lttng": "false", + "node_use_openssl": "true", + "node_use_perfctr": "false", + "openssl_fips": "", + "openssl_no_asm": 0, + "target_arch": "x64", + "uv_parent_path": "/deps/uv/", + "uv_use_dtrace": "true", + "v8_enable_gdbjit": 0, + "v8_enable_i18n_support": 1, + "v8_no_strict_aliasing": 1, + "v8_optimized_debug": 0, + "v8_random_seed": 0, + "v8_use_snapshot": "true", + "want_separate_host_toolset": 0, + "xcode_version": "7.0", + "nodedir": "/Users/joshjohnson/.node-gyp/6.2.0", + "copy_dev_lib": "true", + "standalone_static_library": 1 + } +} diff --git a/index.html b/index.html index 3daef74..0c1a833 100644 --- a/index.html +++ b/index.html @@ -166,9 +166,9 @@ items: ['josh@joshuajohnson.co.uk', { value: 'joe@bloggs.co.uk', label: 'Joe Bloggs' } ], }); - const choices7 = new Choices('#choices-7'); + const choices7 = new Choices('#choices-7', { allowSearch: false }); - const choicesAjax = new Choices('#choices-12', { allowSearch: false }).ajax((callback) => { + const choicesAjax = new Choices('#choices-12').ajax((callback) => { fetch('https://api.discogs.com/artists/391170/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW') .then((response) => { response.json().then(function(data) {