diff --git a/js/info.js b/js/info.js index 31936346ae..9375ef62b6 100644 --- a/js/info.js +++ b/js/info.js @@ -29,7 +29,9 @@ EXT: ".html", INDEX_NAME: "index.html", INDEX_ID: "index", - MAIN_ANCHORS: ["Top", "SEC_Contents"], + CONTENTS_ID: "[Contents]", + CONTENTS_TITLE: "Table of Contents", + MAIN_ANCHORS: ["Top" /*, "SEC_Contents"*/], // ??? WARNING_TIMEOUT: 3000, SCREEN_MIN_WIDTH: 700, @@ -680,7 +682,7 @@ `----------------------------*/ function - Sidebar () + Sidebar (contents_node) { this.element = document.createElement ("div"); this.element.setAttribute ("id", "slider"); @@ -689,6 +691,13 @@ var toc = document.querySelector (".contents"); toc.remove (); + var contents_data = toc.cloneNode(true); + var d = document.createElement ("h1"); + d.appendChild(document.createTextNode(config.CONTENTS_TITLE)); + contents_node.appendChild(d); + contents_node.appendChild(contents_data); + // Also add CONTENTS_TITLE link to sidebar FIXME + /* Move contents of into a a fresh
to let the components treat the index page like other iframe page. */ var nav = document.createElement ("nav"); @@ -726,7 +735,8 @@ index_div.setAttribute ("node", config.INDEX_ID); index_div.setAttribute ("hidden", "true"); this.element = document.createElement ("div"); - this.element.setAttribute ("id", "sub-pages"); + this.element.setAttribute ("id", "sub-pages"); + // var index_div = add_div( config.INDEX_ID); this.element.appendChild (index_div); /** @type {string[]} Currently created divs. */ this.ids = [config.INDEX_ID]; @@ -745,7 +755,8 @@ this.ids.push (pageid); this.element.appendChild (div); if (linkid_contains_index (pageid)) - load_page (pageid); + load_page (pageid); + return div; }; Pages.prototype.render = function render (state) { @@ -873,13 +884,13 @@ /* Create iframe if necessary unless the div is refering to the Index page. */ - if ((pageid === config.INDEX_ID) && visible) + if ((pageid === config.INDEX_ID || pageid === config.CONTENTS_ID) && visible) { div.removeAttribute ("hidden"); /* Unlike iframes, Elements are unlikely to be scrollable (CSSOM Scroll-behavior), so choose an arbitrary element inside "index" div and at the top of it. */ - document.getElementById ("icon-bar").scrollIntoView (); + //document.getElementById ("icon-bar").scrollIntoView (); } else { @@ -1018,7 +1029,7 @@ { var link = linkid_split (state.current); var elem = document.getElementById (link.pageid); - if (link.pageid !== config.INDEX_ID) + if (link.pageid !== config.INDEX_ID && link.pageid !== config.CONTENTS_ID) elem.querySelector ("iframe").focus (); else { @@ -1030,9 +1041,10 @@ } } }; - - components.add (new Pages (index_div)); - components.add (new Sidebar ()); + var pages = new Pages (index_div); + components.add (pages); + var contents_node = pages.add_div(config.CONTENTS_ID); + components.add (new Sidebar (contents_node)); components.add (new Help_page ()); components.add (new Minibuffer ()); components.add (new Echo_area ()); @@ -1377,6 +1389,8 @@ && !external_manual_url_p (href)) { var linkid = href_hash (href) || config.INDEX_ID; + if (linkid === "index.SEC_Contents") + linkid = config.CONTENTS_ID; store.dispatch (actions.set_current_url (linkid)); event.preventDefault (); event.stopPropagation ();