Changeset 2107 for trunk/workflow/js/userinterface/orgchartPrint.js
- Timestamp:
- 03/01/10 17:04:58 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/workflow/js/userinterface/orgchartPrint.js
r795 r2107 1 /** 2 * Show / Hide all employees 3 */ 1 4 function toggleEmployeesVisibility() 2 5 { 3 6 if ($('#employeesVisibility').attr('checked')) 4 $(' div.employees').show();7 $('tr.employees').show(); 5 8 else 6 $('div.employees').hide(); 7 } 8 9 $('tr.employees').hide(); 10 } 11 12 /** 13 * Highlight supervisor names? 14 */ 9 15 function toggleHighlightSupervisor() 10 16 { … … 15 21 } 16 22 23 /** 24 * Show / Hide orgchart area path visibility 25 */ 17 26 function toggleOrgchartPathVisibility() 18 27 { 19 28 if ($('#orgchartPathVisibility').attr('checked')) 20 {21 29 $('span.orgchartPath').css('visibility', 'visible').show(); 22 } 23 else 24 { 30 else { 25 31 if ($('#orgchartPathIndentation').attr('checked')) 26 32 $('span.orgchartPath').show().css('visibility', 'hidden'); … … 30 36 } 31 37 38 /** 39 * Group by area or show a single list alphabetically ordered 40 * For large sets of data this function may be potencially slow 41 */ 42 function toggleGroupByArea() 43 { 44 /* remove the table and compute it again */ 45 $('#employee_table').remove(); 46 47 if ($('#groupByArea').attr('checked')) 48 showGroupedByArea(); 49 else 50 showUngrouped(); 51 52 /* updating supervisor highlight and orgchart path visibility */ 53 toggleHighlightSupervisor(); 54 toggleOrgchartPathVisibility(); 55 } 56 57 /** 58 * Centralize the creation of table rows for employees. 59 * 'showAreaColumn' specifies whether the second column will be shown 60 */ 61 function createEmployeeRow(area_id, user_id, showAreaColumn) 62 { 63 /* set a special 'class' if the employee is a supervisor one */ 64 class_name = 'employee'; 65 if (areas[area_id].titular_funcionario_id == areas[area_id].employees[user_id].funcionario_id) 66 class_name += 'supervisor'; 67 68 /* creating the row. */ 69 element = $('<tr></tr>') 70 /* name: first column */ 71 .append( 72 $('<td></td>') 73 .append( 74 $('<span></span>') 75 .addClass(class_name) 76 .append(areas[area_id].employees[user_id].cn) 77 ) 78 .css('width', '85%') 79 ); 80 81 /* area: second (optional) column */ 82 if (showAreaColumn) 83 element.append( 84 $('<td>' + areas[area_id].sigla + '</td>') 85 .css('width', '15%') 86 ); 87 88 /* telephone: last column */ 89 element.append( 90 $('<td>' + areas[area_id].employees[user_id].telephoneNumber + '</td>') 91 .css('width', '15%') 92 ) 93 .addClass('employees'); 94 95 return element; 96 } 97 98 /** 99 * Creating a employee table grouped by area 100 */ 101 function showGroupedByArea() 102 { 103 var table = $('<table></table>').css('width', '90%').attr('id', 'employee_table'); 104 var i, j; 105 106 /* iterating over areas */ 107 for (i=0; i < areas.length; i++) { 108 109 /* inserting area header */ 110 table.append( 111 $('<tr></tr>') 112 .append( 113 $('<th></th>') 114 .css('text-align', 'left') 115 .css('height', '30') 116 .append( 117 $('<span></span>') 118 .addClass('orgchartPath') 119 .append(areas[i].orgchartPath) 120 ) 121 .append(areas[i].sigla) 122 ) 123 ); 124 125 /* creating employee rows */ 126 for (j=0; j < areas[i].employees.length; j++) 127 table.append(createEmployeeRow(i, j)); 128 } 129 $('#areas_content').append(table); 130 } 131 132 /** 133 * Creating employess ordered alphabetically and ungrouped. In this 134 * function we implemented a 'merge' of all area's employee arrays. 135 * 136 * Be careful if you are going to update this code... =) 137 */ 138 function showUngrouped() 139 { 140 var table = $('<table></table>').css('width', '90%').attr('id', 'employee_table'); 141 var i, less, end; 142 143 /* creating and reseting indexes */ 144 for (i=0; i < areas.length; i++) 145 areas[i].index = 0; 146 147 /* */ 148 while (true) { 149 less = -1; 150 end = true; 151 152 /* searching the area with smallest employee name */ 153 for (i=0; i < areas.length; i++) { 154 155 /* if this area have employees left */ 156 if (areas[i].employees.length > areas[i].index) { 157 158 /* if it's the first area reached in this iteration */ 159 if (less == -1) 160 less = i; 161 162 /* updating less */ 163 if (areas[i].employees[areas[i].index].cn < areas[less].employees[areas[less].index].cn) 164 less = i; 165 166 /* so, we are not done */ 167 end = false; 168 } 169 } 170 /* if we are done */ 171 if (end) break; 172 173 /* inserting the row */ 174 table.append(createEmployeeRow(less, areas[less].index, true)); 175 areas[less].index++; 176 } 177 $('#areas_content').append(table); 178 } 179 180 /** 181 * Print me! 182 */ 32 183 function printAction() 33 184 { … … 35 186 } 36 187 188 /** 189 * Binding events to HTML elements 190 */ 37 191 function bindEvents() 38 192 { 39 193 $('#employeesVisibility').click(toggleEmployeesVisibility); 194 $('#groupByArea').click(toggleGroupByArea); 40 195 $('#highlightSupervisor').click(toggleHighlightSupervisor); 41 196 $('#orgchartPathVisibility').click(toggleOrgchartPathVisibility); … … 45 200 function initialSetup() 46 201 { 202 toggleGroupByArea(); 47 203 toggleEmployeesVisibility(); 48 204 toggleHighlightSupervisor(); … … 50 206 } 51 207 208 /** 209 * Call setup functions on body onload. 210 */ 52 211 function pageLoad() 53 212 {
Note: See TracChangeset
for help on using the changeset viewer.