Permalink
Browse files

categories & tags tabs are being managed through hash value. initial …

…tab activation based on hash added. fixes #31.
  • Loading branch information...
dbtek committed Feb 11, 2016
1 parent 6c0acee commit 04c2a170117c53b1dd664b016fad0bf2b113d47e
Showing with 41 additions and 15 deletions.
  1. +36 −10 assets/js/app.js
  2. +3 −3 categories.html
  3. +2 −2 tags.html
View
@@ -1,15 +1,41 @@
(function($) {
$(document).ready(function() {
/* Sidebar height set */
$('.sidebar').css('min-height',$(document).height());
function init() {
/* Sidebar height set */
$('.sidebar').css('min-height',$(document).height());
/* Secondary contact links */
var $scontacts = $('#contact-list-secondary');
var $contactList = $('#contact-list');
/* Secondary contact links */
var $scontacts = $('#contact-list-secondary');
var $contactList = $('#contact-list');
$scontacts.hide();
$contactList.mouseenter(function(){ $scontacts.fadeIn(); });
$contactList.mouseleave(function(){ $scontacts.fadeOut(); });
/**
* Tags & categories tab activation based on hash value. If hash is undefined then first tab is activated.
*/
function activateTab() {
console.log('hashchange');
if(['/tags.html', '/categories.html'].indexOf(window.location.pathname) > -1) {
var hash = window.location.hash;
if(hash)
console.log(hash + ' aasdasd');
if(hash)
$('.tab-pane').length && $('a[href="' + hash + '"]').tab('show');
else
$('.tab-pane').length && $($('.cat-tag-menu li a')[0]).tab('show');
}
}
// watch hash change and activate relevant tab
$(window).on('hashchange', activateTab);
// initial activation
activateTab();
};
// run init on document ready
$(document).ready(init);
$scontacts.hide();
$contactList.mouseenter(function(){ $scontacts.fadeIn(); });
$contactList.mouseleave(function(){ $scontacts.fadeOut(); });
});
})(jQuery);
View
@@ -6,20 +6,20 @@
---
<div class="col-sm-3 col-xs-6">
<ul class="nav nav-tabs-vertical">
<ul class="nav nav-tabs-vertical cat-tag-menu">
{% assign categories_list = site.categories %}
{% if categories_list.first[0] == null %}
{% for category in categories_list %}
<li>
<a href="{{ site.BASE_PATH }}/{{ site.categories_path }}#{{ category | replace:' ','-' }}-ref" data-toggle="tab">
<a href="#{{ category | replace:' ','-' }}-ref">
{{ category | capitalize }} <span class="badge pull-right">{{ site.categories[category].size }}</span>
</a>
</li>
{% endfor %}
{% else %}
{% for category in categories_list %}
<li>
<a href="{{ site.BASE_PATH }}/{{ site.categories_path }}#{{ category[0] | replace:' ','-' }}-ref" data-toggle="tab">
<a href="#{{ category[0] | replace:' ','-' }}-ref">
{{ category[0] | capitalize }} <span class="badge pull-right">{{ category[1].size }}</span>
</a>
</li>
View
@@ -10,11 +10,11 @@
<div class="col-sm-3 col-xs-6">
<ul class="nav nav-tabs-vertical">
<ul class="nav nav-tabs-vertical cat-tag-menu">
{% for item in (0..site.tags.size) %}{% unless forloop.last %}
{% capture this_word %}{{ tag_words[item] | strip_newlines }}{% endcapture %}
<li>
<a href="#{{ this_word | replace:' ','-' }}-ref" data-toggle="tab">
<a href="#{{ this_word | replace:' ','-' }}-ref">
{{ this_word }}<span class="badge pull-right">{{ site.tags[this_word].size }}</span>
</a>
</li>

0 comments on commit 04c2a17

Please sign in to comment.