-
Notifications
You must be signed in to change notification settings - Fork 8
/
lte.html
327 lines (283 loc) · 12.8 KB
/
lte.html
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
{% extends "./wrapper.html" %}
{% load actionkit_tags %}
{% block script_additions %}
<script type="text/javascript">
function toggleChooser(on) {
var name,
to_row = $("#to_target_row"),
media_target = $("#media_target"),
lte_letter = $('#lte-letter, #lte-submit');
if (on) {
media_target.fadeIn('fast');
//lte_letter.fadeOut('fast');
to_row.fadeOut('fast');
$("input[name=media_target]:checked").attr('checked', false);
} else {
media_target.fadeOut('fast');
lte_letter.fadeIn('fast');
to_row.fadeIn('slow');
name = $("input[name=media_target]:checked").closest(".ak-newspaper-row").find('.ak-newspaper-title a').html();
$("#to_target_name").html("Editor, " + name);
$("html body").scrollTop($("form.ak-form").position().top);
}
}
// adapted from http://blog.themeforest.net/tutorials/creating-a-jquery-word-counter/
function countWords(textarea) {
//console.log('count words running');
var countControl = ( '' + $(textarea).data('wordcount') ).split(',');
var minWords = 0;
var maxWords = 0;
if(countControl.length > 1) {
minWords = countControl[0];
maxWords = countControl[1];
} else {
maxWords = countControl[0];
}
var countArea = $(textarea).siblings(".ak-counter-area");
var countDigits = countArea.children('.ak-counter-words');
var update_func = function() {
// console.log('countWords update_func');
var numWords = jQuery.trim($(textarea).val()).split(/\s+/).length;
if($(textarea).val() === '') {
numWords = 0;
}
countDigits.text(numWords);
if(numWords < minWords || (numWords > maxWords && maxWords != 0)) {
countDigits.addClass('ak-color-error');
} else {
countDigits.removeClass('ak-color-error');
}
};
update_func();
$(textarea).bind('keyup click blur focus change paste', update_func);
}
function abbreviate(name, maxLength) {
return name.length <= maxLength ?
name : name.substring(0, maxLength - 3) + "...";
}
$(window).load( function() {
$('.ak-accordion ul li').children(':not(.ak-accordion-head)').hide();
$(".ak-accordion .ak-accordion-head").on('click', function() {
var section = $(this).parent();
section.toggleClass('active');
section.children(':not(.ak-accordion-head)').slideToggle();
} );
$('.ak-accordion .ak-accordion-head').append(
'<span class="ak-arrow-holder"><span class="ak-arrow"></span></span>'
);
$("input[name=media_target]").change( function() {
toggleChooser(false);
return false;
} );
$('#ak-newspaper-change').click( function() {
toggleChooser(true);
return false;
} );
/*If there is an error on form submission, make sure the page reloads to stay on the form*/
if ($('ul.compact:contains("letter")').length){
toggleChooser(false);
}
} );
</script>
{% endblock %}
{% block content %}
{% load_remember_me %}
<form class="ak-form" name="act" method="POST" action="/act/" accept-charset="utf-8">
<input type="hidden" name="page" value="{{ page.name }}">
<div class="ak-grid-row">
<div class="ak-grid-col ak-grid-col-12-of-12">
<h2>{{ page.title }}</h2>
</div>
</div>
<div class="ak-grid-row">
<div class="ak-grid-col ak-grid-col-6-of-12">
{% if page.custom_fields.featured_image %}
<img class="ak-featured-img" src="{{page.custom_fields.featured_image}}">
{% endif %}
<div class="ak-styled-description ak-text-expander">
{% include_tmpl form.introduction_text %}
</div>
<a href="#" class="ak-read-more ak-mobile" data-lines="10">Read more</a>
<div id="lte-prelim"></div>
<div id="ak-lte-help" class="ak-accordion"></div>
<script type="text/ak-template" for="ak-lte-help">
<ul>
{% if form.talking_points %}
<li>
<div class="ak-accordion-head">
Talking Points
</div>
<div>
{% include_tmpl form.talking_points %}
</div>
</li>
{% endif %}
{% if form.writing_tips %}
<li>
<div class="ak-accordion-head">
Writing Tips
</div>
<div>
{% include_tmpl form.writing_tips %}
</div>
</li>
{% endif %}
{% for letter in form.cannedletter_set.all %}
<li>
<div class="ak-accordion-head">
Sample: {{ letter.subject|truncateletters:"20" }}
</div>
<div>
{% if letter.subject|length > 20 %}
<p><b>{{letter.subject}}</b></p>
{% endif %}
{{letter.letter_text|linebreaks}}
</div>
</li>
{% endfor %}
</ul>
</script>
</div>
<div class="ak-grid-col ak-grid-col-6-of-12">
{% include "./progress_meter.html" %}
<div class="ak-styled-fields {{templateset.custom_fields.field_labels_class|default:"ak-labels-overlaid"}} {{templateset.custom_fields.field_errors_class|default:"ak-errs-below"}}">
<div id="ak-need-contact-info"></div>
<script type="text/ak-template" for="ak-need-contact-info">
[% if (incomplete) { %]
<div class="ak-instructions ak-faded-text">
{% filter ak_text:"lte_needs_contact_info" %}
Please enter your information so we can find newspapers for you to contact.
{% endfilter %}
</div>
[% } %]
</script>
{% include "./user_form_wrapper.html" %}
</div>
<div id="media_target"></div>
<script type="text/ak-template" for="media_target">
[% if (!incomplete) { %]
<p>Choose a newspaper to send a letter to:</p>
[%
var headers = {
"local": "Local Newspapers",
"regional": "Regional Newspapers",
"national": "National Newspapers"
};
var mediaTargets = actionkit.context.mediaTargets || {};
var mediaTargetTypes = ['national', 'regional', 'local'];
for (var j = 0; j < mediaTargetTypes.length; j++) {
var mediaTargetType = mediaTargetTypes[j];
var targetsOfType = mediaTargets[mediaTargetType];
if (targetsOfType) {
%]
<div class="ak-newspaper">
<h3>[%=headers[mediaTargetType]%]</h3>
</div>
[%
var shade = true;
for (var i = 0; i < targetsOfType.length; i++) {
var mediaTarget = targetsOfType[i],
targetId = "media_target_" + mediaTarget.id,
name = abbreviate(mediaTarget.name, 30),
label = "<a>" + name + "</a>";
if (mediaTarget.website_url) {
label = "<a class=\"ak-highlight-on-hover\" target=\"_blank\" href=\"" + mediaTarget.website_url + "\">" + name + "</a>";
}
shade = !shade;
%]
<div class="[%= shade ? "ak-alternate-row" : "" %] ak-newspaper-row">
<div class="ak-newspaper-title">[%=label%]</div>
<div>
<label class="ak-button ak-newspaper-choice" for="[%=targetId%]">
<input class="media_target" id="[%=targetId%]" value="[%=mediaTarget.id%]" type="radio" name="media_target">
Select
</label>
</div>
<div class="ak-faded-text">
<div class="number">
<strong>Circulation:</strong>
[%= actionkit.utils.add_commas(mediaTarget.circulation) %]
</div>
[% if (actionkit.context.show_phones && mediaTarget.phone) { %]
<div class="nowrap">
<strong>Phone:</strong>
[%=mediaTarget.phone%]
</div>
[% } %]
<div class="number">
<strong>Sent:</strong>
[%=mediaTarget.sent%]
</div>
</div>
</div>
[%
}
}
}
} %]
</script>
<div id="lte-letter" style="display: none;"></div>
<script type="text/ak-template" for="lte-letter">
[% if (!incomplete) { %]
<table class="ak-styled-fields ak-message-form">
<tr id="to_target_row">
<th>
<label>
To
</label>
</th>
<td>
<div class="ak-readonly-value">
<span id="to_target_name"></span>
<a id="ak-newspaper-change" href="#">Change</a>
</div>
</td>
</tr>
<tr>
<th>
<label for="letter_subject" >
Subject
</label>
</th>
<td>
<input id="letter_subject" type="text" name="subject" size="40">
</td>
</tr>
<tr>
<th>
<label for="letter_text" >
Message
</label>
</th>
<td>
<textarea id="letter_text" name="letter_text" class="ak-large-message" data-wordcount="250,350"></textarea>
<div class="ak-counter-area">
<span style="font-weight: bold" class="ak-counter-words">0</span> Words.
Most newspapers only consider letters of 250 to 350 words.
</div>
</td>
</tr>
<tr>
<th> </th>
<td>Your name, address and phone number will be added as a signature.</td>
</tr>
</table>
[% } %]
</script>
<div id="lte-submit">
<button type="submit" class="ak-submit-button">Submit</button>
</div>
</div>
</div>
</form>
<div id="na"></div>
<script type="text/ak-template" for="na">
[%
/* Done inside an ak-template to ensure this executes after other ak-templates. */
if (!incomplete) {
countWords($("[data-wordcount]")[0]);
$('#lte-submit').hide()
}
%]
</script>
{% endblock %}