You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
645 B
28 lines
645 B
( function ( $, rwmb ) {
|
|
'use strict';
|
|
|
|
function setActiveClass() {
|
|
var $this = $( this ),
|
|
type = $this.attr( 'type' ),
|
|
selected = $this.is( ':checked' ),
|
|
$parent = $this.parent(),
|
|
$others = $parent.siblings();
|
|
if ( selected ) {
|
|
$parent.addClass( 'rwmb-active' );
|
|
if ( type === 'radio' ) {
|
|
$others.removeClass( 'rwmb-active' );
|
|
}
|
|
} else {
|
|
$parent.removeClass( 'rwmb-active' );
|
|
}
|
|
}
|
|
|
|
function init( e ) {
|
|
$( e.target ).find( '.rwmb-image-select input' ).trigger( 'change' );
|
|
}
|
|
|
|
rwmb.$document
|
|
.on( 'mb_ready', init )
|
|
.on( 'change', '.rwmb-image-select input', setActiveClass );
|
|
} )( jQuery, rwmb );
|