balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

image-select.js (645B)


      1 ( function ( $, rwmb ) {
      2 	'use strict';
      3 
      4 	function setActiveClass() {
      5 		var $this = $( this ),
      6 			type = $this.attr( 'type' ),
      7 			selected = $this.is( ':checked' ),
      8 			$parent = $this.parent(),
      9 			$others = $parent.siblings();
     10 		if ( selected ) {
     11 			$parent.addClass( 'rwmb-active' );
     12 			if ( type === 'radio' ) {
     13 				$others.removeClass( 'rwmb-active' );
     14 			}
     15 		} else {
     16 			$parent.removeClass( 'rwmb-active' );
     17 		}
     18 	}
     19 
     20 	function init( e ) {
     21 		$( e.target ).find( '.rwmb-image-select input' ).trigger( 'change' );
     22 	}
     23 
     24 	rwmb.$document
     25 		.on( 'mb_ready', init )
     26 		.on( 'change', '.rwmb-image-select input', setActiveClass );
     27 } )( jQuery, rwmb );