const WSRInputs = window.WSRInputs || ( function ( document, window, $ ) { const app = { init() { $( app.ready ); }, ready() { app.initFileUploads(); app.initCheckboxMultiselectColumns(); }, initFileUploads() { $( '.wsrw-file-upload' ).each( function () { const $input = $( this ).find( 'input[type=file]' ), $label = $( this ).find( 'label' ), labelVal = $label.html(); $input.on( 'change', function ( event ) { let fileName = ''; if ( this.files && this.files.length > 1 ) { fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length ); } else if ( event.target.value ) { fileName = event.target.value.split( '\\' ).pop(); } if ( fileName ) { $label.find( '.wsrw-file-field' ).html( fileName ); } else { $label.html( labelVal ); } } ); // Firefox bug fix. $input.on( 'focus', function () { $input.addClass( 'has-focus' ); } ).on( 'blur', function () { $input.removeClass( 'has-focus' ); } ); } ); }, initCheckboxMultiselectColumns() { let checked = false; $( document ).on( 'change', '.wsrw-checkbox-multiselect-columns input', function () { var $this = $( this ), $parent = $this.parent(), $container = $this.closest( '.wsrw-checkbox-multiselect-columns' ), label = $parent.text(), itemID = 'check-item-' + $this.val(), $item = $container.find( '#' + itemID ); if ( $this.prop( 'checked' ) ) { $this.parent().addClass( 'checked' ); if ( !$item.length ) { $container.find( '.second-column ul' ).append( '