added JS to handle the changing search query routing, evevents, catalog and site
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 31 Mar 2017 12:20:59 +0000 (08:20 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 31 Mar 2017 12:20:59 +0000 (08:20 -0400)
search

index.php
parts/search-form.php
sections/front-page.php
sections/header.php

index 747bbd3..dbfcb8a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -51,7 +51,7 @@
                     var baseUrl     = '<?php echo home_url('/') ?>';
                     var eventsPage  = '<?php echo get_permalink(131) ?>';
                     var url,queryType;
-                    
+
                     // Public members
                     return {
                         getCatalogSearch: function(){
                             
                             $([catalog,main,events]).each(function(){
                                 $(this).on("change", function(){
-                                   this.queryType = $(this).val();
-                        
-                                    switch(this.queryType){
+                                    queryType = $(this).val();
+
+                                    switch(queryType){
                                         case 'catalog':
-                                            this.url = 'https://charlevoix.bibliocommons.com/search?custom_query=';
+                                            this.url = 'https://charlevoix.bibliocommons.com/search';
                                             form.attr("method", "GET");
-                                            form.children('.search-input').attr('name','query');
+                                            form.children('.search-input').attr('name','custom_query');
                                             break;
                                         case 'site':
                                             this.url = baseUrl + 'site-search';
                                     form.attr('action', this.url);
                                     
                                 });
-                                query = this.queryType;
-                                
                             });
-                        }, 
-                        queryType: this.queryType
-                        
+                        },  
                     }
                 })();
                 search.changeAction(search.getCatalogSearch(),search.getMainSearch(),search.getEventSearch(),search.getSearchForm());
-                $('.searchform').on('submit', function(){
-                    var search_val = $(this).children('.search-input');
-                    if( search.queryType === 'catalog'){
-                        $(this).attr('action', this.url + search_val);
-                    } else {
-                        console.log(search.query);
-                        return false;
-                    }
-                    
-                });
-                console.log(search);
             });
         </script>
     </body>
index 68210b6..d4f4f35 100644 (file)
@@ -2,8 +2,8 @@
     <input class="search-input" type="text" placeholder="Books, Movies, Music & More" value="" name="query">
     <input class="search-button button" type="submit" value="Search" name="submit">
     <div class="radio-area">
-        <input class="catalog-search" type="radio" name="chooseone" value="catalog"> <label for="catalog">Catalog</label>
-        <input class="main-search" type="radio" name="chooseone" value="site"> <label for="site">Site</label>
-        <input class="event-search" type="radio" name="chooseone" value="events"> <label for="events">Events</label>
+        <input class="catalog-search" type="radio" name="queryType" value="catalog"> <label for="catalog">Catalog</label>
+        <input class="main-search" type="radio" name="queryType" value="site"> <label for="site">Site</label>
+        <input class="event-search" type="radio" name="queryType" value="events"> <label for="events">Events</label>
     </div>
 </form>
\ No newline at end of file
index adac252..22e74ff 100644 (file)
@@ -4,9 +4,9 @@
                                 <input class="search-input" type="text" placeholder="Search  for Books, Movies, Music, and More" value="" name="query">
                                 <input class="search-button" type="image" value="Search" name="submit" src="<?php echo esc_url( get_template_directory_uri() );?>/assets/search-icon.png">
                                 <div class="radio-area">
-                                    <input class="catalog-search" type="radio" name="chooseone" value="catalog"> <label for="catalog">Catalog</label>
-                                    <input class="main-search" type="radio" name="chooseone" value="site"> <label for="site">Site</label>
-                                    <input class="event-search" type="radio" name="chooseone" value="events"> <label for="events">Events</label>
+                                    <input class="catalog-search" type="radio" name="queryType" value="catalog"> <label for="catalog">Catalog</label>
+                                    <input class="main-search" type="radio" name="queryType" value="site"> <label for="site">Site</label>
+                                    <input class="event-search" type="radio" name="queryType" value="events"> <label for="events">Events</label>
                                 </div>
                             </form>
                         </div>
index 516b5f1..326b5bb 100644 (file)
@@ -14,9 +14,9 @@
                     <input class="search-input" type="text" placeholder="Search  for Books, Movies, Music, and More" value="" name="query">
                     <input class="search-button" alt="search-button" type="image" value="Search" name="submit" src="<?php echo esc_url( get_template_directory_uri() );?>/assets/search-icon.png">
                     <div class="radio-area">
-                        <input class="catalog-search" type="radio" name="chooseone" value="catalog"> <label for="catalog">Catalog</label>
-                        <input class="main-search" type="radio" name="chooseone" value="site"> <label for="site">Site</label>
-                        <input class="event-search" type="radio" name="chooseone" value="events"> <label for="events">Events</label>
+                        <input class="catalog-search" type="radio" name="queryType" value="catalog"> <label for="catalog">Catalog</label>
+                        <input class="main-search" type="radio" name="queryType" value="site"> <label for="site">Site</label>
+                        <input class="event-search" type="radio" name="queryType" value="events"> <label for="events">Events</label>
                     </div>
                 </form>
             <?php } ?>