From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Rose Subject: Re: Re: Highlight current page in TOC Date: Wed, 24 Nov 2010 20:00:03 +0100 Message-ID: <87ipzmpmx8.fsf@gmx.de> References: <87vd3mpruj.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=38767 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PLKaL-0005Jh-1H for emacs-orgmode@gnu.org; Wed, 24 Nov 2010 14:00:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PLKaJ-0001qC-EP for emacs-orgmode@gnu.org; Wed, 24 Nov 2010 14:00:52 -0500 Received: from mailout-de.gmx.net ([213.165.64.23]:54336 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PLKaI-0001pT-VQ for emacs-orgmode@gnu.org; Wed, 24 Nov 2010 14:00:51 -0500 In-Reply-To: <87vd3mpruj.fsf@gmx.de> (Sebastian Rose's message of "Wed, 24 Nov 2010 18:13:40 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Benny Simonsen Cc: emacs-orgmode@gnu.org Sebastian Rose writes: > Benny Simonsen writes: > >> 2010/11/14 Benny Simonsen >>> >>> Hi >>> >>> With the org-info-js mode enabled each section is shown as a seperate >>> page, but then I would like to get current page marked in the TOC in >>> some way (e.g. class=3Dcurrent and then some CSS to make the markup) >>> ... but is it possible? >>> >>> /Benny >> >> Hi >> >> I have made it. >> >> The result can be seen on a example page I have made (in danish - >> (translated org-info-src.js [1] it into danish)) - >> http://slbs.dk/org/oensker.html >> >> I have modified org-info-src.js [1] to include an extra function >> setLinkClass + using this function at the end of showSection. >> I have also added a small css script [2] with the extra content, which >> could be included in the normal worg.css [3] without side effects, I >> think. >> I include one css - main.css [4] that includes the two css files >> mentioed here + an extra file with my own site style.' >> >> Except the changes in my site slbs.css, the only style changes I have ma= de are: >> - Current page/section are marked black and bold >> - Visited pages are marked in different color >> >> Anyone interested in a patch for the highlighting of the links? >> Anyone interested in a patch for the danish org-info-src.js? >> >> [1] http://slbs.dk/org/scripts/org-info-src.marklinks.js >> =C2=A0=C2=A0=C2=A0=C2=A0 ... in danish: http://slbs.dk/org/scripts/org-i= nfo-src.da.marklinks.js >> =C2=A0=C2=A0=C2=A0=C2=A0 ... in danish without modifications: >> http://slbs.dk/org/scripts/org-info-src.da.js >> [2] http://slbs.dk/org/style/marklink.css >> [3] Copy from http://orgmode.org/worg/worg.css >> [4] http://slbs.dk/org/style/main.css - Which includes the other css fil= es >> >> I have also included lightbox-2.04, and changed it so that a group is >> limited to one visible page(one section) >> >> >> Best regards >> Benny Simonsen > > > Hi Benny! > > > That's very beautiful with fixed T.O.C! > > > I have added a modified version of your patch (just the "className" part > of it). > > The sections now reference their anchor HTML-Element in the TOC passed > as an additional parameter in the constructor OrgNode (in the function > `mkNodeFromHref()'). This might lead to problems in old Internet > Explorers when leaving the page - but in old ones. > > > > I guess the cleanest way to add actions to org-info.js is to add hooks > and use them this way (e.g. in the HTML section): > > > #+STYLE: > > > That's what I'm working at currently: > > Just gimme an hour. You can then hook in your LightBox function. > > Note: currently the names in sources and compressed scripts are > different (see `sed.txt'). We should change that in the future for > some widely used variables (like OrgNode.H <=3D> OrgNode.HEADING). OK. That's how it works now: There are two hooks (maybe more to come) for now. 1. The 'onReady' hook. You may add functions to that hook using #+STYLE: The hook is called with exactly one parameter: the OrgHtmlManager object (which is the first parameter for every hook function). 2. The 'onShowSection' hook. You may add functions to that hook using #+STYLE: The hook is called with two parameters: the OrgHtmlManager object (which is the first parameter for every hook function) and an object {last: OrgNodeObject, current: OrgNodeObject} You may add several functions to a hook by calling the `onReady' method several times. Fist added, first executed. So you would just add your LightBox stuff like this (untested): org_html_manager.onShowSection(function(ohm, secs) { var imgs =3D secs.current.D.getElementsByTagName("img"); for(var i=3D0;i