Blame view

flaskr/templates/estimate.html 5.69 KB
c1421d65   Goutte   Add the `estimate...
1
2
{% extends "base.html" %}

fef4a9fd   Goutte   Rework the templa...
3
4
5

{% block title %}Request an estimation of your travel footprint{% endblock %}

c1421d65   Goutte   Add the `estimate...
6
7

{% block hero %}
fef4a9fd   Goutte   Rework the templa...
8
9
10
11
<div class="jumbotron">
    <h1>{{ content.estimate.hero.title | safe }}</h1>
    <p>{{ content.estimate.hero.description | markdown | safe }}</p>
</div>
c1421d65   Goutte   Add the `estimate...
12
13
{% endblock %}

fef4a9fd   Goutte   Rework the templa...
14

77e86148   Antoine Goutenoir   Fake support for ...
15
16
17
18
19

{#############################################################################}
{# MACROS ######################################################################}


c1421d65   Goutte   Add the `estimate...
20
21
22
23
24
25
26
27
28
{% macro render_field(field) %}
<dt>
    {{ field.label }}
    {% if not field.flags.optional %}
    <span class="required-asterisk" title="This field is required.">*</span>
    {% endif %}
</dt>
<dd>
    {{ field(title=field.description, class_="form-control", **kwargs) | safe }}
77e86148   Antoine Goutenoir   Fake support for ...
29

c1421d65   Goutte   Add the `estimate...
30
    {% if field.errors -%}
77e86148   Antoine Goutenoir   Fake support for ...
31
    <ul class="errors text-danger has-error">
c1421d65   Goutte   Add the `estimate...
32
33
34
35
36
37
38
39
    {% for error in field.errors %}
        <li>{{ error }}</li>
    {% endfor %}
    </ul>
    {%- endif %}
</dd>
{% endmacro %}

c1421d65   Goutte   Add the `estimate...
40

fef4a9fd   Goutte   Rework the templa...
41
42
43
44
45
46
{% macro render_checkbox(field) %}
{{ field(class="form-check-input") }}
{{ field.label(
    class="form-check-label",
    title=field.description
) }}
77e86148   Antoine Goutenoir   Fake support for ...
47
48

{% if field.errors -%}
7b5e18c3   Antoine Goutenoir   Fix the error mes...
49
<p class="text-danger help-block">{{ field.errors[0] | safe }}</p>
77e86148   Antoine Goutenoir   Fake support for ...
50
{%- endif %}
fef4a9fd   Goutte   Rework the templa...
51
{% endmacro %}
c1421d65   Goutte   Add the `estimate...
52

fef4a9fd   Goutte   Rework the templa...
53

77e86148   Antoine Goutenoir   Fake support for ...
54
55
56
57
58

