+ var state_type = $(this).attr('href').substring(1);
+
+ if ($('#state-filter-container').find('input[value=' + state_type + ']').length == 0) {
+ $('#state-filter-container').append($("<input name=\"state_type\" type=\"hidden\" value=\"" + state_type + "\" />"));
+ } else {
+ $('#state-filter-container').find('input[value=' + state_type + ']').remove();
+ }
+
+ $form.submit();
+ });
+
+ $('.action-select').change(function() {
+ $('#action-toggle').removeAttr('checked');
+ var $tr = $(this).parents('tr');
+ if ($(this).attr('checked')) {
+ $tr.addClass('selected');
+ } else {
+ $tr.removeClass('selected');
+ }
+ }).change();
+
+ $('#action-toggle').change(function() {
+ var $rows = $('#result_list').find('tbody').find('tr');
+ var $boxes = $('#result_list').find('tbody').find('input');
+
+ if ($(this).attr('checked')) {
+ $rows.addClass('selected');
+ $boxes.attr('checked', 'checked')
+ } else {
+ $rows.removeClass('selected');
+ $boxes.removeAttr('checked');
+ }
+ });
+
+ $('#author-selector').autocomplete('{% url matching_users %}', {
+ minChars: 1,
+ matchContains: true,
+ max: 10,
+
+ formatItem: function(row, i, max, value) {
+ return row[1] + ' (' + row[2] + ' {% trans "rep" %})';
+ },
+
+ formatResult: function(row, i, max, value){
+ return row[1];
+ }
+ });
+
+ $('#author-selector').result(function(event, data, formatted) {
+ if ($('#author-filter-container').find('input[value=' + data[0] + ']').length == 0) {
+ $('#author-filter-container').append($("<input name=\"authors\" type=\"hidden\" value=\"" + data[0] + "\" />"));
+ $form.submit();
+ }
+ });
+
+ $('.author-filter-remover').click(function() {
+ var id = $(this).attr('rel');
+ if ($('#author-filter-container').find('input[value=' + id + ']').length > 0) {
+ $('#author-filter-container').find('input[value=' + id + ']').remove();
+ $form.submit();
+ }
+ });
+
+ $('#tag-selector').autocomplete('{% url matching_tags %}', {
+ minChars: 1,
+ matchContains: true,
+ max: 10,
+
+ formatItem: function(row, i, max, value) {
+ return row[1] + ' (' + row[2] + ' {% trans "uses" %})';
+ },
+
+ formatResult: function(row, i, max, value){
+ return row[1];
+ }
+ });
+
+ $('#tag-selector').result(function(event, data, formatted) {
+ if ($('#tag-filter-container').find('input[value=' + data[0] + ']').length == 0) {
+ $('#tag-filter-container').append($("<input name=\"tags\" type=\"hidden\" value=\"" + data[0] + "\" />"));
+ $form.submit();
+ }
+ });
+
+ $('.tag-filter-remover').click(function() {
+ var id = $(this).attr('rel');
+ if ($('#tag-filter-container').find('input[value=' + id + ']').length > 0) {
+ $('#tag-filter-container').find('input[value=' + id + ']').remove();
+ $form.submit();
+ }
+ });
+
+ $('#filter-name-box').one('focus', function() {
+ $(this).val('');
+ $(this).css('color', 'black');
+ });
+
+ $('#filter-name-box').keyup(function() {
+ if ($(this).val().trim().length > 0) {
+ $('#save-filter-button').removeAttr('disabled');
+ $('#save-filter-button').css('color', 'black');
+ } else {
+ $('#save-filter-button').css('color', '#AAA');
+ $('#save-filter-button').attr('disabled', 'disabled');
+ }
+ });
+
+ var resize_data = null;
+
+ $('.col-resizer').mousedown(function(e) {
+ var $to_resize = $(this).prev();
+
+ resize_data = {
+ resizer: $(this),
+ to_resize: $to_resize,
+ start_width: $to_resize.innerWidth(),
+ x_start: e.pageX,
+ }
+ });
+
+ $('body').mousemove(function(e) {
+ if (resize_data != null) {
+ var new_size = (resize_data.start_width - (resize_data.x_start - e.pageX)) + 'px';
+ resize_data.to_resize.css({'max-width': new_size, 'min-width': new_size})
+ resize_data.resizer.css('max-width', '3px');
+ }
+ });
+
+ $('body').mouseup(function() {
+ if (resize_data != null)
+ resize_data = null;
+ });
+
+ $('#filter-panel-header').click(function() {
+ $('#filter-panel').slideToggle();
+ });
+
+ $('#state-filter-type').change(function() {
+ $('#state-filter-type-hidden').val($(this).val());
+ $form.submit();
+ });
+
+ $('#reset-text-filter').click(function() {
+ $('#text-filter-input').val('');