Skip to content

Commit b778f81

Browse files
committed
Updated jQuery URL-matching functionality to sidebar
1 parent 08bc8e1 commit b778f81

1 file changed

Lines changed: 96 additions & 4 deletions

File tree

docs/theme/deis/layout.html

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373

7474

7575
<div class="span2 offset1 docs-sidebar hoop">
76-
{%- include "searchbox.html" %}
7776
{{ toctree(collapse=False, maxdepth=3) }}
7877
</div>
7978

@@ -138,7 +137,7 @@
138137
$('.docs-sidebar').height(maxHeight - 145);
139138

140139
//remove the margin from the tallest column if it exists
141-
tallest.height(maxHeight - tallestMargin);
140+
//tallest.height(maxHeight - tallestMargin);
142141

143142
//Set the margin above the social buttons in the left-hand menu
144143
if (maxHeight > 800) {
@@ -148,14 +147,107 @@
148147
$('.social-menu').css({'margin-top': 309})
149148
}
150149

150+
//Check URL
151+
// var path = window.location.pathname;
152+
// var pathName = path.split('/');
153+
// var num = pathName.length - 2;
154+
155+
var path = window.location.href;
156+
var pathName = path.split('/');
157+
var num = pathName.length - 3;
158+
console.log(pathName[num]);
159+
var gettingstarted, terms, client, server, contributing;
160+
161+
switch(pathName[num]) {
162+
case 'gettingstarted':
163+
console.log('case at Getting Started');
164+
$('.toctree-l1 > a').each(function(){
165+
if($(this).html() == "Getting Started") {
166+
$(this).parent().attr('state', 'open');
167+
$(this).attr('state', 'open');
168+
}
169+
});
170+
break;
171+
case 'terms':
172+
console.log('case at Terms');
173+
$('.toctree-l1 > a').each(function(){
174+
if($(this).html() == "Terms") {
175+
$(this).parent().attr('state', 'open');
176+
$(this).attr('state', 'open');
177+
}
178+
});
179+
break;
180+
case 'client':
181+
console.log('case at Client Reference');
182+
$('.toctree-l1 > a').each(function(){
183+
if($(this).html() == "Client Reference") {
184+
$(this).parent().attr('state', 'open');
185+
$(this).attr('state', 'open');
186+
}
187+
});
188+
break;
189+
case 'server':
190+
console.log('case at Server Reference');
191+
$('.toctree-l1 > a').each(function(){
192+
if($(this).html() == "Server Reference") {
193+
$(this).parent().attr('state', 'open');
194+
$(this).attr('state', 'open');
195+
}
196+
});
197+
break;
198+
case 'contributing':
199+
console.log('case at Contributing');
200+
$('.toctree-l1 > a').each(function(){
201+
if($(this).html() == "Contributing") {
202+
$(this).parent().attr('state', 'open');
203+
$(this).attr('state', 'open');
204+
}
205+
});
206+
break;
207+
case 'releases':
208+
//code this out when releases gets filled out
209+
break;
210+
default:
211+
console.log('failure.');
212+
213+
}
214+
215+
216+
// switch(pathName[num]) {
217+
// case gettingstarted:
218+
// $('Getting Started').parent().attr('state', 'open');
219+
// $('Getting Started').attr('state', 'open');
220+
// break;
221+
// }
222+
223+
//Check for match between path name and menu titles
224+
//$('.toctree-l2 > a').each(function(){
225+
// if($(this).html().toLowerCase() == pathName[num]) {
226+
// var parents = $(this).parents();
227+
// $(parents[2]).attr('state', 'open');
228+
// }
229+
//});
230+
151231
//Doc Sidebar: Create accordion
152232
var allPanels = $('.toctree-l1 > ul');
153233
allPanels.hide();
154234

155-
$('.toctree-l1 > a').click(function() {
156-
if($(this).siblings().size() > 0) {
235+
$('.toctree-l1 > a').each(function(){
236+
if($(this).parent().attr('state') == 'open') {
237+
$(this).attr('state', 'open');
238+
$(this).next().show();
239+
}
240+
});
241+
242+
$('.toctree-l1 > a:first-child').click(function() {
243+
if($(this).siblings().size() > 0 && $(this).attr('state') != 'open') {
157244
allPanels.slideUp();
158245
$(this).next().slideDown();
246+
$('.toctree-l1 > a').attr('state', 'closed');
247+
$(this).attr('state', 'open');
248+
return false;
249+
}
250+
if ($(this).attr('state') == 'open') {
159251
return false;
160252
}
161253
});

0 commit comments

Comments
 (0)