~chipaca/unity-lens-video/custom-user-agent

« back to all changes in this revision

Viewing changes to templates/main/search.html

  • Committer: Janos Gyerik
  • Date: 2011-10-09 09:41:07 UTC
  • Revision ID: janos@axiom-20111009094107-j1zs0w81tjrae05r
implemented search page

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{% extends "base.html" %}
 
2
 
 
3
{% load nst %}
 
4
 
 
5
{% block pagetitle %}Search{% endblock %}
 
6
 
 
7
{% block content %}
 
8
 
 
9
<form action="" method="post" id="search-form" style="text-align: center">
 
10
    {{ form.query }}
 
11
 
 
12
    <div id="search-loading" class="invisible">
 
13
        <img src="/media/images/loading.gif" alt="" title="" /> Loading ...
 
14
    </div>
 
15
 
 
16
    <div id="search-errors" class="hidden error">
 
17
        An error occurred during search.
 
18
    </div>
 
19
</form>
 
20
 
 
21
<div id="search-results" class="hidden">
 
22
 
 
23
<h2>Results</h2>
 
24
 
 
25
{% include 'main/oneliners.html' %}
 
26
 
 
27
</div>
 
28
 
 
29
{% endblock %}
 
30
 
 
31
{% block ready %}
 
32
        function search_success(html) {
 
33
            $('#search-results .oneliners').html($(html).html());
 
34
            bind_details_trigger($('#search-results div.oneliners'));
 
35
            $('#search-results').show();
 
36
        }
 
37
 
 
38
        function search_error(err) {
 
39
            $('#search-errors').show();
 
40
        }
 
41
 
 
42
        function search_completed() {
 
43
            $('#search-loading').css('visibility', 'hidden');
 
44
        }
 
45
 
 
46
        $('#search-form').submit(function(e) {
 
47
            e.preventDefault();
 
48
            $('#search-loading').css('visibility', 'visible');
 
49
            $('#search-errors').hide();
 
50
 
 
51
            var options = {
 
52
                'url': '{% url bashoneliners.main.views.search_ajax %}',
 
53
                'type': 'POST',
 
54
                'data': { 'query': $('#id_query').val() },
 
55
                'success': search_success,
 
56
                'error': search_error,
 
57
                'complete': search_completed
 
58
            };
 
59
            $.ajax(options);
 
60
        });
 
61
 
 
62
        $('#id_query').focus();
 
63
{% endblock %}