summaryrefslogtreecommitdiffstats
path: root/askbot/templates/meta/bottom_scripts.html
blob: eec4256dccc90cbcdfeda5caf7d8475c13cc5f6b (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
{# most, if not all javascripts should go here
   this template is included at the very bottow of the
   main template "base.html"
#}
<div id="no-javascript">
    <noscript class="noscript">
        {% trans app_name = settings.APP_SHORT_NAME %}Please note: {{app_name}} requires javascript to work properly, please enable javascript in your browser, <a href="{{noscript_url}}">here is how</a>{% endtrans %}
    </noscript>
    <script type="text/javascript">
        //IE fix to hide the red margin
        var noscript = document.getElementsByTagName('noscript')[0];
        noscript.style.padding = '0px';
        noscript.style.backgroundColor = 'transparent';
    </script>
</div>
{# this section cannot be compressed because lots of data is runtime #}
<script type="text/javascript">
    askbot['urls']['mark_read_message'] = '{% url "read_message" %}';
    askbot['urls']['get_tags_by_wildcard'] = '{% url "get_tags_by_wildcard" %}';
    askbot['urls']['get_tag_list'] = '{% url "get_tag_list" %}';
    askbot['urls']['follow_user'] = '/followit/follow/user/{{'{{'}}userId{{'}}'}}/';
    askbot['urls']['unfollow_user'] = '/followit/unfollow/user/{{'{{'}}userId{{'}}'}}/';
    askbot['urls']['user_signin'] = '{{ settings.LOGIN_URL }}';
    askbot['urls']['getEditor'] = '{% url "get_editor" %}';
    askbot['urls']['apiGetQuestions'] = '{% url "api_get_questions" %}';
    askbot['urls']['ask'] = '{% url "ask" %}';
	askbot['urls']['questions'] = '{% url "questions" %}';
    askbot['settings']['groupsEnabled'] = {{ settings.GROUPS_ENABLED|as_js_bool }};
    askbot['settings']['static_url'] = '{{ settings.STATIC_URL }}';
    askbot['settings']['minSearchWordLength'] = {{ min_search_word_length }};
    askbot['settings']['mathjaxEnabled'] = {{ settings.ENABLE_MATHJAX|as_js_bool }};
    askbot['settings']['sharingSuffixText'] = '{{ settings.SHARING_SUFFIX_TEXT|escape }}';
    askbot['data']['maxCommentLength'] = {{ settings.MAX_COMMENT_LENGTH }};
    askbot['settings']['editorType'] = '{{ settings.EDITOR_TYPE }}';
    askbot['settings']['commentsEditorType'] = '{{ settings.COMMENTS_EDITOR_TYPE }}';
    {% if settings.ALLOWED_UPLOAD_FILE_TYPES %}
        askbot['settings']['allowedUploadFileTypes'] = [
            "{{ settings.ALLOWED_UPLOAD_FILE_TYPES|join('", "')|replace('.','') }}"
        ];
    {% else %}
        askbot['settings']['allowedUploadFileTypes'] = [];
    {% endif %}
    askbot['data']['haveFlashNotifications'] = {{ user_messages|as_js_bool }};
    askbot['data']['activeTab'] = '{{ active_tab }}';
    {% if search_state %}
        askbot['data']['searchUrl'] = '{{ search_state.query_string()|escapejs }}';
    {% else %}
        askbot['data']['searchUrl'] = '';
    {% endif %}
</script>
{# everything below until the custom js and google analytics is compressable #}
{% compress js %}
<script type="text/javascript" src="{{"/js/jquery-1.7.2.min.js"|media}}"></script>
<script type="text/javascript" src='{{"/bootstrap/js/bootstrap.js"|media}}'></script>
<!-- History.js --> 
<script type='text/javascript' src="{{"/js/jquery.history.js"|media }}"></script>
<script type='text/javascript' src="{{"/js/utils.js"|media }}"></script>
<script type="text/javascript" src="{{'/js/live_search.js'|media}}"></script>
<script type="text/javascript">
    /*<![CDATA[*/
    $('.mceStatusbar').remove();//a hack to remove the tinyMCE status bar
    $(document).ready(function(){
        // focus input on the search bar endcomment
        var activeTab = askbot['data']['activeTab'];
        if (inArray(activeTab, ['users', 'questions', 'tags', 'badges'])) {
            var searchInput = $('#keywords');
        } else if (activeTab === 'ask') {
            var searchInput = $('#id_title');
        } else {
            var searchInput = undefined;
            animateHashes();
        }

        if (searchInput) {
            searchInput.focus();
            putCursorAtEnd(searchInput);
        }
        
        if (inArray(activeTab, ['questions', 'badges', 'ask']) && searchInput.length) {
            var search = new FullTextSearch();
            askbot['controllers'] = askbot['controllers'] || {};
            askbot['controllers']['fullTextSearch'] = search;
            search.setSearchUrl(askbot['data']['searchUrl']);
            if (activeTab === 'ask') {
                search.setAskButtonEnabled(false);
            }
            search.decorate(searchInput);
        } else if (activeTab === 'tags') {
            var search = new TagSearch();
            search.decorate(searchInput);
        }

        if (askbot['data']['userIsAdminOrMod']) {
            $('body').addClass('admin');
        }
        if (askbot['settings']['groupsEnabled']) {
            askbot['urls']['add_group'] = "{% url add_group %}";
            var group_dropdown = new GroupDropdown({{ group_list }});
            $('.dropdown').append(group_dropdown.getElement());
            if (askbot['data']['userIsAdmin']) {
                group_dropdown.enableAddGroups();
            }
        }
    });
    if (askbot['data']['haveFlashNotifications']) {
        $('#validate_email_alert').click(function(){notify.close(true)})
        notify.show();
    }
    $('abbr.timeago').timeago();
    /*]]>*/
</script>
{% endcompress %}
{# stuff below should not be compressed #}
{% if settings.ENABLE_MATHJAX %}
    {# we don't want to load mathjax just in case, only if it is really enabled #}
    <script type='text/javascript' src="{{settings.MATHJAX_BASE_URL}}/MathJax.js">
        MathJax.Hub.Config({
            extensions: ["tex2jax.js"],
            jax: ["input/TeX","output/HTML-CSS"],
            tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}
        });
    </script>
{% endif %}
{% if settings.USE_CUSTOM_JS %}
<script 
    src="{% url "custom_js" %}?v={{ settings.MEDIA_RESOURCE_REVISION }}"
    type="text/javascript"
></script>
{% endif %}
{% if settings.GOOGLE_ANALYTICS_KEY %}
<script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker('{{ settings.GOOGLE_ANALYTICS_KEY }}');
    pageTracker._trackPageview();
    } catch(err) {}
</script>
{% endif %}