Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js |
— | — | @@ -242,29 +242,27 @@ |
243 | 243 | es.SurfaceView.prototype.showCursor = function( offset ) { |
244 | 244 | if ( typeof offset !== 'undefined' ) { |
245 | 245 | this.cursor.offset = offset; |
246 | | - var position = this.documentView.getRenderedPosition( offset ); |
| 246 | + var position = this.documentView.getRenderedPosition( this.cursor.offset ); |
247 | 247 | this.cursor.$.css( { |
248 | 248 | 'left': position.left, |
249 | 249 | 'top': position.top, |
250 | 250 | 'height': position.bottom - position.top |
251 | 251 | } ).show(); |
| 252 | + this.$input.css({ |
| 253 | + 'top': this.cursor.$.css('top'), |
| 254 | + 'height': this.cursor.$.css('height') |
| 255 | + }); |
252 | 256 | } else { |
253 | 257 | this.cursor.$.show(); |
254 | 258 | } |
255 | | - // |
256 | | - this.$input.css({ |
257 | | - 'top': this.cursor.$.css('top'), |
258 | | - 'height': this.cursor.$.css('height') |
259 | | - }); |
260 | | - |
261 | 259 | if ( this.cursor.interval ) { |
262 | 260 | clearInterval( this.cursor.interval ); |
263 | 261 | } |
264 | 262 | this.cursor.interval = setInterval( function( surface ) { |
265 | | - surface.cursor.$.css( |
266 | | - 'display', ( 'block' ? surface.cursor.$.hide() : surface.cursor.$.show() ) |
267 | | - ); |
268 | | - }, 500 ); |
| 263 | + surface.cursor.$.css( 'display', function( index, value ) { |
| 264 | + return value === 'block' ? 'none' : 'block'; |
| 265 | + } ); |
| 266 | + }, 500, this ); |
269 | 267 | }; |
270 | 268 | |
271 | 269 | /** |
— | — | @@ -321,19 +319,20 @@ |
322 | 320 | } while ( oldPosition.top === fakePosition.top && offset !== edge ); |
323 | 321 | |
324 | 322 | 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 | | - } |
337 | 323 | } |
| 324 | + |
| 325 | + // Auto scroll to cursor |
| 326 | + var $window = $(window), |
| 327 | + scrollTop = $window.scrollTop(), |
| 328 | + windowHeight = $window.height(), |
| 329 | + inputTop = this.$input.offset().top, |
| 330 | + inputBottom = inputTop + this.$input.height(); |
| 331 | + if (inputTop < scrollTop) { |
| 332 | + $window.scrollTop(inputTop); |
| 333 | + } else if (inputBottom > (scrollTop + windowHeight)) { |
| 334 | + $window.scrollTop(inputBottom - windowHeight); |
| 335 | + } |
| 336 | + |
338 | 337 | return; |
339 | 338 | }; |
340 | 339 | |