var productView = {};

productView.show = function(products) {
  productView.loadTemplate(products);
};

productView.index = function (){
  console.log('productView.index');
  productView.loadTemplate(product.allData);
  productView.handleFilter();
};

productView.loadTemplate = function(products) {
  if (productView.template){
    productView.renderGroup(products);
  }else{
    $.get('/templates/productivityTemplate.html',function(data, msg, xhr) {
      productView.template = Handlebars.compile(data);
      productView.renderGroup(products);
    });
  };

  productView.populateFilter();
};

productView.renderGroup = function(products) {
  productView.nav();
  $('#category-filter').fadeIn();
  $('.projectNav').hide();
  $('#product')
  .empty()
  .fadeIn()
  .append(
    products.map(function(product){
      return productView.template(product);
    })
  )
  .siblings()
  .hide();
};

productView.nav = function() {

  if($('.productNav').css('display') === 'none' && $('.productNav').show().length ===1 ){
    productView.renderNavCrumb();
  }
  if($('.productNav').length === 0){
    productView.renderNavCrumb();
  }
  $('.jumbotron').slideUp();
};

productView.renderNavCrumb = function() {
  var ele ="<ol class='breadcrumb productNav'><li><a href='/'>Home</a></li><li><a href='/productivity'>Productivity</a></li></ol>";
  if($('.productNav').length<1){
    $('#category-filter').before(ele);
  }

  $('#page').find('a').attr('href','/productivity');
  $('#page').find('a').text('Productivity');

};

productView.populateFilter = function() {
  var val;
  var len =_.uniq(product.allData, function(product) {
    return product.category;
    console.log(resource.category);
  }).length;

  if (len !== productView.optLen){
    $('category-filter').empty();
    _.uniq(product.allData, function(product) {
      return product.category;
      console.log(resource.category);
    }).forEach(function(resource) {
      val = resource.category;
      option = '<option value="' + val + '">' + val + '</option>';
      $('#category-filter').append(option);
    });
    productView.optLen = len;
  }

};


productView.handleFilter = function() {
  $('#category-filter').on('change', function(event){
    page('/productivity/' + $(this).val());
    event.preventDefault();
  });

};

@@ -927,495 +927,60 @@
 ) %7B%0A
-%0A
   
-if($('.productNav').css('display') === 'none' && $('.productNav').show().length ===1 )%7B%0A    productView.renderNavCrumb();%0A  %7D%0A  if($('.productNav').length === 0)%7B%0A    productView.renderNavCrumb();%0A  %7D%0A  $('.jumbotron').slideUp();%0A%7D;%0A%0AproductView.renderNavCrumb = function() %7B%0A  var ele =%22%3Col class='breadcrumb productNav'%3E%3Cli%3E%3Ca href='/'%3EHome%3C/a%3E%3C/li%3E%3Cli%3E%3Ca href='/productivity'%3EProductivity%3C/a%3E%3C/li%3E%3C/ol%3E%22;%0A  if($('.productNav').length%3C1)%7B%0A    $('#category-filter').before(ele);%0A  %7D%0A
+$('#page').find('a').attr('href','/productivity');
 %0A  $
@@ -995,39 +995,31 @@
 ).find('a').
-attr('href','/p
+text('P
 roductivity'
@@ -1025,58 +1025,43 @@
 ');%0A
+%0A
   $('
-#page').find('a').text('Productivity'
+.jumbotron').slideUp(
 );%0A
-%0A
 %7D;%0A%0A
+%0A
 prod

fix breadNav in Productivity Page