- function textEditorKeyup( event ) {
- var VK = jQuery.ui.keyCode,
- key = event.keyCode,
- range = document.createRange(),
- selStart = $textEditor[0].selectionStart,
- selEnd = $textEditor[0].selectionEnd,
- textNode = $textEditorClone[0].firstChild,
- buffer = 10,
- offset, cursorTop, cursorBottom, editorTop, editorBottom;
-
- if ( selStart && selEnd && selStart !== selEnd ) {
- return;
- }
-
- // These are not TinyMCE ranges.
- try {
- range.setStart( textNode, selStart );
- range.setEnd( textNode, selEnd + 1 );
- } catch ( ex ) {}
-
- offset = range.getBoundingClientRect();
-
- if ( ! offset.height ) {
- return;
- }
-
- cursorTop = offset.top - buffer;
- cursorBottom = cursorTop + offset.height + buffer;
- editorTop = heights.adminBarHeight + heights.toolsHeight + heights.textTopHeight;
- editorBottom = heights.windowHeight - heights.bottomHeight;
-
- if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
- window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
- } else if ( cursorBottom > editorBottom ) {
- window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );
- }
- }
-
- function textEditorResize() {
- if ( ( mceEditor && ! mceEditor.isHidden() ) || ( ! mceEditor && initialMode === 'tinymce' ) ) {
- return;
- }
-
- var textEditorHeight = $textEditor.height(),
- hiddenHeight;
-
- $textEditorClone.width( $textEditor.width() - 22 );
- $textEditorClone.text( $textEditor.val() + ' ' );
-
- hiddenHeight = $textEditorClone.height();
-
- if ( hiddenHeight < autoresizeMinHeight ) {
- hiddenHeight = autoresizeMinHeight;
- }
-
- if ( hiddenHeight === textEditorHeight ) {
- return;
- }
-
- $textEditor.height( hiddenHeight );
-
- adjust();
- }
-