Changeset 27035
- Timestamp:
- 01/26/2014 03:06:52 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/post.js
r27015 r27035 376 376 postId = $('#post_ID').val() || 0, 377 377 $submitpost = $('#submitpost'), 378 releaseLock = true; 378 releaseLock = true, 379 $postVisibilitySelect = $('#post-visibility-select'), 380 $timestampdiv = $('#timestampdiv'), 381 $postStatusSelect = $('#post-status-select'); 379 382 380 383 postboxes.add_postbox_toggles(pagenow); … … 647 650 648 651 updateVisibility = function() { 649 var pvSelect = $('#post-visibility-select'); 650 if ( $('input:radio:checked', pvSelect).val() != 'public' ) { 652 if ( $postVisibilitySelect.find('input:radio:checked').val() != 'public' ) { 651 653 $('#sticky').prop('checked', false); 652 654 $('#sticky-span').hide(); … … 654 656 $('#sticky-span').show(); 655 657 } 656 if ( $ ('input:radio:checked', pvSelect).val() != 'password' ) {658 if ( $postVisibilitySelect.find('input:radio:checked').val() != 'password' ) { 657 659 $('#password-span').hide(); 658 660 } else { … … 663 665 updateText = function() { 664 666 665 if ( ! $ ('#timestampdiv').length )667 if ( ! $timestampdiv.length ) 666 668 return true; 667 669 … … 675 677 676 678 if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) { 677 $ ('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');679 $timestampdiv.find('.timestamp-wrap').addClass('form-invalid'); 678 680 return false; 679 681 } else { 680 $ ('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');682 $timestampdiv.find('.timestamp-wrap').removeClass('form-invalid'); 681 683 } 682 684 … … 705 707 } 706 708 707 if ( $ ('input:radio:checked', '#post-visibility-select').val() == 'private' ) {709 if ( $postVisibilitySelect.find('input:radio:checked').val() == 'private' ) { 708 710 $('#publish').val( postL10n.update ); 709 711 if ( 0 === optPublish.length ) { … … 713 715 } 714 716 $('option[value="publish"]', postStatus).prop('selected', true); 715 $(' .edit-post-status', '#misc-publishing-actions').hide();717 $('#misc-publishing-actions .edit-post-status').hide(); 716 718 } else { 717 719 if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { … … 724 726 } 725 727 if ( postStatus.is(':hidden') ) 726 $(' .edit-post-status', '#misc-publishing-actions').show();728 $('#misc-publishing-actions .edit-post-status').show(); 727 729 } 728 730 $('#post-status-display').html($('option:selected', postStatus).text()); … … 740 742 }; 741 743 742 $( '.edit-visibility', '#visibility').click(function () {743 if ( $ ( '#post-visibility-select' ).is( ':hidden') ) {744 $( '#visibility .edit-visibility').click( function () { 745 if ( $postVisibilitySelect.is(':hidden') ) { 744 746 updateVisibility(); 745 $ ('#post-visibility-select').slideDown('fast');747 $postVisibilitySelect.slideDown('fast').find('input[type="radio"]').first().focus(); 746 748 $(this).hide(); 747 749 } … … 749 751 }); 750 752 751 $ ('.cancel-post-visibility', '#post-visibility-select').click(function () {752 $ ('#post-visibility-select').slideUp('fast');753 $postVisibilitySelect.find('.cancel-post-visibility').click( function( event ) { 754 $postVisibilitySelect.slideUp('fast'); 753 755 $('#visibility-radio-' + $('#hidden-post-visibility').val()).prop('checked', true); 754 756 $('#post_password').val($('#hidden-post-password').val()); 755 757 $('#sticky').prop('checked', $('#hidden-post-sticky').prop('checked')); 756 758 $('#post-visibility-display').html(visibility); 757 $(' .edit-visibility', '#visibility').show();759 $('#visibility .edit-visibility').show().focus(); 758 760 updateText(); 759 return false; 760 }); 761 762 $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels 763 var pvSelect = $('#post-visibility-select'); 764 765 pvSelect.slideUp('fast'); 766 $('.edit-visibility', '#visibility').show(); 761 event.preventDefault(); 762 }); 763 764 $postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // crazyhorse - multiple ok cancels 765 $postVisibilitySelect.slideUp('fast'); 766 $('#visibility .edit-visibility').show(); 767 767 updateText(); 768 768 769 if ( $ ('input:radio:checked', pvSelect).val() != 'public' ) {769 if ( $postVisibilitySelect.find('input:radio:checked').val() != 'public' ) { 770 770 $('#sticky').prop('checked', false); 771 771 } // WEAPON LOCKED … … 777 777 } 778 778 779 $('#post-visibility-display').html( postL10n[ $('input:radio:checked', pvSelect).val() + sticky] );780 return false;781 }); 782 783 $ ('input:radio', '#post-visibility-select').change(function() {779 $('#post-visibility-display').html( postL10n[ $postVisibilitySelect.find('input:radio:checked').val() + sticky ] ); 780 event.preventDefault(); 781 }); 782 783 $postVisibilitySelect.find('input:radio').change( function() { 784 784 updateVisibility(); 785 785 }); 786 786 787 $ ('#timestampdiv').siblings('a.edit-timestamp').click(function() {788 if ( $ ( '#timestampdiv' ).is( ':hidden' ) ) {789 $ ('#timestampdiv').slideDown('fast');787 $timestampdiv.siblings('a.edit-timestamp').click( function( event ) { 788 if ( $timestampdiv.is( ':hidden' ) ) { 789 $timestampdiv.slideDown('fast'); 790 790 $('#mm').focus(); 791 791 $(this).hide(); 792 792 } 793 return false;794 }); 795 796 $ ('.cancel-timestamp', '#timestampdiv').click(function() {797 $ ('#timestampdiv').slideUp('fast');793 event.preventDefault(); 794 }); 795 796 $timestampdiv.find('.cancel-timestamp').click( function( event ) { 797 $timestampdiv.slideUp('fast').siblings('a.edit-timestamp').show().focus(); 798 798 $('#mm').val($('#hidden_mm').val()); 799 799 $('#jj').val($('#hidden_jj').val()); … … 801 801 $('#hh').val($('#hidden_hh').val()); 802 802 $('#mn').val($('#hidden_mn').val()); 803 $('#timestampdiv').siblings('a.edit-timestamp').show();804 803 updateText(); 805 return false;806 }); 807 808 $ ('.save-timestamp', '#timestampdiv').click(function () { // crazyhorse - multiple ok cancels804 event.preventDefault(); 805 }); 806 807 $timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels 809 808 if ( updateText() ) { 810 $ ('#timestampdiv').slideUp('fast');811 $ ('#timestampdiv').siblings('a.edit-timestamp').show();812 } 813 return false;814 }); 815 816 $('#post').on( 'submit', function( e){809 $timestampdiv.slideUp('fast'); 810 $timestampdiv.siblings('a.edit-timestamp').show(); 811 } 812 event.preventDefault(); 813 }); 814 815 $('#post').on( 'submit', function( event ) { 817 816 if ( ! updateText() ) { 818 e.preventDefault(); 819 $('#timestampdiv').show(); 817 event.preventDefault(); 818 $timestampdiv.show(); 819 820 if ( typeof wp !== 'undefined' && wp.autosave ) { 821 wp.autosave.enableButtons(); 822 } 823 820 824 $('#publishing-action .spinner').hide(); 821 $('#publish').prop('disabled', false).removeClass('button-primary-disabled'); 822 return false; 823 } 824 }); 825 826 $('#post-status-select').siblings('a.edit-post-status').click(function() { 827 if ( $( '#post-status-select' ).is( ':hidden' ) ) { 828 $('#post-status-select').slideDown('fast'); 825 } 826 }); 827 828 $postStatusSelect.siblings('a.edit-post-status').click( function( event ) { 829 if ( $postStatusSelect.is( ':hidden' ) ) { 830 $postStatusSelect.slideDown('fast').find('select').focus(); 829 831 $(this).hide(); 830 832 } 831 return false; 832 }); 833 834 $('.save-post-status', '#post-status-select').click(function() { 835 $('#post-status-select').slideUp('fast'); 836 $('#post-status-select').siblings('a.edit-post-status').show(); 833 event.preventDefault(); 834 }); 835 836 $postStatusSelect.find('.save-post-status').click( function( event ) { 837 $postStatusSelect.slideUp('fast').siblings('a.edit-post-status').show(); 837 838 updateText(); 838 return false; 839 }); 840 841 $('.cancel-post-status', '#post-status-select').click(function() { 842 $('#post-status-select').slideUp('fast'); 843 $('#post_status').val($('#hidden_post_status').val()); 844 $('#post-status-select').siblings('a.edit-post-status').show(); 839 event.preventDefault(); 840 }); 841 842 $postStatusSelect.find('.cancel-post-status').click( function( event ) { 843 $('#post-status-select').slideUp('fast').siblings( 'a.edit-post-status' ).show().focus(); 844 $('#post_status').val( $('#hidden_post_status').val() ); 845 845 updateText(); 846 return false;846 event.preventDefault(); 847 847 }); 848 848 } // end submitdiv
Note: See TracChangeset
for help on using the changeset viewer.