CMB metabox conditional
//////////////////////////////////////////////////////////////
///////// CONDITIONAL INPUTS
//////////////////////////////////////////////////////////////
// HEADER MEDIA
jQuery(document).ready(function(){
jQuery('#header_media_type').on('change',function(){
var selection = jQuery(this).val();
switch(selection){
case "image":
jQuery(".cmb2-id-header-media-image").show("slow");
jQuery(".cmb2-id-header-media-sc").hide("slow");
break;
case "shortcode":
jQuery(".cmb2-id-header-media-image").hide("slow");
jQuery(".cmb2-id-header-media-sc").show("slow");
break;
}
});
jQuery('#header_media_display').on('change',function(){
var selection = jQuery(this).val();
switch(selection){
case "yes":
jQuery(".cmb2-id-header-media-bgcolor").show("slow");
jQuery(".cmb2-id-header-media-type").show("slow");
jQuery('#header_media_type').trigger('change');
break;
case "no":
jQuery(".cmb2-id-header-media-bgcolor").hide("slow");
jQuery(".cmb2-id-header-media-type").hide("slow");
jQuery(".cmb2-id-header-media-sc").hide("slow");
jQuery(".cmb2-id-header-media-image").hide("slow");
}
});
jQuery('#header_media_type').trigger('change');
jQuery('#header_media_display').trigger('change');
});