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:focus,
.button-subtle:hover, .button-subtle:hover,
.button-subtle:active { .button-subtle:active,
.edit-post-link:focus,
.edit-post-link:hover,
.edit-post-link:active {
color: #00a0d2; color: #00a0d2;
} }
.button-subtle:focus, .button-subtle:focus,
.button-subtle:active { .button-subtle:active,
.edit-post-link:focus,
.edit-post-link:active {
outline: 0; outline: 0;
text-decoration: underline; text-decoration: underline;
} }
@ -1373,8 +1378,8 @@ html {
background-size: 20px 20px; background-size: 20px 20px;
opacity: 0.7; opacity: 0.7;
filter: alpha(opacity=70); filter: alpha(opacity=70);
line-height: 30px; line-height: 1;
vertical-align: baseline; vertical-align: middle;
} }
@media print, @media print,
@ -1734,7 +1739,7 @@ html {
.post-actions { .post-actions {
float: left; float: left;
margin: 14px 0 14px 30px; margin: 14px 0 14px 30px;
font-size: 0; font-size: 13px;
} }
@media (max-width: 320px) { @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 */ /* TinyMCE styles */
.editor .wp-media-buttons { .editor .wp-media-buttons {
float: none; 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:focus,
.button-subtle:hover, .button-subtle:hover,
.button-subtle:active { .button-subtle:active,
.edit-post-link:focus,
.edit-post-link:hover,
.edit-post-link:active {
color: #00a0d2; color: #00a0d2;
} }
.button-subtle:focus, .button-subtle:focus,
.button-subtle:active { .button-subtle:active,
.edit-post-link:focus,
.edit-post-link:active {
outline: 0; outline: 0;
text-decoration: underline; text-decoration: underline;
} }
@ -1373,8 +1378,8 @@ html {
background-size: 20px 20px; background-size: 20px 20px;
opacity: 0.7; opacity: 0.7;
filter: alpha(opacity=70); filter: alpha(opacity=70);
line-height: 30px; line-height: 1;
vertical-align: baseline; vertical-align: middle;
} }
@media print, @media print,
@ -1734,7 +1739,7 @@ html {
.post-actions { .post-actions {
float: right; float: right;
margin: 14px 30px 14px 0; margin: 14px 30px 14px 0;
font-size: 0; font-size: 13px;
} }
@media (max-width: 320px) { @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 */ /* TinyMCE styles */
.editor .wp-media-buttons { .editor .wp-media-buttons {
float: none; 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>
<div class="post-actions"> <div class="post-actions">
<span class="spinner">&nbsp;</span> <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-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> <button type="button" class="button-primary publish-button"><?php echo ( current_user_can( 'publish_posts' ) ) ? __( 'Publish' ) : __( 'Submit for Review' ); ?></button>
</div> </div>

View File

@ -184,7 +184,10 @@
data: data data: data
}).always( function() { }).always( function() {
hideSpinner(); hideSpinner();
clearNotices();
}).done( function( response ) { }).done( function( response ) {
var $link, $button, keepFocus;
if ( ! response.success ) { if ( ! response.success ) {
renderError( response.data.errorMessage ); renderError( response.data.errorMessage );
} else if ( response.data.redirect ) { } else if ( response.data.redirect ) {
@ -198,13 +201,33 @@
window.location.href = response.data.redirect; window.location.href = response.data.redirect;
} }
} else if ( response.data.postSaved ) { } 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() { }).fail( function() {
renderError( __( 'serverError' ) ); 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 * 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 ); renderNotice( msg, true );
} }
function clearNotices() {
$( 'div.alerts' ).empty();
}
/** /**
* Render notices on page load, if any already * Render notices on page load, if any already
*/ */
@ -527,6 +554,7 @@
$titleField.on( 'focus', function() { $titleField.on( 'focus', function() {
$placeholder.addClass( 'is-hidden' ); $placeholder.addClass( 'is-hidden' );
resetDraftButton();
}).on( 'blur', function() { }).on( 'blur', function() {
if ( ! $titleField.text() && ! $titleField.html() ) { if ( ! $titleField.text() && ! $titleField.html() ) {
$placeholder.removeClass( 'is-hidden' ); $placeholder.removeClass( 'is-hidden' );
@ -627,9 +655,16 @@
$( document ).on( 'tinymce-editor-init', function( event, ed ) { $( document ).on( 'tinymce-editor-init', function( event, ed ) {
editor = ed; editor = ed;
ed.on( 'focus', function() { function focus() {
hasSetFocus = true; 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 ) { }).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 ) );
@ -637,15 +672,17 @@
}); });
// Publish, Draft and Preview buttons // Publish, Draft and Preview buttons
$( '.post-actions' ).on( 'click.press-this', function( event ) { $( '.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' ) ) { if ( $button.length ) {
if ( $button.hasClass( 'draft-button' ) ) {
$button.addClass( 'is-saving' );
submitPost( 'draft' ); submitPost( 'draft' );
} else if ( $target.hasClass( 'publish-button' ) ) { } else if ( $button.hasClass( 'publish-button' ) ) {
submitPost( 'publish' ); submitPost( 'publish' );
} else if ( $target.hasClass( 'preview-button' ) ) { } else if ( $button.hasClass( 'preview-button' ) ) {
prepareFormData(); prepareFormData();
window.opener && window.opener.focus(); window.opener && window.opener.focus();
@ -653,6 +690,10 @@
$( '#pressthis-form' ).attr( 'target', '_blank' ).submit().attr( 'target', '' ); $( '#pressthis-form' ).attr( 'target', '_blank' ).submit().attr( 'target', '' );
$( '#wp-preview' ).val( '' ); $( '#wp-preview' ).val( '' );
} }
} else if ( $target.hasClass( 'edit-post-link' ) && window.opener ) {
window.opener.focus();
window.self.close();
}
}); });
monitorOptionsModal(); monitorOptionsModal();

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.