com web/php: simplify, and update the fragment in the url when clicking things in the quicktoc: js/common.js
| From: | Paul Dragoonis | Date: | Sat, 01 Jan 2011 19:07:42 +0000 |
| Subject: | com web/php: simplify, and update the fragment in the url when clicking things in the quicktoc: js/common.js | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-23681@lists.php.net to get a copy of this message | ||
Commit: 2e60602d4a419cf49c3eae3e7fa3f882031535ff
Author: Hannes Magnusson <bjori@php.net> Sat, 1 Jan 2011 19:07:42 +0000
Parents: e9c9caed1c0017bc6661a9cca6f331fccb9628b2
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=2e60602d4a419cf49c3eae3e7fa3f882031535ff
Log:
simplify, and update the fragment in the url when clicking things in the quicktoc
Changed paths:
M js/common.js
Diff:
diff --git a/js/common.js b/js/common.js
index 64c95ff..8a404f0 100644
--- a/js/common.js
+++ b/js/common.js
@@ -135,8 +135,10 @@ $(document).ready(function() {
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 @@ $(document).ready(function() {
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 @@ $(document).ready(function() {
$(".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);
});
}
});