profileinfo links now have anchors
authorAntoine Musso <hashar@free.fr>
Mon, 19 Nov 2012 14:34:34 +0000 (15:34 +0100)
committerAntoine Musso <hashar@free.fr>
Mon, 19 Nov 2012 14:34:34 +0000 (15:34 +0100)
Whenever expanding a section in profileinfo, the browser would sent us
to the top again which would force us to browse down to where we were.
Adding basic anchors send the user directly where he was browsing.

Note that HTML5 let you specify anything as an id as long as there is at
least one character.

Change-Id: I5b55297ce25d5c07b29610798fb39eae16d27f6a

profileinfo.php

index ad02ad5..4787594 100644 (file)
@@ -192,10 +192,12 @@ class profile_point {
 
                $ex = isset( $expand[$this->name()] );
 
+               $anchor = str_replace( '"', '', $this->name() );
+
                if ( !$ex ) {
                        if ( count( $this->children ) ) {
                                $url = getEscapedProfileUrl( false, false, $expand + array( $this->name() => true ) );
-                               $extet = ' <a href="' . $url . '">[+]</a>';
+                               $extet = " <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[+]</a>";
                        } else {
                                $extet = '';
                        }
@@ -206,8 +208,8 @@ class profile_point {
                                        $e += array( $name => $ep );
                                }
                        }
-
-                       $extet = ' <a href="' . getEscapedProfileUrl( false, false, $e ) . '">[–]</a>';
+                       $url = getEscapedProfileUrl( false, false, $e );
+                       $extet = " <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[–]</a>";
                }
                ?>
                <tr>