{#############################################################################}
{# BODY ######################################################################}


fef4a9fd   Goutte   Rework the templa...
59
60
61
62
63
64
65
{% block body %}
<div class="row">
    <div class="col-md-2"></div>
    <div class="col-md-8">
        <form role="form" action="{{ url_for('.estimate') }}" method="post">
            {{ form.hidden_tag() }}

f47a875d   Antoine Goutenoir   Remove the email ...
66
67
68
69
{#            <div class="form-group">#}
{#                {{ render_field(form.email) }}#}
{#                <small class="form-text text-muted">We will never share your email with anyone.</small>#}
{#            </div>#}
fef4a9fd   Goutte   Rework the templa...
70
71
72
            <div class="form-group row">
                <div class="col-md-6">
                {{ render_field(form.first_name) }}
461850db   Antoine Goutenoir   Yet another joyfu...
73
                <small class="form-text text-muted">Fill these to say hello.</small>
c1421d65   Goutte   Add the `estimate...
74
                </div>
fef4a9fd   Goutte   Rework the templa...
75
76
                <div class="col-md-6">
                {{ render_field(form.last_name) }}
0b094aac   Antoine Goutenoir   Not satisfied by ...
77
                <small class="form-text text-muted">We will never share your data with anyone.</small>
c1421d65   Goutte   Add the `estimate...
78
                </div>
fef4a9fd   Goutte   Rework the templa...
79
80
81
82
83
84
            </div>
            <div class="form-group">
                {{ render_field(form.institution) }}
            </div>
            <div class="form-group">
                {{ render_field(form.origin_addresses) }}
109b0d46   Antoine Goutenoir   Add more informat...
85
                <small class="form-text text-muted">
77e86148   Antoine Goutenoir   Fake support for ...
86
87
88
                    Use <code>en_US</code> city and country names, without diacritics.
                    &nbsp;
                    The comma matters.
109b0d46   Antoine Goutenoir   Add more informat...
89
90
91
                    <br>
                    These usually are the addresses of your participants.
                </small>
fef4a9fd   Goutte   Rework the templa...
92
93
94
            </div>
            <div class="form-group">
                {{ render_field(form.destination_addresses) }}
109b0d46   Antoine Goutenoir   Add more informat...
95
                <small class="form-text text-muted">
2f22629a   Antoine Goutenoir   Make the "compute...
96
                    Provide <strong>multiple destinations</strong> to compare them and <strong>compute optimum</strong>.
109b0d46   Antoine Goutenoir   Add more informat...
97
98
99
                    <br>
                    These usually are the possible locations for an event.
                </small>
fef4a9fd   Goutte   Rework the templa...
100
            </div>
b9fc86c3   Antoine Goutenoir   Secure the admin ...
101
102
103
{#            <div class="form-check form-group">#}
{#                {{ render_checkbox(form.compute_optimal_destination) }}#}
{#            </div>#}
7f7c6b10   Antoine Goutenoir   Disable RFI in th...
104
105
106
107
{#            <div class="form-check form-group">#}
{#                {{ render_checkbox(form.use_atmosfair_rfi) }}#}
{#                <small class="form-text text-muted">Disabled. Work in Progress. RFI=1.9</small>#}
{#            </div>#}
77e86148   Antoine Goutenoir   Fake support for ...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

            <div class="form-group">

            <h6>Emission Models to consider</h6>
            <div class="form-check">
                {% for model in models %}
                <div>
                {{ render_checkbox(form['use_model_'~model.slug]) }}
                </div>
                {% endfor %}
            </div>
            <small class="form-text text-muted">
                We will use a mean of the selected models.
                &nbsp;
                Please select at least one.
            </small>
            </div>

fef4a9fd   Goutte   Rework the templa...
126
127
128
            <div class="form-group">
                {{ render_field(form.comment) }}
            </div>
c1421d65   Goutte   Add the `estimate...
129

fef4a9fd   Goutte   Rework the templa...
130
131
132
133
            <button type="submit" class="btn btn-primary">
                Submit a Request
            </button>
        </form>
c1421d65   Goutte   Add the `estimate...
134
    </div>
fef4a9fd   Goutte   Rework the templa...
135
136
    <div class="col-md-2"></div>
</div>
c1421d65   Goutte   Add the `estimate...
137
{% endblock %}
d79d2488   Antoine Goutenoir   Work around iPad'...
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

{% block js %}
<script type="text/javascript">

// Multiline placeholders for textarea shim (eg: iPad)
// https://github.com/EmilMoe/multiline-placeholder
$(function() {
  var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;

  // Disable for chrome which already supports multiline
  if (! ((!!window.chrome) && !isOpera)) {
    var style = $('<style>textarea[data-placeholder].active { color: #666; }</style>')
    $('html > head').append(style);

    $('textarea[placeholder]').each(function(index) {
      var text  = $(this).attr('placeholder');
      var match = /\r|\n/.exec(text);

      if (! match)
        return;

      $(this).attr('placeholder', '');
      $(this).attr('data-placeholder', text);
      $(this).addClass('active');
      $(this).val(text);
    });

    $('textarea[data-placeholder]').on('focus', function() {
      if ($(this).attr('data-placeholder') === $(this).val()) {
        $(this).attr('data-placeholder', $(this).val());
        $(this).val('');
        $(this).removeClass('active');
      }
    });

    $('textarea[data-placeholder]').on('blur', function() {
      if ($(this).val() === '') {
        var text = $(this).attr('data-placeholder');
        $(this).val(text);
        $(this).addClass('active');
      }
    });
  }
});

</script>
{% endblock %}