-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent_host_tools.html
More file actions
251 lines (231 loc) · 9.89 KB
/
event_host_tools.html
File metadata and controls
251 lines (231 loc) · 9.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
{% extends "./wrapper.html" %}
{% load actionkit_tags %}
{% block script_additions %}
<script type="text/javascript">
// Roster toggle-all checkbox
function toggleSignups() {
$(this)
.closest('form')
.find('input.toggle')
.attr('checked', this.checked);
}
// Update "N attendee(s)" in email form
function handleSignupsChanged() {
var frm = $(this).closest('form');
var to_count = $('input.toggle:checked').length;
// Mailing all recipients if nobody's checked
if ( !to_count )
to_count = $('input.toggle').length
// They've figured out the checkboxes; no need to advertise
if ( to_count )
frm.find('.check-recipients-help').hide();
frm.find('.to-count').text(to_count);
}
// Email button
function handleEmail() {
var frm = $(this).closest('form');
frm.find('.signup-list-controls').slideUp('fast');
frm.find('.contact-form').slideDown('fast', function() { $(this).css('overflow','visible');});
return false;
}
// "Email attendee", "email cohost", "invite friends" links
// Unhide if needed and fake :target on IE
function handleJumpLink() {
var targetEl;
if ( this.id == 'email-cohosts-link' )
targetEl = $('div.contact-cohosts');
else if ( this.id == 'email-attendees-link' )
targetEl = $('div.contact-attendees');
else if ( this.id == 'invite-friends-link' )
targetEl = $('#taf');
// console.log(targetEl);
// Unhide email form if needed
if ( /^email-/.test(this.id) ) {
var emailButton = targetEl.closest('form').find('input[type="submit"].email');
handleEmail.apply(emailButton, []);
}
// Highlight
targetEl.addClass('target');
// Allow jump to #foo to happen
return true;
}
// Confirm cancelling event
function confirmSubmit() {
return confirm($(this).attr('confirm-message'));
}
// Stash the name of the submit button in the 'action' form field
// (helps the validation JS see which kind of action to validate for)
function setFormAction() {
var formEl = $(this).closest('form')[0];
if ( !formEl && !formEl.action ) return;
formEl.action.value = this.name;
}
// Check for required fields for remove/promote/demote/email
function validateRoster(form) {
var action = form.action.value;
// Nobody to remove/promote/demote
if ( /(change-role|remove)/.test(action)
&& !($(form).find('input.toggle:checked').length) )
actionkit.errors['user_id:missing'] =
actionkit.forms.errorMessage('event_roster_user_ids:missing');
// No message to send
if ( action == 'send_email'
&& !form.body.value )
actionkit.errors['body:missing'] =
actionkit.forms.errorMessage('event_contact_body:missing');
}
// Confirm removing folks
function confirmRoster(form) {
var action = form.action.value;
var actionButton = $(form).find('input[name="' + action + '"]');
var confirmMessage = actionButton.attr('confirm-message');
if ( confirmMessage )
return confirm(confirmMessage);
else
return true;
}
// Click anywhere in row to check/uncheck attendee
function toggleRow(e) {
var toggleEl = $(this).closest('tr').find('.toggle')[0];
if ( toggleEl ) toggleEl.checked = !toggleEl.checked;
return false;
}
// Update the confirmation div from a different page
function updateConfirmationMessage() {
for (var key in actionkit.args) {
if (key.indexOf(':') > 0 && actionkit.args[key] == 1) {
$('#ak-confirmation').text(actionkit.forms.text['error_' + key]);
$('#ak-confirmation').show();
}
}
}
// Set everything up onready
function initHostTools() {
$('input.toggle-all').click(toggleSignups);
$('input.toggle').click(handleSignupsChanged);
$('.signup-list td:not(.toggle-col)').click(toggleRow);
$('input[type="submit"].email').click(handleEmail);
$('input[type="submit"]').click(setFormAction);
$('.jump-link').click(handleJumpLink);
$('a[confirm-message]').click(confirmSubmit);
if ($('#manage-host').length)
actionkit.forms.initValidation('manage-host');
if ($('#manage-attendee').length)
actionkit.forms.initValidation('manage-attendee');
$(window).load(function() {
updateConfirmationMessage();
});
}
$(initHostTools);
</script>
{% endblock %}
{% block content %}
<div id="ak-confirmation" class="ak-confirmation">
</div>
{% if signup and not event.is_inactive %}
<!-- Title -->
<div class="ak-grid-row">
<div class="ak-grid-col ak-grid-col-12-of-12">
{% if campaign.use_title %}
<h2>{{ campaign.local_title }}: {{ event.title }}</h2>
{% else %}
<h2>{{ campaign.local_title }}: Event Tools</h2>
{% endif %}
<!-- Message from mothership -->
<div id="host-tools-intro">
{{ form.tools_text|safe }}
</div>
</div>
</div>
<div class="ak-grid-row ak-grid-row-inverted">
<div class="ak-grid-col ak-grid-col-4-of-12">
<!-- Tools -->
<div class="ak-bar-holder">
<div class="ak-bar ak-field-box" id="event-host-tools">
<h3>Manage Event</h3>
{% if event.is_awaiting_approval %}
<span class="ak-error">Note: this event is awaiting approval by staff.</span>
{% endif %}
<ul id="event-host-links">
{{ form.tools_sidebar|safe }}
{% if user_is_manager %}
<li>Logged in as a manager
{% if campaign.require_email_confirmation and not event.host_is_confirmed %}
<br> <a onclick="$.get('/event/{{campaign.local_name}}/{{event.id}}/modify/confirm/'); $(this).text('Confirmed');" href="#">Confirm event</a>
{% endif %}
</li>
{% endif %}
<li><a href="../../create/?action_id={{ action.id }}&update=1&want_prefill_data=1">Edit event details</a></li>
{% if cohosts %}
<li class="if-js"><a class="jump-link" id="email-cohosts-link" href="#contact-cohosts">Email cohost{{ cohosts|length|pluralize }}</a></li>
{% endif %}
{% if attendees %}
<li class="if-js"><a class="jump-link" id="email-attendees-link" href="#contact-attendees">Email attendee{{ attendees|length|pluralize }}</a></li>
{% else %}
<!-- Flag that the functionality will be there -->
<li class="if-js">
Email attendees<br>
(Available after people sign up for your event.)
</li>
{% endif %}
{% if event.is_open_for_signup and page.pagefollowup.send_taf %}
<li class="if-js"><a class="jump-link" id="invite-friends-link" href="#invite-friends">Invite friends</a></li>
{% endif %}
<li><a confirm-message="Really cancel event? This can't be undone." href="../cancel_event/">Cancel event</a></li>
<li><a href="/logout/">Log out</a></li>
</ul>
</div>
</div><!-- bar holder -->
</div><!-- span -->
<div class="ak-grid-col ak-grid-col-8-of-12">
<!-- Details -->
<div id="host-event-details ak-clearfix">
<h3>
Event Details
(<a class="ak-underline-on-hover" href="../../create/?action_id={{ action.id }}&update=1&want_prefill_data=1">Edit</a>)
</h3>
{% include "./event_host_details.html" %}
</div>
<!-- Cohost roster -->
{% if cohosts %}
{% with cohosts as signups %}
{% include "./event_roster.html" %}
{% endwith %}
{% endif %}
<!-- Guest roster -->
{% if attendees %}
{% with attendees as signups %}
{% include "./event_roster.html" %}
{% endwith %}
{% else %}
<!-- Optional no attendees message, e.g., "go use the Invite Folks tool at right" -->
{% endif %}
<!-- Invite -->
{% if event.is_open_for_signup %}
<div class="ak-margin-top-2 ak-clearfix">
{% include "./event_invite.html" %}
</div>
{% endif %}
</div>
</div>
{% else %}
<div class="ak-grid-row">
<div class="ak-grid-col ak-grid-col-12-of-12">
{% if event.is_inactive %}
<h3>This event is no longer active.</h3>
{% endif %}
{% if not signup %}
<h3>Sorry, you aren't currently signed up for this event.</h3>
<p>If you think this is a mistake, check that you cut-and-pasted the entire link to this page.</p>
{% endif %}
<div><a href="/event/{{ campaign.local_name }}/?akid={{args.akid}}&zip={{args.zip}}">Search for another event</a></div>
</div>
</div>
{% endif %}
{% endblock %}
{% block below_form %}
<script type="text/javascript">
actionkit.forms.contextRoot = '/context/';
actionkit.forms.initTafForm('taf');
</script>
{% endblock %}