| 1 | Index: wp-admin/js/post.js |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/js/post.js (revision 23176) |
|---|
| 4 | +++ wp-admin/js/post.js (working copy) |
|---|
| 5 | @@ -371,6 +371,16 @@ |
|---|
| 6 | stamp = $('#timestamp').html(); |
|---|
| 7 | visibility = $('#post-visibility-display').html(); |
|---|
| 8 | |
|---|
| 9 | + function updatePasswordSubmitability() { |
|---|
| 10 | + var post_password = jQuery.trim($('#post_password').val()); |
|---|
| 11 | + if ( post_password == '' ) { |
|---|
| 12 | + $('.save-post-visibility', '#post-visibility-select').addClass('button-disabled'); |
|---|
| 13 | + } else { |
|---|
| 14 | + $('.save-post-visibility', '#post-visibility-select').removeClass('button-disabled'); |
|---|
| 15 | + $('#post_password').removeClass('form-invalid'); |
|---|
| 16 | + } |
|---|
| 17 | + } |
|---|
| 18 | + |
|---|
| 19 | function updateVisibility() { |
|---|
| 20 | var pvSelect = $('#post-visibility-select'); |
|---|
| 21 | if ( $('input:radio:checked', pvSelect).val() != 'public' ) { |
|---|
| 22 | @@ -380,12 +390,16 @@ |
|---|
| 23 | $('#sticky-span').show(); |
|---|
| 24 | } |
|---|
| 25 | if ( $('input:radio:checked', pvSelect).val() != 'password' ) { |
|---|
| 26 | - $('#password-span').hide(); |
|---|
| 27 | + $('#password-span').hide(); |
|---|
| 28 | + $('.save-post-visibility', '#post-visibility-select').removeClass('button-disabled'); |
|---|
| 29 | } else { |
|---|
| 30 | $('#password-span').show(); |
|---|
| 31 | + updatePasswordSubmitability(); |
|---|
| 32 | } |
|---|
| 33 | } |
|---|
| 34 | - |
|---|
| 35 | + // disable submit button based on password field content |
|---|
| 36 | + $('#post_password').keyup(function() {updatePasswordSubmitability();}); |
|---|
| 37 | + |
|---|
| 38 | function updateText() { |
|---|
| 39 | |
|---|
| 40 | if ( ! $('#timestampdiv').length ) |
|---|
| 41 | @@ -487,6 +501,13 @@ |
|---|
| 42 | $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels |
|---|
| 43 | var pvSelect = $('#post-visibility-select'); |
|---|
| 44 | |
|---|
| 45 | + if ( $('.save-post-visibility', pvSelect).hasClass('button-disabled') ) { |
|---|
| 46 | + $('#post_password').addClass('form-invalid'); |
|---|
| 47 | + return false; |
|---|
| 48 | + } else { |
|---|
| 49 | + $('#post_password').removeClass('form-invalid'); |
|---|
| 50 | + } |
|---|
| 51 | + |
|---|
| 52 | pvSelect.slideUp('fast'); |
|---|
| 53 | $('.edit-visibility', '#visibility').show(); |
|---|
| 54 | updateText(); |
|---|