Browse code

Turn off editing for auto-generated index pages, and scroll the user to the right section

Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@docker.com> (github: SvenDowideit)

Sven Dowideit authored on 2014/10/13 15:32:18
Showing 2 changed files
... ...
@@ -1,3 +1,6 @@
1
+no_edit: true
2
+auto_scroll_to_path: true
3
+
1 4
 # Table of Contents
2 5
 
3 6
 {% for nav_item in nav %}
... ...
@@ -65,8 +65,10 @@
65 65
 		      Latest (Version {{ major_minor }})
66 66
               </a>
67 67
               <ul id="documentation-version-list" class="dropdown-menu pull-right">
68
+{% if not meta.no_edit %}
68 69
 		<li role="presentation" class="divider"></li>
69 70
 		<li> <a class="home-link3 tertiary-nav" href="https://github.com/docker/docker/blob/master/docs/sources/{{ current_page.input_path }}" >Edit on GitHub</a></li>
71
+{% endif %}
70 72
               </ul>
71 73
             </li>
72 74
           </ul>
... ...
@@ -139,6 +141,17 @@ piCId = '1482';
139 139
 		$(e).removeClass()
140 140
 	});
141 141
     });
142
+{% if meta.auto_scroll_to_path %}
143
+    // scroll to the right location in the generated index page
144
+    m=location.pathname.match(/^\/(.*?)\//)
145
+    if (m && m[1]) {
146
+        anchor = m[1].toLowerCase().replace(/ /, "-").replace(/\//, "-")
147
+        anchor_point = $('#'+anchor)
148
+        if (anchor_point && anchor_point[0]) {
149
+            $(window).scrollTop(anchor_point.offset().top);
150
+        }
151
+    }
152
+{% endif %}
142 153
   })
143 154
   var userName = getCookie('docker_sso_username');
144 155
   if (userName) {