svn: /web/php/trunk/js/ common.js

From: Date: Thu, 30 Dec 2010 21:24:37 +0000
Subject: svn: /web/php/trunk/js/ common.js
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-10039@lists.php.net to get a copy of this message
dragoonis Thu, 30 Dec 2010 21:24:37 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=306880 Log: Fixes for rightclick->saveas on the TOC links. Also faster code, using the DOM ID's and no .data() Changed paths: U web/php/trunk/js/common.js Modified: web/php/trunk/js/common.js =================================================================== --- web/php/trunk/js/common.js 2010-12-30 21:19:00 UTC (rev 306879) +++ web/php/trunk/js/common.js 2010-12-30 21:24:37 UTC (rev 306880) @@ -88,21 +88,22 @@ // Make a list, start making <li>'s dynamically. // we use .data() to store which element the TOC item should scrollTo() var l = $('<ul id="toc_list">'); - $(".refsect1 h3, .sect1 h2, .sect2 h3, .sect3 h4").each(function() { + $(".refsect1 h3, .sect1 h2, .sect2 h3, .sect3 h4, .docs .sect4 h5").each(function() { if(foundToc === false) { foundToc = true; } var currItem = $(this); - $('<a class="toc_item" href="#">' + currItem.text() + '</a>') - .data('scrollObject', currItem.parent()) + $('<a class="toc_item" href="#' + currItem.parent().attr('id') + '">' + currItem.text() + '</a>') .appendTo( $('<li>') ).parent().appendTo(l); }); if (foundToc) { jQuery.getScript("/js/jquery.scrollto.min.js", function(){ - l.delegate("a.toc_item","click keypress", function(e) { - $.scrollTo($(this).data('scrollObject'), 800); + l.delegate("a.toc_item","click keypress", function(e) { + // You have to escape the '.' to '\\.' so that it doesn't start doing CSS-like selectors when we refer to "lang.type.string" as an ID + $.scrollTo($(this).attr('href').replace(/\./g, '\\.'), 800); + e.preventDefault(); return false; }); });

« previous php.webmaster (#10039) next »