~motu-p2p/clutch/trunk

« back to all changes in this revision

Viewing changes to web/javascript/torrent.js

  • Committer: davos
  • Date: 2008-01-28 11:17:34 UTC
  • Revision ID: svn-v3-trunk0:cbfa06d0-8a30-0410-a469-a65574b27390:trunk:337
Added the arrow-key scrolling fix from Marcel Laverdet (trac ticket #16).

Show diffs side-by-side

added added

removed removed

Lines of Context:
457
457
        select: function() {
458
458
                this._element.addClass('selected');
459
459
                
 
460
        // Make sure it's visible in the torrent list (i.e. not too far down with the scrollbar all the way up)
 
461
        var container = $('#torrent_container'),
 
462
        offsetTop = this._element.position().top,
 
463
        scrollTop = container.scrollTop(),
 
464
        offsetHeight = this._element.outerHeight(),
 
465
        innerHeight = container.innerHeight();
 
466
        if (offsetTop < scrollTop) { // torrent is too far up
 
467
            container.scrollTop(offsetTop);
 
468
        } else if (innerHeight + scrollTop < offsetTop + offsetHeight) { // torrent is too far down
 
469
            container.scrollTop(offsetTop + offsetHeight - innerHeight);
 
470
        }
 
471
 
 
472
        // Highlight it as selected
 
473
        this._element.addClass('selected');
 
474
  
460
475
                // Inform the controller
461
476
                this._controller.selectTorrent(this);
462
477
        },