1jQuery(document).ready(function($) { 2 3 var table_data_a = []; 4 var comma_separated_numbers_regex = /^(\s*(\d+\s*,\s*)+\d+\s*|\s*\d+\s*)$/; 5 var hex_rgb_regex = /^#(?:[0-9a-fA-F]{3}){1,2}$/; 6 7 //Save the data attributes of all the tables in the table_data_a array of objects 8 $('.dalt-table').each(function(index){ 9 10 var table_obj = new Object(); 11 12 table_obj.id = $(this).attr("id"); 13 14 //sorting options 15 table_obj.enable_sorting = $(this).data("enable-sorting"); 16 table_obj.enable_manual_sorting = $(this).data("enable-manual-sorting"); 17 table_obj.show_position = $(this).data("show-position"); 18 table_obj.position_side = $(this).data("position-side"); 19 table_obj.position_label = $(this).data("position-label"); 20 table_obj.number_format = $(this).data("number-format"); 21 table_obj.order_desc_asc_1 = $(this).data("order-desc-asc-1"); 22 table_obj.order_by_1 = $(this).data("order-by-1"); 23 table_obj.order_data_type_1 = $(this).data("order-data-type-1"); 24 table_obj.order_date_format_1 = $(this).data("order-date-format-1"); 25 table_obj.order_desc_asc_2 = $(this).data("order-desc-asc-2"); 26 table_obj.order_by_2 = $(this).data("order-by-2"); 27 table_obj.order_data_type_2 = $(this).data("order-data-type-2"); 28 table_obj.order_date_format_2 = $(this).data("order-date-format-2"); 29 table_obj.order_desc_asc_3 = $(this).data("order-desc-asc-3"); 30 table_obj.order_by_3 = $(this).data("order-by-3"); 31 table_obj.order_data_type_3 = $(this).data("order-data-type-3"); 32 table_obj.order_date_format_3 = $(this).data("order-date-format-3"); 33 table_obj.order_desc_asc_4 = $(this).data("order-desc-asc-4"); 34 table_obj.order_by_4 = $(this).data("order-by-4"); 35 table_obj.order_data_type_4 = $(this).data("order-data-type-4"); 36 table_obj.order_date_format_4 = $(this).data("order-date-format-4"); 37 table_obj.order_desc_asc_5 = $(this).data("order-desc-asc-5"); 38 table_obj.order_by_5 = $(this).data("order-by-5"); 39 table_obj.order_data_type_5 = $(this).data("order-data-type-5"); 40 table_obj.order_date_format_5 = $(this).data("order-date-format-5"); 41 42 //style options 43 table_obj.table_width = $(this).data("table-width"); 44 table_obj.table_width_value = $(this).data("table-width-value"); 45 table_obj.table_minimum_width = $(this).data("table-minimum-width"); 46 table_obj.table_margin_top = $(this).data("table-margin-top"); 47 table_obj.table_margin_bottom = $(this).data("table-margin-bottom"); 48 table_obj.enable_container = $(this).data("enable-container"); 49 table_obj.container_width = $(this).data("container-width"); 50 table_obj.container_height = $(this).data("container-height"); 51 table_obj.header_font_size = $(this).data("header-font-size"); 52 table_obj.header_font_family = $(this).data("header-font-family"); 53 table_obj.header_font_weight = $(this).data("header-font-weight"); 54 table_obj.header_font_style = $(this).data("header-font-style"); 55 table_obj.header_background_color = $(this).data("header-background-color"); 56 table_obj.header_font_color = $(this).data("header-font-color"); 57 table_obj.header_link_color = $(this).data("header-link-color"); 58 table_obj.header_border_color = $(this).data("header-border-color"); 59 table_obj.header_position_alignment = $(this).data("header-position-alignment"); 60 table_obj.body_font_size = $(this).data("body-font-size"); 61 table_obj.body_font_family = $(this).data("body-font-family"); 62 table_obj.body_font_weight = $(this).data("body-font-weight"); 63 table_obj.body_font_style = $(this).data("body-font-style"); 64 table_obj.even_rows_background_color = $(this).data("even-rows-background-color"); 65 table_obj.odd_rows_background_color = $(this).data("odd-rows-background-color"); 66 table_obj.even_rows_font_color = $(this).data("even-rows-font-color"); 67 table_obj.even_rows_link_color = $(this).data("even-rows-link-color"); 68 table_obj.odd_rows_font_color = $(this).data("odd-rows-font-color"); 69 table_obj.odd_rows_link_color = $(this).data("odd-rows-link-color"); 70 table_obj.rows_border_color = $(this).data("rows-border-color"); 71 72 //autocolors options 73 table_obj.autocolors_priority = $(this).data("autocolors-priority"); 74 table_obj.autocolors_affected_rows_1 = $(this).data("autocolors-affected-rows-1").toString(); 75 table_obj.autocolors_rows_background_color_1 = $(this).data("autocolors-rows-background-color-1"); 76 table_obj.autocolors_rows_font_color_1 = $(this).data("autocolors-rows-font-color-1"); 77 table_obj.autocolors_affected_rows_2 = $(this).data("autocolors-affected-rows-2").toString(); 78 table_obj.autocolors_rows_background_color_2 = $(this).data("autocolors-rows-background-color-2"); 79 table_obj.autocolors_rows_font_color_2 = $(this).data("autocolors-rows-font-color-2"); 80 table_obj.autocolors_affected_rows_3 = $(this).data("autocolors-affected-rows-3").toString(); 81 table_obj.autocolors_rows_background_color_3 = $(this).data("autocolors-rows-background-color-3"); 82 table_obj.autocolors_rows_font_color_3 = $(this).data("autocolors-rows-font-color-3"); 83 table_obj.autocolors_affected_rows_4 = $(this).data("autocolors-affected-rows-4").toString(); 84 table_obj.autocolors_rows_background_color_4 = $(this).data("autocolors-rows-background-color-4"); 85 table_obj.autocolors_rows_font_color_4 = $(this).data("autocolors-rows-font-color-4"); 86 table_obj.autocolors_affected_rows_5 = $(this).data("autocolors-affected-rows-5").toString(); 87 table_obj.autocolors_rows_background_color_5 = $(this).data("autocolors-rows-background-color-5"); 88 table_obj.autocolors_rows_font_color_5 = $(this).data("autocolors-rows-font-color-5"); 89 table_obj.autocolors_affected_columns_1 = $(this).data("autocolors-affected-columns-1").toString(); 90 table_obj.autocolors_columns_background_color_1 = $(this).data("autocolors-columns-background-color-1"); 91 table_obj.autocolors_columns_font_color_1 = $(this).data("autocolors-columns-font-color-1"); 92 table_obj.autocolors_affected_columns_2 = $(this).data("autocolors-affected-columns-2").toString(); 93 table_obj.autocolors_columns_background_color_2 = $(this).data("autocolors-columns-background-color-2"); 94 table_obj.autocolors_columns_font_color_2 = $(this).data("autocolors-columns-font-color-2"); 95 table_obj.autocolors_affected_columns_3 = $(this).data("autocolors-affected-columns-3").toString(); 96 table_obj.autocolors_columns_background_color_3 = $(this).data("autocolors-columns-background-color-3"); 97 table_obj.autocolors_columns_font_color_3 = $(this).data("autocolors-columns-font-color-3"); 98 table_obj.autocolors_affected_columns_4 = $(this).data("autocolors-affected-columns-4").toString(); 99 table_obj.autocolors_columns_background_color_4 = $(this).data("autocolors-columns-background-color-4"); 100 table_obj.autocolors_columns_font_color_4 = $(this).data("autocolors-columns-font-color-4"); 101 table_obj.autocolors_affected_columns_5 = $(this).data("autocolors-affected-columns-5").toString(); 102 table_obj.autocolors_columns_background_color_5 = $(this).data("autocolors-columns-background-color-5"); 103 table_obj.autocolors_columns_font_color_5 = $(this).data("autocolors-columns-font-color-5"); 104 105 //autoalignment options 106 table_obj.autoalignment_priority = $(this).data("autoalignment-priority"); 107 table_obj.autoalignment_affected_rows_left = $(this).data("autoalignment-affected-rows-left").toString(); 108 table_obj.autoalignment_affected_rows_center = $(this).data("autoalignment-affected-rows-center").toString(); 109 table_obj.autoalignment_affected_rows_right = $(this).data("autoalignment-affected-rows-right").toString(); 110 table_obj.autoalignment_affected_columns_left = $(this).data("autoalignment-affected-columns-left").toString(); 111 table_obj.autoalignment_affected_columns_center = $(this).data("autoalignment-affected-columns-center").toString(); 112 table_obj.autoalignment_affected_columns_right = $(this).data("autoalignment-affected-columns-right").toString(); 113 114 //responsive options 115 table_obj.tablet_breakpoint = $(this).data("tablet-breakpoint"); 116 table_obj.hide_tablet_list = $(this).data("hide-tablet-list").toString(); 117 table_obj.tablet_header_font_size = $(this).data("tablet-header-font-size"); 118 table_obj.tablet_body_font_size = $(this).data("tablet-body-font-size"); 119 table_obj.tablet_hide_images = $(this).data("tablet-hide-images"); 120 table_obj.phone_breakpoint = $(this).data("phone-breakpoint"); 121 table_obj.hide_phone_list = $(this).data("hide-phone-list").toString(); 122 table_obj.phone_header_font_size = $(this).data("phone-header-font-size"); 123 table_obj.phone_body_font_size = $(this).data("phone-body-font-size"); 124 table_obj.phone_hide_images = $(this).data("phone-hide-images"); 125 126 //advanced options 127 table_obj.enable_cell_properties = $(this).data("enable-cell-properties"); 128 129 table_data_a[index] = table_obj; 130 131 }); 132 133 /* 134 * Loop trough all the objects available in teh table_data_a array of objects. Each object includes the identifier 135 * of the table and all the data attributes. 136 */ 137 $.each(table_data_a, function( index, table_obj ) { 138 139 //sorting options ---------------------------------------------------------------------------------------------- 140 141 //initialize tablesorter if the "Enable Sorting" option is true 142 if( parseInt(table_obj.enable_sorting, 10) == 1 ){ 143 144 var sortList = []; 145 146 //apply the sorting option to the 5 priority levels 147 for(i=1;i<=5;i++){ 148 149 //apply the sorting only if the "Order" option is not set to 0 (Disabled) 150 if( parseInt(table_obj['order_desc_asc_' + i], 10) == 1 || parseInt(table_obj['order_desc_asc_' + i], 10) == 2 ){ 151 152 //generate the value for the sortList option, used to determine the initial sort of the table 153 sortList.push([(table_obj['order_by_' + i] - 1), Math.abs(parseInt(table_obj['order_desc_asc_' + i], 10) - 2)]); 154 155 /* 156 * If the "Order Data Type" option is different from "Auto" add to the specific th element the 157 * "data-sorter" attribute to set the parser 158 * 159 * If the "Order Data Type" option is equal to "shortDate" add to the specific th element the 160 * "data-date-format" attribute to set the date format 161 */ 162 if( table_obj["order_data_type_" + i] != 'auto' ){ 163 $("#" + table_obj.id + " th:nth-child(" + table_obj['order_by_' + i] + ")" ).attr("data-sorter", table_obj['order_data_type_' + i]); 164 if(table_obj['order_data_type_' + i] == 'shortDate'){ 165 $("#" + table_obj.id + " th:nth-child(" + table_obj['order_by_' + i] + ")" ).attr("data-date-format", table_obj['order_date_format_' + i]); 166 } 167 } 168 169 } 170 171 } 172 173 var configuration = new Object(); 174 175 //define the configuration options ------------------------------------------------------------------------- 176 177 //set the intial sorting order 178 configuration.sortList = sortList; 179 180 //set the number format 181 if( parseInt(table_obj.number_format, 10) == 1 ){ 182 configuration.usNumberFormat = true; 183 }else{ 184 configuration.usNumberFormat = false;
185 } 186 187 //init tablesorter 188 $("#" + table_obj.id).tablesorter(configuration); 189 190 //enable or disable the manual sorting 191 if( parseInt(table_obj.enable_manual_sorting, 10) == 0 ){ 192 //disable the event used to trigger the manual sorting 193 $( "#" + table_obj.id +" > thead th").off(); 194 }else{ 195 //set the mouse cursor to pointer 196 $( "#" + table_obj.id +" > thead th").addClass('dalt-cursor-pointer'); 197 } 198 199 } 200 201 //generate the position column 202 if( parseInt(table_obj.show_position, 10) == 1 ){ 203 204 if(table_obj.position_side == 'left'){ 205 206 //Generate the position column on the left side of the table ------------------------------------------- 207 208 //add a "th" element with the "Position Label" as the content in the "table > thead > tr" element 209 if( parseInt(table_obj.enable_sorting, 10) == 1 ){ 210 //include the <div> to maintain a DOM structure similar to the one of the other header cells 211 $('#' + table_obj.id + ' > thead > tr').prepend('<th><div>' + table_obj.position_label + '</div></th>'); 212 }else{ 213 //do not include the <div> to maintain a DOM structure similar to the one of the other header cells 214 $('#' + table_obj.id + ' > thead > tr').prepend('<th>' + table_obj.position_label + '</th>'); 215 } 216 217 //add the "td" element as the first child of each "table > tbody > tr" element 218 $('#' + table_obj.id + ' > tbody > tr').each(function(index){ 219 $(this).prepend('<td>' + (index + 1) + '</td>'); 220 }); 221 222 }else{ 223 224 //Generate the position column on the right side of the table ------------------------------------------ 225 226 //add a "th" element with the "Position Label" as the content in the "table > thead > tr" element 227 if( parseInt(table_obj.enable_sorting, 10) == 1 ){ 228 //include the <div> to maintain a DOM structure similar to the one of the other header cells 229 $('#' + table_obj.id + ' > thead > tr').append('<th><div>' + table_obj.position_label + '</div></th>'); 230 }else{ 231 //do not include the <div> to maintain a DOM structure similar to the one of the other header cells 232 $('#' + table_obj.id + ' > thead > tr').append('<th>' + table_obj.position_label + '</th>'); 233 } 234 235 //add the "td" element as the first child of each "table > tbody > tr" element 236 $('#' + table_obj.id + ' > tbody > tr').each(function(index){ 237 $(this).append('<td>' + (index + 1) + '</td>'); 238 }); 239 240 } 241 242 243 244 } 245 246 //style options ------------------------------------------------------------------------------------------------ 247 248 //Table Width 249 switch(parseInt(table_obj.table_width, 10)){ 250 case 0: 251 $('#' + table_obj.id).css('width', '100%'); 252 break; 253 case 1: 254 $('#' + table_obj.id).css('width', 'auto'); 255 break; 256 case 2: 257 $('#' + table_obj.id).css('width', table_obj.table_width_value + 'px'); 258 break; 259 } 260 261 //Table Minimum Width 262 $('#' + table_obj.id).css('min-width', table_obj.table_minimum_width + 'px'); 263 264 //If the container is enabled apply it with the related styles, otherwise apply only the margin to the table 265 if(parseInt(table_obj.enable_container) == 1){ 266 267 //If the container is enabled apply the two margins to the container 268 $('#' + table_obj.id).parent().css('margin-top', table_obj.table_margin_top + 'px'); 269 $('#' + table_obj.id).parent().css('margin-bottom', table_obj.table_margin_bottom + 'px'); 270 271 //Container Width 272 if(parseInt(table_obj.container_width, 10) > 0){ 273 $('#' + table_obj.id).parent().css('width', table_obj.container_width + 'px'); 274 }else{ 275 $('#' + table_obj.id).parent().css('width', 'auto'); 276 } 277 278 //Container Height 279 if(parseInt(table_obj.container_height, 10) > 0){ 280 $('#' + table_obj.id).parent().css('height', table_obj.container_height + 'px'); 281 }else{ 282 $('#' + table_obj.id).parent().css('height', 'auto'); 283 } 284 285 }else{ 286 287 //If the container is not enabled apply the two margins to the table 288 $('#' + table_obj.id).css('margin-top', table_obj.table_margin_top + 'px'); 289 $('#' + table_obj.id).css('margin-bottom', table_obj.table_margin_bottom + 'px'); 290 291 } 292 293 //Header Cells Padding based on the Header Font Size 294 var vertical_padding = Math.round(0.636363 * table_obj.header_font_size) + 'px'; 295 var horizontal_padding = Math.round(0.909090 * table_obj.header_font_size) + 'px'; 296 $('#' + table_obj.id + ' th').css('padding', vertical_padding + ' ' + horizontal_padding); 297 298 //Image Height - Based on the Header Font size 299 var image_height = Math.round(1.545454 * table_obj.header_font_size) + 'px'; 300 $('#' + table_obj.id + ' th img.dalt-image-left, #' + table_obj.id + ' th img.dalt-image-right').css('height', image_height); 301 302 //Image Left - Margin based on the Header Font Size 303 var margin = '0 ' + Math.round(0.454545 * table_obj.header_font_size) + 'px 0 0'; 304 $('#' + table_obj.id + ' th img.dalt-image-left').css('margin', margin); 305 306 //Image Right - Margin based on the Header Font Size 307 var margin = '0 0 0 ' + Math.round(0.454545 * table_obj.header_font_size) + 'px'; 308 $('#' + table_obj.id + ' th img.dalt-image-right').css('margin', margin); 309 310 /* 311 * If the sorting is enabled Tablesorter adds a <div> as the child of the <th> element, for this reason some CSS 312 * rules should be applied to different selectors. 313 */ 314 if( parseInt(table_obj.enable_sorting, 10) == 1 ){ 315 316 //Line Height based on the Header Font Size 317 var line_height = Math.round(1.454545 * table_obj.header_font_size) + 'px'; 318 $('#' + table_obj.id + ' th > div').css('line-height', line_height); 319 320 //Header Font Size 321 $('#' + table_obj.id + ' th > div').css('font-size', table_obj.header_font_size + 'px'); 322 323 //Header Font Family 324 $('#' + table_obj.id + ' th > div').css('font-family', table_obj.header_font_family); 325 326 //Header Font Weight 327 $('#' + table_obj.id + ' th > div').css('font-weight', table_obj.header_font_weight); 328 329 //Header Font Style 330 $('#' + table_obj.id + ' th > div').css('font-style', table_obj.header_font_style); 331 332 //Header Font Color 333 $('#' + table_obj.id + ' th > div').css('color', table_obj.header_font_color); 334 335 //Header Link Color 336 $('#' + table_obj.id + ' th > div a').css('color', table_obj.header_link_color); 337 338 }else{ 339 340 //Line Height based on the Header Font Size 341 var line_height = Math.round(1.454545 * table_obj.header_font_size) + 'px'; 342 $('#' + table_obj.id + ' th').css('line-height', line_height); 343 344 //Header Font Size 345 $('#' + table_obj.id + ' th').css('font-size', table_obj.header_font_size + 'px'); 346 347 //Header Font Family 348 $('#' + table_obj.id + ' th').css('font-family', table_obj.header_font_family); 349 350 //Header Font Weight 351 $('#' + table_obj.id + ' th').css('font-weight', table_obj.header_font_weight); 352 353 //Header Font Style 354 $('#' + table_obj.id + ' th').css('font-style', table_obj.header_font_style); 355 356 //Header Font Color 357 $('#' + table_obj.id + ' th').css('color', table_obj.header_font_color); 358 359 //Header Link Color 360 $('#' + table_obj.id + ' th a').css('color', table_obj.header_link_color); 361 362 } 363
364 //Header Background Color 365 $('#' + table_obj.id + ' th').css('background-color', table_obj.header_background_color); 366 367 //Header Border Color 368 $('#' + table_obj.id + ' th').css('border-color', table_obj.header_border_color); 369 370 //Header Position Alignment 371 if(parseInt(table_obj.show_position, 10) == 1){ 372 if(table_obj.position_side == 'left'){ 373 $('#' + table_obj.id + ' th').first().css('text-align', table_obj.header_position_alignment); 374 }else{ 375 $('#' + table_obj.id + ' th').last().css('text-align', table_obj.header_position_alignment); 376 } 377 } 378 379 //Body Font Size 380 $('#' + table_obj.id + ' td').css('font-size', table_obj.body_font_size); 381 382 //Body Cells Padding based on the Body Font Size 383 var vertical_padding = Math.round(0.272727 * table_obj.body_font_size) + 'px'; 384 var horizontal_padding = Math.round(0.909090 * table_obj.body_font_size) + 'px'; 385 $('#' + table_obj.id + ' td').css('padding', vertical_padding + ' ' + horizontal_padding); 386 387 //Line Height based on the Body Font Size 388 var line_height = Math.round(1.545454 * table_obj.body_font_size) + 'px'; 389 $('#' + table_obj.id + ' td').css('line-height', line_height); 390 391 //Image Height - Based on the Body Font size 392 var image_height = Math.round(1.545454 * table_obj.body_font_size) + 'px'; 393 $('#' + table_obj.id + ' td img.dalt-image-left, #' + table_obj.id + ' td img.dalt-image-right').css('height', image_height); 394 395 //Image Left - Margin based on the Body Font Size 396 var margin = '0 ' + Math.round(0.454545 * table_obj.body_font_size) + 'px 0 0'; 397 $('#' + table_obj.id + ' td img.dalt-image-left').css('margin', margin); 398 399 //Image Right - Margin based on the Body Font Size 400 var margin = '0 0 0 ' + Math.round(0.454545 * table_obj.body_font_size) + 'px'; 401 $('#' + table_obj.id + ' td img.dalt-image-right').css('margin', margin); 402 403 //Body Font Family 404 $('#' + table_obj.id + ' td').css('font-family', table_obj.body_font_family); 405 406 //Body Font Weight 407 $('#' + table_obj.id + ' td').css('font-weight', table_obj.body_font_weight); 408 409 //Body Font Style 410 $('#' + table_obj.id + ' td').css('font-style', table_obj.body_font_style); 411 412 //Even Rows Background Color 413 $('head').append('<style type="text/css">' + '\#' + table_obj.id + ' tr:nth-child(even) td{background-color: ' + table_obj.even_rows_background_color + ';}</style>'); 414 415 //Even Rows Font Color 416 $('head').append('<style type="text/css">' + '\#' + table_obj.id + ' tr:nth-child(even) td{color: ' + table_obj.even_rows_font_color + ';}</style>'); 417 418 //Even Rows Link Color 419 $('head').append('<style type="text/css">' + '\#' + table_obj.id + ' tr:nth-child(even) td a{color: ' + table_obj.even_rows_link_color + ';}</style>'); 420 421 //Odd Rows Background Color 422 $('head').append('<style type="text/css">' + '\#' + table_obj.id + ' tr:nth-child(odd) td{background-color: ' + table_obj.odd_rows_background_color + ';}</style>'); 423 424 //Odd Rows Font Color 425 $('head').append('<style type="text/css">' + '\#' + table_obj.id + ' tr:nth-child(odd) td{color: ' + table_obj.odd_rows_font_color + ';}</style>'); 426 427 //Odd Rows Link Color 428 $('head').append('<style type="text/css">' + '\#' + table_obj.id + ' tr:nth-child(odd) td a{color: ' + table_obj.odd_rows_link_color + ';}</style>'); 429 430 //Rows Border Color 431 $('#' + table_obj.id + ' td').css('border-color', table_obj.rows_border_color); 432 433 //Autocolors options ------------------------------------------------------------------------------------------- 434 if(table_obj.autocolors_priority == 'columns'){ 435 //Columns has the priority 436 apply_autocolors_on_rows(table_obj); 437 apply_autocolors_on_columns(table_obj); 438 }else{ 439 //Rows has the priority 440 apply_autocolors_on_columns(table_obj); 441 apply_autocolors_on_rows(table_obj); 442 } 443 444 //Autoalignment options ---------------------------------------------------------------------------------------- 445 if(table_obj.autoalignment_priority == 'columns'){ 446 //Columns has the priority 447 apply_autoalignment_on_rows(table_obj); 448 apply_autoalignment_on_columns(table_obj); 449 }else{ 450 //Rows has the priority 451 apply_autoalignment_on_columns(table_obj); 452 apply_autoalignment_on_rows(table_obj); 453 } 454 455 //responsive options ------------------------------------------------------------------------------------------- 456 457 //Tablet 458 459 //generate an array from the table_obj.hidden_columns_tablet string 460 var hide_tablet_list_a = table_obj.hide_tablet_list.split(','); 461 462 //init css rule 463 var hidden_cells = ''; 464 465 //generate the selectors of the css rule by using the values included in the hidden_columns_tablet_a array 466 $.each(hide_tablet_list_a, function( index, value ) { 467 hidden_cells += '#' + table_obj.id + ' tr th:nth-child(' + value + '),'; 468 hidden_cells += '#' + table_obj.id + ' tr td:nth-child(' + value + ')'; 469 if(hide_tablet_list_a.length > (index + 1)){hidden_cells += ',';} 470 }); 471 472 //complete the css rule with the declaration block 473 if(hidden_cells.length > 0){hidden_cells += '{display: none;}'} 474 475 //set the font size for table cells in the header 476 var header_font_size_cells = '#' + table_obj.id + ' tr th, #' + table_obj.id + ' tr th div{font-size: ' + table_obj.tablet_header_font_size+ 'px !important}'; 477 478 //set the padding for the table cells in the header 479 var vertical_padding = Math.round(0.636363 * table_obj.tablet_header_font_size) + 'px'; 480 var horizontal_padding = Math.round(0.909090 * table_obj.tablet_header_font_size) + 'px'; 481 var header_padding_cells = '#' + table_obj.id + ' tr th{padding: ' + vertical_padding + ' ' + horizontal_padding + ' !important}'; 482 483 //Image Height - Based on the Header Font size 484 var image_height_value = Math.round(1.545454 * table_obj.tablet_header_font_size) + 'px'; 485 var header_image_height = '#' + table_obj.id + ' th img.dalt-image-left, #' + table_obj.id + ' th img.dalt-image-right{height: ' + image_height_value + ' !important}'; 486 487 //Image Left - Margin based on the Header Font Size 488 var margin = '0 ' + Math.round(0.454545 * table_obj.tablet_header_font_size) + 'px 0 0'; 489 var header_image_left_margin = '#' + table_obj.id + ' th img.dalt-image-left{margin: ' + margin + ' !important;}'; 490 491 //Image Right - Margin based on the Header Font Size 492 var margin = '0 0 0 ' + Math.round(0.454545 * table_obj.tablet_header_font_size) + 'px'; 493 var header_image_right_margin = '#' + table_obj.id + ' th img.dalt-image-right{margin: ' + margin + ' !important;}'; 494 495 //Line Height based on the Header Font Size 496 var line_height_value = Math.round(1.454545 * table_obj.tablet_header_font_size) + 'px'; 497 if( parseInt(table_obj.enable_sorting, 10) == 1 ) { 498 var header_line_height = '#' + table_obj.id + ' th > div{line-height: ' + line_height_value + ' !important;}'; 499 }else{ 500 var header_line_height = '#' + table_obj.id + ' th{line-height: ' + line_height_value + ' !important;}'; 501 } 502 503 //set the font size for table cells in the body 504 var body_font_size_cells = '#' + table_obj.id + ' tr td{font-size: ' + table_obj.tablet_body_font_size+ 'px !important}'; 505 506 //set the padding for the table cells in the body 507 var vertical_padding = Math.round(0.272727 * table_obj.tablet_body_font_size) + 'px'; 508 var horizontal_padding = Math.round(0.909090 * table_obj.tablet_body_font_size) + 'px'; 509 var body_padding_cells = '#' + table_obj.id + ' tr td{padding: ' + vertical_padding + ' ' + horizontal_padding + ' !important}'; 510 511 //Line Height based on the Body Font Size 512 var line_height_value = Math.round(1.545454 * table_obj.tablet_body_font_size) + 'px'; 513 var body_line_height = '#' + table_obj.id + ' td{line-height: ' + line_height_value + ' !important;}'; 514 515 //Image Height - Based on the Body Font size 516 var image_height_value = Math.round(1.545454 * table_obj.tablet_body_font_size) + 'px'; 517 var body_image_height = '#' + table_obj.id + ' td img.dalt-image-left, #' + table_obj.id + ' td img.dalt-image-right{height: ' + image_height_value + ' !important}'; 518 519 //Image Left - Margin based on the Body Font Size 520 var margin = '0 ' + Math.round(0.454545 * table_obj.tablet_body_font_size) + 'px 0 0'; 521 var body_image_left_margin = '#' + table_obj.id + ' td img.dalt-image-left{margin: ' + margin + ' !important;}'; 522 523 //Image Right - Margin based on the Body Font Size 524 var margin = '0 0 0 ' + Math.round(0.454545 * table_obj.tablet_body_font_size) + 'px'; 525 var body_image_right_margin = '#' + table_obj.id + ' td img.dalt-image-right{margin: ' + margin + ' !important;}'; 526 527 //append the media query with the css rule in the head 528 $('head').append('<style type="text/css">@media all and (max-width: ' + table_obj.tablet_breakpoint + 'px){' + hidden_cells + header_font_size_cells + header_padding_cells + header_image_height + header_image_left_margin + header_image_right_margin + header_line_height + body_font_size_cells + body_padding_cells + body_line_height + body_image_height + body_image_left_margin + body_image_right_margin + '} </style>'); 529 530 //tablet hide images 531 if(parseInt(table_obj.tablet_hide_images) == 1){ 532 $('head').append('<style type="text/css">@media all and (max-width: ' + table_obj.tablet_breakpoint + 'px){\#' + table_obj.id + ' img{ display: none !important;}}</style>'); 533 } 534 535 //Phone 536 537 //generate an array from table_obj.hidden_columns_phone string 538 var hide_phone_list_a = table_obj.hide_phone_list.split(','); 539 540 //init css rule 541 var hidden_cells = ''; 542 543 //generate the selectors of the css rule by using the values included in the hidden_columns_phone_a array 544 $.each(hide_phone_list_a, function( index, value ) { 545 hidden_cells += '#' + table_obj.id + ' tr th:nth-child(' + value + '),'; 546 hidden_cells += '#' + table_obj.id + ' tr td:nth-child(' + value + ')'; 547 if(hide_phone_list_a.length > (index + 1)){hidden_cells += ',';} 548 }); 549 550 //complete the css rule with the declaration block 551 if(hidden_cells.length > 0){hidden_cells += '{display: none;}'} 552 553 //set the font size for table cells in the header 554 var header_font_size_cells = '#' + table_obj.id + ' tr th, #' + table_obj.id + ' tr th div{font-size: ' + table_obj.phone_header_font_size + 'px !important}'; 555 556 //set the padding for the table cells in the header 557 var vertical_padding = Math.round(0.636363 * table_obj.phone_header_font_size) + 'px'; 558 var horizontal_padding = Math.round(0.909090 * table_obj.phone_header_font_size) + 'px'; 559 var header_padding_cells = '#' + table_obj.id + ' tr th{padding: ' + vertical_padding + ' ' + horizontal_padding + ' !important}'; 560 561 //Image Height - Based on the Header Font size 562 var image_height_value = Math.round(1.545454 * table_obj.phone_header_font_size) + 'px'; 563 var header_image_height = '#' + table_obj.id + ' th img.dalt-image-left, #' + table_obj.id + ' th img.dalt-image-right{height: ' + image_height_value + ' !important}'; 564 565 //Image Left - Margin based on the Header Font Size 566 var margin = '0 ' + Math.round(0.454545 * table_obj.phone_header_font_size) + 'px 0 0'; 567 var header_image_left_margin = '#' + table_obj.id + ' th img.dalt-image-left{margin: ' + margin + ' !important;}'; 568 569 //Image Right - Margin based on the Header Font Size 570 var margin = '0 0 0 ' + Math.round(0.454545 * table_obj.phone_header_font_size) + 'px'; 571 var header_image_right_margin = '#' + table_obj.id + ' th img.dalt-image-right{margin: ' + margin + ' !important;}'; 572 573 //Line Height based on the Header Font Size 574 var line_height_value = Math.round(1.454545 * table_obj.phone_header_font_size) + 'px'; 575 if( parseInt(table_obj.enable_sorting, 10) == 1 ) { 576 var header_line_height = '#' + table_obj.id + ' th > div{line-height: ' + line_height_value + ' !important;}'; 577 }else{ 578 var header_line_height = '#' + table_obj.id + ' th{line-height: ' + line_height_value + ' !important;}'; 579 } 580 581 //set the font size for table cells in the body 582 var body_font_size_cells = '#' + table_obj.id + ' tr td{font-size: ' + table_obj.phone_body_font_size + 'px !important}'; 583 584 //set the padding for the table cells in the body 585 var vertical_padding = Math.round(0.272727 * table_obj.phone_body_font_size) + 'px'; 586 var horizontal_padding = Math.round(0.909090 * table_obj.phone_body_font_size) + 'px'; 587 var body_padding_cells = '#' + table_obj.id + ' tr td{padding: ' + vertical_padding + ' ' + horizontal_padding + ' !important}'; 588 589 //Line Height based on the Body Font Size 590 var line_height_value = Math.round(1.545454 * table_obj.phone_body_font_size) + 'px'; 591 var body_line_height = '#' + table_obj.id + ' td{line-height: ' + line_height_value + ' !important;}'; 592 593 //Image Height - Based on the Body Font size 594 var image_height_value = Math.round(1.545454 * table_obj.phone_body_font_size) + 'px'; 595 var body_image_height = '#' + table_obj.id + ' td img.dalt-image-left, #' + table_obj.id + ' td img.dalt-image-right{height: ' + image_height_value + ' !important}'; 596 597 //Image Left - Margin based on the Body Font Size 598 var margin = '0 ' + Math.round(0.454545 * table_obj.phone_body_font_size) + 'px 0 0'; 599 var body_image_left_margin = '#' + table_obj.id + ' td img.dalt-image-left{margin: ' + margin + ' !important;}'; 600 601 //Image Right - Margin based on the Body Font Size 602 var margin = '0 0 0 ' + Math.round(0.454545 * table_obj.phone_body_font_size) + 'px'; 603 var body_image_right_margin = '#' + table_obj.id + ' td img.dalt-image-right{margin: ' + margin + ' !important;}'; 604 605 //append the media query with the css rule in the head 606 $('head').append('<style type="text/css">@media all and (max-width: ' + table_obj.phone_breakpoint + 'px){' + hidden_cells + header_font_size_cells + header_padding_cells + header_image_height + header_image_left_margin + header_image_right_margin + header_line_height + body_font_size_cells + body_padding_cells + body_line_height + body_image_height + body_image_left_margin + body_image_right_margin + '} </style>'); 607 608 //phone hide images 609 if(parseInt(table_obj.phone_hide_images) == 1){ 610 $('head').append('<style type="text/css">@media all and (max-width: ' + table_obj.phone_breakpoint + 'px){\#' + table_obj.id + ' img{ display: none !important;}}</style>'); 611 } 612 613 //cell properties ---------------------------------------------------------------------------------------------- 614 if(parseInt(table_obj.enable_cell_properties, 10) == 1){ 615 616 $('#' + table_obj.id + ' th, #' + table_obj.id + ' td').each(function(index){ 617 618 if( $(this).attr('data-cell-properties') == 'true' ){ 619 620 //get the cell properties 621 var text_color = $(this).attr('data-text-color'); 622 var background_color = $(this).attr('data-background-color'); 623 var font_weight = $(this).attr('data-font-weight'); 624 var font_style = $(this).attr('data-font-style'); 625 var link_color = $(this).attr('data-link-color'); 626 var alignment = $(this).attr('data-alignment'); 627
628 //Background Color 629 if(background_color.match(hex_rgb_regex)){ 630 $(this).css('background', background_color); 631 } 632 633 /* 634 * If the sorting is enabled Tablesorter adds a <div> as the child of the <th> element, for this 635 * reason in the header some CSS rules should be applied to different selectors. 636 */ 637 if( $(this).is('th') && parseInt(table_obj.enable_sorting) == 1 ){ 638 var target = $(this).children(); 639 }else{ 640 var target = $(this); 641 } 642 643 //Text Color 644 if(text_color.match(hex_rgb_regex)){ 645 target.css('color', text_color); 646 } 647 648 //Font Weight 649 target.css('font-weight', font_weight); 650 651 //Font Style 652 target.css('font-style', font_style); 653 654 //Link Color 655 if(link_color.match(hex_rgb_regex)){ 656 $(target).children('a').css('color', link_color); 657 } 658 659 //Alignment 660 target.css('text-align', alignment); 661 662 } 663 664 }); 665 666 } 667 668 $('#' + table_obj.id).css('visibility', 'visible'); 669 670 }); 671 672 /* 673 * Applies the autocolors of the rows for all the 5 priority levels 674 */ 675 function apply_autocolors_on_rows(table_obj){ 676 677 //Priority 1 678 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_rows_1)) { 679 var autocolors_affected_rows_1 = table_obj.autocolors_affected_rows_1.split(','); 680 $.each(autocolors_affected_rows_1, function( index, value ) { 681 $('#' + table_obj.id + ' tr:nth-child(' + parseInt(value, 10) + ') td').css('background-color', table_obj.autocolors_rows_background_color_1).css('color', table_obj.autocolors_rows_font_color_1); 682 }); 683 } 684 685 //Priority 2 686 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_rows_2)) { 687 var autocolors_affected_rows_2 = table_obj.autocolors_affected_rows_2.split(','); 688 $.each(autocolors_affected_rows_2, function (index, value) { 689 $('#' + table_obj.id + ' tr:nth-child(' + parseInt(value, 10) + ') td').css('background-color', table_obj.autocolors_rows_background_color_2).css('color', table_obj.autocolors_rows_font_color_2); 690 }); 691 } 692 693 //Priority 3 694 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_rows_3)){ 695 var autocolors_affected_rows_3 = table_obj.autocolors_affected_rows_3.split(','); 696 $.each(autocolors_affected_rows_3, function (index, value) { 697 $('#' + table_obj.id + ' tr:nth-child(' + parseInt(value, 10) + ') td').css('background-color', table_obj.autocolors_rows_background_color_3).css('color', table_obj.autocolors_rows_font_color_3); 698 }); 699 } 700 701 //Priority 4 702 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_rows_4)) { 703 var autocolors_affected_rows_4 = table_obj.autocolors_affected_rows_4.split(','); 704 $.each(autocolors_affected_rows_4, function (index, value) { 705 $('#' + table_obj.id + ' tr:nth-child(' + parseInt(value, 10) + ') td').css('background-color', table_obj.autocolors_rows_background_color_4).css('color', table_obj.autocolors_rows_font_color_4); 706 }); 707 } 708 709 //Priority 5 710 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_rows_5)) { 711 var autocolors_affected_rows_5 = table_obj.autocolors_affected_rows_5.split(','); 712 $.each(autocolors_affected_rows_5, function (index, value) { 713 $('#' + table_obj.id + ' tr:nth-child(' + parseInt(value, 10) + ') td').css('background-color', table_obj.autocolors_rows_background_color_5).css('color', table_obj.autocolors_rows_font_color_5); 714 }); 715 } 716 717 } 718 719 /* 720 * Applies the autocolors of the columns for all the 5 priority levels 721 */ 722 function apply_autocolors_on_columns(table_obj){ 723 724 //Priority 1 725 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_columns_1)) { 726 var autocolors_affected_columns_1 = table_obj.autocolors_affected_columns_1.split(','); 727 $.each(autocolors_affected_columns_1, function( index, value ) { 728 $('#' + table_obj.id + ' tr td:nth-child('+ parseInt(value, 10) +')').css('background-color', table_obj.autocolors_columns_background_color_1).css('color', table_obj.autocolors_columns_font_color_1); 729 }); 730 } 731 732 //Priority 2 733 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_columns_2)) { 734 var autocolors_affected_columns_2 = table_obj.autocolors_affected_columns_2.split(','); 735 $.each(autocolors_affected_columns_2, function( index, value ) { 736 $('#' + table_obj.id + ' tr td:nth-child('+ parseInt(value, 10) +')').css('background-color', table_obj.autocolors_columns_background_color_2).css('color', table_obj.autocolors_columns_font_color_2); 737 }); 738 } 739 740 //Priority 3 741 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_columns_3)) { 742 var autocolors_affected_columns_3 = table_obj.autocolors_affected_columns_3.split(','); 743 $.each(autocolors_affected_columns_3, function( index, value ) { 744 $('#' + table_obj.id + ' tr td:nth-child('+ parseInt(value, 10) +')').css('background-color', table_obj.autocolors_columns_background_color_3).css('color', table_obj.autocolors_columns_font_color_3); 745 }); 746 } 747 748 //Priority 4 749 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_columns_4)) { 750 var autocolors_affected_columns_4 = table_obj.autocolors_affected_columns_4.split(','); 751 $.each(autocolors_affected_columns_4, function( index, value ) { 752 $('#' + table_obj.id + ' tr td:nth-child('+ parseInt(value, 10) +')').css('background-color', table_obj.autocolors_columns_background_color_4).css('color', table_obj.autocolors_columns_font_color_4); 753 }); 754 } 755 756 //Priority 5 757 if(comma_separated_numbers_regex.test(table_obj.autocolors_affected_columns_5)) { 758 var autocolors_affected_columns_5 = table_obj.autocolors_affected_columns_5.split(','); 759 $.each(autocolors_affected_columns_5, function( index, value ) { 760 $('#' + table_obj.id + ' tr td:nth-child('+ parseInt(value, 10) +')').css('background-color', table_obj.autocolors_columns_background_color_5).css('color', table_obj.autocolors_columns_font_color_5); 761 }); 762 } 763 764 } 765 766 /* 767 * Applies the autoalignment of the rows for the "Left", "Center" and "Right" category. 768 */ 769 function apply_autoalignment_on_rows(table_obj){ 770 771 //Left 772 if(comma_separated_numbers_regex.test(table_obj.autoalignment_affected_rows_left)) { 773 var autoalignment_affected_rows_left = table_obj.autoalignment_affected_rows_left.split(','); 774 $.each(autoalignment_affected_rows_left, function( index, value ) { 775 $('#' + table_obj.id + ' tr:nth-child(' + parseInt(value, 10) + ') td').css('text-align', 'left'); 776 }); 777 } 778 779 //Center 780 if(comma_separated_numbers_regex.test(table_obj.autoalignment_affected_rows_center)) { 781 var autoalignment_affected_rows_center = table_obj.autoalignment_affected_rows_center.split(','); 782 $.each(autoalignment_affected_rows_center, function( index, value ) { 783 $('#' + table_obj.id + ' tr:nth-child(' + parseInt(value, 10) + ') td').css('text-align', 'center'); 784 }); 785 } 786 787 //Right 788 if(comma_separated_numbers_regex.test(table_obj.autoalignment_affected_rows_right)) { 789 var autoalignment_affected_rows_right = table_obj.autoalignment_affected_rows_right.split(','); 790 $.each(autoalignment_affected_rows_right, function( index, value ) { 791 $('#' + table_obj.id + ' tr:nth-child(' + parseInt(value, 10) + ') td').css('text-align', 'right'); 792 }); 793 } 794 795 } 796 797 /* 798 * Applies the autoalignment of the columns for the "Left", "Center" and "Right" category. 799 */ 800 function apply_autoalignment_on_columns(table_obj){ 801 802 //Left 803 if(comma_separated_numbers_regex.test(table_obj.autoalignment_affected_columns_left)) { 804 var autoalignment_affected_columns_left = table_obj.autoalignment_affected_columns_left.split(','); 805 $.each(autoalignment_affected_columns_left, function( index, value ) { 806 $('#' + table_obj.id + ' tr td:nth-child('+ parseInt(value, 10) +')').css('text-align', 'left'); 807 }); 808 } 809 810 //Center 811 if(comma_separated_numbers_regex.test(table_obj.autoalignment_affected_columns_center)) { 812 var autoalignment_affected_columns_center = table_obj.autoalignment_affected_columns_center.split(','); 813 $.each(autoalignment_affected_columns_center, function( index, value ) { 814 $('#' + table_obj.id + ' tr td:nth-child('+ parseInt(value, 10) +')').css('text-align', 'center'); 815 }); 816 } 817 818 //Right 819 if(comma_separated_numbers_regex.test(table_obj.autoalignment_affected_columns_right)) { 820 var autoalignment_affected_columns_right = table_obj.autoalignment_affected_columns_right.split(','); 821 $.each(autoalignment_affected_columns_right, function( index, value ) { 822 $('#' + table_obj.id + ' tr td:nth-child('+ parseInt(value, 10) +')').css('text-align', 'right'); 823 }); 824 } 825 826 } 827 828});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.