Changeset 27038
- Timestamp:
- 01/27/2014 12:27:42 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/post.js
r27035 r27038 1 /* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting , getUserSetting, setUserSetting*/2 /* global theList:true, theExtraList:true, autosave:true*/3 4 var tagBox, commentsBox, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint ;1 /* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting */ 2 /* global theList:true, theExtraList:true, getUserSetting, setUserSetting */ 3 4 var tagBox, commentsBox, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint, makeSlugeditClickable, editPermalink; 5 5 // Back-compat: prevent fatal errors 6 6 makeSlugeditClickable = editPermalink = function(){}; 7 8 window.wp = window.wp || {}; 7 9 8 10 // return an array with any duplicate, whitespace or values removed … … 284 286 285 287 if ( wrap.length && ! wrap.is(':visible') ) { 286 if ( typeof wp != 'undefined' &&wp.autosave ) {288 if ( wp.autosave ) { 287 289 // Save the latest changes and disable 288 290 $(document).one( 'heartbeat-tick', function() { 289 wp.autosave.server. disable();291 wp.autosave.server.suspend(); 290 292 wrap.removeClass('saving').addClass('saved'); 291 293 $(window).off( 'beforeunload.edit-post' ); … … 314 316 action: 'sample-permalink', 315 317 post_id: $('#post_ID').val(), 316 new_title: typeof fullscreen != 'undefined' && fullscreen.settings.visible ? $('#wp-fullscreen-title').val() :$('#title').val(),318 new_title: $('#title').val(), 317 319 samplepermalinknonce: $('#samplepermalinknonce').val() 318 320 }, … … 369 371 370 372 jQuery(document).ready( function($) { 371 var stamp, visibility, $submitButtons, 373 var stamp, visibility, $submitButtons, updateVisibility, updateText, 372 374 sticky = '', 373 375 last = 0, … … 400 402 401 403 // Set the heartbeat interval to 15 sec. if post lock dialogs are enabled 402 if ( typeof wp !== 'undefined' &&wp.heartbeat && $('#post-lock-dialog').length ) {404 if ( wp.heartbeat && $('#post-lock-dialog').length ) { 403 405 wp.heartbeat.interval( 15 ); 404 406 } … … 408 410 var $button = $(this); 409 411 410 if ( $button.hasClass(' button-disabled') ) {412 if ( $button.hasClass('disabled') ) { 411 413 event.preventDefault(); 412 414 return; … … 424 426 } 425 427 426 if ( typeof wp != 'undefined' && wp.autosave ) { 427 wp.autosave.server.disable(); 428 // Stop autosave 429 if ( wp.autosave ) { 430 wp.autosave.server.suspend(); 428 431 } 429 432 … … 431 434 $(window).off( 'beforeunload.edit-post' ); 432 435 433 $submitButtons.addClass( ' button-disabled' );436 $submitButtons.addClass( 'disabled' ); 434 437 435 438 if ( $button.attr('id') === 'publish' ) { … … 448 451 target = $this.attr('target') || 'wp-preview', 449 452 ua = navigator.userAgent.toLowerCase(); 450 453 451 454 event.preventDefault(); 452 455 453 if ( $this. prop('disabled') ) {456 if ( $this.hasClass('disabled') ) { 454 457 return; 455 458 } 456 459 457 if ( typeof wp != 'undefined' &&wp.autosave ) {460 if ( wp.autosave ) { 458 461 wp.autosave.server.tempBlockSave(); 459 462 } … … 497 500 } 498 501 499 if ( typeof wp != 'undefined' &&wp.autosave ) {502 if ( wp.autosave ) { 500 503 wp.autosave.server.triggerSave(); 501 504 } … … 504 507 505 508 $(document).on( 'autosave-disable-buttons.edit-post', function() { 506 $submitButtons.addClass( ' button-disabled' );509 $submitButtons.addClass( 'disabled' ); 507 510 }).on( 'autosave-enable-buttons.edit-post', function() { 508 if ( ! window.wp || ! window.wp.heartbeat || ! window.wp.heartbeat.hasConnectionError() ) { 509 $submitButtons.removeClass( 'button-disabled' ); 510 } 511 if ( ! wp.heartbeat || ! wp.heartbeat.hasConnectionError() ) { 512 $submitButtons.removeClass( 'disabled' ); 513 } 514 }).on( 'before-autosave.edit-post', function() { 515 $( '.autosave-message' ).text( postL10n.savingText ); 516 }).on( 'after-autosave.edit-post', function( event, data ) { 517 $( '.autosave-message' ).text( data.message ); 511 518 }); 512 519 … … 514 521 var editor = typeof tinymce !== 'undefined' && tinymce.get('content'); 515 522 516 if ( ( editor && ! editor.isHidden() && editor.isDirty() ) || 517 ( typeof wp !== 'undefined' &&wp.autosave && wp.autosave.server.postChanged() ) ) {518 519 return autosaveL10n.saveAlert;523 if ( ( editor && ! editor.isHidden() && editor.isDirty() ) || 524 ( wp.autosave && wp.autosave.server.postChanged() ) ) { 525 526 return postL10n.saveAlert; 520 527 } 521 528 }).on( 'unload.edit-post', function( event ) { … … 818 825 $timestampdiv.show(); 819 826 820 if ( typeof wp !== 'undefined' &&wp.autosave ) {827 if ( wp.autosave ) { 821 828 wp.autosave.enableButtons(); 822 829 } … … 849 856 850 857 // permalink 858 function editPermalink() { 859 var i, slug_value, 860 c = 0, 861 e = $('#editable-post-name'), 862 revert_e = e.html(), 863 real_slug = $('#post_name'), 864 revert_slug = real_slug.val(), 865 b = $('#edit-slug-buttons'), 866 revert_b = b.html(), 867 full = $('#editable-post-name-full').html(); 868 869 $('#view-post-btn').hide(); 870 b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); 871 b.children('.save').click(function() { 872 var new_slug = e.children('input').val(); 873 if ( new_slug == $('#editable-post-name-full').text() ) { 874 return $('#edit-slug-buttons .cancel').click(); 875 } 876 $.post(ajaxurl, { 877 action: 'sample-permalink', 878 post_id: postId, 879 new_slug: new_slug, 880 new_title: $('#title').val(), 881 samplepermalinknonce: $('#samplepermalinknonce').val() 882 }, function(data) { 883 var box = $('#edit-slug-box'); 884 box.html(data); 885 if (box.hasClass('hidden')) { 886 box.fadeIn('fast', function () { 887 box.removeClass('hidden'); 888 }); 889 } 890 b.html(revert_b); 891 real_slug.val(new_slug); 892 $('#view-post-btn').show(); 893 }); 894 return false; 895 }); 896 897 $('#edit-slug-buttons .cancel').click(function() { 898 $('#view-post-btn').show(); 899 e.html(revert_e); 900 b.html(revert_b); 901 real_slug.val(revert_slug); 902 return false; 903 }); 904 905 for ( i = 0; i < full.length; ++i ) { 906 if ( '%' == full.charAt(i) ) 907 c++; 908 } 909 910 slug_value = ( c > full.length / 4 ) ? '' : full; 911 e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e) { 912 var key = e.keyCode || 0; 913 // on enter, just save the new slug, don't save the post 914 if ( 13 == key ) { 915 b.children('.save').click(); 916 return false; 917 } 918 if ( 27 == key ) { 919 b.children('.cancel').click(); 920 return false; 921 } 922 } ).keyup( function() { 923 real_slug.val(this.value); 924 }).focus(); 925 } 926 851 927 if ( $editSlugWrap.length ) { 852 function editPermalink() {853 var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'),854 revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(),855 full = $('#editable-post-name-full').html();856 857 $('#view-post-btn').hide();858 b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');859 b.children('.save').click(function() {860 var new_slug = e.children('input').val();861 if ( new_slug == $('#editable-post-name-full').text() ) {862 return $('#edit-slug-buttons .cancel').click();863 }864 $.post(ajaxurl, {865 action: 'sample-permalink',866 post_id: postId,867 new_slug: new_slug,868 new_title: $('#title').val(),869 samplepermalinknonce: $('#samplepermalinknonce').val()870 }, function(data) {871 var box = $('#edit-slug-box');872 box.html(data);873 if (box.hasClass('hidden')) {874 box.fadeIn('fast', function () {875 box.removeClass('hidden');876 });877 }878 b.html(revert_b);879 real_slug.val(new_slug);880 $('#view-post-btn').show();881 });882 return false;883 });884 885 $('#edit-slug-buttons .cancel').click(function() {886 $('#view-post-btn').show();887 e.html(revert_e);888 b.html(revert_b);889 real_slug.val(revert_slug);890 return false;891 });892 893 for ( i = 0; i < full.length; ++i ) {894 if ( '%' == full.charAt(i) )895 c++;896 }897 898 slug_value = ( c > full.length / 4 ) ? '' : full;899 e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e) {900 var key = e.keyCode || 0;901 // on enter, just save the new slug, don't save the post902 if ( 13 == key ) {903 b.children('.save').click();904 return false;905 }906 if ( 27 == key ) {907 b.children('.cancel').click();908 return false;909 }910 } ).keyup( function() {911 real_slug.val(this.value);912 }).focus();913 };914 915 928 $editSlugWrap.on( 'click', function( event ) { 916 929 var $target = $( event.target ); … … 972 985 $textarea = $('textarea#content'), 973 986 $handle = $('#post-status-info'); 974 987 975 988 // No point for touch devices 976 989 if ( ! $textarea.length || 'ontouchstart' in window ) { -
trunk/src/wp-includes/css/buttons.css
r26993 r27038 166 166 .wp-core-ui .button[disabled], 167 167 .wp-core-ui .button:disabled, 168 .wp-core-ui .button.disabled, 168 169 .wp-core-ui .button-secondary[disabled], 169 170 .wp-core-ui .button-secondary:disabled, 171 .wp-core-ui .button-secondary.disabled, 170 172 .wp-core-ui .button-disabled { 171 173 color: #aaa !important; … … 222 224 .wp-core-ui .button-primary[disabled], 223 225 .wp-core-ui .button-primary:disabled, 224 .wp-core-ui .button-primary-disabled { 226 .wp-core-ui .button-primary-disabled, 227 .wp-core-ui .button-primary.disabled { 225 228 color: #94cde7 !important; 226 229 background: #298cba !important; -
trunk/src/wp-includes/js/autosave.js
r26995 r27038 7 7 var initialCompareString, 8 8 lastTriggerSave = 0, 9 isSuspended = false,10 9 $document = $(document); 11 10 … … 88 87 } 89 88 90 function suspend() {91 isSuspended = true;92 }93 94 function resume() {95 isSuspended = false;96 }97 98 89 // Autosave in localStorage 99 90 function autosaveLocal() { 100 91 var restorePostData, undoPostData, blog_id, post_id, hasStorage, intervalTimer, 101 lastCompareString; 92 lastCompareString, 93 isSuspended = false; 102 94 103 95 // Check if the browser supports sessionStorage and it's not disabled … … 195 187 196 188 return setStorage( stored ); 189 } 190 191 function suspend() { 192 isSuspended = true; 193 } 194 195 function resume() { 196 isSuspended = false; 197 197 } 198 198 … … 416 416 hasStorage: hasStorage, 417 417 getSavedPostData: getSavedPostData, 418 save: save 418 save: save, 419 suspend: suspend, 420 resume: resume 419 421 }; 420 422 } … … 422 424 // Autosave on the server 423 425 function autosaveServer() { 424 var _disabled, _blockSave, _blockSaveTimer, previousCompareString, lastCompareString, 425 nextRun = 0; 426 var _blockSave, _blockSaveTimer, previousCompareString, lastCompareString, 427 nextRun = 0, 428 isSuspended = false; 426 429 427 430 // Block saving for the next 10 sec. … … 433 436 _blockSave = false; 434 437 }, 10000 ); 438 } 439 440 function suspend() { 441 isSuspended = true; 442 } 443 444 function resume() { 445 isSuspended = false; 435 446 } 436 447 … … 443 454 444 455 $document.trigger( 'after-autosave', [data] ); 445 $( '.autosave-message' ).text( data.message );446 456 enableButtons(); 447 457 … … 453 463 454 464 /** 455 * Disable autosave456 *457 * Intended to run on form.submit458 */459 function disable() {460 _disabled = true;461 }462 463 /**464 465 * Save immediately 465 466 * … … 489 490 var postData, compareString; 490 491 491 if ( isSuspended || _ disabled || _blockSave ) {492 if ( isSuspended || _blockSave ) { 492 493 return false; 493 494 } … … 517 518 .trigger( 'before-autosave', [ postData ] ); 518 519 519 $( '.autosave-message' ).text( autosaveL10n.savingText );520 520 postData._wpnonce = $( '#_wpnonce' ).val() || ''; 521 521 … … 557 557 558 558 return { 559 disable: disable,560 559 tempBlockSave: tempBlockSave, 561 560 triggerSave: triggerSave, 562 postChanged: postChanged 561 postChanged: postChanged, 562 suspend: suspend, 563 resume: resume 563 564 }; 564 565 } … … 585 586 disableButtons: disableButtons, 586 587 enableButtons: enableButtons, 587 suspend: suspend,588 resume: resume,589 588 local: autosaveLocal(), 590 589 server: autosaveServer() -
trunk/src/wp-includes/script-loader.php
r27028 r27038 431 431 'published' => __('Published'), 432 432 'comma' => _x( ',', 'tag delimiter' ), 433 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), 434 'savingText' => __('Saving Draft…'), 433 435 ) ); 434 436 … … 654 656 wp_localize_script( 'autosave', 'autosaveL10n', array( 655 657 'autosaveInterval' => AUTOSAVE_INTERVAL, 656 'savingText' => __('Saving Draft…'),657 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),658 658 'blog_id' => get_current_blog_id(), 659 659 ) );
Note: See TracChangeset
for help on using the changeset viewer.