Do not attempt a slide transition if the current and switched-to post
formats both have no UI. Do not slide if clicking on the current format. see #19570 git-svn-id: http://core.svn.wordpress.org/trunk@23854 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fb78aa819e
commit
9c80f135d0
|
@ -1,28 +1,44 @@
|
||||||
window.wp = window.wp || {};
|
window.wp = window.wp || {};
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
var mediaFrame, lastMimeType, lastMenu, mediaPreview;
|
var container, mediaFrame, lastMimeType, lastMenu, mediaPreview, noUIFormats = ['standard', 'chat', 'status', 'aside'];
|
||||||
|
|
||||||
|
function switchFormatClass( format ) {
|
||||||
|
container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
|
||||||
|
container.addClass('wp-format-' + format);
|
||||||
|
}
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
var $container = $( '.post-formats-fields' );
|
var $container = $( '.post-formats-fields' );
|
||||||
|
|
||||||
// Post formats selection
|
// Post formats selection
|
||||||
$('.post-format-options').on( 'click', 'a', function(e){
|
$('.post-format-options').on( 'click', 'a', function(e){
|
||||||
|
e.preventDefault();
|
||||||
var $this = $(this), editor, body,
|
var $this = $(this), editor, body,
|
||||||
parent = $this.parent(),
|
parent = $this.parent(),
|
||||||
format = $this.data('wp-format'),
|
format = $this.data('wp-format'),
|
||||||
container = $('#post-body-content'),
|
|
||||||
description = $('.post-format-description');
|
description = $('.post-format-description');
|
||||||
|
|
||||||
|
if ( typeof container === 'undefined' )
|
||||||
|
container = $('#post-body-content');
|
||||||
|
|
||||||
|
// Already on this post format. Bail.
|
||||||
|
if ( format === postFormats.currentPostFormat )
|
||||||
|
return;
|
||||||
|
|
||||||
parent.find('a.active').removeClass('active');
|
parent.find('a.active').removeClass('active');
|
||||||
$this.addClass('active');
|
$this.addClass('active');
|
||||||
$('#icon-edit').removeClass(postFormats.currentPostFormat).addClass(format);
|
$('#icon-edit').removeClass(postFormats.currentPostFormat).addClass(format);
|
||||||
$('#post_format').val(format);
|
$('#post_format').val(format);
|
||||||
|
|
||||||
$container.slideUp( 200, function(){
|
if ( -1 < $.inArray( format, noUIFormats ) && -1 < $.inArray( postFormats.currentPostFormat, noUIFormats ) ) {
|
||||||
container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
|
switchFormatClass( format ); // No slide
|
||||||
container.addClass('wp-format-' + format);
|
} else {
|
||||||
$container.slideDown( 400 );
|
$container.slideUp( 200, function(){
|
||||||
});
|
switchFormatClass( format );
|
||||||
|
$container.slideDown( 400 );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$('#title').focus();
|
$('#title').focus();
|
||||||
|
|
||||||
|
@ -43,8 +59,6 @@ window.wp = window.wp || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
postFormats.currentPostFormat = format;
|
postFormats.currentPostFormat = format;
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
}).on('mouseenter focusin', 'a', function () {
|
}).on('mouseenter focusin', 'a', function () {
|
||||||
$('.post-format-tip').html( $(this).prop('title') );
|
$('.post-format-tip').html( $(this).prop('title') );
|
||||||
}).on('mouseleave focusout', 'a', function () {
|
}).on('mouseleave focusout', 'a', function () {
|
||||||
|
|
Loading…
Reference in New Issue