1 var navTreeSubIndices =
new Array();
3 function getData(varName)
5 var i = varName.lastIndexOf(
'/');
6 var n = i>=0 ? varName.substring(i+1) : varName;
7 return eval(n.replace(/\-/g,
'_'));
10 function stripPath(uri)
12 return uri.substring(uri.lastIndexOf(
'/')+1);
15 function stripPath2(uri)
17 var i = uri.lastIndexOf(
'/');
18 var s = uri.substring(i+1);
19 var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/);
20 return m ? uri.substring(i-6) : s;
25 return $(location).attr(
'hash').substring(1).replace(/[^\w\-]/g,
'');
30 return '#'+hashValue();
35 return $(location).attr(
'pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g,
'');
38 function localStorageSupported()
41 return 'localStorage' in window && window[
'localStorage'] !== null && window.localStorage.getItem;
49 function storeLink(link)
51 if (!$(
"#nav-sync").hasClass(
'sync') && localStorageSupported()) {
52 window.localStorage.setItem(
'navpath',link);
58 if (localStorageSupported()) {
59 window.localStorage.setItem(
'navpath',
'');
65 if (localStorageSupported()) {
66 return window.localStorage.getItem(
'navpath');
72 function getScript(scriptName,func,show)
74 var head = document.getElementsByTagName(
"head")[0];
75 var script = document.createElement(
'script');
76 script.id = scriptName;
77 script.type =
'text/javascript';
79 script.src = scriptName+
'.js';
80 if ($.browser.msie && $.browser.version<=8) {
82 script.onreadystatechange =
function() {
83 if (script.readyState==
'complete' || script.readyState==
'loaded') {
84 func();
if (show) showRoot();
88 head.appendChild(script);
91 function createIndent(o,domNode,node,level)
95 while (n.parentNode) { level++; n=n.parentNode; }
96 if (node.childrenData) {
97 var imgNode = document.createElement(
"img");
98 imgNode.style.paddingLeft=(16*level).toString()+
'px';
102 node.plus_img = imgNode;
103 node.expandToggle = document.createElement(
"a");
104 node.expandToggle.href =
"javascript:void(0)";
105 node.expandToggle.onclick =
function() {
107 $(node.getChildrenUL()).slideUp(
"fast");
108 node.plus_img.src = node.relpath+
"arrowright.png";
109 node.expanded =
false;
111 expandNode(o, node,
false,
false);
114 node.expandToggle.appendChild(imgNode);
115 domNode.appendChild(node.expandToggle);
116 imgNode.src = node.relpath+
"arrowright.png";
118 var span = document.createElement(
"span");
119 span.style.display =
'inline-block';
120 span.style.width = 16*(level+1)+
'px';
121 span.style.height =
'22px';
122 span.innerHTML =
' ';
123 domNode.appendChild(span);
127 var animationInProgress =
false;
129 function gotoAnchor(anchor,aname,updateLocation)
131 var pos, docContent = $(
'#doc-content');
132 var ancParent = $(anchor.parent());
133 if (ancParent.hasClass(
'memItemLeft') ||
134 ancParent.hasClass(
'fieldname') ||
135 ancParent.hasClass(
'fieldtype') ||
136 ancParent.is(
':header'))
138 pos = ancParent.position().top;
139 }
else if (anchor.position()) {
140 pos = anchor.position().top;
143 var dist = Math.abs(Math.min(
144 pos-docContent.offset().top,
145 docContent[0].scrollHeight-
146 docContent.height()-docContent.scrollTop()));
147 animationInProgress=
true;
149 scrollTop: pos + docContent.scrollTop() - docContent.offset().top
150 },Math.max(50,Math.min(500,dist)),
function(){
151 if (updateLocation) window.location.href=aname;
152 animationInProgress=
false;
157 function newNode(o, po, text, link, childrenData, lastNode)
159 var node =
new Object();
160 node.children = Array();
161 node.childrenData = childrenData;
162 node.depth = po.depth + 1;
163 node.relpath = po.relpath;
164 node.isLast = lastNode;
166 node.li = document.createElement(
"li");
167 po.getChildrenUL().appendChild(node.li);
168 node.parentNode = po;
170 node.itemDiv = document.createElement(
"div");
171 node.itemDiv.className =
"item";
173 node.labelSpan = document.createElement(
"span");
174 node.labelSpan.className =
"label";
176 createIndent(o,node.itemDiv,node,0);
177 node.itemDiv.appendChild(node.labelSpan);
178 node.li.appendChild(node.itemDiv);
180 var
a = document.createElement(
"a");
181 node.labelSpan.appendChild(a);
182 node.label = document.createTextNode(text);
183 node.expanded =
false;
184 a.appendChild(node.label);
187 if (link.substring(0,1)==
'^') {
188 url = link.substring(1);
191 url = node.relpath+link;
193 a.className = stripPath(link.replace(
'#',
':'));
194 if (link.indexOf(
'#')!=-1) {
195 var aname =
'#'+link.split(
'#')[1];
196 var srcPage = stripPath(pathName());
197 var targetPage = stripPath(link.split(
'#')[0]);
198 a.href = srcPage!=targetPage ? url :
"javascript:void(0)";
199 a.onclick =
function(){
201 if (!$(a).parent().parent().hasClass(
'selected'))
203 $(
'.item').removeClass(
'selected');
204 $(
'.item').removeAttr(
'id');
205 $(a).parent().parent().addClass(
'selected');
206 $(a).parent().parent().attr(
'id',
'selected');
208 var anchor = $(aname);
209 gotoAnchor(anchor,aname,
true);
213 a.onclick =
function() { storeLink(link); }
216 if (childrenData != null)
218 a.className =
"nolink";
219 a.href =
"javascript:void(0)";
220 a.onclick = node.expandToggle.onclick;
224 node.childrenUL = null;
225 node.getChildrenUL =
function() {
226 if (!node.childrenUL) {
227 node.childrenUL = document.createElement(
"ul");
228 node.childrenUL.className =
"children_ul";
229 node.childrenUL.style.display =
"none";
230 node.li.appendChild(node.childrenUL);
232 return node.childrenUL;
240 var headerHeight = $(
"#top").height();
241 var footerHeight = $(
"#nav-path").height();
242 var windowHeight = $(window).height() - headerHeight - footerHeight;
245 var navtree=$(
'#nav-tree');
246 navtree.scrollTo(
'#selected',0,{offset:-windowHeight/2});
248 setTimeout(arguments.callee, 0);
253 function expandNode(o, node, imm, showRoot)
255 if (node.childrenData && !node.expanded) {
256 if (typeof(node.childrenData)===
'string') {
257 var varName = node.childrenData;
258 getScript(node.relpath+varName,
function(){
259 node.childrenData = getData(varName);
260 expandNode(o, node, imm, showRoot);
263 if (!node.childrenVisited) {
265 }
if (imm || ($.browser.msie && $.browser.version>8)) {
267 $(node.getChildrenUL()).show();
269 $(node.getChildrenUL()).slideDown(
"fast");
272 node.plus_img.src = node.relpath+
"arrowdown.png";
274 node.plus_img.src = node.relpath+
"arrowdown.png";
276 node.expanded =
true;
281 function glowEffect(n,duration)
283 n.addClass(
'glow').delay(duration).queue(
function(next){
284 $(
this).removeClass(
'glow');next();
288 function highlightAnchor()
290 var aname = hashUrl();
291 var anchor = $(aname);
292 if (anchor.parent().attr(
'class')==
'memItemLeft'){
293 var rows = $(
'.memberdecls tr[class$="'+hashValue()+
'"]');
294 glowEffect(rows.children(),300);
295 }
else if (anchor.parent().attr(
'class')==
'fieldname'){
296 glowEffect(anchor.parent().parent(),1000);
297 }
else if (anchor.parent().attr(
'class')==
'fieldtype'){
298 glowEffect(anchor.parent().parent(),1000);
299 }
else if (anchor.parent().is(
":header")) {
300 glowEffect(anchor.parent(),1000);
302 glowEffect(anchor.next(),1000);
304 gotoAnchor(anchor,aname,
false);
307 function selectAndHighlight(hash,n)
311 var link=stripPath(pathName())+
':'+hash.substring(1);
312 a=$(
'.item a[class$="'+link+
'"]');
315 a.parent().parent().addClass(
'selected');
316 a.parent().parent().attr(
'id',
'selected');
319 $(n.itemDiv).addClass(
'selected');
320 $(n.itemDiv).attr(
'id',
'selected');
322 if ($(
'#nav-tree-contents .item:first').hasClass(
'selected')) {
323 $(
'#nav-sync').css(
'top',
'30px');
325 $(
'#nav-sync').css(
'top',
'5px');
330 function showNode(o, node, index, hash)
332 if (node && node.childrenData) {
333 if (typeof(node.childrenData)===
'string') {
334 var varName = node.childrenData;
335 getScript(node.relpath+varName,
function(){
336 node.childrenData = getData(varName);
337 showNode(o,node,index,hash);
340 if (!node.childrenVisited) {
343 $(node.getChildrenUL()).css({
'display':
'block'});
344 node.plus_img.src = node.relpath+
"arrowdown.png";
345 node.expanded =
true;
346 var n = node.children[o.breadcrumbs[index]];
347 if (index+1<o.breadcrumbs.length) {
348 showNode(o,n,index+1,hash);
350 if (typeof(n.childrenData)===
'string') {
351 var varName = n.childrenData;
352 getScript(n.relpath+varName,
function(){
353 n.childrenData = getData(varName);
355 showNode(o,node,index,hash);
358 var rootBase = stripPath(o.toroot.replace(/\..+$/,
''));
359 if (rootBase==
"index" || rootBase==
"pages" || rootBase==
"search") {
360 expandNode(o, n,
true,
true);
362 selectAndHighlight(hash,n);
367 selectAndHighlight(hash);
371 function removeToInsertLater(element) {
372 var parentNode = element.parentNode;
373 var nextSibling = element.nextSibling;
374 parentNode.removeChild(element);
377 parentNode.insertBefore(element, nextSibling);
379 parentNode.appendChild(element);
384 function getNode(o, po)
386 var insertFunction = removeToInsertLater(po.li);
387 po.childrenVisited =
true;
388 var l = po.childrenData.length-1;
389 for (var i in po.childrenData) {
390 var nodeData = po.childrenData[i];
391 po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],
397 function gotoNode(o,subIndex,root,hash,relpath)
399 var nti = navTreeSubIndices[subIndex][root+hash];
400 o.breadcrumbs = $.extend(
true, [], nti ? nti : navTreeSubIndices[subIndex][root]);
401 if (!o.breadcrumbs && root!=NAVTREE[0][1]) {
402 navTo(o,NAVTREE[0][1],
"",relpath);
403 $(
'.item').removeClass(
'selected');
404 $(
'.item').removeAttr(
'id');
407 o.breadcrumbs.unshift(0);
408 showNode(o, o.node, 0, hash);
412 function navTo(o,root,hash,relpath)
414 var link = cachedLink();
416 var parts = link.split(
'#');
418 if (parts.length>1) hash =
'#'+parts[1].replace(/[^\w\-]/g,
'');
421 if (hash.match(/^#l\d+$/)) {
422 var anchor=$(
'a[name='+hash.substring(1)+
']');
423 glowEffect(anchor.parent(),1000);
428 while (NAVTREEINDEX[i+1]<=url) i++;
429 if (i==-1) { i=0; root=NAVTREE[0][1]; }
430 if (navTreeSubIndices[i]) {
431 gotoNode(o,i,root,hash,relpath)
433 getScript(relpath+
'navtreeindex'+i,
function(){
434 navTreeSubIndices[i] = eval(
'NAVTREEINDEX'+i);
435 if (navTreeSubIndices[i]) {
436 gotoNode(o,i,root,hash,relpath);
442 function showSyncOff(n,relpath)
444 n.html(
'<img src="'+relpath+
'sync_off.png" title="'+SYNCOFFMSG+
'"/>');
447 function showSyncOn(n,relpath)
449 n.html(
'<img src="'+relpath+
'sync_on.png" title="'+SYNCONMSG+
'"/>');
452 function toggleSyncButton(relpath)
454 var navSync = $(
'#nav-sync');
455 if (navSync.hasClass(
'sync')) {
456 navSync.removeClass(
'sync');
457 showSyncOff(navSync,relpath);
458 storeLink(stripPath2(pathName())+hashUrl());
460 navSync.addClass(
'sync');
461 showSyncOn(navSync,relpath);
466 function initNavTree(toroot,relpath)
468 var o =
new Object();
470 o.node =
new Object();
471 o.node.li = document.getElementById(
"nav-tree-contents");
472 o.node.childrenData = NAVTREE;
473 o.node.children =
new Array();
474 o.node.childrenUL = document.createElement(
"ul");
475 o.node.getChildrenUL =
function() {
return o.node.childrenUL; };
476 o.node.li.appendChild(o.node.childrenUL);
478 o.node.relpath = relpath;
479 o.node.expanded =
false;
480 o.node.isLast =
true;
481 o.node.plus_img = document.createElement(
"img");
482 o.node.plus_img.src = relpath+
"arrowright.png";
483 o.node.plus_img.width = 16;
484 o.node.plus_img.height = 22;
486 if (localStorageSupported()) {
487 var navSync = $(
'#nav-sync');
489 showSyncOff(navSync,relpath);
490 navSync.removeClass(
'sync');
492 showSyncOn(navSync,relpath);
494 navSync.click(
function(){ toggleSyncButton(relpath); });
497 $(window).load(
function(){
498 navTo(o,toroot,hashUrl(),relpath);
502 $(window).bind(
'hashchange',
function(){
503 if (window.location.hash && window.location.hash.length>1){
505 if ($(location).attr(
'hash')){
506 var clslink=stripPath(pathName())+
':'+hashValue();
507 a=$(
'.item a[class$="'+clslink.replace(/</g,
'\\3c ')+
'"]');
509 if (a==null || !$(a).parent().parent().hasClass(
'selected')){
510 $(
'.item').removeClass(
'selected');
511 $(
'.item').removeAttr(
'id');
513 var link=stripPath2(pathName());
514 navTo(o,link,hashUrl(),relpath);
515 }
else if (!animationInProgress) {
516 $(
'#doc-content').scrollTop(0);
517 $(
'.item').removeClass(
'selected');
518 $(
'.item').removeAttr(
'id');
519 navTo(o,toroot,hashUrl(),relpath);