(trunk web) building an array of toolbar buttons is sort of expensive in jQuery, so just do it once on startup, and keep that copy.

This commit is contained in:
Charles Kerr 2009-05-23 21:39:16 +00:00
parent 998c6e6e8e
commit ae8335bf7a
1 changed files with 4 additions and 7 deletions

View File

@ -78,6 +78,7 @@ Transmission.prototype =
this._torrent_list = $('#torrent_list')[0];
this._inspector_file_list = $('#inspector_file_list')[0];
this._inspector_tab_files = $('#inspector_tab_files')[0];
this._toolbar_buttons = $('#torrent_global_menu ul li');
// Setup the preference box
this.setupPrefConstraints();
@ -1443,11 +1444,9 @@ Transmission.prototype =
updateButtonStates: function()
{
var showing_dialog = new RegExp("(prefs_showing|dialog_showing|open_showing)").test(document.body.className);
if (showing_dialog)
{
$('.torrent_global_menu ul li').addClass('disabled');
}
else
this._toolbar_buttons.toggleClass( 'disabled', showing_dialog );
if (!showing_dialog)
{
var torrents = this.getVisibleTorrents( );
var haveSelection = false;
@ -1466,8 +1465,6 @@ Transmission.prototype =
if( isSelected && !isActive ) havePausedSelection = true;
}
$('.torrent_global_menu ul li.disabled').removeClass('disabled');
this.setEnabled( 'li#pause_selected', haveActiveSelection );
this.setEnabled( 'li.context_pause_selected', haveActiveSelection );
this.setEnabled( 'li#resume_selected', havePausedSelection );