allow toggle back to current/future events
authorAndrew Hunt <andrew@aghstrategies.com>
Fri, 9 Aug 2013 01:52:06 +0000 (21:52 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Fri, 9 Aug 2013 01:52:06 +0000 (21:52 -0400)
templates/CRM/Event/Form/Participant.tpl

index 34135b1b67b2309fb3dac422ebd0f2dc2996fcbf..20a6b81c8b36a1495f8d1349a7294e6d32233286 100644 (file)
           {/if}
           <tr class="crm-participant-form-block-event_id">
             <td class="label">{$form.event_id.label}</td><td class="view-value bold">{$form.event_id.html}&nbsp;
-            {if $action eq 1 && $past neq 1 }<span id='past-event-section'>
-              <br />&raquo; {ts}Include past event(s) in this select list:{/ts}
-              {if !$past}<a href="#" onclick="buildSelect('event_id', 2); return false;" class='3-mo-past-event'>{ts}past three months{/ts}</a> <span class='3-mo-past-event'>|</span>{/if}
-              <a href="#" onclick="buildSelect('event_id', 1); return false;">{ts}all{/ts}</a></span>
+            {if $action eq 1}<span id='past-event-section'>
+              <br />&raquo; <span id="showing-event-info"></span>
             {/if}
             {if $is_test}
               {ts}(test){/ts}
         for (i = 0; i < response.length; i++) {
           cj( elementID ).get(0).add(new Option(response[i].name, response[i].value), document.all ? i : null);
         }
-        if (listallVal == 1) {
-          cj('#past-event-section').hide( );
-        }
-        else {
-          cj('.3-mo-past-event').hide( );
-        }
+        getShowEventInfo(listallVal);
         cj('input[name="past_event"]').val(listallVal);
         cj("#feeBlock").html( '' );
       });
     }
+
+    {/literal}
+    {if $action eq 1}getShowEventInfo({$past});{/if}
+    {literal}
+
+    function getShowEventInfo (listallVal) {
+      switch(listallVal) {
+        case 1:
+          cj('#showing-event-info').html({/literal}'{ts}Showing all events: show{/ts}'{literal}+' <a href="#" onclick="buildSelect(\'event_id\', 0); return false;">'+{/literal}'{ts}current and future{/ts}'{literal}+'</a> | <a href="#" onclick="buildSelect(\'event_id\', 2); return false;">'+{/literal}'{ts}past three months{/ts}'{literal}+'</a>');
+          break;
+        case 2:
+          cj('#showing-event-info').html({/literal}'{ts}Showing events since three months ago: show{/ts}'{literal}+' <a href="#" onclick="buildSelect(\'event_id\', 0); return false;">'+{/literal}'{ts}current and future{/ts}'{literal}+'</a> | <a href="#" onclick="buildSelect(\'event_id\', 1); return false;">'+{/literal}'{ts}all{/ts}'{literal}+'</a>');
+          break;
+        default:
+          cj('#showing-event-info').html({/literal}'{ts}Showing current and future events: show{/ts}'{literal}+' <a href="#" onclick="buildSelect(\'event_id\', 2); return false;">'+{/literal}'{ts}past three months{/ts}'{literal}+'</a> | <a href="#" onclick="buildSelect(\'event_id\', 1); return false;">'+{/literal}'{ts}all{/ts}'{literal}+'</a>');
+          break;
+      }
+    }
     {/literal}
 
     {if $preloadJSSnippet}