|
1 // Fix IE bug: when frameset is opened in a new window with "Open in |
|
2 // new window", "main" frame name is set for frameset, not content |
|
3 // frame. |
|
4 if (window.name === "nav" && |
|
5 window.parent.name === "main" && |
|
6 window.parent.frameElement === null) { |
|
7 window.parent.name = ""; |
|
8 } |
|
9 |
|
10 /** |
|
11 * Initialize navigation frame document. |
|
12 */ |
|
13 function initNav() { |
|
14 setMainFrameContents(); |
|
15 resizeFrame(); |
|
16 } |
|
17 |
|
18 /** |
|
19 * Sets the main frame contents if frameset URL contains definition for it. |
|
20 */ |
|
21 function setMainFrameContents() { |
|
22 if (window.parent !== undefined && |
|
23 window.parent.frames.main !== undefined && |
|
24 window.parent.frames.toc !== undefined) { |
|
25 var u = new RegExp(URL_SEPARATOR_PATTERN); |
|
26 var l = window.parent.location.href; |
|
27 var c = l.match(u); |
|
28 if (c !== null && c.length !== 1) { |
|
29 var mainUrl = c[1]; |
|
30 findTocItem(mainUrl); |
|
31 window.parent.frames.main.location.href = mainUrl; |
|
32 } |
|
33 } |
|
34 } |
|
35 |
|
36 /** |
|
37 * Add permalink button to document header. |
|
38 */ |
|
39 function addPermalinkButton() { |
|
40 var div = document.createElement("div"); |
|
41 div.style.padding = "2px"; |
|
42 div.style.textAlign = "right"; |
|
43 var button = document.createElement("button"); |
|
44 button.appendChild(document.createTextNode("Permalink")); |
|
45 attachEventListener(button, "click", openPermalink); |
|
46 div.appendChild(button); |
|
47 var body = document.getElementsByTagName("body"); |
|
48 if (body.length > 0) { |
|
49 body[0].insertBefore(div, body[0].firstChild); |
|
50 } |
|
51 } |
|
52 |
|
53 /** |
|
54 * Permalink button click handler. |
|
55 */ |
|
56 function openPermalink(event) { |
|
57 if (window.parent !== undefined && window.parent.frames.main !== undefined) { |
|
58 var contentUrl = String(window.parent.frames.main.location.href); |
|
59 var baseUrl = getBaseUrl(); |
|
60 var mainUrl = getRelativeUrl(contentUrl, baseUrl); |
|
61 window.parent.location.href = URL_BASE + URL_SEPARATOR + mainUrl; |
|
62 } |
|
63 } |
|
64 |
|
65 /** |
|
66 * Generate TOC synchronization button. |
|
67 */ |
|
68 function addSyncButton() { |
|
69 if (!automaticSync) { |
|
70 //var b = document.createElement("img"); |
|
71 //b.src = "images/xhtml/e_synch_nav.gif"; |
|
72 var b = document.createElement("button"); |
|
73 b.appendChild(document.createTextNode(STATIC_STRING_TOC_SYNC)); |
|
74 b.title = STATIC_STRING_TOC_SYNC_HELP; |
|
75 addClass(b, "button-manual_sync"); |
|
76 attachEventListener(b, "click", manualSyncTocHandler); |
|
77 var bc = document.createElement("div"); |
|
78 addClass(bc, "button-manual_sync-container"); |
|
79 bc.appendChild(b); |
|
80 var nav3 = getFirstElementByClassName(document, "nav3", "div"); |
|
81 if (nav3 !== null) { |
|
82 nav3.insertBefore(bc, nav3.firstChild); |
|
83 } |
|
84 } |
|
85 } |
|
86 |
|
87 /** |
|
88 * Button listener for manual TOC sync. |
|
89 */ |
|
90 function manualSyncTocHandler(event) { |
|
91 startProcess("Synchronizing TOC"); |
|
92 var b = getTargetNode(event); |
|
93 var contentUrl = String(window.top.frames.main.location.href); |
|
94 var baseUrl = getBaseUrl(); |
|
95 var href = getRelativeUrl(contentUrl, baseUrl); |
|
96 findTocItem(href); |
|
97 endProcess("Done"); |
|
98 } |
|
99 |
|
100 /** |
|
101 * TOC frame toggler. |
|
102 */ |
|
103 function toggleTocFrame(event) { |
|
104 var target = getTargetNode(event); |
|
105 var frame = window.parent.toc.frameElement; |
|
106 var cols = frame.parentNode.cols; |
|
107 if (cols == "0, *") { |
|
108 if (previousTocWidth === undefined) { |
|
109 previousTocWidth = "300, *"; |
|
110 } |
|
111 frame.parentNode.setAttribute("cols", previousTocWidth); |
|
112 target.firstChild.data = "Hide TOC"; |
|
113 target.title = "Hides TOC"; |
|
114 } else { |
|
115 previousTocWidth = String(cols); |
|
116 frame.parentNode.setAttribute("cols", "0, *"); |
|
117 target.firstChild.data = "Show TOC"; |
|
118 target.title = "Shows TOC"; |
|
119 } |
|
120 } |
|
121 var previousTocWidth; |
|
122 |
|
123 /** |
|
124 * Rezide nav frame to minimum height. |
|
125 */ |
|
126 function resizeFrame() { |
|
127 var div = document.getElementById("toolbar"); |
|
128 if (div) { |
|
129 // extra 2 pixels for IE6 |
|
130 var height = div.offsetTop + div.offsetHeight + 2; |
|
131 if (window.frameElement && window.frameElement.parentNode) { |
|
132 window.frameElement.parentNode.rows = height + ",*"; |
|
133 } |
|
134 } |
|
135 } |