svn: /web/php/trunk/js/ common.js
| From: | Paul Dragoonis | Date: | Thu, 30 Dec 2010 21:37:13 +0000 |
| Subject: | svn: /web/php/trunk/js/ common.js | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-10041@lists.php.net to get a copy of this message | ||
dragoonis Thu, 30 Dec 2010 21:37:13 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=306881
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:
U web/php/trunk/js/common.js
Modified: web/php/trunk/js/common.js
===================================================================
--- web/php/trunk/js/common.js 2010-12-30 21:24:37 UTC (rev 306880)
+++ web/php/trunk/js/common.js 2010-12-30 21:37:13 UTC (rev 306881)
@@ -102,9 +102,12 @@
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);