Repository: polygene-website Updated Branches: refs/heads/asf-site ea4d77b09 -> 9f7fffb60
Fix version switcher in /2.0 and /2.1 Project: http://git-wip-us.apache.org/repos/asf/polygene-website/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-website/commit/9f7fffb6 Tree: http://git-wip-us.apache.org/repos/asf/polygene-website/tree/9f7fffb6 Diff: http://git-wip-us.apache.org/repos/asf/polygene-website/diff/9f7fffb6 Branch: refs/heads/asf-site Commit: 9f7fffb608c1a83b469c7773d53faed1331e0374 Parents: ea4d77b Author: Paul Merlin <[email protected]> Authored: Mon Apr 10 18:27:46 2017 +0200 Committer: Paul Merlin <[email protected]> Committed: Mon Apr 10 18:27:46 2017 +0200 ---------------------------------------------------------------------- content/java/2.0/js/progressive-enhancement.js | 58 ++++++++++++++++++--- content/java/2.1/js/progressive-enhancement.js | 35 +++++++------ 2 files changed, 69 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-website/blob/9f7fffb6/content/java/2.0/js/progressive-enhancement.js ---------------------------------------------------------------------- diff --git a/content/java/2.0/js/progressive-enhancement.js b/content/java/2.0/js/progressive-enhancement.js index 767bebf..02d8952 100644 --- a/content/java/2.0/js/progressive-enhancement.js +++ b/content/java/2.0/js/progressive-enhancement.js @@ -1,10 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + */ /** - * Qi4j Documentation WebSite Progressive Enhancement. + * Apache Polygene Documentation WebSite Progressive Enhancement. */ $( document ).ready( function($){ + var atHome = window.location.hostname == "polygene.apache.org" + /** * Glossary. */ @@ -25,9 +46,7 @@ $( document ).ready( function($){ var dt = target.parent(); var dd = dt.next(); // Scroll - $.scrollTo( dt, 200, { - 'offset': -96 - }); + $.scrollTo( dt, 200, { 'offset': -96 }); // Highlight dd.fadeOut(50).fadeIn(200); } @@ -70,13 +89,13 @@ $( document ).ready( function($){ $( "div.logo" ).append( switcher_html ); var toURL = function( displayName ) { - if( window.location.hostname == "zest.apache.org" ) + if( atHome ) { return "../" + versions[ displayName ]; } else { - return "https://zest.apache.org/qi4j/" + versions[ displayName ]; + return "https://polygene.apache.org/java/" + versions[ displayName ]; } } $( "div.logo select" ).change( function() @@ -90,7 +109,32 @@ $( document ).ready( function($){ } } ); - // Add separator space between tutorials series + // Title links to their own anchor + $( "body > div.section .title" ).each( function( idx, title ) { + var $title = $( title ); + var id = $title.find( 'a' ).attr( 'id' ); + if( id ) { + $title.click( function() { + window.location.hash = id; + } ); + } + } ); + + // Scroll down a bit on hash change so that target is not hidden under the floating top menu + function scrollToHash( hash ) { + if( hash ) { + var $target = $( hash ); + if( $target ) { + setTimeout( function() { $.scrollTo( $target, 100, { 'offset': -96 }) }, 50 ); + } + } + }; + $( window ).bind( 'hashchange', function() { + scrollToHash( window.location.hash ); + }); + scrollToHash( window.location.hash ); + + // Enhance left nav $( "div.sub-nav div.toc dt" ).each( function( idx, dt ) { var $dt = $( dt ); var item = $dt.find( "span.section:first-child" ).text().trim(); http://git-wip-us.apache.org/repos/asf/polygene-website/blob/9f7fffb6/content/java/2.1/js/progressive-enhancement.js ---------------------------------------------------------------------- diff --git a/content/java/2.1/js/progressive-enhancement.js b/content/java/2.1/js/progressive-enhancement.js index 1f57de0..40e935d 100644 --- a/content/java/2.1/js/progressive-enhancement.js +++ b/content/java/2.1/js/progressive-enhancement.js @@ -1,29 +1,30 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. */ /** - * Qi4j Documentation WebSite Progressive Enhancement. + * Apache Polygene Documentation WebSite Progressive Enhancement. */ $( document ).ready( function($){ - var atHome = window.location.hostname == "zest.apache.org" + var atHome = window.location.hostname == "polygene.apache.org" /** * Glossary. @@ -94,7 +95,7 @@ $( document ).ready( function($){ } else { - return "https://zest.apache.org/java/" + versions[ displayName ]; + return "https://polygene.apache.org/java/" + versions[ displayName ]; } } $( "div.logo select" ).change( function()
