com web/php: Better validation, scrollTo() plugin doesn't check if an elem exists before trying to scroll to it, so we check that prior to calling
scrollTo(): js/common.js
| From: | Paul Dragoonis | Date: | Thu, 30 Dec 2010 21:37:13 +0000 |
| Subject: | com web/php: Better validation, scrollTo() plugin doesn't check if an elem exists before trying to scroll to it, so we check that prior to calling scrollTo(): js/common.js |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-23701@lists.php.net to get a copy of this message | ||
Commit: f6ddccd93112f256a7021b125bff7d90d0d6b534
Author: Paul Dragoonis <dragoonis@gmail.com> Thu, 30 Dec 2010 21:37:13 +0000
Parents: 9d01251291f9ae30ea484f82bc722e7e72e76cba
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=f6ddccd93112f256a7021b125bff7d90d0d6b534
Log:
Better validation, scrollTo() plugin doesn't check if an elem exists before trying to scroll to
it, so we check that prior to calling scrollTo()
Changed paths:
M js/common.js
Diff:
diff --git a/js/common.js b/js/common.js
index 8efa7ec..981710d 100644
--- a/js/common.js
+++ b/js/common.js
@@ -102,9 +102,12 @@ $(document).ready(function() {
jQuery.getScript("/js/jquery.scrollto.min.js", function(){
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);
+ var scrollToElem = $(this).attr('href').replace(/\./g, '\\.');
+ if($(scrollToElem).length) {
+ $.scrollTo(scrollToElem, 800);
+ }
e.preventDefault();
- return false;
+ return false;
});
});
$("#quicktoc").append("<h5>Quick TOC</h5>").append(l);