summaryrefslogtreecommitdiffstats
path: root/askbot/skins/default/templates/question.html
blob: 637f8afba7d2310a8effad900a224419d30432d4 (plain)
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
{% extends "two_column_body.html" %}
{% import "macros.html" as macros %}
<!-- question.html -->
{% block title %}{% spaceless %}{{ question.get_question_title() }}{% endspaceless %}{% endblock %}
{% block meta_description %}
        <meta name="description" content="{{question.summary|striptags|escape}}" />
{% endblock %}
{% block keywords %}{{question.tagname_meta_generator()}}{% endblock %}
{% block forestyle %}
    <link rel="canonical" href="{{settings.APP_URL}}{{question.get_absolute_url()}}" />
    <link rel="stylesheet" type="text/css" href="{{'/js/wmd/wmd.css'|media}}" />
{% endblock %}
{% block content %}
<h1><a href="{{ question.get_absolute_url() }}">{{ question.get_question_title() }}</a></h1>
<table style="width:100%;" id="question-table" {% if question.deleted %}class="deleted"{%endif%}>
    <tr>
        <td style="width:30px;vertical-align:top">
            <div class="vote-buttons">
                {% if question_vote %}
                <img id="question-img-upvote-{{ question.id }}" class="question-img-upvote" 
                    {% if question_vote.is_upvote() %}
                        src="{{'/images/vote-arrow-up-on.png'|media}}" 
                    {% else %}
                        src="{{'/images/vote-arrow-up.png'|media}}"
                    {% endif %}
                    alt="{% trans %}i like this post (click again to cancel){% endtrans %}"
                    title="{% trans %}i like this post (click again to cancel){% endtrans %}" />
                <div id="question-vote-number-{{ question.id }}" class="vote-number" 
                    title="{% trans %}current number of votes{% endtrans %}">
                    {{ question.score }}
                </div>
                <img id="question-img-downvote-{{ question.id }}" class="question-img-downvote" 
                    {% if question_vote.is_downvote() %}
                        src="{{'/images/vote-arrow-down-on.png'|media}}" 
                    {% else %}
                        src="{{'/images/vote-arrow-down.png'|media}}" 
                    {% endif %}
                    alt="{% trans %}i dont like this post (click again to cancel){% endtrans %}"
                    title="{% trans %}i dont like this post (click again to cancel){% endtrans %}" />
                {% else %}
                <img id="question-img-upvote-{{ question.id }}" class="question-img-upvote" 
                    alt="{% trans %}i like this post (click again to cancel){% endtrans %}"
                    src="{{'/images/vote-arrow-up.png'|media}}" 
                    title="{% trans %}i like this post (click again to cancel){% endtrans %}" />
                <div id="question-vote-number-{{ question.id }}" class="vote-number" 
                    title="{% trans %}current number of votes{% endtrans %}">
                    {{ question.score }}
                </div>
                <img id="question-img-downvote-{{ question.id }}" class="question-img-downvote" 
                    src="{{'/images/vote-arrow-down.png'|media}}"
                    alt="{% trans %}i dont like this post (click again to cancel){% endtrans %}"
                    title="{% trans %}i dont like this post (click again to cancel){% endtrans %}" />
                {% endif %}
                
                {% if settings.ENABLE_SHARING_TWITTER %}{{ macros.share(site = 'twitter', icon = True) }}{% endif %}
                {% if settings.ENABLE_SHARING_FACEBOOK %}{{ macros.share(site = 'facebook', icon = True) }}{% endif %}
                {% if settings.ENABLE_SHARING_LINKEDIN %}{{ macros.share(site = 'linkedin', icon = True) }}{% endif %}
                {% if settings.ENABLE_SHARING_IDENTICA %}{{ macros.share(site = 'identica', icon = True) }}{% endif %}
                {% if settings.ENABLE_SHARING_GOOGLE %}<g:plusone size="small" count="false"></g:plusone>{% endif %}
            </div>
        </td>
        <td>
            <div class="question-body">
                {{question.html}}
            </div>
            <ul id="question-tags" class="post-tags tags">
                {% for tag in question.get_tag_names() %}
                    {{ macros.tag_widget(
                            tag,
                            css_class = 'post-tag',
                            html_tag = 'li'
                        )
                    }}
                {% endfor %}
            </ul>
            <div id="question-controls" class="post-controls">
                {% set pipe=joiner('<span class="sep">|</span>') %}
                {% if request.user|can_edit_post(question) %}{{ pipe() }}
                    <a href="{% url edit_question question.id %}">{% trans %}edit{% endtrans %}</a>
                {% endif %}
                {% if request.user|can_retag_question(question) %}{{ pipe() }}
                    <a id="retag" href="{% url retag_question question.id %}">{% trans %}retag{% endtrans %}</a>
                    <script type="text/javascript">
                        var retagUrl = "{% url retag_question question.id %}";
                    </script>
                {% endif %}
                {% if question.closed %}
                    {% if request.user|can_reopen_question(question) %}{{ pipe() }}
                    <a href="{% url reopen question.id %}">{% trans %}reopen{% endtrans %}</a>
                    {% endif %}
                {% else %}
                    {% if request.user|can_close_question(question) %}{{ pipe() }}
                    <a href="{% url close question.id %}">{% trans %}close{% endtrans %}</a>
                    {% endif %}
                {% endif %}
                {% if request.user|can_flag_offensive(question) %}{{ pipe() }}
                <span id="question-offensive-flag-{{ question.id }}" class="offensive-flag" 
                    title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}">
                    <a>{% trans %}flag offensive{% endtrans %}</a>
                    {% if request.user|can_see_offensive_flags(question) %}
                        <span class="darkred">{% if question.offensive_flag_count > 0 %}({{ question.offensive_flag_count }}){% endif %}</span>
                    {% endif %}
                </span>
                {% endif %}
                {% if request.user|can_delete_post(question) %}{{ pipe() }}
                    <a id="question-delete-link-{{question.id}}">{% if question.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %}</a>
                {% endif %}
            </div>
            <div class="post-update-info-container">
                    {{ 
                        macros.post_contributor_info(
                                        question,
                                        "original_author",
                                        question.wiki,
                                        settings.MIN_REP_TO_EDIT_WIKI
                                    )
                    }}
                    {{ 
                        macros.post_contributor_info(
                                        question,
                                        "last_updater",
                                        question.wiki,
                                        settings.MIN_REP_TO_EDIT_WIKI,
                                    )
                    }}
            </div>
            {{
                macros.post_comments_widget(
                        post = question,
                        show_post = show_post,
                        show_comment = show_comment,
                        comment_order_number = comment_order_number,
                        user = request.user,
                        max_comments = settings.MAX_COMMENTS_TO_SHOW
                    )
            }}
            <!--/div-->
        </td>
    </tr>
