diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js
index 2eb67e8..2b77113 100644
a
|
b
|
window.SelectFilter = {
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | var from_box = document.getElementById(field_id); |
24 | | from_box.id += '_from'; // change its ID |
| 24 | |
| 25 | // Create a clone to keep the actual values to be sent with the form |
| 26 | var real_box = $(from_box).clone().insertBefore(from_box).hide(); |
| 27 | |
| 28 | from_box.id += '_from'; |
| 29 | from_box.name += '_from'; |
25 | 30 | from_box.className = 'filtered'; |
26 | 31 | |
27 | 32 | var ps = from_box.parentNode.getElementsByTagName('p'); |
… |
… |
window.SelectFilter = {
|
77 | 82 | var title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Added %s') + ' ', [field_name])); |
78 | 83 | quickElement('img', title_chosen, '', 'src', admin_media_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of added %s. You may remove some by selecting them below and then clicking the "Remove" button.'), [field_name])); |
79 | 84 | |
80 | | var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name')); |
| 85 | var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', real_box.attr('name') + '_to'); |
81 | 86 | to_box.className = 'filtered'; |
82 | 87 | var clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'href', 'javascript: (function() { SelectBox.move_all("' + field_id + '_to", "' + field_id + '_from"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_remove_all_link'); |
83 | 88 | clear_all.className = 'selector-clearall'; |
84 | 89 | |
85 | | from_box.setAttribute('name', from_box.getAttribute('name') + '_old'); |
86 | | |
87 | 90 | // Set up the JavaScript event handlers for the select box filter interface |
88 | 91 | addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); }); |
89 | 92 | addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); }); |
90 | | addEvent(from_box, 'change', function(e) { SelectFilter.refresh_icons(field_id) }); |
91 | | addEvent(to_box, 'change', function(e) { SelectFilter.refresh_icons(field_id) }); |
92 | | addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); SelectFilter.refresh_icons(field_id); }); |
93 | | addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); SelectFilter.refresh_icons(field_id); }); |
| 93 | addEvent(from_box, 'change', function(e) { SelectFilter.refresh_state(field_id) }); |
| 94 | addEvent(to_box, 'change', function(e) { SelectFilter.refresh_state(field_id) }); |
| 95 | addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); SelectFilter.refresh_state(field_id); }); |
| 96 | addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); SelectFilter.refresh_state(field_id); }); |
94 | 97 | addEvent(findForm(from_box), 'submit', function() { SelectBox.select_all(field_id + '_to'); }); |
95 | 98 | SelectBox.init(field_id + '_from'); |
96 | 99 | SelectBox.init(field_id + '_to'); |
… |
… |
window.SelectFilter = {
|
103 | 106 | } |
104 | 107 | |
105 | 108 | // Initial icon refresh |
106 | | SelectFilter.refresh_icons(field_id); |
| 109 | SelectFilter.refresh_state(field_id); |
107 | 110 | }, |
108 | | refresh_icons: function(field_id) { |
| 111 | refresh_state: function(field_id) { |
| 112 | // Refresh icons |
| 113 | var real = $('#' + field_id); |
109 | 114 | var from = $('#' + field_id + '_from'); |
110 | 115 | var to = $('#' + field_id + '_to'); |
111 | 116 | var is_from_selected = from.find('option:selected').length > 0; |
… |
… |
window.SelectFilter = {
|
116 | 121 | // Active if the corresponding box isn't empty |
117 | 122 | $('#' + field_id + '_add_all_link').toggleClass('active', from.find('option').length > 0); |
118 | 123 | $('#' + field_id + '_remove_all_link').toggleClass('active', to.find('option').length > 0); |
| 124 | |
| 125 | // Refresh selected items |
| 126 | real.find('option').attr('selected', false); // Deselect everything |
| 127 | to.find('option').each(function() { |
| 128 | // Select the same options as the ones present in the 'to' box. |
| 129 | real.find('option[value="' + this.value + '"]').attr('selected', true); |
| 130 | }); |
119 | 131 | }, |
120 | 132 | filter_key_up: function(event, field_id) { |
121 | 133 | var from = document.getElementById(field_id + '_from'); |