jQuery(document).ready(function($) {

	// Dynamically show/hide achievement meta inputs based on "Award By" selection
	$("#_badgeos_earned_by").change( function() {

		// Define our potentially unnecessary inputs
		var badgeos_sequential = $('#_badgeos_sequential').parent().parent();
		var badgeos_points_required = $('#_badgeos_points_required').parent().parent();

		// // Hide our potentially unnecessary inputs
		badgeos_sequential.hide();
		badgeos_points_required.hide();

		// Determine which inputs we should show
		if ( 'triggers' == $(this).val() )
			badgeos_sequential.show();
		else if ( 'points' == $(this).val() )
			badgeos_points_required.show();

	}).change();

	$('[href="#show-api-key"]').click( function(event) {
		event.preventDefault();
		$('#credly-settings tr, #credly-settings .toggle').toggle();
	});

	// Throw a warning on Achievement Type editor if title is > 20 characters
	$('#titlewrap').on( 'keyup', 'input[name=post_title]', function() {

		// Make sure we're editing an achievement type
		if ( 'achievement-type' == $('#post_type').val() ) {
			// Cache the title input selector
			var $title = $(this);
			if ( $title.val().length > 20 ) {
				// Set input to look like danger
				$title.css({'background':'#faa', 'color':'#a00', 'border-color':'#a55' });

				// Output a custom warning (and delete any existing version of that warning)
				$('#title-warning').remove();
				$title.parent().append('<p id="title-warning">Achievement Type supports a maximum of 20 characters. Please choose a shorter title.</p>');
			} else {
				// Set the input to standard style, hide our custom warning
				$title.css({'background':'#fff', 'color':'#333', 'border-color':'#DFDFDF'});
				$('#title-warning').remove();
			}
		}
	} );

});
@@ -1752,11 +1752,1405 @@
 %0A%09%7D );%0A%0A
-%7D);
+%09// Listen for Credly Badge Builder events%0A%09window.addEventListener( 'message', function(e) %7B%0A%09%09// Only continue if data is from credly.com%0A%09%09if ( %22https://credly.com%22 === e.origin && %22object%22 === typeof( data = e.data ) ) %7B%0A%09%09%09var win = window.dialogArguments %7C%7C opener %7C%7C parent %7C%7C top;%0A%0A%09%09%09// Remove the badge builder thickbox%0A%09%09%09tb_remove();%0A%0A%09%09%09win.WPSetThumbnailHTML('%3Cp%3EUpdating featured image, please wait...%3C/p%3E');%0A%0A%09%09%09// Send the badge data along for uploading%0A%09%09%09$.ajax(%7B%0A%09%09%09%09url: ajaxurl,%0A%09%09%09%09data: %7B%0A%09%09%09%09%09'action':     'credly-save-badge',%0A%09%09%09%09%09'post_id':    $('#post_ID').val(),%0A%09%09%09%09%09'image':      e.data.image,%0A%09%09%09%09%09'icon_meta':  e.data.iconMetadata,%0A%09%09%09%09%09'badge_meta': e.data.packagedData,%0A%09%09%09%09%09'all_data':   e.data%0A%09%09%09%09%7D,%0A%09%09%09%09dataType: 'json',%0A%09%09%09%09success: function( response ) %7B%0A%09%09%09%09%09console.log( response );%0A%0A%09%09%09%09%09// Update the featured image metabox%0A%09%09%09%09%09win.WPSetThumbnailHTML(response.data.metabox_html);%0A%0A%09%09%09%09%7D%0A%09%09%09%7D);%0A%09%09%7D%0A%09%7D);%0A%0A%09// Force ThickBox to be our specified width/height%0A%09$('.badge-builder-link').on( 'click', function() %7B%0A%09%09var $link = $(this);%0A%09%09setTimeout( function() %7B%0A%0A%09%09%09var width  = $link.attr('data-width');%0A%09%09%09var height = $link.attr('data-height');%0A%0A%09%09%09console.log( 'width: ' + width + ' height: ' + height );%0A%0A%09%09%09$('#TB_window').css(%7B 'marginLeft': -(width / 2) %7D);%0A%09%09%09$('#TB_window, #TB_iframeContent').width(width).height(height);%0A%0A%09%09%7D, 0 );%0A%09%7D);%0A%0A%7D);%0A

Update badge builder JS