![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 /* $Id: base.js 38 2008-02-11 11:38:51Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/js/base.js $ */ 2 /* Copyright 2003,2004 Adam Donnison <adam@saki.com.au> 3 4 This file is part of the collected works of Adam Donnison. 5 6 This file is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This file is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 */ 17 18 // If we are an IE window, set undefined to null. This is an ECMAscript 19 // standard, but then MS makes its own standards. 20 if (navigator.userAgent.indexOf('MSIE') != -1) { 21 var undefined = null; 22 } 23 24 navigator.family='ie'; 25 if (window.navigator.userAgent.toLowerCase().match(/gecko/)) { 26 navigator.family = 'gecko'; 27 } 28 if (navigator.userAgent.toLowerCase().indexOf('opera') + 1 || window.opera) { 29 navigator.family = 'opera'; 30 } 31 32 /* function center_window 33 * Create the window options clause required to ensure a window is 34 * centered over the calling window. A width or height of 0 or less 35 * results in using the corresponding value for the parent window. 36 * e.g. 0,0 results in a window exactly the same size and overlapping 37 * the parent exactly. 38 */ 39 function center_window(width, height) { 40 var ix = window.outerWidth; 41 var iy = window.outerHeight; 42 var mx = window.screenX; 43 var my = window.screenY; 44 var result; 45 46 var cx; 47 var cy; 48 49 if (width <= 0) { 50 width = ix; 51 cx = mx; 52 } else { 53 mx += ( ix / 2 ); 54 mx -= ( width / 2 ); 55 cx = Math.round(mx); 56 } 57 if (height <= 0) { 58 cy = my; 59 height = iy; 60 } else { 61 my += ( iy / 2 ); 62 my -= ( height / 2 ); 63 cy = Math.round(my); 64 } 65 66 result = 'screenX=' + cx + ',screenY=' + cy + ',outerHeight=' + height + ',outerWidth=' + width; 67 return result; 68 } 69 70 // Class Comparable 71 // Define new Comparable object capable of being used to store 72 // data in an array. 73 74 // constructor CompItem 75 function CompItem(key, data) { 76 this.key = key; 77 this.data = data; 78 this.compare = comp_keys; 79 this.equals = comp_equal; 80 } 81 // 82 83 // function comp_keys 84 // Compare function to compare two Comparable objects 85 function comp_keys(target) { 86 if (this.key == target.key) return 0; 87 if (this.key < target.key) return -1; 88 return 1; 89 } 90 91 // function comp_equal 92 function comp_equal(target) { 93 if (this.key == target) return true; 94 return false; 95 } 96 97 // Comparison array class constructor 98 function Comparable() { 99 this.list = new Array(); 100 this.add = ca_add; 101 this.find = ca_find; 102 this.length = ca_length; 103 this.get = ca_get; 104 this.search = ca_search; 105 this.count = 0; 106 } 107 108 // function ca_add 109 function ca_add(key, data) { 110 var last_id = this.search(key); 111 if (last_id != -1) { 112 this.list[last_id] = new CompItem(key, data); 113 } else { 114 this.list[this.count] = new CompItem(key, data); 115 this.count++; 116 } 117 // this.list.push(new CompItem(key, data)); 118 } 119 120 // function ca_find 121 function ca_find(key) { 122 var end = this.list.length; 123 for ( var i = 0; i < end; i++) { 124 cp = this.list[i]; 125 if (cp.equals(key)) { 126 return cp.data; 127 } 128 } 129 return undefined; 130 } 131 132 // function ca_search 133 function ca_search(key) { 134 var end = this.list.length; 135 for ( var i = 0; i < end; i++) { 136 cp = this.list[i]; 137 if (cp.equals(key)) { 138 return i; 139 } 140 } 141 return -1; 142 } 143 144 // function ca_length 145 function ca_length() { 146 return this.list.length; 147 } 148 149 // function ca_get 150 function ca_get(id) { 151 return this.list[id]; 152 } 153 154 // Class HTMLex 155 // Constructor HTMLex 156 function HTMLex() { 157 this.addTable = _HTMLaddTable; 158 this.addRow = _HTMLaddRow; 159 this.addHeader = _HTMLaddHeader; 160 this.addHeaderNode = _HTMLaddHeaderNode; 161 this.addCell = _HTMLaddCell; 162 this.addCellNode = _HTMLaddCellNode; 163 this.addTextInput = _HTMLaddTextInput; 164 this.addHidden = _HTMLaddHidden; 165 this.addTextNode = _HTMLaddTextNode; 166 this.addNode = _HTMLaddNode; 167 this.addSpan = _HTMLaddSpan; 168 this.addSelect = _HTMLaddSelect; 169 this.addOption = _HTMLaddOption; 170 } 171 172 // function _HTMLaddTable 173 function _HTMLaddTable(id, width, border) { 174 var c = new Comparable; 175 if (width) { 176 c.add('width', width); 177 } 178 if (border) { 179 c.add('border', border); 180 } 181 if (id) { 182 c.add('id', id); 183 } 184 return this.addNode('table', false, c); 185 } 186 187 // function _HTMLaddRow 188 function _HTMLaddRow(id) { 189 var tr = document.createElement('tr'); 190 if (id) { 191 tr.setAttribute('id', id); 192 } 193 return tr; 194 } 195 196 // function _HTMLaddHeaderNode 197 function _HTMLaddHeaderNode(node, id, width) { 198 var c = new Comparable; 199 if (id) { 200 c.add('id', id); 201 } 202 if (width) { 203 c.add('width', width); 204 } 205 return this.addNode('th', node, c); 206 } 207 208 // function _HTMLaddHeader 209 function _HTMLaddHeader(text, id, width) { 210 var c = new Comparable; 211 if (id) { 212 c.add('id', id); 213 } 214 if (width) { 215 c.add('width', width); 216 } 217 return this.addTextNode('th', text, c); 218 } 219 220 // function _HTMLaddCell 221 function _HTMLaddCell(text, id, width, bold) { 222 var c = new Comparable; 223 if (id) { 224 c.add('id', id); 225 } 226 if (width) { 227 c.add('width', width); 228 } 229 return this.addTextNode('td', text, c, bold); 230 } 231 232 // function _HTMLaddSpan 233 function _HTMLaddSpan(text, id) { 234 var c = new Comparable; 235 if (id) { 236 c.add('id', id); 237 } 238 return this.addTextNode('span', text, c); 239 } 240 241 // function _HTMLaddCellNode 242 function _HTMLaddCellNode(node, id, width) { 243 var c = new Comparable; 244 if (id) { 245 c.add('id', id); 246 } 247 if (width) { 248 c.add('width', width); 249 } 250 return this.addNode('td', node, c); 251 } 252 253 // function _HTMLaddTextNode 254 function _HTMLaddTextNode(type, text, args, bold) { 255 var node = document.createElement(type); 256 if (bold) { 257 var b = node.appendChild(document.createElement('b')); 258 if (text) { 259 b.appendChild(document.createTextNode(text)); 260 } 261 } else { 262 if (text) { 263 node.appendChild(document.createTextNode(text)); 264 } 265 } 266 var i; 267 if (args) { 268 for (i = args.length() -1; i >=0; i--) { 269 var elem = args.get(i); 270 node.setAttribute(elem.key, elem.data); 271 } 272 } 273 return node; 274 } 275 276 // function _HTMLaddNode 277 function _HTMLaddNode(type, child, args) { 278 var node = document.createElement(type); 279 if (child) { 280 node.appendChild(child); 281 } 282 var i; 283 for (i = args.length() -1; i >=0; i--) { 284 var elem = args.get(i); 285 node.setAttribute(elem.key, elem.data); 286 } 287 return node; 288 } 289 290 // function _HTMLaddTextInput 291 function _HTMLaddTextInput(id, value, size, maxlength) { 292 var c = new Comparable; 293 c.add('id', id); 294 c.add('name', id); 295 c.add('type', 'text'); 296 if (size) { 297 c.add('size', size); 298 } 299 if (maxlength) { 300 c.add('maxlength', maxlength); 301 } 302 if (value) { 303 c.add('value', value); 304 } 305 return this.addNode('input', false, c); 306 } 307 308 // function _HTMLaddHidden 309 function _HTMLaddHidden(id, value) { 310 var c = new Comparable; 311 c.add('id', id); 312 c.add('name', id); 313 if (navigator.family == "gecko" || navigator.family == "opera"){ 314 c.add('type', 'hidden'); 315 type = 'input'; 316 } else { 317 type = 'textarea'; 318 c.add('className', 'hidden'); 319 } 320 c.add('value', value); 321 return this.addNode(type, false, c); 322 } 323 324 // function _HTMLaddSelect 325 function _HTMLaddSelect(id, cls, multi) { 326 var c = new Comparable; 327 c.add('id', id); 328 c.add('name', id); 329 if (cls) { 330 c.add('class', cls); 331 } 332 if (multi) { 333 c.add('multiple', 'multiple'); 334 } 335 return this.addNode('select', false, c); 336 } 337 338 // function _HTMLaddOption 339 function _HTMLaddOption(value, text, selected) { 340 var c = new Comparable; 341 c.add('value', value); 342 if (selected) { 343 c.add('selected', 'selected'); 344 } 345 return this.addTextNode('option', text, c); 346 } 347 348 // class CommonEvent {{{ 349 function CommonEvent(e) { 350 // Handle IE, standard Javascript, and passable fields for non-events. 351 // Tuned to run with NS 4 and above and IE 4 and above. 352 // Tested with Mozilla 1.7, Firefox 0.8, and IE 5 353 var target = null; 354 var x = 0; 355 var y = 0; 356 var type = null; 357 var button = null; 358 var keycode = null; 359 var altKey = false; 360 var shiftKey = false; 361 var ctrlKey = false; 362 var metaKey = false; 363 364 if (e) { 365 if (e.target) { 366 this.target = e.target; 367 this.type = e.type; 368 this.x = e.x; 369 this.y = e.y; 370 if (e.modifiers) { 371 this.altKey = (e.modifiers & ALT_MASK) ? true : false; 372 this.ctrlKey = (e.modifiers & CONTROL_MASK) ? true : false; 373 this.shiftKey = (e.modifiers & SHIFT_MASK) ? true : false; 374 this.metaKey = (e.modifiers & META_MASK) ? true : false; 375 } else { 376 if (e.altKey) this.altKey = true; 377 if (e.shiftKey) this.shiftKey = true; 378 if (e.ctrlKey) this.ctrlKey = true; 379 if (e.metaKey) this.metaKey = true; 380 } 381 if (e.type.substr(0,3).toLowerCase() == 'key') { 382 this.keycode = e.which; 383 } else { 384 this.button = e.which; 385 } 386 } else { 387 this.target = e; 388 this.type = 'field'; 389 } 390 } else if (event) { 391 this.target = event.srcElement; 392 this.type = event.type; 393 this.x = event.x; 394 this.y = event.y; 395 this.button = event.button; 396 this.keycode = event.keyCode; 397 this.altKey = event.altKey; 398 this.shiftKey = event.shiftKey; 399 this.ctrlKey = event.ctrlKey; 400 } 401 } 402 403 // function ucfirst 404 function ucfirst(s, delim) { 405 if (!delim) { 406 delim = ' '; 407 } 408 var a = s.split(delim); 409 var res = ""; 410 var start = false; 411 for (var i = 0; i < a.length; i++) { 412 if (start) { 413 res += " "; 414 } else { 415 start = true; 416 } 417 res += a[i].substr(0, 1).toUpperCase() + a[i].substr(1); 418 } 419 return res; 420 } 421 422 /** function clear_span 423 * Removes any children of an element by ID. 424 */ 425 function clear_span(id) { 426 var span = document.getElementById(id); 427 if (span) { 428 if (span.hasChildNodes()) { 429 for (var i = span.childNodes.length - 1; i >= 0; i--) { 430 span.removeChild(span.childNodes.item(i)); 431 } 432 } 433 } 434 return span; 435 } 436 437 // function show_message 438 function show_message(fname, txt) { 439 display_message(txt, fname + '_message'); 440 } 441 442 // function show_instruction 443 function show_instruction(txt) { 444 display_message(txt, 'instruct'); 445 } 446 447 /** function display_message 448 * Generic message display. This looks for the required element on 449 * the page and if found it adds a text node, (or changes an existing 450 * one) to the text required. Used by show_message and show_instruction. 451 * The element name is supplied with the 'id=' attribute of the 452 * HTML. 453 */ 454 function display_message(txt, elem) { 455 var span = document.getElementById(elem); 456 if (span == null) { 457 return; 458 } 459 460 var text; 461 if (span.hasChildNodes()) { 462 text = span.childNodes.item(0); 463 text.nodeValue = txt; 464 } else { 465 text = span.appendChild(document.createTextNode(txt)); 466 } 467 } 468 469 // clear_message, reset_message, default_instruction 470 function clear_message(fname) { 471 reset_message( fname + '_message'); 472 } 473 474 function clear_instruction() { 475 reset_message('instruct'); 476 } 477 478 479 /** function reset_message 480 * Function to clear the text node associated with an element. 481 * The element name is supplied with the 'id=' attribute of the 482 * HTML. This can be used to remove text on any node that supports it. 483 */ 484 function reset_message(elem) { 485 var span = document.getElementById(elem); 486 if (span == null) { 487 return; 488 } 489 490 var text; 491 if (span.hasChildNodes()) { 492 text = span.childNodes.item(0); 493 text.nodeValue = ''; 494 } else { 495 text = span.appendChild(document.createTextNode('')); 496 } 497 } 498 499 // function find_anchor {{{ 500 // The find_anchor function is usually called when the browser 501 // is IE based and therefore doesn't use the name to provide 502 // an index into document.anchors. Should probably be replaced 503 // to use getElementById or getElementsByTagName instead of 504 // relying on browser-specific extensions. 505 function find_anchor(a) { 506 for (var i = 0; i < document.anchors.length; i++) { 507 if (document.anchors[i].name == a) { 508 return true; 509 } 510 } 511 return false; 512 } 513 514 // function getInnerHeight 515 function getInnerHeight(win) { 516 var winHeight; 517 if (win.innerHeight) { 518 winHeight = win.innerHeight; 519 } else if (win.document.documentElement && win.document.documentElement.clientHeight) { 520 winHeight = win.document.documentElement.clientHeight; 521 } else if (win.document.body) { 522 winHeight = win.document.body.clientHeight; 523 } else { 524 winHeight = 0; // This should never happens 525 } 526 return winHeight; 527 } 528 529 /** 530 * Support for collapsible views. 531 * 532 * Rows are marked with an ID. Rows are deleted by ID, or added by ID. 533 * The user 534 */ 535 536 var saved_rows = new Comparable; 537 538 function toggle_collapse(item, collapse) { 539 var item_image = document.getElementById('image_' + item); 540 if (! item_image) { 541 return false; 542 } 543 // Grab the row that belongs to the icon 544 var item_elem = document.getElementById('r_' + item); 545 var parent = item_elem.parentNode; 546 // Check to see if the item is toggled. 547 // This braindead method is required because IE does not 548 // implement substr correctly and you cannot use negative 549 // offsets. Why anyone would use such a crappy browser is 550 // beyond me. 551 var bottom = item_image.name.substr(item_image.name.length-2,2); 552 if (bottom == '_0') { 553 // Item is collapsed, expand it. 554 if (collapse) { 555 return false; 556 } 557 var orig = saved_rows.find(item); 558 if (orig) { 559 // Find the next sibling and insert the node before it. 560 var next = item_elem.nextSibling; 561 for (var j = 0, j_cmp = orig.length; j < j_cmp; j++) 562 parent.insertBefore(orig[j], next); 563 item_image.name = item_image.id + '_1'; 564 item_image.src = './images/arrow-down.gif'; 565 } 566 } else { 567 // Item is expanded, collapse it. 568 item_image.name = item_image.id + '_0'; 569 item_image.src = './images/arrow-right.gif'; 570 var row_array = new Array(); 571 var rid = 0; 572 var sib = item_elem.nextSibling; 573 var level_item = document.getElementById('rl_' + item); 574 var level = level_item.value; 575 while (sib) { 576 if (! sib.id) { 577 sib = sib.nextSibling; 578 continue; 579 } 580 var sib_id = sib.id.substr(2); 581 var sublevel = document.getElementById('rl_' + sib_id).value; 582 if (sublevel <= level) 583 break; 584 var nxt = sib.nextSibling; 585 // Now delete the row 586 row_array[rid++] = parent.removeChild(sib); 587 sib = nxt; 588 } 589 saved_rows.add(item, row_array); 590 } 591 return true; 592 } 593 594 function collapse_all(parent) { 595 var parent_elem = document.getElementById(parent); 596 for (var i = 0, i_cmp = parent_elem.childNodes.length; i < i_cmp; i++) { 597 if (parent_elem.childNodes[i].tagName == 'TR' && parent_elem.childNodes[i].id) { 598 toggle_collapse(parent_elem.childNodes[i].id.substr(2), true); 599 } 600 } 601 } 602 603 var show_tab_function = null; 604 var hide_tab_function = null; 605 606 function show_tab(i) { 607 hide_tabs(); 608 if (show_tab_function) { 609 show_tab_function(i); 610 return; 611 } 612 var tab = document.getElementById('tab_' + i); 613 tab.style.display = 'block'; 614 tab = document.getElementById('toptab_' + i); 615 tab.className = 'tabon'; 616 tab.style = 'font-style:bold;'; 617 } 618 619 function hide_tabs() { 620 if (hide_tab_function) { 621 hide_tab_function(); 622 return; 623 } 624 var tabs = document.getElementsByTagName('td'); 625 var i; 626 for(i = 0; i < tabs.length; i++) { 627 if (tabs[i].className == 'tabon') { 628 tabs[i].className = 'taboff'; 629 tabs[i].style = 'font-style:normal;'; 630 } 631 } 632 633 tabs = document.getElementsByTagName('div'); 634 for(i = 0; i < tabs.length; i++) { 635 if (tabs[i].className == 'tab') { 636 tabs[i].style.display = 'none'; 637 } 638 } 639 } 640 hide_tab_function = gt_hide_tabs; 641 show_tab_function = gt_show_tab; 642 643 function expand_collapse(id, table_name, option, opt_level, root) { 644 var expand = (option == 'expand' ? 1 : 0); 645 var collapse = (option == 'collapse' ? 1 : 0); 646 var level = (opt_level == 0 ? 0 : (opt_level > 0 ? opt_level : -1)); 647 //root can be used in two ways: 648 //1 = root (level 0) is to be shown/hidden just like an ordinary row 649 //2 = root (level 0) is not to be hidden meaning the only thing that shifts is the state of the auxiliary images 650 var include_root = (root ? root : 0); 651 //done controls if the sublevels have been treated already so that we do not treat another level again 652 var done = false; 653 //found controls if the root level has been found so that the following rows are treated 654 var found = false; 655 656 //catch all the rows of the table 657 var trs = document.getElementsByTagName('tr'); 658 659 for (var i=0;i < trs.length;i++) { 660 var tr_name = trs.item(i).id; 661 //First lets handle non level situations 662 if ((tr_name.indexOf(id) >= 0) && level<0) { 663 var tr = document.getElementById(tr_name); 664 if (collapse || expand) { 665 if (collapse) { 666 if (navigator.family == "gecko" || navigator.family == "opera"){ 667 tr.style.visibility = "collapse"; 668 tr.style.display = "none"; 669 var img_expand = document.getElementById(tr_name+'_expand'); 670 var img_collapse = document.getElementById(tr_name+'_collapse'); 671 if (img_expand==null) { 672 var img_expand = document.getElementById(id+'_expand'); 673 } 674 if (img_collapse==null) { 675 var img_collapse = document.getElementById(id+'_collapse'); 676 } 677 img_collapse.style.display = "none"; 678 img_expand.style.display = "inline"; 679 } else { 680 tr.style.display = "none"; 681 var img_expand = document.getElementById(tr_name+'_expand'); 682 var img_collapse = document.getElementById(tr_name+'_collapse'); 683 if (img_expand==null) { 684 var img_expand = document.getElementById(id+'_expand'); 685 } 686 if (img_collapse==null) { 687 var img_collapse = document.getElementById(id+'_collapse'); 688 } 689 img_collapse.style.display = "none"; 690 img_expand.style.display = "inline"; 691 } 692 } else { 693 if (navigator.family == "gecko" || navigator.family == "opera"){ 694 tr.style.visibility = "visible"; 695 tr.style.display = ""; 696 var img_expand = document.getElementById(tr_name+'_expand'); 697 var img_collapse = document.getElementById(tr_name+'_collapse'); 698 if (img_expand==null) { 699 var img_expand = document.getElementById(id+'_expand'); 700 } 701 if (img_collapse==null) { 702 var img_collapse = document.getElementById(id+'_collapse'); 703 } 704 img_collapse.style.display = "inline"; 705 img_expand.style.display = "none"; 706 } else { 707 tr.style.display = ""; 708 var img_expand = document.getElementById(tr_name+'_expand'); 709 var img_collapse = document.getElementById(tr_name+'_collapse'); 710 if (img_expand==null) { 711 var img_expand = document.getElementById(id+'_expand'); 712 } 713 if (img_collapse==null) { 714 var img_collapse = document.getElementById(id+'_collapse'); 715 } 716 img_collapse.style.display = "inline"; 717 img_expand.style.display = "none"; 718 } 719 } 720 } else { 721 if (navigator.family == "gecko" || navigator.family == "opera"){ 722 tr.style.visibility = (tr.style.visibility == '' || tr.style.visibility == "collapse") ? "visible" : "collapse"; 723 tr.style.display = (tr.style.display == "none") ? "" : "none"; 724 var img_expand = document.getElementById(tr_name+'_expand'); 725 var img_collapse = document.getElementById(tr_name+'_collapse'); 726 if (img_expand==null) { 727 var img_expand = document.getElementById(id+'_expand'); 728 } 729 if (img_collapse==null) { 730 var img_collapse = document.getElementById(id+'_collapse'); 731 } 732 img_collapse.style.display = (tr.style.visibility == 'visible') ? "inline" : "none"; 733 img_expand.style.display = (tr.style.visibility == '' || tr.style.visibility == "collapse") ? "inline" : "none"; 734 } else { 735 tr.style.display = (tr.style.display == "none") ? "" : "none"; 736 var img_expand = document.getElementById(tr_name+'_expand'); 737 var img_collapse = document.getElementById(tr_name+'_collapse'); 738 if (img_expand==null) { 739 var img_expand = document.getElementById(id+'_expand'); 740 } 741 if (img_collapse==null) { 742 var img_collapse = document.getElementById(id+'_collapse'); 743 } 744 img_collapse.style.display = (tr.style.display == '') ? "inline" : "none"; 745 img_expand.style.display = (tr.style.display == 'none') ? "inline" : "none"; 746 } 747 } 748 //lets handle expand collapses of leveled rows (like tasks dynamics/parents) - THIS "ELSEIF" HANDLES THE PARENT TASK ROW ITSELF 749 //Here we don't show/hide the row itself, we only handle the +/- image 750 } else if((tr_name.indexOf(id) >= 0) && level>=0 && !done && !found && !include_root) { 751 //So we found the root row lets record that: 752 found = true; 753 var tr = document.getElementById(tr_name); 754 var img_expand = document.getElementById(tr_name+'_expand'); 755 var img_collapse = document.getElementById(tr_name+'_collapse'); 756 if (img_expand==null) { 757 var img_expand = document.getElementById(id+'_expand'); 758 } 759 if (img_collapse==null) { 760 var img_collapse = document.getElementById(id+'_collapse'); 761 } 762 if (!(img_collapse==null)) { 763 img_collapse.style.display = (img_collapse.style.display == 'none') ? "inline" : "none"; 764 } 765 if (!(img_expand==null)) { 766 img_expand.style.display = (img_expand.style.display == 'none') ? "inline" : "none"; 767 //define what we will be doing with the rows below this one 768 opt = (img_expand.style.display == "inline") ? "collapse" : "expand"; 769 collapse = (opt == 'collapse' ? 1 : 0); 770 expand = (opt == 'expand' ? 1 : 0); 771 } 772 //If we included the root for collapsing/expand lets do it: 773 } else if((tr_name.indexOf(id) >= 0) && level>=0 && include_root) { 774 found = true; 775 var tr = document.getElementById(tr_name); 776 current_level = parseInt(tr_name.substr(tr_name.indexOf('>')+1,tr_name.indexOf('<')-tr_name.indexOf('>')-1)); 777 778 if (collapse) { 779 if (navigator.family == "gecko" || navigator.family == "opera"){ 780 //if root mode is 1 hide, if not then don't do a thing 781 if ((include_root == 1 && level == 0) || (current_level > 0)) { 782 tr.style.visibility = "collapse"; 783 tr.style.display = "none"; 784 } 785 var img_expand = document.getElementById(tr_name+'_expand'); 786 var img_collapse = document.getElementById(tr_name+'_collapse'); 787 if (img_expand==null) { 788 var img_expand = document.getElementById(id+'_expand'); 789 } 790 if (img_collapse==null) { 791 var img_collapse = document.getElementById(id+'_collapse'); 792 } 793 if (!(img_collapse==null)) { 794 img_collapse.style.display = "none"; 795 } 796 if (!(img_expand==null)) { 797 img_expand.style.display = "inline"; 798 } 799 } else { 800 //if root mode is 1 hide, if not then don't do a thing 801 if ((include_root == 1 && level == 0) || (current_level > 0)) { 802 tr.style.display = "none"; 803 } 804 var img_expand = document.getElementById(tr_name+'_expand'); 805 var img_collapse = document.getElementById(tr_name+'_collapse'); 806 if (img_expand==null) { 807 var img_expand = document.getElementById(id+'_expand'); 808 } 809 if (img_collapse==null) { 810 var img_collapse = document.getElementById(id+'_collapse'); 811 } 812 if (!(img_collapse==null)) { 813 img_collapse.style.display = "none"; 814 } 815 if (!(img_expand==null)) { 816 img_expand.style.display = "inline"; 817 } 818 } 819 } else { 820 if (navigator.family == "gecko" || navigator.family == "opera"){ 821 //if root mode is 1 hide, if not then don't do a thing 822 if ((include_root == 1 && level == 0) || (current_level > 0)) { 823 tr.style.visibility = "visible"; 824 tr.style.display = ""; 825 } 826 var img_expand = document.getElementById(tr_name+'_expand'); 827 var img_collapse = document.getElementById(tr_name+'_collapse'); 828 if (img_expand==null) { 829 var img_expand = document.getElementById(id+'_expand'); 830 } 831 if (img_collapse==null) { 832 var img_collapse = document.getElementById(id+'_collapse'); 833 } 834 if (!(img_collapse==null)) { 835 img_collapse.style.display = "inline"; 836 } 837 if (!(img_expand==null)) { 838 img_expand.style.display = "none"; 839 } 840 } else { 841 //if root mode is 1 hide, if not then don't do a thing 842 if ((include_root == 1 && level == 0) || (current_level > 0)) { 843 tr.style.display = ""; 844 } 845 var img_expand = document.getElementById(tr_name+'_expand'); 846 var img_collapse = document.getElementById(tr_name+'_collapse'); 847 if (img_expand==null) { 848 var img_expand = document.getElementById(id+'_expand'); 849 } 850 if (img_collapse==null) { 851 var img_collapse = document.getElementById(id+'_collapse'); 852 } 853 if (!(img_collapse==null)) { 854 img_collapse.style.display = "inline"; 855 } 856 if (!(img_expand==null)) { 857 img_expand.style.display = "none"; 858 } 859 } 860 } 861 //Now that we found the right root or we want to act on every row (collapse all/expand all) then 862 //lets handle expand collapses of leveled rows (like tasks dynamics) - THIS "ELSEIF" HANDLES THE ROWS THEMSELVES 863 } else if(level>0 && !done && (found || level==0)) { 864 //Lets catch the level 865 current_level = parseInt(tr_name.substr(tr_name.indexOf('>')+1,tr_name.indexOf('<')-tr_name.indexOf('>')-1)); 866 //If the current_level is equal or lower then we are done and we are already on another tree. 867 if (current_level < level) { 868 done = true; 869 //And don't waste more time on this function and get back to the application 870 return; 871 } else { 872 var tr = document.getElementById(tr_name); 873 if (collapse) { 874 if (navigator.family == "gecko" || navigator.family == "opera"){ 875 tr.style.visibility = "collapse"; 876 tr.style.display = "none"; 877 var img_expand = document.getElementById(tr_name+'_expand'); 878 var img_collapse = document.getElementById(tr_name+'_collapse'); 879 if (img_expand==null) { 880 var img_expand = document.getElementById(id+'_expand'); 881 } 882 if (img_collapse==null) { 883 var img_collapse = document.getElementById(id+'_collapse'); 884 } 885 if (!(img_collapse==null)) { 886 img_collapse.style.display = "none"; 887 } 888 if (!(img_expand==null)) { 889 img_expand.style.display = "inline"; 890 } 891 } else { 892 tr.style.display = "none"; 893 var img_expand = document.getElementById(tr_name+'_expand'); 894 var img_collapse = document.getElementById(tr_name+'_collapse'); 895 if (img_expand==null) { 896 var img_expand = document.getElementById(id+'_expand'); 897 } 898 if (img_collapse==null) { 899 var img_collapse = document.getElementById(id+'_collapse'); 900 } 901 if (!(img_collapse==null)) { 902 img_collapse.style.display = "none"; 903 } 904 if (!(img_expand==null)) { 905 img_expand.style.display = "inline"; 906 } 907 } 908 } else { 909 if (navigator.family == "gecko" || navigator.family == "opera"){ 910 tr.style.visibility = "visible"; 911 tr.style.display = ""; 912 var img_expand = document.getElementById(tr_name+'_expand'); 913 var img_collapse = document.getElementById(tr_name+'_collapse'); 914 if (img_expand==null) { 915 var img_expand = document.getElementById(id+'_expand'); 916 } 917 if (img_collapse==null) { 918 var img_collapse = document.getElementById(id+'_collapse'); 919 } 920 if (!(img_collapse==null)) { 921 img_collapse.style.display = "inline"; 922 } 923 if (!(img_expand==null)) { 924 img_expand.style.display = "none"; 925 } 926 } else { 927 tr.style.display = ""; 928 var img_expand = document.getElementById(tr_name+'_expand'); 929 var img_collapse = document.getElementById(tr_name+'_collapse'); 930 if (img_expand==null) { 931 var img_expand = document.getElementById(id+'_expand'); 932 } 933 if (img_collapse==null) { 934 var img_collapse = document.getElementById(id+'_collapse'); 935 } 936 if (!(img_collapse==null)) { 937 img_collapse.style.display = "inline"; 938 } 939 if (!(img_expand==null)) { 940 img_expand.style.display = "none"; 941 } 942 } 943 } 944 } 945 } 946 } 947 } 948 949 function expandAll(id, table_name) { 950 expand_collapse(id, table_name, 'expand'); 951 } 952 953 function collapseAll(id, table_name) { 954 expand_collapse(id, table_name, 'collapse'); 955 } 956 957 // Ajax support functions 958 function addOption(selectId, val, txt) { 959 var objOption = new Option(txt, val); 960 document.getElementById(selectId).options.add(objOption); 961 } 962 963 /* 964 xajax.loadingFunction = 965 function(){ 966 xajax.$('loadingMessage').style.display='block'; 967 if (navigator.userAgent.indexOf('MSIE') != -1) { 968 xajax.$('w2PfadeDIV').style['filter'] = 'alpha(opacity=30)'; 969 } else { 970 xajax.$('w2PfadeDIV').style.opacity=.3; 971 } 972 }; 973 974 function hideLoadingMessage() 975 { 976 xajax.$('loadingMessage').style.display = 'none'; 977 if (navigator.userAgent.indexOf('MSIE') != -1) { 978 xajax.$('w2PfadeDIV').style['filter'] = 'alpha(opacity=100)'; 979 } else { 980 xajax.$('w2PfadeDIV').style.opacity=1; 981 } 982 } 983 xajax.doneLoadingFunction = hideLoadingMessage; 984 */ 985 if (typeof(xajax) != 'undefined') { 986 xajax.callback.global.onRequest = 987 function(){ 988 if (navigator.userAgent.indexOf('MSIE') != -1) { 989 AllByTag.hide("SELECT"); 990 } 991 xajax.$('loadingMessage').style.display='block'; 992 if (navigator.userAgent.indexOf('MSIE') != -1) { 993 xajax.$('w2PfadeDIV').style['filter'] = 'alpha(opacity=30)'; 994 } else { 995 xajax.$('w2PfadeDIV').style.opacity=.3; 996 } 997 }; 998 999 function hideLoadingMessage() { 1000 xajax.$('loadingMessage').style.display = 'none'; 1001 if (navigator.userAgent.indexOf('MSIE') != -1) { 1002 xajax.$('w2PfadeDIV').style['filter'] = 'alpha(opacity=100)'; 1003 } else { 1004 xajax.$('w2PfadeDIV').style.opacity=1; 1005 } 1006 if (navigator.userAgent.indexOf('MSIE') != -1) { 1007 AllByTag.show("SELECT"); 1008 } 1009 } 1010 xajax.callback.global.onComplete = hideLoadingMessage; 1011 } 1012 1013 function emptyCombo(combo) { 1014 combo.options.length = 0; 1015 } 1016 1017 function AllByTag() { 1018 // no actions 1019 } 1020 1021 AllByTag.setStyleDisplay = function(tagName,value) { 1022 var elements = document.getElementsByTagName(tagName); 1023 for (var i = 0; i < elements.length; i++) { 1024 elements[i].style.display = value; 1025 } 1026 }; 1027 1028 AllByTag.show = function(tagName,dispType) { 1029 AllByTag.setStyleDisplay(tagName, dispType ? dispType : 'inline'); 1030 }; 1031 1032 AllByTag.hide = function(tagName,dispType) { 1033 AllByTag.setStyleDisplay(tagName, 'none'); 1034 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Jul 17 03:00:04 2010 | Cross-referenced by PHPXref 0.7 |