577 } |
577 } |
578 } |
578 } |
579 |
579 |
580 return page_id; |
580 return page_id; |
581 } |
581 } |
|
582 |
|
583 /* |
|
584 * Expandable fieldsets |
|
585 */ |
|
586 |
|
587 var expander_onload = function() |
|
588 { |
|
589 var sets = document.getElementsByTagName('fieldset'); |
|
590 if ( sets.length < 1 ) |
|
591 return false; |
|
592 for ( var i = 0; i < sets.length; i++ ) |
|
593 { |
|
594 var mode = sets[i].getAttribute('enano:expand'); |
|
595 if ( mode == 'closed' || mode == 'open' ) |
|
596 { |
|
597 expander_init_element(sets[i]); |
|
598 } |
|
599 } |
|
600 } |
|
601 |
|
602 function expander_init_element(el) |
|
603 { |
|
604 // get the legend tag |
|
605 var legend = el.getElementsByTagName('legend')[0]; |
|
606 if ( !legend ) |
|
607 return false; |
|
608 // existing content |
|
609 var existing_inner = legend.innerHTML; |
|
610 // blank the innerHTML and replace it with a link |
|
611 legend.innerHTML = ''; |
|
612 var button = document.createElement('a'); |
|
613 button.className = 'expander expander-open'; |
|
614 button.innerHTML = existing_inner; |
|
615 button.href = '#'; |
|
616 |
|
617 legend.appendChild(button); |
|
618 |
|
619 button.onclick = function() |
|
620 { |
|
621 try |
|
622 { |
|
623 expander_handle_click(this); |
|
624 } |
|
625 catch(e) |
|
626 { |
|
627 } |
|
628 return false; |
|
629 } |
|
630 |
|
631 if ( el.getAttribute('enano:expand') == 'closed' ) |
|
632 { |
|
633 expander_close(el); |
|
634 } |
|
635 } |
|
636 |
|
637 function expander_handle_click(el) |
|
638 { |
|
639 if ( el.parentNode.parentNode.tagName != 'FIELDSET' ) |
|
640 return false; |
|
641 var parent = el.parentNode.parentNode; |
|
642 if ( parent.getAttribute('enano:expand') == 'closed' ) |
|
643 { |
|
644 expander_open(parent); |
|
645 } |
|
646 else |
|
647 { |
|
648 expander_close(parent); |
|
649 } |
|
650 } |
|
651 |
|
652 function expander_close(el) |
|
653 { |
|
654 var children = el.childNodes; |
|
655 for ( var i = 0; i < children.length; i++ ) |
|
656 { |
|
657 var child = children[i]; |
|
658 if ( child.tagName == 'LEGEND' ) |
|
659 { |
|
660 var a = child.getElementsByTagName('a')[0]; |
|
661 $(a).rmClass('expander-open'); |
|
662 $(a).addClass('expander-closed'); |
|
663 continue; |
|
664 } |
|
665 child.expander_meta_old_state = child.style.display; |
|
666 child.style.display = 'none'; |
|
667 } |
|
668 el.expander_meta_padbak = el.style.padding; |
|
669 el.setAttribute('enano:expand', 'closed'); |
|
670 } |
|
671 |
|
672 function expander_open(el) |
|
673 { |
|
674 var children = el.childNodes; |
|
675 for ( var i = 0; i < children.length; i++ ) |
|
676 { |
|
677 var child = children[i]; |
|
678 if ( child.tagName == 'LEGEND' ) |
|
679 { |
|
680 var a = child.getElementsByTagName('a')[0]; |
|
681 $(a).rmClass('expander-closed'); |
|
682 $(a).addClass('expander-open'); |
|
683 continue; |
|
684 } |
|
685 if ( child.expander_meta_old_state ) |
|
686 { |
|
687 child.style.display = child.expander_meta_old_state; |
|
688 child.expander_meta_old_state = null; |
|
689 } |
|
690 else |
|
691 { |
|
692 child.style.display = null; |
|
693 } |
|
694 } |
|
695 if ( el.expander_meta_padbak ) |
|
696 { |
|
697 el.style.padding = el.expander_meta_padbak; |
|
698 el.expander_meta_padbak = null; |
|
699 } |
|
700 else |
|
701 { |
|
702 el.style.padding = null; |
|
703 } |
|
704 el.setAttribute('enano:expand', 'open'); |
|
705 } |
|
706 |
|
707 addOnloadHook(expander_onload); |