r100652 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100651‎ | r100652 | r100653 >
Date:22:15, 24 October 2011
Author:inez
Status:deferred
Tags:
Comment:
Fix broken blinking cursor functionality
Improve auto scroll to cursor code (now works for all arrow directions - not only up or down)
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/views/es.SurfaceView.js
@@ -242,29 +242,27 @@
243243 es.SurfaceView.prototype.showCursor = function( offset ) {
244244 if ( typeof offset !== 'undefined' ) {
245245 this.cursor.offset = offset;
246 - var position = this.documentView.getRenderedPosition( offset );
 246+ var position = this.documentView.getRenderedPosition( this.cursor.offset );
247247 this.cursor.$.css( {
248248 'left': position.left,
249249 'top': position.top,
250250 'height': position.bottom - position.top
251251 } ).show();
 252+ this.$input.css({
 253+ 'top': this.cursor.$.css('top'),
 254+ 'height': this.cursor.$.css('height')
 255+ });
252256 } else {
253257 this.cursor.$.show();
254258 }
255 - //
256 - this.$input.css({
257 - 'top': this.cursor.$.css('top'),
258 - 'height': this.cursor.$.css('height')
259 - });
260 -
261259 if ( this.cursor.interval ) {
262260 clearInterval( this.cursor.interval );
263261 }
264262 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 );
269267 };
270268
271269 /**
@@ -321,19 +319,20 @@
322320 } while ( oldPosition.top === fakePosition.top && offset !== edge );
323321
324322 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 - }
337323 }
 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+
338337 return;
339338 };
340339

Status & tagging log