Ticket #6183: newforms-admin_ManyToManyField-widget.patch
File newforms-admin_ManyToManyField-widget.patch, 3.5 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/related.py
637 637 self.db_table = kwargs.pop('db_table', None) 638 638 Field.__init__(self, **kwargs) 639 639 640 msg = ugettext_lazy(' Hold down "Control", or "Command" on a Mac, to select more than one.')640 msg = ugettext_lazy('<span class="select-multiple-help-text">Hold down "Control", or "Command" on a Mac, to select more than one.</span>') 641 641 self.help_text = string_concat(self.help_text, ' ', msg) 642 642 643 643 def get_manipulator_field_objs(self): -
django/contrib/admin/media/js/SelectFilter2.js
14 14 return node; 15 15 } 16 16 17 function findSelectMultipleHelpTextNode(node) { 18 var nodes = node.getElementsByTagName('span'); 19 for (var i=0, length=nodes.length; i<length; i++) { 20 if (nodes[i].className == 'select-multiple-help-text') { 21 // assume there's only one 22 return nodes[i]; 23 } 24 } 25 return null; 26 } 27 28 function findHelpTextNodes(node) { 29 var nodes = node.getElementsByTagName('p'); 30 var result = []; 31 for (var i=0, length=nodes.length; i<length; i++) { 32 if (nodes[i].className == 'help') { 33 result.push(nodes[i]); 34 } 35 } 36 return result; 37 } 38 17 39 var SelectFilter = { 18 40 init: function(field_id, field_name, is_stacked, admin_media_prefix) { 19 41 var from_box = document.getElementById(field_id); 20 42 from_box.id += '_from'; // change its ID 21 43 from_box.className = 'filtered'; 22 44 23 // Remove <p class="info">, because it just gets in the way. 24 var ps = from_box.parentNode.getElementsByTagName('p'); 25 for (var i=0; i<ps.length; i++) { 26 from_box.parentNode.removeChild(ps[i]); 45 // Find and remove the span tag wich holds the 46 // 'Hold down "Control", or "Command" on a Mac, to select more than one.' 47 // message. 48 var smhelp_node = findSelectMultipleHelpTextNode(from_box.parentNode); 49 if (smhelp_node) { 50 smhelp_node.parentNode.removeChild(smhelp_node); 27 51 } 28 52 53 // Find and remove all user supplied help_text's. 54 var help_text_nodes = findHelpTextNodes(from_box.parentNode); 55 var removed_nodes = []; 56 for (var i=0, length=help_text_nodes.length; i<length; i++) { 57 removed_nodes.push(help_text_nodes[i].parentNode.removeChild(help_text_nodes[i])); 58 } 59 29 60 // <div class="selector"> or <div class="selector stacked"> 30 61 var selector_div = quickElement('div', from_box.parentNode); 31 62 selector_div.className = is_stacked ? 'selector stacked' : 'selector'; … … 76 107 SelectBox.init(field_id + '_to'); 77 108 // Move selected from_box options to to_box 78 109 SelectBox.move(field_id + '_from', field_id + '_to'); 110 111 // Put the user supplied help_text's back into the dom at a place where they 112 // don't interfere with the SelectFilter widget. 113 for (var i=0, length=removed_nodes.length; i<length; i++) { 114 from_box.parentNode.parentNode.parentNode.appendChild(removed_nodes[i]); 115 } 79 116 }, 80 117 filter_key_up: function(event, field_id) { 81 118 from = document.getElementById(field_id + '_from');