Press This:
- Fix focusing the Standard Editor link after saving draft, if the user has not focused another element. - Reset the Save Draft button on node change in the editor. See #31923. Built from https://develop.svn.wordpress.org/trunk@32098 git-svn-id: http://core.svn.wordpress.org/trunk@32077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5a547231b7
commit
923ca312e4
|
@ -6,6 +6,7 @@
|
||||||
var PressThis = function() {
|
var PressThis = function() {
|
||||||
var editor, $mediaList, $mediaThumbWrap,
|
var editor, $mediaList, $mediaThumbWrap,
|
||||||
saveAlert = false,
|
saveAlert = false,
|
||||||
|
editLinkVisible = false,
|
||||||
textarea = document.createElement( 'textarea' ),
|
textarea = document.createElement( 'textarea' ),
|
||||||
sidebarIsOpen = false,
|
sidebarIsOpen = false,
|
||||||
settings = window.wpPressThisConfig || {},
|
settings = window.wpPressThisConfig || {},
|
||||||
|
@ -102,9 +103,7 @@
|
||||||
*/
|
*/
|
||||||
function showSpinner() {
|
function showSpinner() {
|
||||||
$( '.spinner' ).addClass( 'is-active' );
|
$( '.spinner' ).addClass( 'is-active' );
|
||||||
$( '.post-actions button' ).each( function() {
|
$( '.post-actions button' ).attr( 'disabled', 'disabled' );
|
||||||
$( this ).attr( 'disabled', 'disabled' );
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,9 +111,7 @@
|
||||||
*/
|
*/
|
||||||
function hideSpinner() {
|
function hideSpinner() {
|
||||||
$( '.spinner' ).removeClass( 'is-active' );
|
$( '.spinner' ).removeClass( 'is-active' );
|
||||||
$( '.post-actions button' ).each( function() {
|
$( '.post-actions button' ).removeAttr( 'disabled' );
|
||||||
$( this ).removeAttr( 'disabled' );
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +163,8 @@
|
||||||
* @param action string publish|draft
|
* @param action string publish|draft
|
||||||
*/
|
*/
|
||||||
function submitPost( action ) {
|
function submitPost( action ) {
|
||||||
var data;
|
var data,
|
||||||
|
keepFocus = $( document.activeElement ).hasClass( 'draft-button' );
|
||||||
|
|
||||||
saveAlert = false;
|
saveAlert = false;
|
||||||
showSpinner();
|
showSpinner();
|
||||||
|
@ -186,7 +184,7 @@
|
||||||
hideSpinner();
|
hideSpinner();
|
||||||
clearNotices();
|
clearNotices();
|
||||||
}).done( function( response ) {
|
}).done( function( response ) {
|
||||||
var $link, $button, keepFocus;
|
var $link, $button;
|
||||||
|
|
||||||
if ( ! response.success ) {
|
if ( ! response.success ) {
|
||||||
renderError( response.data.errorMessage );
|
renderError( response.data.errorMessage );
|
||||||
|
@ -203,18 +201,17 @@
|
||||||
} else if ( response.data.postSaved ) {
|
} else if ( response.data.postSaved ) {
|
||||||
$link = $( '.edit-post-link' );
|
$link = $( '.edit-post-link' );
|
||||||
$button = $( '.draft-button' );
|
$button = $( '.draft-button' );
|
||||||
|
editLinkVisible = true;
|
||||||
if ( document.activeElement && document.activeElement.className.indexOf( 'draft-button' ) > -1 ) {
|
|
||||||
keepFocus = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$button.fadeOut( 200, function() {
|
$button.fadeOut( 200, function() {
|
||||||
$button.removeClass( 'is-saving' );
|
$button.removeClass( 'is-saving' );
|
||||||
$link.fadeIn( 200 );
|
$link.fadeIn( 200, function() {
|
||||||
|
var active = document.activeElement;
|
||||||
if ( keepFocus ) {
|
// Different browsers move the focus to different places when the button is disabled.
|
||||||
$link.focus();
|
if ( keepFocus && ( active === $button[0] || $( active ).hasClass( 'post-actions' ) || active.nodeName === 'BODY' ) ) {
|
||||||
}
|
$link.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).fail( function() {
|
}).fail( function() {
|
||||||
|
@ -223,9 +220,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetDraftButton() {
|
function resetDraftButton() {
|
||||||
$( '.edit-post-link' ).fadeOut( 200, function() {
|
if ( editLinkVisible ) {
|
||||||
$( '.draft-button' ).removeClass( 'is-saving' ).fadeIn( 200 );
|
editLinkVisible = false;
|
||||||
});
|
|
||||||
|
$( '.edit-post-link' ).fadeOut( 200, function() {
|
||||||
|
$( '.draft-button' ).removeClass( 'is-saving' ).fadeIn( 200 );
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -655,16 +656,10 @@
|
||||||
$( document ).on( 'tinymce-editor-init', function( event, ed ) {
|
$( document ).on( 'tinymce-editor-init', function( event, ed ) {
|
||||||
editor = ed;
|
editor = ed;
|
||||||
|
|
||||||
function focus() {
|
editor.on( 'nodechange', function() {
|
||||||
hasSetFocus = true;
|
hasSetFocus = true;
|
||||||
resetDraftButton();
|
resetDraftButton();
|
||||||
}
|
} );
|
||||||
|
|
||||||
if ( window.tinymce.Env.iOS ) {
|
|
||||||
editor.on( 'click', focus );
|
|
||||||
} else {
|
|
||||||
editor.on( 'focus', focus );
|
|
||||||
}
|
|
||||||
}).on( 'click.press-this keypress.press-this', '.suggested-media-thumbnail', function( event ) {
|
}).on( 'click.press-this keypress.press-this', '.suggested-media-thumbnail', function( event ) {
|
||||||
if ( event.type === 'click' || event.keyCode === 13 ) {
|
if ( event.type === 'click' || event.keyCode === 13 ) {
|
||||||
insertSelectedMedia( $( this ) );
|
insertSelectedMedia( $( this ) );
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-beta4-32097';
|
$wp_version = '4.2-beta4-32098';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue