Choices/assets/scripts/dist/choices.min.js

2 lines
41 KiB
JavaScript
Raw Normal View History

2016-05-10 10:02:59 +02:00
!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;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),r=i(2),a=i(3),l=i(4),c=n(l),u=i(5),d=n(u),h=e.Choices=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?"[data-choice]":arguments[0],i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(s(this,t),(0,a.isType)("String",e)){var n=document.querySelectorAll(e);if(n.length>1)for(var o=1;o<n.length;o++){var r=n[o];new t(r,i)}}var l={items:[],addItems:!0,removeItems:!0,editItems:!1,maxItems:!1,delimiter:",",allowDuplicates:!0,allowPaste:!0,allowSearch:!0,regexFilter:!1,placeholder:!0,placeholderValue:"",prependValue:!1,appendValue:!1,selectAll:!0,templates:{},classNames:{containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemOption:"choices__item--option",group:"choices__group",groupHeading:"choices__heading",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",hiddenState:"is-hidden",flippedState:"is-flipped",selectedState:"is-selected"},callbackOnInit:function(){},callbackOnRemoveItem:function(){},callbackOnAddItem:function(){}};this.options=(0,a.extend)(l,i),this.store=new d.default(this.render),this.initialised=!1,this.currentState={},this.prevState={},this.passedElement=(0,a.isType)("String",e)?document.querySelector(e):e,this.highlightPosition=0,this.presetItems=[],this.options.items.length?this.presetItems=this.options.items:""!==this.passedElement.value&&(this.presetItems=this.passedElement.value.split(this.options.delimiter)),this.init=this.init.bind(this),this.render=this.render.bind(this),this.destroy=this.destroy.bind(this),this.disable=this.disable.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onMouseOver=this.onMouseOver.bind(this);var c="querySelector"in document&&"addEventListener"in document&&"classList"in document.createElement("div");c||console.error("Choices: Your browser doesn't support Choices");var u=["select-one","select-multiple","text"],h=this.passedElement&&u.includes(this.passedElement.type);h?this.init():console.error("Choices: Incompatible input passed")}return o(t,[{key:"handleEnter",value:function(t,e){var i=!0;if(this.options.addItems?this.options.maxItems&&this.options.maxItems<=this.list.children.length?i=!1:this.options.allowDuplicates===!1&&this.passedElement.value&&(i=!t.some(function(t){return t.value===e})):i=!1,i){var n=!0;this.options.regexFilter&&(n=this.regexFilter(e)),n&&(this.toggleDropdown(),this.addItem(e),this.clearInput(this.passedElement))}}},{key:"handleBackspace",value:function(t){if(this.options.removeItems&&t){var e=t[t.length-1],i=t.some(function(t){return t.selected===!0});this.options.editItems&&!i&&e?(this.input.value=e.value,this.removeItem(e)):(this.selectItem(e),this.removeSelectedItems())}}},{key:"onKeyDown",value:function(t){if(t.target===this.input){var e=t.ctrlKey||t.metaKey,i=46,n=8,s=13,o=65,r=27,l=38,c=40,u=this.store.getItemsFi
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;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),r=i(6),a=i(16),l=n(a),c=e.Store=function(){function t(){s(this,t),this.store=(0,r.createStore)(l.default,window.devToolsExtension?window.devToolsExtension():void 0)}return o(t,[{key:"getState",value:function(){return this.store.getState()}},{key:"dispatch",value:function(t){this.store.dispatch(t)}},{key:"subscribe",value:function(t){this.store.subscribe(t)}},{key:"getItems",value:function(){var t=this.store.getState();return t.items}},{key:"getItemsFilteredByActive",value:function(){var t=this.getItems(),e=t.filter(function(t){return t.active===!0},[]);return e}},{key:"getItemsReducedToValues",value:function(){var t=arguments.length<=0||void 0===arguments[0]?this.getItems():arguments[0],e=t.reduce(function(t,e){return t.push(e.value),t},[]);return e}},{key:"getOptions",value:function(){var t=this.store.getState();return t.options}},{key:"getOptionsFilteredByActive",value:function(){var t=this.getOptions(),e=t.filter(function(t){return t.active===!0},[]);return e}},{key:"getOptionsFiltedBySelectable",value:function(){var t=this.getOptions(),e=t.filter(function(t){return t.selected===!1&&t.disabled!==!0},[]);return e}},{key:"getGroups",value:function(){var t=this.store.getState();return t.groups}},{key:"getGroupsFilteredByActive",value:function(){var t=this.getGroups(),e=this.getOptions(),i=t.filter(function(t){var i=t.active===!0&&t.disabled===!1,n=e.some(function(t){return t.active===!0&&t.disabled===!1});return!(!i||!n)},[]);return i}}]),t}();t.exports=c},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0,e.compose=e.applyMiddleware=e.bindActionCreators=e.combineReducers=e.createStore=void 0;var s=i(7),o=n(s),r=i(11),a=n(r),l=i(13),c=n(l),u=i(14),d=n(u),h=i(15),p=n(h),f=i(12);n(f);e.createStore=o.default,e.combineReducers=a.default,e.bindActionCreators=c.default,e.applyMiddleware=d.default,e.compose=p.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e,i){function n(){f===p&&(f=p.slice())}function o(){return h}function l(t){if("function"!=typeof t)throw new Error("Expected listener to be a function.");var e=!0;return n(),f.push(t),function(){if(e){e=!1,n();var i=f.indexOf(t);f.splice(i,1)}}}function c(t){if(!(0,r.default)(t))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if("undefined"==typeof t.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(v)throw new Error("Reducers may not dispatch actions.");try{v=!0,h=d(h,t)}finally{v=!1}for(var e=p=f,i=0;i<e.length;i++)e[i]();return t}function u(t){if("function"!=typeof t)throw new Error("Expected the nextReducer to be a function.");d=t,c({type:a.INIT})}if("function"==typeof e&&"undefined"==typeof i&&(i=e,e=void 0),"undefined"!=typeof i){if("function"!=typeof i)throw new Error("Expected the enhancer to be a function.");return i(s)(t,e)}if("function"!=typeof t)throw new Error("Expected the reducer to be a function.");var d=t,h=e,p=[],f=p,v=!1;return c({type:a.INIT}),{dispatch:c,subscribe:l,getState:o,replaceReducer:u}}e.__esModule=!0,e.ActionTypes=void 0,e.default=s;var o=i(8),r=n(o),a=e.ActionTypes={INIT:"@@redux/INIT"}},function(t,e,i){function n(t){if(!o(t)||u.call(t)!=r||s(t))return!1;var e=d(t);if(null===e)return!0;var i=e.constructor;return"function"==typeof i&&i instanceof i&&l.call(i)==c}var s=i(9),o=i(10),r="[object Object]",a=