select.js (533B)
1 ( function ( $, rwmb ) { 2 'use strict'; 3 4 function toggleAll( e ) { 5 e.preventDefault(); 6 7 var $this = $( this ), 8 $select = $this.parent().siblings( 'select' ); 9 10 if ( 'none' === $this.data( 'type' ) ) { 11 $select.val( [] ).trigger( 'change' ); 12 return; 13 } 14 var selected = []; 15 $select.find( 'option' ).each( function ( index, option ) { 16 selected.push( option.value ); 17 } ); 18 $select.val( selected ).trigger( 'change' ); 19 }; 20 21 rwmb.$document.on( 'click', '.rwmb-select-all-none a', toggleAll ); 22 } )( jQuery, rwmb );