Changeset 23302
- Timestamp:
- 01/16/2013 07:10:38 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/post.js
r23278 r23302 688 688 var textarea = $('textarea#content'), offset = null, el; 689 689 // No point for touch devices 690 if ( 'ontouchstart' in window )690 if ( !textarea.length || 'ontouchstart' in window ) 691 691 return; 692 692 … … 697 697 698 698 function endDrag(e) { 699 var height = $('#wp-content-editor-container').height();699 var height; 700 700 701 701 textarea.focus(); 702 702 $(document).unbind('mousemove', dragging).unbind('mouseup', endDrag); 703 703 704 height -= 33; // compensate for toolbars, padding... 704 height = parseInt( textarea.css('height'), 10 ); 705 705 706 // sanity check 706 if ( height > 50 && height < 5000 && height != getUserSetting( 'ed_size' ))707 if ( height && height > 50 && height < 5000 ) 707 708 setUserSetting( 'ed_size', height ); 708 709 } … … 725 726 return; 726 727 728 function getHeight() { 729 var height, node = document.getElementById('content_ifr'), 730 ifr_height = node ? parseInt( node.style.height, 10 ) : 0, 731 tb_height = $('#content_tbl tr.mceFirst').height(); 732 733 if ( !ifr_height || !tb_height ) 734 return false; 735 736 // total height including toolbar and statusbar 737 height = ifr_height + tb_height + 21; 738 // textarea height = total height - 33px toolbar 739 height -= 33; 740 741 return height; 742 } 743 727 744 // resize TinyMCE to match the textarea height when switching Text -> Visual 728 745 ed.onLoadContent.add( function(ed, o) { 729 var ifr_height, height = parseInt( $('#content').css('height'), 10 ), 730 tb_height = $('#content_tbl tr.mceFirst').height(); 731 732 if ( height && !isNaN(height) && tb_height ) { 733 ifr_height = (height - tb_height) + 12; // compensate for padding in the textarea 734 // sanity check 735 if ( ifr_height > 50 && ifr_height < 5000 ) { 736 $('#content_tbl').css('height', '' ); 737 $('#content_ifr').css('height', ifr_height + 'px' ); 738 } 746 var ifr_height, node = document.getElementById('content'), 747 height = node ? parseInt( node.style.height, 10 ) : 0, 748 tb_height = $('#content_tbl tr.mceFirst').height() || 33; 749 750 // height cannot be under 50 or over 5000 751 if ( !height || height < 50 || height > 5000 ) 752 height = 360; // default height for the main editor 753 754 if ( getUserSetting( 'ed_size' ) > 5000 ) 755 setUserSetting( 'ed_size', 360 ); 756 757 // compensate for padding and toolbars 758 ifr_height = ( height - tb_height ) + 12; 759 760 // sanity check 761 if ( ifr_height > 50 && ifr_height < 5000 ) { 762 $('#content_tbl').css('height', '' ); 763 $('#content_ifr').css('height', ifr_height + 'px' ); 739 764 } 740 765 }); … … 742 767 // resize the textarea to match TinyMCE's height when switching Visual -> Text 743 768 ed.onSaveContent.add( function(ed, o) { 744 var height = $('#content_tbl').height(); 745 746 if ( height && height > 83 && height < 5000 ) { 747 height -= 33; 748 749 $('#content').css( 'height', height + 'px' ); 750 } 769 var height = getHeight(); 770 771 if ( !height || height < 50 || height > 5000 ) 772 return; 773 774 $('textarea#content').css( 'height', height + 'px' ); 751 775 }); 752 776 … … 755 779 $('#content_resize').on('mousedown.wp-mce-resize', function(e){ 756 780 $(document).on('mouseup.wp-mce-resize', function(e){ 757 var height = $('#wp-content-editor-container').height(); 758 759 height -= 33; 781 var height; 782 783 $(document).off('mouseup.wp-mce-resize'); 784 785 height = getHeight(); 760 786 // sanity check 761 if ( height > 50 && height < 5000 && height != getUserSetting( 'ed_size' ))787 if ( height && height > 50 && height < 5000 ) 762 788 setUserSetting( 'ed_size', height ); 763 764 $(document).off('mouseup.wp-mce-resize');765 789 }); 766 790 });
Note: See TracChangeset
for help on using the changeset viewer.