</table>
{% if question.closed %}
<div class="question-status" style="margin-bottom:15px">
<h3>{% trans close_reason=question.get_close_reason_display() %}The question has been closed for the following reason "{{ close_reason }}" by{% endtrans %} 
<a href="{{ question.closed_by.get_profile_url() }}">{{ question.closed_by.username }}</a> 
{% trans closed_at=question.closed_at %}close date {{closed_at}}{% endtrans %}</h3>
</div>
{% endif %}
{% if answers %}
    <div class="tabBar">
        <h2 id="sort-top">
        {% trans counter=answers|length %}
        {{counter}} Answer:
        {% pluralize %}
        {{counter}} Answers:
        {% endtrans %}
        </h2>
        <div class="tabsA">
            <a id="oldest" href="{{ question.get_absolute_url() }}?sort=oldest#sort-top" 
                title="{% trans %}oldest answers will be shown first{% endtrans %}"
            ><span>{% trans %}oldest answers{% endtrans %}</span></a>
            <a id="latest" href="{{ question.get_absolute_url() }}?sort=latest#sort-top" 
                title="{% trans %}newest answers will be shown first{% endtrans %}"
            ><span>{% trans %}newest answers{% endtrans %}</span></a>
            <a id="votes" href="{{ question.get_absolute_url() }}?sort=votes#sort-top" 
                title="{% trans %}most voted answers will be shown first{% endtrans %}"
            ><span>{% trans %}popular answers{% endtrans %}</span></a>   
        </div>
    </div>
    {{ macros.paginator(paginator_context) }}

    {% for answer in answers %}
        <a name="{{ answer.id }}"></a>
        <div id="answer-container-{{ answer.id }}" class="answer {% if answer.accepted %}accepted-answer{% endif %} {% if answer.author_id==question.author_id %} answered-by-owner{% endif %} {% if answer.deleted %}deleted{% endif %}">
            <table style="width:100%;" class="answer-table">
                <tr>
                    <td style="width:30px;vertical-align:top">
                        <div class="vote-buttons">
                            <img id="answer-img-upvote-{{ answer.id }}" class="answer-img-upvote" 
                                {% if user_answer_votes[answer.id] == 1 %}
                                    src="{{'/images/vote-arrow-up-on.png'|media}}" 
                                {% else %}
                                    src="{{'/images/vote-arrow-up.png'|media}}" 
                                {% endif %}
                                alt="{% trans %}i like this answer (click again to cancel){% endtrans %}"
                                title="{% trans %}i like this answer (click again to cancel){% endtrans %}"/>
                            <div id="answer-vote-number-{{ answer.id }}" class="vote-number" title="{% trans %}current number of votes{% endtrans %}">
                                {{ answer.score }}
                            </div>
                            <img id="answer-img-downvote-{{ answer.id }}" class="answer-img-downvote" 
                                {% if user_answer_votes[answer.id] == -1 %}
                                    src="{{'/images/vote-arrow-down-on.png'|media}}" 
                                {% else %}
                                    src="{{'/images/vote-arrow-down.png'|media}}" 
                                {% endif %}
                                alt="{% trans %}i dont like this answer (click again to cancel){% endtrans %}"
                                title="{% trans %}i dont like this answer (click again to cancel){% endtrans %}" />
                            {% if request.user == question.author %}
                            <img id="answer-img-accept-{{ answer.id }}" class="answer-img-accept" 
                                {% if answer.accepted %}
                                    src="{{'/images/vote-accepted-on.png'|media}}"
                                {% else %}
                                    src="{{'/images/vote-accepted.png'|media}}" 
                                {% endif %}
                                alt="{% trans %}mark this answer as favorite (click again to undo){% endtrans %}"
                                title="{% trans %}mark this answer as favorite (click again to undo){% endtrans %}" />
                            {% else %}
                                {% if answer.accepted %}
                                <img id="answer-img-accept-{{ answer.id }}" class="answer-img-accept" 
                                    {% if answer.accepted %}
                                        src="{{'/images/vote-accepted-on.png'|media}}"
                                    {% else %}
                                        src="{{'/images/vote-accepted.png'|media}}"
                                    {% endif %}
                                    alt="{% trans question_author=question.author.username %}{{question_author}} has selected this answer as correct{% endtrans %}"
                                    title="{% trans questsion_author=question.author.username%}{{question_author}} has selected this answer as correct{% endtrans %}"
                                {% endif %}
                            {% endif %}
                        </div>
                    </td>
                    <td>
                        <div class="item-right">
                            <div class="answer-body">
                                {{ answer.html }}
                            </div>
                            <div class="answer-controls post-controls">
                                {% set pipe=joiner('<span class="sep">|</span>') %}
                                <span class="linksopt">{{ pipe() }}
                                    <a 
                                        href="{{ answer.get_absolute_url() }}" 
                                        title="{% trans %}answer permanent link{% endtrans %}">
                                        {% trans %}permanent link{% endtrans %}
                                    </a>
                                </span>
                                {% if request.user|can_edit_post(answer) %}{{ pipe() }}
                                <span class="action-link"><a href="{% url edit_answer answer.id %}">{% trans %}edit{% endtrans %}</a></span>
                                {% endif %}
                                {% if request.user|can_flag_offensive(answer) %}{{ pipe() }}
                                <span id="answer-offensive-flag-{{ answer.id }}" class="offensive-flag" 
                                    title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}">
                                    <a>{% trans %}flag offensive{% endtrans %}</a>
                                    {% if request.user|can_see_offensive_flags(answer) %}
                                        <span class="darkred">{% if answer.offensive_flag_count > 0 %}({{ answer.offensive_flag_count }}){% endif %}</span>
                                    {% endif %}
                                </span>
                                {% endif %}
                                {% if request.user|can_delete_post(answer) %}{{ pipe() }}
                                    {% spaceless %}
                                    <span class="action-link">
                                        <a id="answer-delete-link-{{answer.id}}">
                                        {% if answer.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %}</a>
                                    </span>
                                    {% endspaceless %}
                                {% endif %}
                                {% if settings.ALLOW_SWAPPING_QUESTION_WITH_ANSWER and request.user.is_authenticated() and request.user.is_administrator_or_moderator() %}{{ pipe() }}
                                    <span class="action-link">
                                        <a id="swap-question-with-answer-{{answer.id}}">{% trans %}swap with question{% endtrans %}</a>
                                    </span>
                                {% endif %}
                            </div>
                            <div class="post-update-info-container">
                                    {{
                                        macros.post_contributor_info(
                                            answer,
                                            "original_author",
                                            answer.wiki,
                                            settings.MIN_REP_TO_EDIT_WIKI
                                        )
                                    }}
                                    {{ 
                                        macros.post_contributor_info(
                                            answer,
                                            "last_updater",
                                            answer.wiki,
                                            settings.MIN_REP_TO_EDIT_WIKI
                                        )
                                    }}
                            </div>
                            {{
                                macros.post_comments_widget(
                                        post = answer,
                                        show_post = show_post,
                                        show_comment = show_comment,
                                        comment_order_number = comment_order_number,
                                        user = request.user,
                                        max_comments = settings.MAX_COMMENTS_TO_SHOW
                                    )
                            }}
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    {% endfor %}
    {{ macros.paginator(paginator_context) }}
{% else %}
    {% set question_url=settings.APP_URL+question.get_absolute_url()|urlencode %}
    <h2 class="share-question">{% trans %}Know someone who can answer?  Share a <a href="{{ question_url }}">link</a> to this question via{% endtrans %}
        {% if settings.ENABLE_SHARING_TWITTER %}{{ macros.share(site = 'twitter', site_label = 'Twitter') }},{% endif %}
        {% if settings.ENABLE_SHARING_FACEBOOK %}{{ macros.share(site = 'facebook', site_label = 'Facebook') }},{% endif %}
        {% if settings.ENABLE_SHARING_LINKEDIN %}{{ macros.share(site = 'linkedin', site_label = 'LinkedIn') }},{% endif %}
        {% if settings.ENABLE_SHARING_IDENTICA %}{{ macros.share(site = 'identica', site_label = 'Identi.ca') }},{% endif %}
        {%- if settings.ENABLE_SHARING_TWITTER or settings.ENABLE_SHARING_FACEBOOK or settings.ENABLE_SHARING_LINKEDIN or settings.ENABLE_SHARING_IDENTICA -%}
            {% trans %} or{% endtrans %}
        {% endif %}
        <a href="mailto:?subject={{ settings.APP_SHORT_NAME|urlencode }}&amp;body={{ question_url }}">{% trans %}email{% endtrans %}</a>.
    </h2>
{% endif %}
<form id="fmanswer" action="{% url answer question.id %}" method="post">{% csrf_token %}
    {% if request.user.is_authenticated() %}
        <p style="padding-left:3px">
        {{ answer.email_notify }} 
        <label for="question-subscribe-updates">
        {% set email_feed_frequency = request.user.get_followed_question_alert_frequency() %}
        {% if email_feed_frequency =='n' %}
            {% trans %}Notify me once a day when there are any new answers{% endtrans %}
        {% elif email_feed_frequency =='d' %}
            {% trans %}Notify me once a day when there are any new answers{% endtrans %}
        {% elif email_feed_frequency =='w' %}
            {% trans %}Notify me weekly when there are any new answers{% endtrans %}
        {% elif email_feed_frequency =='i' %}
            {% trans %}Notify me immediately when there are any new answers{% endtrans %}
        {% endif %}
        </label>
        {% trans profile_url=request.user.get_profile_url() %}You can always adjust frequency of email updates from your {{profile_url}}{% endtrans %}
        </p>
    {% else %}
        <p style="padding-left:3px">
            {{ answer.email_notify }} 
            <label>{% trans %}once you sign in you will be able to subscribe for any updates here{% endtrans %}</label>
        </p>
    {% endif %}
    <div style="clear:both">
    </div>
    {% if request.user.is_anonymous() and settings.ALLOW_POSTING_BEFORE_LOGGING_IN == False %}
        {% if not question.closed %}
            <a 
                class="submit"
                href="{{settings.LOGIN_URL}}?next={% url question question.id %}"
            >{% trans %}Login/Signup to Answer{% endtrans %}</a>
        {% endif %}
    {% else %}
        {% if not question.closed %}
            <div style="padding:10px 0 0 0;">
                {% spaceless %}
                <h2>
                    {% if answers %}
                        {% trans %}Your answer{% endtrans %}
                    {% else %}
                        {% trans %}Be the first one to answer this question!{% endtrans %}
                    {% endif %}
                </h2>
                {% endspaceless %}
            </div>
            {% if request.user.is_anonymous() %}
                <div class="message">{% trans %}you can answer anonymously and then login{% endtrans %}</div>
            {% else %}
                <p class="message">
                    {% if request.user==question.author  %}
                        {% trans %}answer your own question only to give an answer{% endtrans %}
                    {% else %}
                        {% trans %}please only give an answer, no discussions{% endtrans %}
                    {% endif %}
                </p>
            {% endif %}
            {{ macros.edit_post(answer) }}
            <input type="submit" 
                {% if user.is_anonymous() %}
                    value="{% trans %}Login/Signup to Post Your Answer{% endtrans %}" 
                {% else %}
                    {% if user == question.author %}
                        value="{% trans %}Answer Your Own Question{% endtrans %}" 
                    {% else %}
                        value="{% trans %}Answer the question{% endtrans %}" 
                    {% endif %}
                {% endif %}
                class="submit after-editor" style="float:left"/>
                {% if settings.WIKI_ON %}
                    {{ macros.checkbox_in_div(answer.wiki) }}
                {% endif %}
        {% endif %}
    {% endif %}
    </form>
{% endblock %}

