2013-02-18 20:11:24 +01:00
|
|
|
(function($){
|
|
|
|
|
|
|
|
// Post formats selection
|
2013-03-16 06:57:54 +01:00
|
|
|
$('.post-format-select a').on( 'click.post-format', function(e) {
|
2013-03-19 18:18:07 +01:00
|
|
|
var $this = $(this),
|
|
|
|
editor,
|
|
|
|
body,
|
|
|
|
format = $this.data('wp-format'),
|
|
|
|
container = $('#post-body-content');
|
2013-03-16 06:57:54 +01:00
|
|
|
|
2013-02-18 20:11:24 +01:00
|
|
|
$('.post-format-select a.nav-tab-active').removeClass('nav-tab-active');
|
|
|
|
$this.addClass('nav-tab-active').blur();
|
|
|
|
$('#post_format').val(format);
|
2013-03-16 06:57:54 +01:00
|
|
|
|
|
|
|
container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
|
|
|
|
container.addClass('wp-format-' + format);
|
|
|
|
|
|
|
|
if ( typeof tinymce != 'undefined' ) {
|
|
|
|
editor = tinymce.get('content');
|
|
|
|
|
|
|
|
if ( editor ) {
|
|
|
|
body = editor.getBody();
|
|
|
|
body.className = body.className.replace( /\bpost-format-[^ ]+/, '' );
|
|
|
|
editor.dom.addClass( body, 'post-format-' + format );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
e.preventDefault();
|
2013-02-18 20:11:24 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|