+ var selected_count = $("#changes-list .entry.selected").length;
+
+ if ($this.hasClass('selected')) {
+ $this.removeClass('selected');
+ selected_count -= 1;
+ }
+ else {
+ if (selected_count < 2) {
+ $this.addClass('selected');
+ selected_count += 1;
+ };
+ };
+
+ $('#history-view-editor .toolbar button').attr('disabled', 'disabled').
+ filter('*[data-enabled-when~=' + selected_count + '], *[data-enabled-when~=*]').
+ attr('disabled', null);