{% block sidebar %}

{{ settings.SIDEBAR_QUESTION_HEADER }}
<div class="boxC vote-buttons">
    <h2 style="font-size: 22px;margin-top: 11px; text-align: left;">{% trans %}Question tools{% endtrans %}</h2>
    {% if favorited %}
        <a class="button followed" 
            alt="{% trans %}click to unfollow this question{% endtrans %}">
            <div>{% trans %}Following{% endtrans %}</div>
            <div class='unfollow'>{% trans %}Unfollow{% endtrans %}</div>
        </a>
    {% else %}
        <a class="button follow"
            alt="{% trans %}click to follow this question{% endtrans %}">
            {%trans %}Follow{%endtrans%}
        </a>
    {% endif %}
    <div class="clearfix"></div>
    <div id="favorite-number" class="favorite-number{% if favorited %} my-favorite-number{% endif %}">
        {% set follower_count = question.favourite_count %}
        {% if follower_count > 0 %}
            {% trans count=follower_count %}{{count}} follower{% pluralize %}{{count}} followers{% endtrans %}
        {% endif %}
    </div>
<div class="notify-sidebar">
    {%if request.user.is_authenticated() %}
    <input type="checkbox" id="question-subscribe-sidebar"/>
    <label for="question-subscribe-sidebar">{% trans %}email the updates{% endtrans %}</label>
    {%else%}
    <input type="checkbox" id="question-subscribe-sidebar"/>
    <label for="question-subscribe-sidebar">{% trans %}<strong>Here</strong> (once you log in) you will be able to sign up for the periodic email updates about this question.{% endtrans %}</label>
    {%endif%}
    </div> 
