Automatically rewriting WCF::getAnchor() to current page
authorAlexander Ebert <ebert@woltlab.com>
Fri, 8 Mar 2013 19:16:29 +0000 (20:16 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 8 Mar 2013 19:16:29 +0000 (20:16 +0100)
wcfsetup/install/files/js/WCF.js

index 6d8a8067d47656745775beeab2933e88b1b76113..7353f78aa67acb4617c32286317dcefd1fc5a5b3 100755 (executable)
@@ -1611,6 +1611,16 @@ WCF.Action.Proxy = Class.extend({
                
                // disable DOMNodeInserted event
                WCF.DOMNodeInsertedHandler.disable();
+               
+               // fix anchor tags generated through WCF::getAnchor()
+               $('a[href*=#]').each(function(index, link) {
+                       var $link = $(link);
+                       if ($link.prop('href').indexOf('AJAXProxy')) {
+                               var $anchor = $link.prop('href').substr($link.prop('href').indexOf('#'));
+                               var $pageLink = document.location.toString().replace(/#.*/, '');
+                               $link.prop('href', $pageLink + $anchor);
+                       }
+               });
        },
        
        /**