(trunk web) #2052: when adding new torrents to the list (such as on startup), batch together all the additions to prevent unnecessary dom reflows

This commit is contained in:
Charles Kerr 2009-05-24 01:29:03 +00:00
parent f357fc013c
commit 05bd3caaf9
2 changed files with 9 additions and 12 deletions

View File

@ -6,8 +6,8 @@
* Class Torrent * Class Torrent
*/ */
function Torrent(controller,data) { function Torrent(domParent,controller,data) {
this.initialize(controller,data); this.initialize(domParent,controller,data);
} }
// Constants // Constants
@ -23,7 +23,7 @@ Torrent.prototype =
/* /*
* Constructor * Constructor
*/ */
initialize: function(controller, data) { initialize: function(domParent,controller, data) {
this._id = data.id; this._id = data.id;
this._is_private = data.isPrivate; this._is_private = data.isPrivate;
this._hashString = data.hashString; this._hashString = data.hashString;
@ -102,7 +102,7 @@ Torrent.prototype =
this._element.css('margin-top', '7px'); this._element.css('margin-top', '7px');
// insert the element // insert the element
this._controller._torrent_list.appendChild( top_e ); domParent.appendChild(top_e);
this.initializeTorrentFilesInspectorGroup(); this.initializeTorrentFilesInspectorGroup();

View File

@ -1154,14 +1154,11 @@ Transmission.prototype =
}, },
addTorrents: function( new_torrents ){ addTorrents: function( new_torrents ){
var tr = this; var fragment = document.createDocumentFragment( );
for( var i=0, row; row=new_torrents[i]; ++i )
$.each( new_torrents, function(){ this._torrents.push( new Torrent( fragment, this, row ) );
var torrent = this; this._torrent_list.appendChild( fragment );
tr._torrents.push( new Torrent( tr, torrent ) ); this.refilter( );
});
this.refilter();
}, },
deleteTorrents: function(torrent_ids){ deleteTorrents: function(torrent_ids){