</div>
{% cache 0 "questions_tags" questions_tags question.id language_code %}
{% if settings.SIDEBAR_QUESTION_SHOW_TAGS %}
    <div class="boxC">
        <div class="clearfix"></div>
        <h2>
            {% trans %}Question tags{% endtrans %}:
        </h2>
        <ul id="related-tags" class="tags">
            {% for tag in tags %}
            <li>
                {{ macros.tag_widget(
                        tag,
                        html_tag = 'div',
                        url_params = 'start_over=true',
                        extra_content = '<span class="tag-number">&#215; ' ~
                            tag.used_count|intcomma ~ '</span>'
                    )
                }}
            </li>
            {% endfor %}
        </ul>
    </div>
{% endif %}

{% if settings.SIDEBAR_QUESTION_SHOW_META %}
<div class="boxC">
    <div class="clearfix"></div>
    <h2>{% trans %}Stats:{% endtrans %}</h2>
    <p>
        {% trans %}question asked{% endtrans %}: <strong title="{{ question.added_at }}">{{question.added_at|diff_date}}</strong>
    </p>
    <p> 
        {% trans %}question was seen{% endtrans %}: <strong>{{ question.view_count|intcomma }} {% trans %}times{% endtrans %}</strong>
    </p>
    <p>
        {% trans %}last updated{% endtrans %}: <strong title="{{ question.last_activity_at }}">{{question.last_activity_at|diff_date}}</strong>
    </p>
