Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js |
— | — | @@ -251,14 +251,20 @@ |
252 | 252 | } else { |
253 | 253 | this.cursor.$.show(); |
254 | 254 | } |
| 255 | + // |
| 256 | + this.$input.css({ |
| 257 | + 'top': this.cursor.$.css('top'), |
| 258 | + 'height': this.cursor.$.css('height') |
| 259 | + }); |
255 | 260 | |
256 | 261 | if ( this.cursor.interval ) { |
257 | 262 | clearInterval( this.cursor.interval ); |
258 | 263 | } |
259 | 264 | this.cursor.interval = setInterval( function( surface ) { |
260 | | - surface.cursor.$.css( 'display' ) == 'block' |
261 | | - ? surface.cursor.$.hide() : surface.cursor.$.show(); |
262 | | - }, 500, this ); |
| 265 | + surface.cursor.$.css( |
| 266 | + 'display', ( 'block' ? surface.cursor.$.hide() : surface.cursor.$.show() ) |
| 267 | + ); |
| 268 | + }, 500 ); |
263 | 269 | }; |
264 | 270 | |
265 | 271 | /** |
— | — | @@ -298,7 +304,7 @@ |
299 | 305 | offset, |
300 | 306 | step, |
301 | 307 | edge; |
302 | | - |
| 308 | + |
303 | 309 | if ( direction === 'up' ) { |
304 | 310 | step = -5; |
305 | 311 | edge = 0; |
— | — | @@ -315,6 +321,18 @@ |
316 | 322 | } while ( oldPosition.top === fakePosition.top && offset !== edge ); |
317 | 323 | |
318 | 324 | this.showCursor( this.documentView.getOffsetFromPosition( fakePosition ) ); |
| 325 | + |
| 326 | + // Auto scroll to cursor |
| 327 | + var $window = $(window), |
| 328 | + scrollTop = $window.scrollTop(), |
| 329 | + windowHeight = $window.height(), |
| 330 | + inputTop = this.$input.offset().top, |
| 331 | + inputBottom = inputTop + this.$input.height(); |
| 332 | + if (inputTop < scrollTop) { |
| 333 | + $window.scrollTop(inputTop); |
| 334 | + } else if (inputBottom > (scrollTop + windowHeight)) { |
| 335 | + $window.scrollTop(inputBottom - windowHeight); |
| 336 | + } |
319 | 337 | } |
320 | 338 | return; |
321 | 339 | }; |