svn: /web/php/trunk/js/ common.js

[email protected] (Paul Dragoonis)
Newsgroups php.webmaster
Message-ID <[email protected]>
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);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.