Skip to content

Commit 0b954a0

Browse files
committed
API docs: Make validate() options linkable
Use anchorify plugin to generate anchors on the client side. Uses some extra CSS to only show them on hover of the option name. Fixes jquery-validation/jquery-validation#1034
1 parent a323bec commit 0b954a0

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

anchorify.min.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api-demo.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
// TODO convert to a WP plugin?
2-
31
(function() {
2+
// silly selector to match only the options for the validate() method
3+
$(".signature ul ul div > strong").anchorify({
4+
position: "prepend"
5+
});
6+
47
$( ".entry-example" ).each(function() {
58
var iframeSrc,
69
src = $( this ).find( ".syntaxhighlighter" ),

functions.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
function scripts() {
33
echo '<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>' . "\n";
4+
echo '<script src="' . get_stylesheet_directory_uri() . '/anchorify.min.js"></script>' . "\n";
45
echo '<script src="' . get_stylesheet_directory_uri() . '/api-demo.js"></script>' . "\n";
56
}
67
add_action( 'wp_footer', 'scripts' );

style.css

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ Description: jQuery Validation Plugin Theme based on twentytwelve
99

1010
@import url("../twentytwelve/style.css");
1111

12+
/* show anchor on hover, adjust offset */
13+
strong[id] .anchor-link {
14+
margin-left: -9px;
15+
visibility: hidden;
16+
}
17+
strong[id]:hover .anchor-link {
18+
visibility: inherit;
19+
}
20+
1221
/* Syntax Highlighting ---------------------- */
1322

1423
pre, code {

0 commit comments

Comments
 (0)