Changeset 497
- Timestamp:
- 01/25/07 20:50:17 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/form_system_263/app/views/form_layout/edit.rhtml
r495 r497 1 1 <% content_for('page_scripts') do -%> 2 3 var field_group_count = 1; 2 4 3 5 function create_new_field_group() 4 6 { 5 7 name_text_field = $('new_field_group_name'); 6 group_template = $('group_template') ;8 group_template = $('group_template') 7 9 10 /* Clone the template */ 8 11 new_group = group_template.cloneNode(true); 12 13 /* Show it */ 9 14 new_group.style.display = 'block' 10 new_group.getElementsByTagName('h3')[0].firstChild.nodeValue = name_text_field.value 11 /* [0].nodeValue = 'Foobar yeyeye' */ 15 new_group.id = 'field_group_div_' + field_group_count.toString(); 16 17 /* Update the group name text field */ 18 new_group.getElementsByTagName('input')[0].value = name_text_field.value 19 20 /* Set the table id */ 21 new_group.getElementsByTagName('table')[1].id = 'field_group_table_' + field_group_count.toString(); 22 23 /* Set the table id */ 24 new_group.getElementsByTagName('table')[2].id = 'field_group_buttons_table_' + field_group_count.toString(); 25 26 /* Insert before the group template div */ 12 27 group_template.parentNode.insertBefore(new_group, group_template.nextSibling); 28 29 name_text_field.value = '' 30 field_group_count += 1; 31 } 32 33 function adpot_selected_fields(event) 34 { 35 /* Determine field group */ 36 node = event.target 37 while (node.nodeName.toString() != 'TABLE') 38 node = node.parentNode 39 target_table = $('field_group_table_' + node.id.substr(26)) 40 41 inputs = document.getElementsByTagName('input'); 42 for (var i = 0; i < inputs.length; i++) 43 { 44 /* Look for checked fields */ 45 if (inputs[i].type == 'checkbox' && inputs[i].checked == true && inputs[i].id.match('field_select_') != null) 46 { 47 inputs[i].checked = false 48 id_substr = inputs[i].id.substr(13) 49 row = $('field_row_' + id_substr) 50 target_table.appendChild(row) 51 } 52 } 53 } 54 55 function move_field_up(event) 56 { 57 node = event.target 58 while (node.nodeName.toString() != 'TR') 59 node = node.parentNode 60 up = node.previousSibling 61 while (up != null && up.nodeType != 1) /* Could be whitespace */ 62 up = up.previousSibling 63 64 if (up == null || up.id == '') /* Already the first row */ 65 return 66 67 node.parentNode.insertBefore(node, up) 68 } 69 70 function move_field_down(event) 71 { 72 node = event.target 73 while (node.nodeName.toString() != 'TR') 74 node = node.parentNode 75 down = node.nextSibling 76 while (down != null && up.nodeType != 1) /* Could be whitespace */ 77 down = down.nextSibling 78 79 if (down == null || down.id == '') /* Already the last row */ 80 return 81 82 down = down.nextSibling 83 if (down == null) 84 node.parentNode.appendChild(node) 85 else 86 node.parentNode.insertBefore(node, down) 13 87 } 14 88 … … 32 106 33 107 <div id="group_template" style="display: none;"> 108 <h3><%= _('Group') %></h3> 34 109 <table class="form"> 35 110 <tr> 36 <td> 37 <h3>template</h3> 111 <th><%= _('Name') %></th> 112 <td><%= text_field_tag('field_group_name', '') %></td> 113 </tr> 114 <tr> 115 <td colspan="2"> 38 116 <table class="form"> 39 117 <tr> … … 41 119 <th><%= _('User field name') %></th> 42 120 <th><%= _('Type') %></th> 121 <th><%= _('Select') %></th> 43 122 </tr> 44 123 </table> 124 </td> 125 </tr> 126 </table> 127 <table class="buttons"> 128 <tr> 129 <td> 130 <input type="button" onclick="remove_field_group(event)" value="<%= _('Remove group') %>"/> 131 <input type="button" onclick="adpot_selected_fields(event)" value="<%= _('Move selected fields to this group') %>"/> 45 132 </td> 46 133 </tr> … … 62 149 <th><%= _('User field name') %></th> 63 150 <th><%= _('Type') %></th> 151 <th><%= _('Move') %></th> 152 <th><%= _('Select') %></th> 64 153 </tr> 65 154 <% for @field in @form_fields -%> 66 <tr >67 <td><%= text_field('field', 'name', :size => 40, :maxlength => 40 ) %></td>155 <tr id="<%= h("field_row_#{@field.id}") %>"> 156 <td><%= text_field('field', 'name', :size => 40, :maxlength => 40, :id => h("field_name_#{@field.id}")) %></td> 68 157 <td><%= h(@field.user_field_name) %></td> 69 158 <td><%= h(field_type_to_text[@field.type_code]) %></td> 159 <td> 160 <input type="button" onclick="move_field_up(event)" value="<%= _('Up') %>"/> 161 <input type="button" onclick="move_field_down(event)" value="<%= _('Down') %>"/> 162 </td> 163 <td><%= check_box_tag("field_select[#{@field.id}]", 1, false, :id => h("field_select_#{@field.id}")) %></td> 70 164 </tr> 71 165 <% end -%>