svn: /web/php/trunk/js/ common.js
[email protected] (Hannes Magnusson)
| Newsgroups | php.webmaster |
|---|---|
| Message-ID | <[email protected]> |
bjori Sat, 01 Jan 2011 19:07:42 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=306955
Log:
simplify, and update the fragment in the url when clicking things in the quicktoc
Changed paths:
U web/php/trunk/js/common.js
Modified: web/php/trunk/js/common.js
===================================================================
--- web/php/trunk/js/common.js 2011-01-01 18:34:27 UTC (rev 306954)
+++ web/php/trunk/js/common.js 2011-01-01 19:07:42 UTC (rev 306955)
@@ -135,8 +135,10 @@
var bugurl = "http://bugs.php.net/report.php?bug_type=Documentation+problem&manpage=" + pageid;
// Add edit & bugreporting urls to the footer
- $($(".footmenu")[1]).append("<li><a href='" + editurl + "'>Edit this page</a></li>");
- $($(".footmenu")[1]).append("<li><a href='" + bugurl + "'>Report bug on this page</a></li>");
+ $($(".footmenu")[1])
+ .append("<li><a href='" + editurl + "'>Edit this page</a></li>")
+ .append("<li><a href='" + bugurl + "'>Report bug on this page</a></li>")
+ ;
// Make a list, start making <li>'s dynamically.
// we use .data() to store which element the TOC item should scrollTo()
@@ -154,14 +156,8 @@
if (foundToc) {
jQuery.getScript("/js/jquery.scrollto.min.js", function(){
l.delegate("a.toc_item","click keypress", function(e) {
- var scrollToElem = $(this).attr('href');
- // 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
- scrollToElem = scrollToElem.substr(scrollToElem.indexOf('#')).replace(/\./g, '\\.');
- if($(scrollToElem).length) {
- $.scrollTo(scrollToElem, 800);
- }
- e.preventDefault();
- return false;
+ // Escape dots in ids so they won't be treated as class selectors
+ $.scrollTo($(this).attr("href").replace(".", "\\\."), 800);
});
});
$("#quicktoc").append("<h5>Quick TOC</h5>").append(l);
@@ -177,7 +173,7 @@
$(".parameters .term i > tt.parameter").each(function (idx, param) {
if ($(param).text() == $(node).text().substring(1)) {
$(node).click(function() {
- $.scrollTo($(param), 800);
+ $(param).scrollTo(0, 800);
});
}
});