Commit:    9d01251291f9ae30ea484f82bc722e7e72e76cba
Author:    Paul Dragoonis <[email protected]>         Thu, 30 Dec 2010 
21:24:37 +0000
Parents:   f9f4219f95530970ab0c25d2f4c8652413ec5ba6
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=9d01251291f9ae30ea484f82bc722e7e72e76cba

Log:
Fixes for rightclick->saveas on the TOC links. Also faster code, using the DOM 
ID's and no .data()

Changed paths:
  M  js/common.js


Diff:
diff --git a/js/common.js b/js/common.js
index cd74ff2..8efa7ec 100644
--- a/js/common.js
+++ b/js/common.js
@@ -88,21 +88,22 @@ $(document).ready(function() {
         // 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;
                 });
             });


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to