From ae8335bf7a69898fe1544575642dd06a33c4972e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 23 May 2009 21:39:16 +0000 Subject: [PATCH] (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. --- web/javascript/transmission.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index ccc00cd0f..22a8dc1cb 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -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 );