{"version":3,"sources":["select-multiple.js"],"names":["e4","selectMultiple","init","event","util","registerEvents","bindEvents","jQuery","each","intIndex","domNode","setSelection","document","on","closeComponent","target","debounce","searchOptions","settings","debounceDelay","input","setModalMinHeight","currentTarget","setSearchInputFocus","updateDropDownPosition","applySelection","hasSelectionChanged","closest","trigger","selectionChanged","jSelectMultiple","jSelectMultipleLabel","find","jSelectedOptionInputs","getSelectedOptionInputs","strSelectedOptionValues","getSelectedOptionInputValuesAsString","undefined","data","html","length","attr","addClass","removeClass","strSelectedOptionValuesPrevious","stringify","filter","returnValue","arrSelectedOptionValues","push","value","join","is","dropdown","modal","jModalBody","css","outerHeight","jInput","strSearchQuery","val","trim","toLowerCase","jOptions","index","jOption","indexOf","intIntervalRunCounter","intUpdateIntervalId","jDropdownToggle","jDropdownMenu","domDropdownMenu","get","domCanvas","objDropDownRect","getBoundingClientRect","objCanvasRect","right","width","setInterval","clearInterval"],"mappings":"AAAAA,GAAAC,eAAA,CACAC,KAAA,WACAF,GAAAC,eAAAE,MAAAH,GAAAI,KAAAC,eAAA,mBAAA,kBACAL,GAAAC,eAAAK,aACAC,OAAA,yBAAAC,KAAA,SAAAC,EAAAC,GACAV,GAAAC,eAAAU,aAAAD,MAGAJ,WAAA,WACAC,OAAAK,UAAAC,GAAA,SAAA,4CAAA,SAAAV,GACAH,GAAAC,eAAAa,eAAAX,EAAAY,UACAF,GAAA,QAAA,kCAAA,SAAAV,GACAH,GAAAC,eAAAa,eAAAX,EAAAY,UACAF,GAAA,QAAA,qCAAAb,GAAAI,KAAAY,SAAA,SAAAb,GACAH,GAAAC,eAAAgB,cAAAd,EAAAY,SACAf,GAAAkB,SAAAC,cAAAC,QAAAP,GAAA,iBAAA,iCAAA,SAAAV,GACAH,GAAAC,eAAAoB,kBAAAlB,EAAAmB,eACAtB,GAAAC,eAAAsB,oBAAApB,EAAAmB,iBACAT,GAAA,oBAAA,wBAAA,SAAAV,GACAH,GAAAC,eAAAuB,uBAAArB,EAAAY,UACA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OAAAG,GAAAiB,QAAA,0BACA,IAAAG,EAAAsB,GAAA,qBACAtB,EAAAE,KAAA,4BAAAqB,SAAA,WAEA,IAAAvB,EAAAsB,GAAA,cACAtB,EAAAE,KAAA,UAAAsB,MAAA,SAGAjC,kBAAA,SAAAX,GACA6C,EAAAhD,OAAAG,GAAAsB,KAAA,eACAuB,EAAAC,IAAA,aAAAD,EAAAE,cAAA,OAEAlC,oBAAA,SAAAb,GACAH,OAAAG,GAAAsB,KAAA,sCAAAJ,QAAA,UAEAX,cAAA,SAAAP,GACA,IAAAgD,EAAAnD,OAAAG,GACAiD,EAAAD,EAAAE,MAAAC,OAAAC,cACAC,EAAAL,EAAA/B,QAAA,iCAAAK,KAAA,gCACA,EAAA2B,EAAAnB,OACAuB,EAAAvD,KAAA,SAAAwD,EAAAtD,GACAuD,EAAA1D,OAAAG,IAEA,EADAV,GAAAI,KAAAyC,UAAAoB,EAAAjC,KAAA,SAAAM,KAAA,UAAAuB,OAAAC,cACAI,QAAAP,GACAM,EAAAtB,YAAA,UAGAsB,EAAAvB,SAAA,YAKAqB,EAAApB,YAAA,WAGAnB,uBAAA,SAAAd,GAIA,IAQAyD,EAGAC,EAXAC,EAAA9D,OAAAG,GAAAsB,KAAA,oBACAsC,EAAA/D,OAAAG,GAAAsB,KAAA,kBACAuC,EAAAD,EAAAE,IAAA,GACAC,EAAAlE,OAAA,gBAAAiE,IAAA,GACAE,EAAAH,EAAAI,wBACAC,EAAAH,EAAAE,wBACAD,EAAAG,MAAAD,EAAAE,QACAR,EAAA5B,SAAA,aACAyB,EAAA,EAGAC,EAAAW,YAAA,WACAZ,IACAO,EAAAH,EAAAI,wBACAC,EAAAH,EAAAE,wBACAD,EAAAG,MAAAD,EAAAE,OAAAX,EANA,GAOAE,EAAAhB,SAAA,WAGAiB,EAAA3B,YAAA,aACAqC,cAAAZ,KAVA","file":"select-multiple.js","sourcesContent":["e4.selectMultiple = {\r\n init: function () {\r\n e4.selectMultiple.event = e4.util.registerEvents( 'selectionChanged', 'selectMultiple' );\r\n e4.selectMultiple.bindEvents();\r\n jQuery( '.js-e-select-multiple' ).each( function ( intIndex, domNode ) {\r\n e4.selectMultiple.setSelection( domNode );\r\n } );\r\n },\r\n bindEvents: function () {\r\n jQuery( document ).on( 'change', '.js-e-select-multiple input[type=\"radio\"]', function ( event ) {\r\n e4.selectMultiple.closeComponent( event.target );\r\n } ).on( 'click', '.js-e-select-multiple-apply-btn', function ( event ) {\r\n e4.selectMultiple.closeComponent( event.target );\r\n } ).on( 'input', '.js-e-select-multiple-search-input', e4.util.debounce( function ( event ) {\r\n e4.selectMultiple.searchOptions( event.target );\r\n }, e4.settings.debounceDelay.input ) ).on( 'shown.bs.modal', '.js-e-select-multiple.is-modal', function ( event ) {\r\n e4.selectMultiple.setModalMinHeight( event.currentTarget );\r\n e4.selectMultiple.setSearchInputFocus( event.currentTarget );\r\n } ).on( 'shown.bs.dropdown', '.js-e-select-multiple', function ( event ) {\r\n e4.selectMultiple.updateDropDownPosition( event.target );\r\n } ).on( 'hidden.bs.dropdown hidden.bs.modal', '.js-e-select-multiple', function ( event ) {\r\n e4.selectMultiple.applySelection( event.currentTarget );\r\n } );\r\n },\r\n applySelection: function ( domNode ) {\r\n if ( e4.selectMultiple.hasSelectionChanged( domNode ) === true ) {\r\n e4.selectMultiple.setSelection( domNode );\r\n jQuery( domNode ).closest( '.js-e-select-multiple' ).trigger( e4.selectMultiple.event.selectionChanged );\r\n }\r\n },\r\n setSelection: function ( domNode ) {\r\n var jSelectMultiple = jQuery( domNode ),\r\n jSelectMultipleLabel = jSelectMultiple.find( '.js-e-select-multiple-label' ),\r\n jSelectedOptionInputs = e4.selectMultiple.getSelectedOptionInputs( domNode ),\r\n strSelectedOptionValues = e4.selectMultiple.getSelectedOptionInputValuesAsString( domNode );\r\n\r\n if ( jSelectMultiple.data( 'original-label' ) === undefined ) {\r\n jSelectMultiple.data( 'original-label', jSelectMultipleLabel.html() );\r\n }\r\n if ( jSelectedOptionInputs.length > 0 ) {\r\n\r\n if ( jSelectedOptionInputs.attr( 'type' ) === 'radio' ) {\r\n jSelectMultipleLabel.html( jSelectedOptionInputs.data( 'label' ) );\r\n }\r\n else if ( jSelectedOptionInputs.attr( 'type' ) === 'checkbox' ) {\r\n jSelectMultipleLabel.addClass( 'font-weight-bold' ).html( jSelectMultiple.data( 'original-label' ) + ' (' + jSelectedOptionInputs.length + ')' );\r\n }\r\n\r\n }\r\n else {\r\n jSelectMultipleLabel.removeClass( 'font-weight-bold' ).html( jSelectMultiple.data( 'original-label' ) );\r\n }\r\n\r\n jSelectMultiple.data( 'selectedOptionValues', strSelectedOptionValues );\r\n\r\n },\r\n hasSelectionChanged: function ( domNode ) {\r\n var returnValue = false,\r\n strSelectedOptionValuesPrevious = e4.util.stringify( jQuery( domNode ).data( 'selectedOptionValues' ) ),\r\n strSelectedOptionValuesCurrent = e4.selectMultiple.getSelectedOptionInputValuesAsString( domNode );\r\n if ( strSelectedOptionValuesPrevious === undefined ) {\r\n strSelectedOptionValuesPrevious = '';\r\n }\r\n returnValue = strSelectedOptionValuesPrevious !== strSelectedOptionValuesCurrent;\r\n return returnValue;\r\n\r\n },\r\n getSelectedOptionInputs: function ( domNode ) {\r\n return jQuery( domNode ).find( '.js-e-select-multiple-content' ).find( 'input' ).filter( ':checked' );\r\n },\r\n getSelectedOptionInputValuesAsString: function ( domNode ) {\r\n var returnValue = '',\r\n jSelectedOptionInputs = e4.selectMultiple.getSelectedOptionInputs( domNode ),\r\n arrSelectedOptionValues = [];\r\n\r\n if ( jSelectedOptionInputs.length > 0 ) {\r\n jSelectedOptionInputs.each( function ( intIndex, domNode ) {\r\n arrSelectedOptionValues.push( domNode.value );\r\n } );\r\n returnValue = arrSelectedOptionValues.join( ',' );\r\n }\r\n return returnValue;\r\n\r\n },\r\n closeComponent: function ( domNode ) {\r\n var jSelectMultiple = jQuery( domNode ).closest( '.js-e-select-multiple' );\r\n if ( jSelectMultiple.is( '.is-dropdown.show' ) === true ) {\r\n jSelectMultiple.find( '[data-toggle=\"dropdown\"]' ).dropdown( 'toggle' );\r\n }\r\n else if ( jSelectMultiple.is( '.is-modal' ) === true ) {\r\n jSelectMultiple.find( '.modal' ).modal( 'hide' );\r\n }\r\n },\r\n setModalMinHeight: function ( domNode ) {\r\n var jModalBody = jQuery( domNode ).find( '.modal-body' );\r\n jModalBody.css( 'min-height', jModalBody.outerHeight() + 'px' );\r\n },\r\n setSearchInputFocus: function ( domNode ) {\r\n jQuery( domNode ).find( '.js-e-select-multiple-search-input' ).trigger( 'focus' );\r\n },\r\n searchOptions: function ( domNode ) {\r\n var jInput = jQuery( domNode ),\r\n strSearchQuery = jInput.val().trim().toLowerCase(),\r\n jOptions = jInput.closest( '.js-e-select-multiple-content' ).find( '.js-e-select-multiple-option' );\r\n if ( strSearchQuery.length > 0 ) {\r\n jOptions.each( function ( index, domNode ) {\r\n var jOption = jQuery( domNode ),\r\n strOptionValue = e4.util.stringify( jOption.find( 'input' ).data( 'label' ) ).trim().toLowerCase();\r\n if ( strOptionValue.indexOf( strSearchQuery ) > -1 ) {\r\n jOption.removeClass( 'd-none' );\r\n }\r\n else {\r\n jOption.addClass( 'd-none' );\r\n }\r\n } );\r\n }\r\n else {\r\n jOptions.removeClass( 'd-none' );\r\n }\r\n },\r\n updateDropDownPosition: function ( domNode ) {\r\n // Bug: Nasty workaround for Popper.js bug when dropdown overflows scrollParent with fixed width:\r\n // https://codepen.io/damngood/pen/OJjaymB\r\n // Proper fix will require Popper.js upgrade to v2.x.x or Bootstrap v5.x.x\r\n var jDropdownToggle = jQuery( domNode ).find( '.dropdown-toggle' ),\r\n jDropdownMenu = jQuery( domNode ).find( '.dropdown-menu' ),\r\n domDropdownMenu = jDropdownMenu.get( 0 ),\r\n domCanvas = jQuery( '.js-e-canvas' ).get( 0 ),\r\n objDropDownRect = domDropdownMenu.getBoundingClientRect(),\r\n objCanvasRect = domCanvas.getBoundingClientRect();\r\n if ( objDropDownRect.right > objCanvasRect.width ) {\r\n jDropdownMenu.addClass( 'invisible' );\r\n var intIntervalRunCounter = 0,\r\n intIntervalRunMax = 50,\r\n intIntervalTime = 5,\r\n intUpdateIntervalId = setInterval( function () {\r\n intIntervalRunCounter++;\r\n objDropDownRect = domDropdownMenu.getBoundingClientRect();\r\n objCanvasRect = domCanvas.getBoundingClientRect();\r\n if ( objDropDownRect.right > objCanvasRect.width && intIntervalRunCounter < intIntervalRunMax ) {\r\n jDropdownToggle.dropdown( 'update' );\r\n }\r\n else {\r\n jDropdownMenu.removeClass( 'invisible' );\r\n clearInterval( intUpdateIntervalId );\r\n }\r\n }, intIntervalTime );\r\n }\r\n }\r\n};\r\n"]}