summaryrefslogtreecommitdiffstats
path: root/askbot/templates/meta/bottom_scripts.html
blob: 805974cc080b86d3ec443c840726767885ce9f4b (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
{# 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']['titleSearch'] = '{% url "title_search" %}';
    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'] = {{ settings.MIN_SEARCH_WORD_LENGTH }};
    askbot['settings']['mathjaxEnabled'] = {{ settings.ENABLE_MATHJAX|as_js_bool }};
    askbot['settings']['sharingSuffixText'] = '{{ settings.SHARING_SUFFIX_TEXT|escape }}';
    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>
{% 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 %}
<script type="text/javascript">
    /*<![CDATA[*/
    $(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);
        }

        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.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 %}