r100607 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100606‎ | r100607 | r100608 >
Date:16:09, 24 October 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added auto-scrolling when the cursor is moved and fixed some syntax issues that jshint caught
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
@@ -251,14 +251,20 @@
252252 } else {
253253 this.cursor.$.show();
254254 }
 255+ //
 256+ this.$input.css({
 257+ 'top': this.cursor.$.css('top'),
 258+ 'height': this.cursor.$.css('height')
 259+ });
255260
256261 if ( this.cursor.interval ) {
257262 clearInterval( this.cursor.interval );
258263 }
259264 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 );
263269 };
264270
265271 /**
@@ -298,7 +304,7 @@
299305 offset,
300306 step,
301307 edge;
302 -
 308+
303309 if ( direction === 'up' ) {
304310 step = -5;
305311 edge = 0;
@@ -315,6 +321,18 @@
316322 } while ( oldPosition.top === fakePosition.top && offset !== edge );
317323
318324 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+ }
319337 }
320338 return;
321339 };

Status & tagging log