Skip to content

Commit

Permalink
hash filter works with checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
zanematthew committed Jan 1, 2012
1 parent ff61541 commit f7dd3e5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
8 changes: 4 additions & 4 deletions library/hash.js
Expand Up @@ -72,10 +72,10 @@ function filterRows() {
changeHash();
}

function build_filters() {
function build_filters( _form_selector ) {
var searchClasses = '';
_filters = {};
jQuery( "#filter_task_form select" ).each(function() {
_filters = {};
jQuery( _form_selector + " select" ).each(function() {
if(jQuery(this).val()) {
// searchClasses += "." + jQuery(this).val();
if(typeof _filters[this.name] !== "object") {
Expand All @@ -84,7 +84,7 @@ function build_filters() {
_filters[this.name].push(jQuery('option:selected', this).attr("data-value"));
}
});
jQuery( "#filter_task_form input[type=checkbox]").each(function() {
jQuery( _form_selector + " input[type=checkbox]").each(function() {
if(jQuery(this).prop('checked')) {
if(typeof _filters[this.name] !== "object") {
_filters[this.name] = [];
Expand Down
1 change: 1 addition & 0 deletions template-redirect.php
Expand Up @@ -21,6 +21,7 @@ function quote_tracker_redirect( $params=array() ) {

if ( ! is_admin() ) {
wp_enqueue_script( 'zm-cpt-hash', plugin_dir_url( __FILE__ ) . 'library/hash.js', array('jquery' ), '0.0.1' );
wp_enqueue_script( 'quote-script', plugin_dir_url( __FILE__ ) . 'theme/script.js', array('jquery', 'zm-cpt-hash' ), '0.0.1' );
}
/*
Expand Down
14 changes: 14 additions & 0 deletions theme/archive-zm-quote-tracker.php
Expand Up @@ -25,6 +25,20 @@
<div class="container-zm-quote-tracker">
<div class="taxonomy-zm-quote-tracker">
<div class="sidebar-zm-quote-tracker">

<div class="zm-default-form-container">
<form action="javascript://" id="filter_task_form">
<div class="form-wrapper">
<input type="hidden" value="task" name="post_type" />
<?php
foreach( $cpt_obj[ $post_type ]->taxonomies as $taxonomy ) {
zm_base_build_input( array( 'taxonomy' => $taxonomy, 'prepend' => $taxonomy.'-', 'type' => 'checkbox' ) );
}
?>
</div>
</form>
</div>

<ul>
<li>Admin Menu</li>
<li><?php do_action('create_quote'); ?></li>
Expand Down
4 changes: 4 additions & 0 deletions theme/script.js
@@ -1,3 +1,7 @@
jQuery(document).ready(function( $ ){
console.log('loaded');

$( '#filter_task_form input[type=checkbox]' ).on( 'change', function(){
build_filters( _form_selector='#filter_task_form' );
});
});
6 changes: 5 additions & 1 deletion theme/style.css
Expand Up @@ -290,4 +290,8 @@ label {
text-transform: capitalize;
letter-spacing: 0.1em;
}
/* ---------------------------------------------------------- */
/* ---------------------------------------------------------- */

.zm-default-form-container fieldset { float: left; clear: both; width: 100%; margin-bottom: 20px; }
.zm-default-form-container label { float: left; width: 100%; font-weight: normal; }
.zm-default-form-container input[type="checkbox"] { float: left; width: auto; }

0 comments on commit f7dd3e5

Please sign in to comment.