Sha256: 81dfe242269d935b899fc87ff6a57916e24c1924b969a024a8584603489ffddb

Contents?: true

Size: 995 Bytes

Versions: 13

Compression:

Stored size: 995 Bytes

Contents

spud = (typeof(spud) == 'undefined') ? {} : spud;

spud.blog = new function(){
  
  var self = this;

  this.init = function(){
    $('body').on('submit', '.spud_blog_filter_form', self.didSubmitFilterForm);
  };

  this.didSubmitFilterForm = function(event){
    event.preventDefault();
    var form = $(this);
    var base = form.attr('action');
    var url = '';

    // find filter values    
    var category_select = $(this).find('select[rel=category]');
    if(category_select){
      var category = category_select.val();
    }
    var archive_select = $(this).find('select[rel=archive]');
    if(archive_select){
      var archive = archive_select.val();
    }

    // build url and redirect
    if(category && archive){
      url = '/category/' + category + '/' + archive;
    }
    else if(category){
      url = '/category/' + category;
    }
    else if(archive){
      url = '/archive/' + archive;
    }
    window.location = base + url;
  };
};

$(document).ready(spud.blog.init);

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
spud_blog-1.0.2 app/assets/javascripts/spud/blog.js
spud_blog-1.0.1 app/assets/javascripts/spud/blog.js
spud_blog-1.0.0 app/assets/javascripts/spud/blog.js
spud_blog-1.0.0.rc1.1 app/assets/javascripts/spud/blog.js
spud_blog-1.0.0.rc1 app/assets/javascripts/spud/blog.js
tb_blog-1.0.4 app/assets/javascripts/spud/blog.js
tb_blog-1.0.3 app/assets/javascripts/spud/blog.js
spud_blog-0.9.11 app/assets/javascripts/spud/blog.js
tb_blog-1.0.2 app/assets/javascripts/spud/blog.js
tb_blog-1.0.1 app/assets/javascripts/spud/blog.js
tb_blog-1.0 app/assets/javascripts/spud/blog.js
spud_blog-0.9.10 app/assets/javascripts/spud/blog.js
spud_blog-0.9.9 app/assets/javascripts/spud/blog.js