Setting up jquery for venue select if the use_member_location checked
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 4 Nov 2016 19:49:42 +0000 (15:49 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 4 Nov 2016 19:49:42 +0000 (15:49 -0400)
If they pick the use_member_loction then set the venue and lock it to
that member. unlocking it when the uncheck the field.

views/front/events/frontAdd.html

index 1971598..ce95049 100644 (file)
@@ -5,7 +5,7 @@
 <form action="{$thisUrl}" method="post" enctype="multipart/form-data" name="frontAddForm" id="frontForm">
     {if $memberOnly && $memberContact}
         <input type="hidden" name="ref_type" value="{$memberContact.ref_type}" />
-        <input type="hidden" name="ref_dest" value="{$memberContact.ref_dest}" />
+        <input type="hidden" id="refDest" name="ref_dest" value="{$memberContact.ref_dest}" />
     {/if}
     <table id="glm-table-descr" class="glm-admin-table glm-event-table">
         <tr id="glmRealEmail">
@@ -16,7 +16,7 @@
             <tr>
                 <td> Member </td>
                 <td>
-                    <select name="ref_dest">
+                    <select id="refDest" name="ref_dest">
                         <option value="0">Choose Member</option>
                         {foreach $members as $m}
                         <option value="{$m.id}">{$m.name}</option>
                 <th></th>
                 <td>
                     <label>
-                        <input type="checkbox" name="use_member_location" value="1" />
+                        <input type="checkbox" id="useMemberLocation" name="use_member_location" value="1" />
                         Use {if $memberContact}your{else}{$terms.term_member}{/if} location
                     </label>
                 </td>
                     <input type="hidden" name="city" />
                     <input type="hidden" name="state" />
                     <input type="hidden" name="zip" />
-                    <select name="other_ref_dest">
+                    <select name="other_ref_dest" id="otherRefDest">
                         <option value="0">Choose Venue</option>
                         {foreach $venues as $m}
                             <option value="{$m.id}">{$m.name}</option>
     </table>
     <input class="button radius" id="newEvent" name='newEvent' type="submit" value="Add Event">
 </form>
+{if $settings.use_venue_locations}
+<script>
+jQuery(document).ready(function($) {
+    // setup memberId
+    $('#useMemberLocation').on('click', function(){
+        var memberId = $('#refDest').val();
+        if ( $(this).is(':checked') ) {
+            $('#otherRefDest').val(memberId);
+            // lock the venue
+            $('#otherRefDest option:not(:selected)').prop('disabled', true);;
+        } else {
+            $('#otherRefDest option').removeAttr('disabled');
+        }
+    });
+});
+</script>
+{/if}