app/soc/templates/soc/templatetags/_as_table_row.html
author Mario Ferraro <fadinlight@gmail.com>
Thu, 09 Jul 2009 10:16:29 +0200
changeset 2575 e319fd52cbc4
parent 2561 2751a2462bb3
child 2661 03fcd4812eaa
permissions -rw-r--r--
Extended tooltip timeout to 10 seconds for all fields. This is because the tooltip currently timesout to fast for people to read the whole stories they can contain. Especially because Surveys can have custom tooltips. Reviewed by: Lennard de Rijk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
741
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
{% comment %}
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
Licensed under the Apache License, Version 2.0 (the "License");
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
you may not use this file except in compliance with the License.
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
You may obtain a copy of the License at
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
  http://www.apache.org/licenses/LICENSE-2.0
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
Unless required by applicable law or agreed to in writing, software
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
distributed under the License is distributed on an "AS IS" BASIS,
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
See the License for the specific language governing permissions and
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
limitations under the License.
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
{% endcomment %}
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
{% if errors %}
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
<tr>
1819
1e34fa8c5da0 Make the error message align with the input field
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1369
diff changeset
    17
  {% block error_td %}
1e34fa8c5da0 Make the error message align with the input field
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1369
diff changeset
    18
  <td>&nbsp;</td>
1e34fa8c5da0 Make the error message align with the input field
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1369
diff changeset
    19
  <td colspan="3" class="formfielderror">
1e34fa8c5da0 Make the error message align with the input field
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1369
diff changeset
    20
  {% endblock error_td %}
741
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
  {% for error in errors %}
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
    <span class="formfielderrorlabel">{{ error }}</span> <br />
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
  {% endfor %}
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
  </td>
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
</tr>
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
{% endif %}
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
785
c740d0129cce Added a twoline_edit.html page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 741
diff changeset
    28
{% block label_row %}{% endblock %}
c740d0129cce Added a twoline_edit.html page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 741
diff changeset
    29
2295
8566fb2b8012 Replace BeautyTips tooltips with purr info box for all form fields with help text.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1819
diff changeset
    30
<tr>
785
c740d0129cce Added a twoline_edit.html page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 741
diff changeset
    31
  {% block label_column %}
741
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
  <td class="{{ field_class_type }}">
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
    {{ label }}
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
  </td>
785
c740d0129cce Added a twoline_edit.html page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 741
diff changeset
    35
  {% endblock %}
1369
0be1f471413c Make the web forms look a little nicer.
Tim Ansell <mithro@gmail.com>
parents: 1302
diff changeset
    36
  <td class="formfieldvalue">
1215
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    37
  {% if select_url %}
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    38
    <script type="text/javascript">
1302
54e736a805b5 We generate the select url ourselves, so it's safe
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1270
diff changeset
    39
      $.getJSON("{{ select_url|safe }}",
1215
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    40
        function(data){
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    41
          $("#{{ field_id }}").autocomplete(data.data, {
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    42
            matchContains: true,
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    43
            formatItem: function(item) {
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    44
              return item.link_id+" ("+item.name+")";
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    45
            },
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    46
            formatResult: function(item) {
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    47
              return item.link_id;
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    48
            }
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    49
          });
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    50
        }
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    51
      );
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    52
    </script>
b21e40ef8dad Hook up the new jquery plugins in base.html and _as_table_row.html
Sverre Rabbelier <srabbelier@gmail.com>
parents: 956
diff changeset
    53
  {% endif %}
2295
8566fb2b8012 Replace BeautyTips tooltips with purr info box for all form fields with help text.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1819
diff changeset
    54
  {% if help_text %}
8566fb2b8012 Replace BeautyTips tooltips with purr info box for all form fields with help text.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1819
diff changeset
    55
  <script type="text/javascript">
