Skip to content

Commit

Permalink
improved support for Unicode anchors in Mojolicious::Plugin::PODRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 26, 2014
1 parent a5e62ba commit 3ae054c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

5.19 2014-07-26
- Improved support for Unicode anchors in Mojolicious::Plugin::PODRenderer.

5.18 2014-07-25
- Improved is_readable performance in Mojo::Reactor.
Expand Down
13 changes: 8 additions & 5 deletions lib/Mojolicious/templates/mojobar.html.ep
Expand Up @@ -68,10 +68,15 @@
</div>
</div>
<script>
function escapeAnchor(hash) {
var anchor = hash.split("#")[1]
anchor = anchor.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&");
return "#" + anchor;
}
var mojobar = $('#mojobar');
var mojobarHeight = mojobar.outerHeight();
function fixOffset() {
var offset = $(window.location.hash).offset();
var offset = $(escapeAnchor(window.location.hash)).offset();
if (offset) {
$('html, body').animate({scrollTop: offset.top - mojobarHeight}, 1);
}
Expand Down Expand Up @@ -111,10 +116,8 @@
$(".mojoscroll").click(function(e) {
e.preventDefault();
e.stopPropagation();
var hash = this.href.split("#")[1];
hash = hash.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&");
hash = "#" + hash;
var target = $(hash);
var hash = "#" + this.href.split("#")[1];
var target = $(escapeAnchor(hash));
var old = target.attr('id');
target.attr('id', '');
location.hash = hash;
Expand Down

0 comments on commit 3ae054c

Please sign in to comment.