Press This:

- When saving a draft change the text of the Save Draft button to Saving...
- On success, hide the button and show Edit Post link in its place. If the user focuses the title or the editor, hide the link and show the button again.
Fixes #31923.
Built from https://develop.svn.wordpress.org/trunk@32092


git-svn-id: http://core.svn.wordpress.org/trunk@32071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-04-08 23:14:28 +00:00
parent d43d1503f7
commit 33a0022773
8 changed files with 120 additions and 31 deletions

View File

@ -341,12 +341,17 @@ strong {
.button-subtle:focus,
.button-subtle:hover,
.button-subtle:active {
.button-subtle:active,
.edit-post-link:focus,
.edit-post-link:hover,
.edit-post-link:active {
color: #00a0d2;
}
.button-subtle:focus,
.button-subtle:active {
.button-subtle:active,
.edit-post-link:focus,
.edit-post-link:active {
outline: 0;
text-decoration: underline;
}
@ -1373,8 +1378,8 @@ html {
background-size: 20px 20px;
opacity: 0.7;
filter: alpha(opacity=70);
line-height: 30px;
vertical-align: baseline;
line-height: 1;
vertical-align: middle;
}
@media print,
@ -1734,7 +1739,7 @@ html {
.post-actions {
float: left;
margin: 14px 0 14px 30px;
font-size: 0;
font-size: 13px;
}
@media (max-width: 320px) {
@ -1743,6 +1748,23 @@ html {
}
}
.edit-post-link {
font-size: 13px;
display: inline-block;
text-decoration: none;
padding: 0 10px;
}
.draft-button.is-hidden,
.draft-button .saving-draft,
.draft-button.is-saving .save-draft {
display: none;
}
.draft-button.is-saving .saving-draft {
display: inline;
}
/* TinyMCE styles */
.editor .wp-media-buttons {
float: none;

File diff suppressed because one or more lines are too long

View File

@ -341,12 +341,17 @@ strong {
.button-subtle:focus,
.button-subtle:hover,
.button-subtle:active {
.button-subtle:active,
.edit-post-link:focus,
.edit-post-link:hover,
.edit-post-link:active {
color: #00a0d2;
}
.button-subtle:focus,
.button-subtle:active {
.button-subtle:active,
.edit-post-link:focus,
.edit-post-link:active {
outline: 0;
text-decoration: underline;
}
@ -1373,8 +1378,8 @@ html {
background-size: 20px 20px;
opacity: 0.7;
filter: alpha(opacity=70);
line-height: 30px;
vertical-align: baseline;
line-height: 1;
vertical-align: middle;
}
@media print,
@ -1734,7 +1739,7 @@ html {
.post-actions {
float: right;
margin: 14px 30px 14px 0;
font-size: 0;
font-size: 13px;
}
@media (max-width: 320px) {
@ -1743,6 +1748,23 @@ html {
}
}
.edit-post-link {
font-size: 13px;
display: inline-block;
text-decoration: none;
padding: 0 10px;
}
.draft-button.is-hidden,
.draft-button .saving-draft,
.draft-button.is-saving .save-draft {
display: none;
}
.draft-button.is-saving .saving-draft {
display: inline;
}
/* TinyMCE styles */
.editor .wp-media-buttons {
float: none;

File diff suppressed because one or more lines are too long

View File

@ -1430,7 +1430,11 @@ class WP_Press_This {
</div>
<div class="post-actions">
<span class="spinner">&nbsp;</span>
<button type="button" class="button-subtle draft-button"><?php _e( 'Save Draft' ); ?></button>
<button type="button" class="button-subtle draft-button" aria-live="polite">
<span class="save-draft"><?php _e( 'Save Draft' ); ?></span>
<span class="saving-draft"><?php _e( 'Saving...' ); ?></span>
</button>
<a href="<?php echo esc_url( get_edit_post_link( $post_ID ) ); ?>" class="edit-post-link" style="display: none;" target="_blank"><?php _e( 'Edit Post' ); ?></a>
<button type="button" class="button-subtle preview-button"><?php _e( 'Preview' ); ?></button>
<button type="button" class="button-primary publish-button"><?php echo ( current_user_can( 'publish_posts' ) ) ? __( 'Publish' ) : __( 'Submit for Review' ); ?></button>
</div>

View File

@ -184,7 +184,10 @@
data: data
}).always( function() {
hideSpinner();
clearNotices();
}).done( function( response ) {
var $link, $button, keepFocus;
if ( ! response.success ) {
renderError( response.data.errorMessage );
} else if ( response.data.redirect ) {
@ -198,13 +201,33 @@
window.location.href = response.data.redirect;
}
} else if ( response.data.postSaved ) {
// show "success" message?
$link = $( '.edit-post-link' );
$button = $( '.draft-button' );
if ( document.activeElement && document.activeElement.className.indexOf( 'draft-button' ) > -1 ) {
keepFocus = true;
}
$button.fadeOut( 200, function() {
$button.removeClass( 'is-saving' );
$link.fadeIn( 200 );
if ( keepFocus ) {
$link.focus();
}
});
}
}).fail( function() {
renderError( __( 'serverError' ) );
});
}
function resetDraftButton() {
$( '.edit-post-link' ).fadeOut( 200, function() {
$( '.draft-button' ).removeClass( 'is-saving' ).fadeIn( 200 );
});
}
/**
* Inserts the media a user has selected from the presented list inside the editor, as an image or embed, based on type
*
@ -328,6 +351,10 @@
renderNotice( msg, true );
}
function clearNotices() {
$( 'div.alerts' ).empty();
}
/**
* Render notices on page load, if any already
*/
@ -527,6 +554,7 @@
$titleField.on( 'focus', function() {
$placeholder.addClass( 'is-hidden' );
resetDraftButton();
}).on( 'blur', function() {
if ( ! $titleField.text() && ! $titleField.html() ) {
$placeholder.removeClass( 'is-hidden' );
@ -623,13 +651,20 @@
/**
* Set app events and other state monitoring related code.
*/
function monitor(){
function monitor() {
$( document ).on( 'tinymce-editor-init', function( event, ed ) {
editor = ed;
ed.on( 'focus', function() {
function focus() {
hasSetFocus = true;
} );
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 ) {
if ( event.type === 'click' || event.keyCode === 13 ) {
insertSelectedMedia( $( this ) );
@ -637,21 +672,27 @@
});
// Publish, Draft and Preview buttons
$( '.post-actions' ).on( 'click.press-this', function( event ) {
var $target = $( event.target );
var $target = $( event.target ),
$button = $target.closest( 'button' );
if ( $target.hasClass( 'draft-button' ) ) {
submitPost( 'draft' );
} else if ( $target.hasClass( 'publish-button' ) ) {
submitPost( 'publish' );
} else if ( $target.hasClass( 'preview-button' ) ) {
prepareFormData();
window.opener && window.opener.focus();
if ( $button.length ) {
if ( $button.hasClass( 'draft-button' ) ) {
$button.addClass( 'is-saving' );
submitPost( 'draft' );
} else if ( $button.hasClass( 'publish-button' ) ) {
submitPost( 'publish' );
} else if ( $button.hasClass( 'preview-button' ) ) {
prepareFormData();
window.opener && window.opener.focus();
$( '#wp-preview' ).val( 'dopreview' );
$( '#pressthis-form' ).attr( 'target', '_blank' ).submit().attr( 'target', '' );
$( '#wp-preview' ).val( '' );
$( '#wp-preview' ).val( 'dopreview' );
$( '#pressthis-form' ).attr( 'target', '_blank' ).submit().attr( 'target', '' );
$( '#wp-preview' ).val( '' );
}
} else if ( $target.hasClass( 'edit-post-link' ) && window.opener ) {
window.opener.focus();
window.self.close();
}
});

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta4-32091';
$wp_version = '4.2-beta4-32092';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.