Skip to content

Commit 31131d2

Browse files
committed
api.jqueryui.com: Add links for all versions in the sidebar and make it clear which version the current docs apply to. Fixes jquery#234.
1 parent 81dc9d9 commit 31131d2

File tree

3 files changed

+58
-10
lines changed

3 files changed

+58
-10
lines changed

themes/api.jqueryui.com/functions.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
function jq_ui_api_versions() {
4+
// Must be listed with newest first
5+
return array(
6+
"1.10" => "1.6 and newer",
7+
"1.9" => "1.6 and newer",
8+
"1.8" => "1.3.2 and newer",
9+
);
10+
}
11+
12+
function jq_ui_api_version_latest() {
13+
$versions = jq_ui_api_versions();
14+
return key( $versions );
15+
}
16+
17+
function jq_ui_api_version_current() {
18+
$thisVersion = explode( "/", JQUERY_LIVE_SITE );
19+
return count( $thisVersion ) === 2 ?
20+
$thisVersion[ 1 ] :
21+
jq_ui_api_version_latest();
22+
}

themes/api.jqueryui.com/index.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22
get_header();
33
the_post();
44

5-
// Must be listed with newest first
6-
$versions = array(
7-
"1.10" => "1.6 and newer",
8-
"1.9" => "1.6 and newer",
9-
"1.8" => "1.3.2 and newer",
10-
);
11-
12-
$latestVersion = key( $versions );
13-
$thisVersion = explode( "/", JQUERY_LIVE_SITE );
14-
$thisVersion = count( $thisVersion ) === 2 ? $thisVersion[ 1 ] : $latestVersion;
5+
$versions = jq_ui_api_versions();
6+
$latestVersion = jq_ui_api_version_latest();
7+
$thisVersion = jq_ui_api_version_current();
158
$rootUrl = $thisVersion === $latestVersion ? '' : "/$thisVersion";
169
?>
1710

themes/api.jqueryui.com/sidebar.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
$versions = jq_ui_api_versions();
3+
$thisVersion = jq_ui_api_version_current();
4+
$latestVersion = jq_ui_api_version_latest();
5+
?>
6+
7+
<div id="sidebar" class="widget-area" role="complementary">
8+
<aside id="categories" class="widget">
9+
<h3 class="widget-title">jQuery UI <?php echo $thisVersion; ?></h3>
10+
<ul>
11+
<?php wp_list_categories( array(
12+
'depth' => 2,
13+
'title_li' => '',
14+
'current_category' => jq_post_category(),
15+
'use_desc_for_title' => false
16+
) ); ?>
17+
</ul>
18+
</aside>
19+
20+
<aside id="categories" class="widget">
21+
<h3 class="widget-title">Other Versions</h3>
22+
<ul>
23+
<?php foreach( $versions as $version => $_ ) {
24+
if ( $version === $thisVersion ) {
25+
continue;
26+
}
27+
28+
$url = $version === $latestVersion ? '/' : "/$version/";
29+
echo "<li><a href=\"$url\">jQuery UI $version</a></li>";
30+
} ?>
31+
</ul>
32+
</aside>
33+
</div>

0 commit comments

Comments
 (0)