</div>
{% endif %}
{% endcache %}

{% if similar_questions.data and settings.SIDEBAR_QUESTION_SHOW_RELATED %}
    {#% cache 1800 "related_questions" related_questions question.id language_code %#}
    <div class="boxC">
        <h2>{% trans %}Related questions{% endtrans %}</h2>
        <div class="questions-related">
            {% for question in similar_questions.data() %}
            <p>
                <a href="{{ question.get_absolute_url() }}">{{ question.get_question_title() }}</a>
            </p>
            {% endfor %}
        </div>
    </div>
    {#% endcache %#}
{% endif %}

{{ settings.SIDEBAR_QUESTION_FOOTER }}

{% endblock %}
{% block endjs %}
    {% if not question.closed %}
        <script type='text/javascript' src='{{"/js/editor.js"|media}}'></script>
        <script type='text/javascript'>
            {% if settings.ENABLE_MATHJAX or settings.MARKUP_CODE_FRIENDLY %}
            var codeFriendlyMarkdown = true;
            {% else %}
            var codeFriendlyMarkdown = false;
            {% endif %}
            var maxCommentLength = {{settings.MAX_COMMENT_LENGTH}};
            askbot['urls']['postComments'] = '{% url post_comments %}';
            askbot['urls']['editComment'] = '{% url edit_comment %}';
            askbot['urls']['deleteComment'] = '{% url delete_comment %}';
            askbot['urls']['getComment'] = '{% url get_comment %}';
            askbot['urls']['question_url_template'] = scriptUrl + '{% trans %}question/{% endtrans %}{{ "{{QuestionID}}/{{questionSlug}}" }}';{# yes it needs to be that whacky #}
            askbot['urls']['user_signin'] = '{{ settings.LOGIN_URL }}';
            askbot['urls']['vote_url_template'] = scriptUrl + '{% trans %}questions/{% endtrans %}{{ "{{QuestionID}}/" }}{% trans %}vote/{% endtrans %}';
            askbot['urls']['swap_question_with_answer'] = '{% url swap_question_with_answer %}';
            askbot['urls']['upvote_comment'] = '{% url upvote_comment %}';
            askbot['messages']['addComment'] = '{% trans %}add comment{% endtrans %}';
            {% if settings.SAVE_COMMENT_ON_ENTER %}
                askbot['settings']['saveCommentOnEnter'] = true;
            {% else %}
                askbot['settings']['saveCommentOnEnter'] = false;
            {% endif %}
        </script>
        <script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
        <script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
    {% endif %}
    <script type='text/javascript' src='{{"/js/jquery.validate.min.js"|media}}'></script>
    <script type='text/javascript' src='{{"/js/post.js"|media}}'></script>
    <script type="text/javascript">
        // define reputation needs for comments
        var repNeededForComments = 50;
        $().ready(function(){
            {% if request.user.is_authenticated() %}
              if ($('#question-subscribe-updates')[0].checked){
                 $('#question-subscribe-sidebar').attr({'checked': 'checked'});
              }
            {%endif%}
            $("#nav_questions").attr('className',"on");
            var answer_sort_tab = "{{ tab_id }}";
            $("#" + answer_sort_tab).attr('className',"on");
            
            Vote.init({{ question.id }}, '{{ question.title|slugify }}', '{{ question.author.id }}','{{ request.user.id }}');
            
            {% if not question.closed and request.user.is_authenticated %}initEditor();{% endif %}
            
            lanai.highlightSyntax();
            $('#btLogin').bind('click', function(){window.location.href='{{ settings.LOGIN_URL }}'; } )
            if (window.location.hash === 'fmanswer'){
                $('#fmanswer textarea').focus();
            }
            {% if settings.ENABLE_SHARING_GOOGLE %}$.getScript("http://apis.google.com/js/plusone.js"){% endif %}
            var answer_id = window.location.hash.substring(1);
            if (answer_id!=""){
              $("#answer-container-" + answer_id).addClass('highlight');
              $("#answer-container-" + answer_id).hide();
              $("#answer-container-" + answer_id).fadeIn(2000);
              //using window.setTimeout
              /*function foo(){
                $("#answer-container-" + answer_id).removeClass('highlight')
              }
              var timeout = window.setTimeout(foo, 2000);
              */
            }
        });
        
        function initEditor(){
            $('#editor').TextAreaResizer();
            //highlight code synctax when editor has new text
            $("#editor").typeWatch({highlight: false, wait: 3000,
                             captureLength: 5, callback: lanai.highlightSyntax});
                             
            var display = true;
            var txt = "[{% trans %}hide preview{% endtrans %}]";
            $('#pre-collapse').text(txt);
            $('#pre-collapse').bind('click', function(){
                txt = display ? "[{% trans %}show preview{% endtrans %}]" : "[{% trans %}hide preview{% endtrans %}]";
                display = !display;
                $('#previewer').toggle();
                $('#pre-collapse').text(txt);
            });
            setupFormValidation($("#fmanswer"), CPValidator.getQuestionFormRules(), CPValidator.getQuestionFormMessages());
        }
    </script>
    {% include "blocks/editor_data.html" %}
{% endblock %}