adding more js to change the donation form input to a dropdown
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 6 Feb 2018 14:43:53 +0000 (09:43 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 6 Feb 2018 14:43:53 +0000 (09:43 -0500)
changing the donation form input field to a dropdown

functions.php
js/app.js
js/custom/gravityForms.js
lib/funds.php

index 324b18d..47ea6ad 100644 (file)
@@ -196,30 +196,17 @@ if (!function_exists('is_in_tree')) {
 add_action('init', function(){
     function get_funds(){
         $all_funds = [];
-        $custom_terms = get_terms('fund_group');
-        foreach($custom_terms as $custom_term) {
             wp_reset_query();
             $args = array(
                 'post_type' => 'fund',
                 'numberposts' => -1,
-                'tax_query' => array(
-                    array(
-                        'taxonomy' => 'fund_group',
-                        'field' => 'slug',
-                        'terms' => $custom_term->slug,
-                        'hide_empty' => false
-                     ),
-                ),
              );
 
             $loop = get_posts($args);
             foreach($loop as $l){
-                $funds_grouped[$custom_term->name][] = $l->post_title;
                 $all_funds[]= $l->post_title;
             }
-        }
 
-        $js_funds_grouped = json_encode($funds_grouped);
         $js_all_funds     = json_encode($all_funds);
 
         return $js_all_funds;
index 8f35071..aab4536 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -26,11 +26,13 @@ var g=a(f(this.selector(c),a("<div></div>").html(c.attr("title")).html())),h=thi
         var amount = 0;
 
         // set up autocomplete
-        $('.gfield_list_2_cell2').children().autocomplete({source: tags});
+        // $('.gfield_list_2_cell2').children().autocomplete({source: tags});
         
-        $(document).on('keydown.autocomplete','.gfield_list_2_cell2 > input', function(){
-            $(this).autocomplete({source: tags});
-        });
+        // $(document).on('keydown.autocomplete','.gfield_list_2_cell2 > input', function(){
+            // $(this).autocomplete({source: tags});
+        // });
+
+        $('.gfield_list_2_cell2 > input').swapSelect();
 
         $(document).on("click", '.delete_list_item', function(e){
             var amount =  $(this).parent().prev().prev().children('input').val();
@@ -94,6 +96,31 @@ var g=a(f(this.selector(c),a("<div></div>").html(c.attr("title")).html())),h=thi
             }
         })
     });
+
+    $.fn.swapSelect = function(){
+        var parent = this.parent();
+        parent.css("width", "50%");
+        this.remove();
+        var select = $("<select />",
+            {
+                class: "dropdown-excerpt-background",
+                name: "input_2[]",
+                css:{
+                    display: 'none',
+                }
+            }
+
+        );
+        
+        select.appendTo(parent);
+        $('<option value="">Select a Fund</option>').appendTo(select);
+        $.each(all_funds, function(){
+            $('<option value="' + this + '">' + this + '</option>').appendTo(select);
+        })
+        this.fadeOut(function(){
+            select.fadeIn();
+        });
+    }
 });;// Load foundation
 $(document).foundation();
 $(document).ready(function () {
index 52804e5..ed70e7c 100644 (file)
@@ -17,11 +17,13 @@ $(function(){
         var amount = 0;
 
         // set up autocomplete
-        $('.gfield_list_2_cell2').children().autocomplete({source: tags});
+        // $('.gfield_list_2_cell2').children().autocomplete({source: tags});
         
-        $(document).on('keydown.autocomplete','.gfield_list_2_cell2 > input', function(){
-            $(this).autocomplete({source: tags});
-        });
+        // $(document).on('keydown.autocomplete','.gfield_list_2_cell2 > input', function(){
+            // $(this).autocomplete({source: tags});
+        // });
+
+        $('.gfield_list_2_cell2 > input').swapSelect();
 
         $(document).on("click", '.delete_list_item', function(e){
             var amount =  $(this).parent().prev().prev().children('input').val();
@@ -85,4 +87,29 @@ $(function(){
             }
         })
     });
+
+    $.fn.swapSelect = function(){
+        var parent = this.parent();
+        parent.css("width", "50%");
+        this.remove();
+        var select = $("<select />",
+            {
+                class: "dropdown-excerpt-background",
+                name: "input_2[]",
+                css:{
+                    display: 'none',
+                }
+            }
+
+        );
+        
+        select.appendTo(parent);
+        $('<option value="">Select a Fund</option>').appendTo(select);
+        $.each(all_funds, function(){
+            $('<option value="' + this + '">' + this + '</option>').appendTo(select);
+        })
+        this.fadeOut(function(){
+            select.fadeIn();
+        });
+    }
 });
\ No newline at end of file
index 389e8f0..aa6aa73 100644 (file)
@@ -144,7 +144,7 @@ function funds_shortcode($atts)
     ob_end_clean();
     return $output;
 }
-add_action( 'init', 'fund_taxonomies' );
+// add_action( 'init', 'fund_taxonomies' );
 add_action( 'init', 'custom_post_type' );
 add_shortcode( 'list-funds', 'funds_shortcode' );
 /**
@@ -237,48 +237,3 @@ function fund_taxonomy_filter_post_type_request( $query )
 }
 add_filter( 'parse_query', 'fund_taxonomy_filter_post_type_request' );
 
-/**
- * Save Meta Data
- *
- * Saves the meta fields for the product
- *
- * @access public
- * @return void
- */
-//function save_meta() {
-//    global $post;
-//    if ( isset( $_POST['title-meta-noncename'] ) && ! wp_verify_nonce( $_POST['title-meta-noncename'], 'title-meta-noncename' ) ) {
-//        return $post->ID;
-//    }
-//    if ( isset( $post ) && ! current_user_can( 'edit_post', $post->ID ) ) {
-//        return $post->ID;
-//    }
-//    $name  = ( isset( $_POST['partner_name'] )  ? filter_var( $_POST['partner_name'] ) : '' );
-//    $title = ( isset( $_POST['partner_title'] ) ? filter_var( $_POST['partner_title'] ) : '' );
-//    $email = ( isset( $_POST['partner_email'] ) ? filter_var( $_POST['partner_email'] )  : '');
-//    $phone = ( isset( $_POST['partner_phone'] ) ? filter_var( $_POST['partner_phone'] )  : '');
-//    $url   = ( isset( $_POST['partner_url'] )   ? filter_var( $_POST['partner_url'] )  : '');
-//
-//    if ( isset( $post ) ) {
-//        update_post_meta( $post->ID, 'partner_name', $name );
-//        update_post_meta( $post->ID, 'partner_title', $title );
-//        update_post_meta( $post->ID, 'partner_email', $email );
-//        update_post_meta( $post->ID, 'partner_phone', $phone );
-//        update_post_meta( $post->ID, 'partner_url', $url );
-//        update_post_meta($post->ID, 'internal_url', $_POST['internal_url']);
-//        update_post_meta($post->ID, 'internal_page', $_POST['internal_page']);
-//    }
-//}
-
-/**
- * add_metaboxes
- *
- * Add the meta fields
- *
- * @access public
- * @return void
- */
-//function add_metaboxes() {
-//    add_meta_box( 'partner_info', 'Partner Information', 'partner_info', GLM_POST_TYPE, 'normal', 'low' );
-//}
-//add_action( 'save_post', 'save_meta' );