/**
 * Classic editor "Add Flipbook" button: opens the picker modal and inserts the
 * [flipa id="N"] shortcode via the editor.
 */
jQuery(function($){
	var $m=$('#flipa-pick');
	$(document).on('click', '.flipa-insert-btn', function(e){ e.preventDefault(); $m.css('display','block'); });
	$(document).on('click', '#flipa-pick-cancel', function(){ $m.hide(); });
	$m.on('click', function(e){ if(e.target===this) $m.hide(); });
	$(document).on('click', '#flipa-pick-insert', function(){
		var id=$('#flipa-pick-sel').val();
		if(id && window.send_to_editor){ window.send_to_editor('[flipa id="'+id+'"]'); }
		$m.hide();
	});
});
