Changeset 32098
- Timestamp:
- 04/09/2015 07:06:41 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/press-this.js
r32092 r32098 7 7 var editor, $mediaList, $mediaThumbWrap, 8 8 saveAlert = false, 9 editLinkVisible = false, 9 10 textarea = document.createElement( 'textarea' ), 10 11 sidebarIsOpen = false, … … 103 104 function showSpinner() { 104 105 $( '.spinner' ).addClass( 'is-active' ); 105 $( '.post-actions button' ).each( function() { 106 $( this ).attr( 'disabled', 'disabled' ); 107 } ); 106 $( '.post-actions button' ).attr( 'disabled', 'disabled' ); 108 107 } 109 108 … … 113 112 function hideSpinner() { 114 113 $( '.spinner' ).removeClass( 'is-active' ); 115 $( '.post-actions button' ).each( function() { 116 $( this ).removeAttr( 'disabled' ); 117 } ); 114 $( '.post-actions button' ).removeAttr( 'disabled' ); 118 115 } 119 116 … … 167 164 */ 168 165 function submitPost( action ) { 169 var data; 166 var data, 167 keepFocus = $( document.activeElement ).hasClass( 'draft-button' ); 170 168 171 169 saveAlert = false; … … 187 185 clearNotices(); 188 186 }).done( function( response ) { 189 var $link, $button , keepFocus;187 var $link, $button; 190 188 191 189 if ( ! response.success ) { … … 204 202 $link = $( '.edit-post-link' ); 205 203 $button = $( '.draft-button' ); 206 207 if ( document.activeElement && document.activeElement.className.indexOf( 'draft-button' ) > -1 ) { 208 keepFocus = true; 209 } 204 editLinkVisible = true; 210 205 211 206 $button.fadeOut( 200, function() { 212 207 $button.removeClass( 'is-saving' ); 213 $link.fadeIn( 200 ); 214 215 if ( keepFocus ) { 216 $link.focus(); 217 } 208 $link.fadeIn( 200, function() { 209 var active = document.activeElement; 210 // Different browsers move the focus to different places when the button is disabled. 211 if ( keepFocus && ( active === $button[0] || $( active ).hasClass( 'post-actions' ) || active.nodeName === 'BODY' ) ) { 212 $link.focus(); 213 } 214 }); 218 215 }); 219 216 } … … 224 221 225 222 function resetDraftButton() { 226 $( '.edit-post-link' ).fadeOut( 200, function() { 227 $( '.draft-button' ).removeClass( 'is-saving' ).fadeIn( 200 ); 228 }); 223 if ( editLinkVisible ) { 224 editLinkVisible = false; 225 226 $( '.edit-post-link' ).fadeOut( 200, function() { 227 $( '.draft-button' ).removeClass( 'is-saving' ).fadeIn( 200 ); 228 }); 229 } 229 230 } 230 231 … … 656 657 editor = ed; 657 658 658 function focus() {659 editor.on( 'nodechange', function() { 659 660 hasSetFocus = true; 660 661 resetDraftButton(); 661 } 662 663 if ( window.tinymce.Env.iOS ) { 664 editor.on( 'click', focus ); 665 } else { 666 editor.on( 'focus', focus ); 667 } 662 } ); 668 663 }).on( 'click.press-this keypress.press-this', '.suggested-media-thumbnail', function( event ) { 669 664 if ( event.type === 'click' || event.keyCode === 13 ) {
Note: See TracChangeset
for help on using the changeset viewer.