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

View File

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