Ticket #25994: 25994.1.diff
| File 25994.1.diff, 9.8 KB (added by , 13 years ago) |
|---|
-
src/wp-admin/js/post.js
1 /* global postL10n, ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce */ 2 /* global theList: true, theExtraList: true */ 3 1 4 var tagBox, commentsBox, editPermalink, makeSlugeditClickable, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint; 2 5 3 6 // return an array with any duplicate, whitespace or values removed … … 82 85 83 86 flushTags : function(el, a, f) { 84 87 a = a || false; 85 var tags = $('.the-tags', el), 88 var tagsval, newtags, text, 89 tags = $('.the-tags', el), 86 90 newtag = $('input.newtag', el), 87 comma = postL10n.comma, 88 newtags, text; 91 comma = postL10n.comma; 89 92 90 93 text = a ? $(a).text() : newtag.val(); 91 94 tagsval = tags.val(); … … 108 111 var tax = id.substr(id.indexOf('-')+1); 109 112 110 113 $.post(ajaxurl, {'action':'get-tagcloud', 'tax':tax}, function(r, stat) { 111 if ( 0 == r || 'success' != stat )114 if ( 0 === r || 'success' != stat ) 112 115 r = wpAjax.broken; 113 116 114 117 r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>'); … … 137 140 }); 138 141 139 142 $('input.newtag', ajaxtag).blur(function() { 140 if ( this.value == '')143 if ( '' === this.value ) 141 144 $(this).parent().siblings('.taghint').css('visibility', ''); 142 145 }).focus(function(){ 143 146 $(this).parent().siblings('.taghint').css('visibility', 'hidden'); … … 206 209 $('#the-comment-list').append( r.responses[0].data ); 207 210 208 211 theList = theExtraList = null; 209 $( "a[className*=':']").unbind();212 $( 'a[className*=\':\']' ).unbind(); 210 213 211 214 if ( commentsBox.st > commentsBox.total ) 212 215 $('#show-comments').hide(); … … 240 243 241 244 WPRemoveThumbnail = function(nonce){ 242 245 $.post(ajaxurl, { 243 action: "set-post-thumbnail", post_id: $('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)246 action: 'set-post-thumbnail', post_id: $( '#post_ID' ).val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) 244 247 }, function(str){ 245 248 if ( str == '0' ) { 246 alert( setPostThumbnailL10n.error );249 window.alert( setPostThumbnailL10n.error ); 247 250 } else { 248 251 WPSetThumbnailHTML(str); 249 252 } … … 259 262 if ( ! post_id || ! $('#post-lock-dialog').length ) 260 263 return; 261 264 262 send ['post_id']= post_id;265 send.post_id = post_id; 263 266 264 267 if ( lock ) 265 send ['lock']= lock;268 send.lock = lock; 266 269 267 270 data['wp-refresh-post-lock'] = send; 268 271 }); … … 288 291 }); 289 292 290 293 // Save the latest changes and disable 291 if ( ! autosave() )294 if ( ! window.autosave() ) 292 295 window.onbeforeunload = null; 293 296 294 autosave = function(){};297 window.autosave = function(){}; 295 298 } 296 299 297 300 if ( received.lock_error.avatar_src ) { … … 401 404 $('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide(); 402 405 $(t).show(); 403 406 if ( '#' + taxonomy + '-all' == t ) 404 deleteUserSetting(settingName);407 window.deleteUserSetting( settingName ); 405 408 else 406 setUserSetting(settingName, 'pop');409 window.setUserSetting( settingName, 'pop' ); 407 410 return false; 408 411 }); 409 412 410 if ( getUserSetting(settingName) )413 if ( window.getUserSetting( settingName ) ) 411 414 $('a[href="#' + taxonomy + '-pop"]', '#' + taxonomy + '-tabs').click(); 412 415 413 416 // Ajax Cat 414 $( '#new' + taxonomy).one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' )} );417 $( '#new' + taxonomy ).one( 'focus', function() { $( this ).val( '' ).removeClass( 'form-input-tip' ); } ); 415 418 416 419 $('#new' + taxonomy).keypress( function(event){ 417 420 if( 13 === event.keyCode ) { … … 463 466 464 467 // Custom Fields 465 468 if ( $('#postcustom').length ) { 466 $( '#the-list').wpList( { addAfter: function( xml, s) {469 $( '#the-list' ).wpList( { addAfter: function() { 467 470 $('table#list-table').show(); 468 471 }, addBefore: function( s ) { 469 472 s.data += '&post_id=' + $('#post_ID').val(); … … 531 534 .replace( '%2$s', jj ) 532 535 .replace( '%3$s', aa ) 533 536 .replace( '%4$s', hh ) 534 .replace( '%5$s', mn ) 535 +'</b> '537 .replace( '%5$s', mn ) + 538 '</b> ' 536 539 ); 537 540 } 538 541 539 542 if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) { 540 543 $('#publish').val( postL10n.update ); 541 if ( optPublish.length == 0) {544 if ( 0 === optPublish.length ) { 542 545 postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>'); 543 546 } else { 544 547 optPublish.html( postL10n.privatelyPublished ); … … 572 575 } 573 576 574 577 $('.edit-visibility', '#visibility').click(function () { 575 if ( $('#post-visibility-select').is(":hidden")) {578 if ( $( '#post-visibility-select' ).is( ':hidden' ) ) { 576 579 updateVisibility(); 577 580 $('#post-visibility-select').slideDown('fast'); 578 581 $(this).hide(); … … 602 605 $('#sticky').prop('checked', false); 603 606 } // WEAPON LOCKED 604 607 605 if ( true == $('#sticky').prop('checked') ) {608 if ( true === $('#sticky').prop('checked') ) { 606 609 sticky = 'Sticky'; 607 610 } else { 608 611 sticky = ''; … … 617 620 }); 618 621 619 622 $('#timestampdiv').siblings('a.edit-timestamp').click(function() { 620 if ( $('#timestampdiv').is(":hidden")) {623 if ( $( '#timestampdiv' ).is( ':hidden' ) ) { 621 624 $('#timestampdiv').slideDown('fast'); 622 625 $('#mm').focus(); 623 626 $(this).hide(); … … 656 659 }); 657 660 658 661 $('#post-status-select').siblings('a.edit-post-status').click(function() { 659 if ( $('#post-status-select').is(":hidden")) {662 if ( $( '#post-status-select' ).is( ':hidden' ) ) { 660 663 $('#post-status-select').slideDown('fast'); 661 664 $(this).hide(); 662 665 } … … 682 685 // permalink 683 686 if ( $('#edit-slug-box').length ) { 684 687 editPermalink = function(post_id) { 685 var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'), revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(), full = $('#editable-post-name-full').html(); 688 var slug_value, i, 689 c = 0, 690 e = $( '#editable-post-name' ), 691 revert_e = e.html(), 692 real_slug = $( '#post_name' ), 693 revert_slug = real_slug.val(), 694 b = $( '#edit-slug-buttons' ), 695 revert_b = b.html(), 696 full = $( '#editable-post-name-full' ).html(); 686 697 687 698 $('#view-post-btn').hide(); 688 699 b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); … … 738 749 b.children('.cancel').click(); 739 750 return false; 740 751 } 741 } ).keyup(function(e) {752 } ).keyup( function() { 742 753 real_slug.val(this.value); 743 754 }).focus(); 744 } 755 }; 745 756 746 757 makeSlugeditClickable = function() { 747 758 $('#editable-post-name').click(function() { 748 759 $('#edit-slug-buttons').children('.edit-slug').click(); 749 760 }); 750 } 761 }; 751 762 makeSlugeditClickable(); 752 763 } 753 764 … … 774 785 775 786 var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text'); 776 787 777 if ( title.val() == '')788 if ( '' === title.val() ) 778 789 titleprompt.removeClass('screen-reader-text'); 779 790 780 791 titleprompt.click(function(){ … … 783 794 }); 784 795 785 796 title.blur(function(){ 786 if ( this.value == '')797 if ( '' === this.value ) 787 798 titleprompt.removeClass('screen-reader-text'); 788 799 }).focus(function(){ 789 800 titleprompt.addClass('screen-reader-text'); … … 791 802 titleprompt.addClass('screen-reader-text'); 792 803 $(this).unbind(e); 793 804 }); 794 } 805 }; 795 806 796 807 wptitlehint(); 797 808 … … 807 818 return false; 808 819 } 809 820 810 function endDrag( e) {821 function endDrag() { 811 822 var height; 812 823 813 824 textarea.focus(); … … 817 828 818 829 // sanity check 819 830 if ( height && height > 50 && height < 5000 ) 820 setUserSetting( 'ed_size', height );831 window.setUserSetting( 'ed_size', height ); 821 832 } 822 833 823 834 textarea.css('resize', 'none'); … … 854 865 } 855 866 856 867 // resize TinyMCE to match the textarea height when switching Text -> Visual 857 ed.onLoadContent.add( function( ed, o) {868 ed.onLoadContent.add( function() { 858 869 var ifr_height, node = document.getElementById('content'), 859 870 height = node ? parseInt( node.style.height, 10 ) : 0, 860 871 tb_height = $('#content_tbl tr.mceFirst').height() || 33; … … 863 874 if ( !height || height < 50 || height > 5000 ) 864 875 height = 360; // default height for the main editor 865 876 866 if ( getUserSetting( 'ed_size' ) > 5000 )867 setUserSetting( 'ed_size', 360 );877 if ( window.getUserSetting( 'ed_size' ) > 5000 ) 878 window.setUserSetting( 'ed_size', 360 ); 868 879 869 880 // compensate for padding and toolbars 870 881 ifr_height = ( height - tb_height ) + 12; … … 877 888 }); 878 889 879 890 // resize the textarea to match TinyMCE's height when switching Visual -> Text 880 ed.onSaveContent.add( function( ed, o) {891 ed.onSaveContent.add( function() { 881 892 var height = getHeight(); 882 893 883 894 if ( !height || height < 50 || height > 5000 ) … … 888 899 889 900 // save on resizing TinyMCE 890 901 ed.onPostRender.add(function() { 891 $( '#content_resize').on('mousedown.wp-mce-resize', function(e){892 $( document).on('mouseup.wp-mce-resize', function(e){902 $( '#content_resize' ).on( 'mousedown.wp-mce-resize', function() { 903 $( document ).on( 'mouseup.wp-mce-resize', function() { 893 904 var height; 894 905 895 906 $(document).off('mouseup.wp-mce-resize'); … … 897 908 height = getHeight(); 898 909 // sanity check 899 910 if ( height && height > 50 && height < 5000 ) 900 setUserSetting( 'ed_size', height );911 window.setUserSetting( 'ed_size', height ); 901 912 }); 902 913 }); 903 914 }); 904 915 }); 905 916 906 917 // When changing post formats, change the editor body class 907 $( '#post-formats-select input.post-format').on( 'change.set-editor-class', function( event) {918 $( '#post-formats-select input.post-format' ).on( 'change.set-editor-class', function() { 908 919 var editor, body, format = this.id; 909 920 910 921 if ( format && $( this ).prop('checked') ) {