bigger textfields in admin panel

 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
{% extends "admin/base.html" %}

{% block footer %}
<script type="text/javascript">
/* <![CDATA[ */
function textarea_resize() {
    //
    // Resize all textareas
    //
    textareas = document.getElementsByTagName("textarea");
    for (var i = 0; i <= textareas.length-1; i++) {
        try {
            textarea = textareas[i];
            try {
                rows = textarea.firstChild.data.split("\n").length;
                if (rows > 30) {
                    rows = 30;
                }
            } catch(e) {
                rows = 5;
            }
            textarea.rows = rows;
        } catch (e) {
            alert("textarea_resize() error:" + e);
        }
    }
}
textarea_resize()
/* ]]> */
</script>
<style type="text/css">
textarea {
    font-family: monospace;
}
.colM .aligned .vLargeTextField, .colM .aligned .vXMLLargeTextField {
    width:80%;
}
</style>
{% endblock %}

More like this

  1. FCKEditor replace all vLargeTextField in admin by aronchi 4 years, 7 months ago
  2. admin: edit related object shortcut by christian 5 years, 8 months ago
  3. Unobtrusvie Foldable Admin Interface by whiteinge 5 years, 4 months ago
  4. jstree integration to django admin by pawnhearts 3 years, 5 months ago
  5. google.js template for GoogleAdmin by jbronn 4 years, 8 months ago

Comments

capolise (on October 11, 2008):

At line 16 maybe you mean "if (rows < 30) {"

#

sitaktif (on February 10, 2010):

Thanks, works perfectly !

I'd make a small change (line 16) to have a minimum size concerning the textbox (useful when we are creating a new object)

 if (rows < 20) {
      rows = 20;
 }
 else if (rows > 30) {
      rows = 30;
 }

#

(Forgotten your password?)