From: Anthony Talarico Date: Tue, 6 Feb 2018 14:43:53 +0000 (-0500) Subject: adding more js to change the donation form input to a dropdown X-Git-Tag: v1.0.0^2~24 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=6f261302509e99f5c9ac73e87675de0d0b7f33c8;p=WP-Themes%2Fkhako.git adding more js to change the donation form input to a dropdown changing the donation form input field to a dropdown --- diff --git a/functions.php b/functions.php index 324b18d..47ea6ad 100644 --- a/functions.php +++ b/functions.php @@ -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; diff --git a/js/app.js b/js/app.js index 8f35071..aab4536 100644 --- a/js/app.js +++ b/js/app.js @@ -26,11 +26,13 @@ var g=a(f(this.selector(c),a("
").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("
").html(c.attr("title")).html())),h=thi } }) }); + + $.fn.swapSelect = function(){ + var parent = this.parent(); + parent.css("width", "50%"); + this.remove(); + var select = $("", + { + class: "dropdown-excerpt-background", + name: "input_2[]", + css:{ + display: 'none', + } + } + + ); + + select.appendTo(parent); + $('').appendTo(select); + $.each(all_funds, function(){ + $('').appendTo(select); + }) + this.fadeOut(function(){ + select.fadeIn(); + }); + } }); \ No newline at end of file diff --git a/lib/funds.php b/lib/funds.php index 389e8f0..aa6aa73 100644 --- a/lib/funds.php +++ b/lib/funds.php @@ -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' );