8566fb2b8012 Replace BeautyTips tooltips with purr info box for all form fields with help text.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1819
diff changeset
    56
  $(document).ready( function() {
2561
2751a2462bb3 Now properly escaping JS and converting new lines into br for Tooltips.
Mario Ferraro <fadinlight@gmail.com>
parents: 2419
diff changeset
    57
    var tooltip = "<div class='tooltip'><div class='tooltip-body'><img src='/soc/content/images/purrInfo.png' alt='' /><h3>Info</h3><p>{% autoescape off %}{{ help_text|linebreaksbr|escapejs }}{% endautoescape %}</p></div><div class='tooltip-bottom'></div></div>";
2295
8566fb2b8012 Replace BeautyTips tooltips with purr info box for all form fields with help text.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1819
diff changeset
    58
    var tooltip_object=null;
2419
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    59
    var documented = $("#{{ field_id }}");
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    60
    var not_fieldset = documented.attr('tagName') !== 'FIELDSET';
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    61
    if (not_fieldset) {
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    62
      documented.focus(function() {
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    63
        if (tooltip_object==null) {
2575
e319fd52cbc4 Extended tooltip timeout to 10 seconds for all fields.
Mario Ferraro <fadinlight@gmail.com>
parents: 2561
diff changeset
    64
          tooltip_object = $(tooltip).purr({usingTransparentPNG: true,removeTimer: 10000});
2419
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    65
        }
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    66
      });
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    67
      documented.blur(function() {
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    68
        if (tooltip_object!==null) {
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    69
          tooltip_object.remove();
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    70
          tooltip_object=null;
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    71
        }
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    72
      });
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    73
    }
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    74
    else {
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    75
      documented.find("input").hover(function() {
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    76
        if (tooltip_object==null) {
2575
e319fd52cbc4 Extended tooltip timeout to 10 seconds for all fields.
Mario Ferraro <fadinlight@gmail.com>
parents: 2561
diff changeset
    77
          tooltip_object = $(tooltip).purr({usingTransparentPNG: true,removeTimer: 10000});
2419
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    78
        }
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    79
      },
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    80
      function() {
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    81
        if (tooltip_object!==null) {
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    82
          tooltip_object.remove();
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    83
          tooltip_object=null;
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    84
        }
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    85
      });
82ce842da661 Patch that touches 'upstream' templates, for use in surveys.
Daniel Diniz <ajaksu@gmail.com>
parents: 2300
diff changeset
    86
    }
2295
8566fb2b8012 Replace BeautyTips tooltips with purr info box for all form fields with help text.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1819
diff changeset
    87
  });
8566fb2b8012 Replace BeautyTips tooltips with purr info box for all form fields with help text.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1819
diff changeset
    88
  </script>
8566fb2b8012 Replace BeautyTips tooltips with purr info box for all form fields with help text.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1819
diff changeset
    89
  {% endif %}
1270
a48a592919b0 Fields are always safe, as we generate them ourselves
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1215
diff changeset
    90
    {{ field|safe }}
924
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
    91
  </td>
741
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    92
924
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
    93
  {% if required %}
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
    94
  <td class="formfieldrequired">(required)</td>
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
    95
  {% else %}
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
    96
  <td></td>
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
    97
  {% endif %}
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
    98
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
    99
  {% if example_text %}
34f944dc4502 Generate proper html instead of having nested <td> tags
Sverre Rabbelier <srabbelier@gmail.com>
parents: 861
diff changeset
   100
    <td class="formfieldexample">{{ example_text|safe }}</td>
941
6eac584ce14c Add a warning about discarding unsaved changes
Sverre Rabbelier <srabbelier@gmail.com>
parents: 935
diff changeset
   101
  {% else %}
6eac584ce14c Add a warning about discarding unsaved changes
Sverre Rabbelier <srabbelier@gmail.com>
parents: 935
diff changeset
   102
      <td></td>
6eac584ce14c Add a warning about discarding unsaved changes
Sverre Rabbelier <srabbelier@gmail.com>
parents: 935
diff changeset
   103
  {% endif %}
741
2dc2c65c5f76 Converted as_table to be a template tag
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   104
</tr>