Sha256: e79df31a7f3a4e0c6cf1d2eff881b594de3ceb193e8233ac336dab8b7a60b3f4

Contents?: true

Size: 988 Bytes

Versions: 34

Compression:

Stored size: 988 Bytes

Contents

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

Spud.Blog = new function(){
  
  var self = this;

  this.init = function(){
    $('.spud_blog_filter_form').live('submit', 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

34 entries across 34 versions & 1 rubygems

Version Path
spud_blog-0.9.8 app/assets/javascripts/spud/blog.js
spud_blog-0.9.7 app/assets/javascripts/spud/blog.js
spud_blog-0.9.5 app/assets/javascripts/spud/blog.js
spud_blog-0.9.4 app/assets/javascripts/spud/blog.js
spud_blog-0.9.3 app/assets/javascripts/spud/blog.js
spud_blog-0.9.2 app/assets/javascripts/spud/blog.js
spud_blog-0.9.1 app/assets/javascripts/spud/blog.js
spud_blog-0.9.0 app/assets/javascripts/spud/blog.js
spud_blog-0.8.18 app/assets/javascripts/spud/blog.js
spud_blog-0.8.17 app/assets/javascripts/spud/blog.js
spud_blog-0.8.16 app/assets/javascripts/spud/blog.js
spud_blog-0.8.15 app/assets/javascripts/spud/blog.js
spud_blog-0.8.14 app/assets/javascripts/spud/blog.js
spud_blog-0.8.13 app/assets/javascripts/spud/blog.js
spud_blog-0.8.12 app/assets/javascripts/spud/blog.js
spud_blog-0.8.11 app/assets/javascripts/spud/blog.js
spud_blog-0.8.8 app/assets/javascripts/spud/blog.js
spud_blog-0.8.7 app/assets/javascripts/spud/blog.js
spud_blog-0.8.6 app/assets/javascripts/spud/blog.js
spud_blog-0.8.5 app/assets/javascripts/spud/blog.js