| |
597 |
597 |
|
| |
598 |
598 |
toc instproc ajax_tree {js_tree_cmds} { |
| |
599 |
599 |
return "<div id='[self]'> |
| |
600 |
600 |
<script type = 'text/javascript'> |
| |
601 |
601 |
var TocTree = { |
| |
602 |
602 |
|
| |
603 |
603 |
count : this.count = [my set navigation(count)], |
| |
604 |
604 |
|
| |
605 |
605 |
getPage: function(href, c) { |
| |
606 |
606 |
// console.log('getPage: ' + href + ' type: ' + typeof href) ; |
| |
607 |
607 |
|
| |
608 |
608 |
if ( typeof c == 'undefined' ) { |
| |
609 |
609 |
|
| |
610 |
610 |
// no c given, search it from the objects |
| |
611 |
611 |
// console.log('search for href <' + href + '>'); |
| |
612 |
612 |
|
| |
613 |
613 |
for (i in this.objs) { |
| |
614 |
614 |
if (this.objs\[i\].ref == href) { |
| |
615 |
615 |
c = this.objs\[i\].c; |
| |
616 |
616 |
// console.log('found href ' + href + ' c=' + c); |
| |
617 |
|
var node = this.tree.getNodeByIndex(c).parent; |
| |
|
617 |
var node = this.tree.getNodeByIndex(c); |
| |
|
618 |
if (!node.expanded) {node.expand();} |
| |
|
619 |
node = node.parent; |
| |
618 |
620 |
while (node.index > 1) { |
| |
619 |
621 |
if (!node.expanded) {node.expand();} |
| |
620 |
622 |
node = node.parent; |
| |
621 |
623 |
} |
| |
622 |
624 |
break; |
| |
623 |
625 |
} |
| |
624 |
626 |
} |
| |
625 |
627 |
if (typeof c == 'undefined') { |
| |
626 |
628 |
// console.warn('c undefined'); |
| |
627 |
629 |
return false; |
| |
628 |
630 |
} |
| |
629 |
631 |
} |
| |
630 |
632 |
// console.log('have href ' + href + ' c=' + c); |
| |
631 |
633 |
|
| |
632 |
634 |
var transaction = YAHOO.util.Connect.asyncRequest('GET', \ |
| |
633 |
635 |
href + '?template_file=view-page', |
| |
634 |
636 |
{ |
| |
635 |
637 |
success:function(o) { |
| |
636 |
638 |
var bookpage = document.getElementById('book-page'); |
| |
637 |
639 |
var fadeOutAnim = new YAHOO.util.Anim(bookpage, { opacity: {to: 0} }, 0.5 ); |
|
| |
648 |
650 |
// console.info(this); |
| |
649 |
651 |
|
| |
650 |
652 |
if (this.count > 0) { |
| |
651 |
653 |
var percent = (100 * o.argument / this.count).toFixed(2) + '%'; |
| |
652 |
654 |
} else { |
| |
653 |
655 |
var percent = '0.00%'; |
| |
654 |
656 |
} |
| |
655 |
657 |
|
| |
656 |
658 |
if (o.argument > 1) { |
| |
657 |
659 |
var link = this.objs\[o.argument - 1 \].ref; |
| |
658 |
660 |
var src = '/resources/xowiki/previous.png'; |
| |
659 |
661 |
var onclick = 'return TocTree.getPage(\"' + link + '\");' ; |
| |
660 |
662 |
} else { |
| |
661 |
663 |
var link = '#'; |
| |
662 |
664 |
var onclick = ''; |
| |
663 |
665 |
var src = '/resources/xowiki/previous-end.png'; |
| |
664 |
666 |
} |
| |
665 |
667 |
|
| |
666 |
668 |
// console.log('changing prev href to ' + link); |
| |
667 |
669 |
// console.log('changing prev onclick to ' + onclick); |
| |
|
670 |
|
| |
668 |
671 |
document.getElementById('bookNavPrev.img').src = src; |
| |
669 |
672 |
document.getElementById('bookNavPrev.a').href = link; |
| |
670 |
|
document.getElementById('bookNavPrev.a').attributes\['onclick'\].value = onclick; |
| |
|
673 |
document.getElementById('bookNavPrev.a').setAttribute('onclick',onclick); |
| |
671 |
674 |
|
| |
672 |
675 |
if (o.argument < this.count) { |
| |
673 |
676 |
var link = this.objs\[o.argument + 1 \].ref; |
| |
674 |
677 |
var src = '/resources/xowiki/next.png'; |
| |
675 |
678 |
var onclick = 'return TocTree.getPage(\"' + link + '\");' ; |
| |
676 |
679 |
} else { |
| |
677 |
680 |
var link = '#'; |
| |
678 |
681 |
var onclick = ''; |
| |
679 |
682 |
var src = '/resources/xowiki/next-end.png'; |
| |
680 |
683 |
} |
| |
681 |
684 |
|
| |
682 |
685 |
// console.log('changing next href to ' + link); |
| |
683 |
686 |
// console.log('changing next onclick to ' + onclick); |
| |
684 |
687 |
document.getElementById('bookNavNext.img').src = src; |
| |
685 |
688 |
document.getElementById('bookNavNext.a').href = link; |
| |
686 |
|
document.getElementById('bookNavNext.a').attributes\['onclick'\].value = onclick; |
| |
687 |
689 |
|
| |
|
690 |
document.getElementById('bookNavNext.a').setAttribute('onclick',onclick); |
| |
688 |
691 |
document.getElementById('bookNavRelPosText').innerHTML = percent; |
| |
689 |
|
document.getElementById('bookNavBar').attributes\['style'\].value = 'width: ' + percent + ';'; |
| |
|
692 |
document.getElementById('bookNavBar').setAttribute('style', 'width: ' + percent + ';'); |
| |
690 |
693 |
|
| |
691 |
694 |
fadeOutAnim.onComplete.subscribe(doFadeIn); |
| |
692 |
695 |
fadeOutAnim.animate(); |
| |
693 |
696 |
}, |
| |
694 |
697 |
failure:function(o) { |
| |
695 |
698 |
// console.error(o); |
| |
696 |
699 |
// alert('failure '); |
| |
697 |
700 |
return false; |
| |
698 |
701 |
}, |
| |
699 |
702 |
argument: c, |
| |
700 |
703 |
scope: TocTree |
| |
701 |
704 |
}, null); |
| |
702 |
705 |
|
| |
703 |
706 |
return false; |
| |
704 |
707 |
}, |
| |
705 |
708 |
|
| |
706 |
709 |
|
| |
707 |
710 |
treeInit: function() { |
| |
708 |
711 |
TocTree.tree = new YAHOO.widget.TreeView('[self]'); |
| |
709 |
712 |
root = TocTree.tree.getRoot(); |