Ticket #28328: 28328.13.patch
File 28328.13.patch, 2.4 KB (added by , 11 years ago) |
---|
-
src/wp-admin/js/editor-expand.js
122 122 }, 200 ); 123 123 } ); 124 124 125 // Make sure the cursor is always visible. 126 // This is not only necessary to keep the cursor between the toolbars, 127 // but also to scroll the window when the cursor moves out of the viewport to a wpview. 128 // Setting a buffer > 0 will prevent the browser default. 129 // Some browsers will scroll to the middle, 130 // others to the top/bottom of the *window* when moving the cursor out of the viewport. 125 131 editor.on( 'keyup', function() { 126 132 var offset = getCursorOffset(), 127 133 windowHeight = $window.height(), 134 buffer = 10, 128 135 cursorTop, cursorBottom, editorTop, editorBottom; 129 136 130 137 if ( ! offset ) { … … 133 140 134 141 cursorTop = offset.top + editor.getContentAreaContainer().getElementsByTagName( 'iframe' )[0].getBoundingClientRect().top; 135 142 cursorBottom = cursorTop + offset.height; 143 cursorTop = cursorTop - buffer; 144 cursorBottom = cursorBottom + buffer; 136 145 editorTop = $adminBar.outerHeight() + $tools.outerHeight() + $visualTop.outerHeight(); 137 editorBottom = $window.height()- $bottom.outerHeight();146 editorBottom = windowHeight - $bottom.outerHeight(); 138 147 139 if ( cursorTop < editorTop || cursorBottom > editorBottom ) { 140 window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - windowHeight / 2 ); 148 if ( cursorTop < editorTop ) { 149 window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop ); 150 } else if ( cursorBottom > editorBottom ) { 151 window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom ); 141 152 } 142 153 } ); 143 154 … … 145 156 var selection = editor.selection, 146 157 node = selection.getNode(), 147 158 range = selection.getRng(), 148 view, clone, right,offset;159 view, clone, offset; 149 160 150 161 if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) { 151 162 return; … … 159 170 if ( clone.startContainer.length > 1 ) { 160 171 if ( clone.startContainer.length > clone.endOffset ) { 161 172 clone.setEnd( clone.startContainer, clone.endOffset + 1 ); 162 right = true;163 173 } else { 164 174 clone.setStart( clone.startContainer, clone.endOffset - 1 ); 165 175 } … … 175 185 } 176 186 177 187 if ( ! offset.height ) { 178 return false;188 return; 179 189 } 180 190 181 191 return offset;