~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to django/contrib/admin/templates/admin/prepopulated_fields_js.html

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<script type="text/javascript">
 
2
(function($) {
 
3
    var field = null;
 
4
 
2
5
{% for field in prepopulated_fields %}
3
 
    document.getElementById("{{ field.field.auto_id }}").onchange = function() { this._changed = true; };
 
6
    field = {
 
7
        id: '#{{ field.field.auto_id }}',
 
8
        dependency_ids: [],
 
9
        dependency_list: [],
 
10
        maxLength: {{ field.field.field.max_length|default_if_none:"50" }}
 
11
    };
 
12
 
4
13
    {% for dependency in field.dependencies %}
5
 
    document.getElementById("{{ dependency.auto_id }}").onkeyup = function() {
6
 
        var e = document.getElementById("{{ field.field.auto_id }}");
7
 
        if (!e._changed) { e.value = URLify({% for innerdep in field.dependencies %}document.getElementById("{{ innerdep.auto_id }}").value{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:"50" }}); }
8
 
    }
 
14
    field['dependency_ids'].push('#{{ dependency.auto_id }}');
 
15
    field['dependency_list'].push('.{{ dependency.name }}');
9
16
    {% endfor %}
 
17
 
 
18
    $('.empty-form .{{ field.field.name }}').addClass('prepopulated_field');
 
19
    $(field.id).data('dependency_list', field['dependency_list'])
 
20
               .prepopulate($(field['dependency_ids'].join(',')), field.maxLength);
10
21
{% endfor %}
 
22
})(django.jQuery);
11
23
</script>