Ticket #7009: collapsedFieldsets_by_id.diff
File collapsedFieldsets_by_id.diff, 3.6 KB (added by , 16 years ago) |
---|
-
CollapsedFieldsets.js
25 25 collapsed_seen = true; 26 26 // Give it an additional class, used by CSS to hide it. 27 27 fs.className += ' ' + CollapsedFieldsets.collapsed_class; 28 if(! fs.id) { 29 fs.id = 'django-collapsing-fieldset-'+i; 30 } 28 31 // (<a id="fieldsetcollapser3" class="collapse-toggle" href="#">Show</a>) 29 32 var collapse_link = document.createElement('a'); 30 33 collapse_link.className = 'collapse-toggle'; 31 collapse_link.id = 'fieldsetcollapser' + i; 32 collapse_link.onclick = new Function('CollapsedFieldsets.show('+i+'); return false;'); 34 collapse_link.id = 'fieldsetcollapser' + fs.id; 35 36 collapse_link.onclick = new Function('CollapsedFieldsets.show("'+fs.id+'"); return false;'); 33 37 collapse_link.href = '#'; 34 38 collapse_link.innerHTML = gettext('Show'); 35 39 var h2 = fs.getElementsByTagName('h2')[0]; … … 53 57 } 54 58 return false; 55 59 }, 56 show: function(fieldset_i ndex) {57 var fs = document.getElement sByTagName('fieldset')[fieldset_index];60 show: function(fieldset_id) { 61 var fs = document.getElementById(fieldset_id); 58 62 // Remove the class name that causes the "display: none". 59 fs.className = fs.className.replace(CollapsedFieldsets.collapsed_re, ''); 63 if (fs.className) { 64 fs.className = fs.className.replace(CollapsedFieldsets.collapsed_re, ''); 65 } 60 66 // Toggle the "Show" link to a "Hide" link 61 var collapse_link = document.getElementById('fieldsetcollapser' + fieldset_i ndex);62 collapse_link.onclick = new Function('CollapsedFieldsets.hide( '+fieldset_index+'); return false;');67 var collapse_link = document.getElementById('fieldsetcollapser' + fieldset_id); 68 collapse_link.onclick = new Function('CollapsedFieldsets.hide("'+fs.id+'"); return false;'); 63 69 collapse_link.innerHTML = gettext('Hide'); 64 70 }, 65 hide: function(fieldset_i ndex) {66 var fs = document.getElement sByTagName('fieldset')[fieldset_index];71 hide: function(fieldset_id) { 72 var fs = document.getElementById(fieldset_id); 67 73 // Add the class name that causes the "display: none". 68 74 fs.className += ' ' + CollapsedFieldsets.collapsed_class; 69 75 // Toggle the "Hide" link to a "Show" link 70 var collapse_link = document.getElementById('fieldsetcollapser' + fieldset_i ndex);71 collapse_link.onclick = new Function('CollapsedFieldsets.show( '+fieldset_index+'); return false;');76 var collapse_link = document.getElementById('fieldsetcollapser' + fieldset_id); 77 collapse_link.onclick = new Function('CollapsedFieldsets.show("'+fs.id+'"); return false;'); 72 78 collapse_link.innerHTML = gettext('Show'); 73 79 }, 74 80 … … 76 82 var fieldsets = document.getElementsByTagName('fieldset'); 77 83 for (var i=0; i<fieldsets.length; i++) { 78 84 if (fieldsets[i].className.match(CollapsedFieldsets.collapsed_re)) { 79 CollapsedFieldsets.show( i);85 CollapsedFieldsets.show(fieldsets[i].id); 80 86 } 81 87 } 82 88 } 83 } 89 }; 84 90 85 addEvent(window, 'load', CollapsedFieldsets.init); 91 addEvent(window, 'load', CollapsedFieldsets.init); 92 No newline at end of file