4 from turbogears import widgets
6 class CustomTextField(widgets.TextField):
7 """Un input con un div al lado para ponerle info"""
9 <span xmlns:py="http://purl.org/kid/ns#">
13 class="${field_class}"
18 <span id="${field_id}_info" />
24 function _on_alumno_get_result(lista, loading, results)
26 load = MochiKit.DOM.getElement(loading);
27 load.style.visibility = 'hidden';
32 MochiKit.DOM.appendChildNodes(lista, OPTION({'value':results.msg.id}, results.msg.value));
33 l = MochiKit.DOM.getElement(lista);
34 for (i=0; i<l.options.length; i++) {
35 l.options[i].selected = true;
39 function _on_alumno_get_error(loading, results)
42 load = MochiKit.DOM.getElement(loading);
43 load.style.visibility = 'hidden';
46 function sacar_de_la_lista(lista)
48 l = MochiKit.DOM.getElement(lista);
49 if (l.selectedIndex < 0) return;
51 /* caso especial, 1 solo item */
52 if (l.options.length == 1) {
57 for (i=l.selectedIndex; i<l.options.length-1;i++)
58 l.options[i] = l.options[i+1];
62 class AjaxMultiSelect(widgets.MultipleSelectField):
64 <div style="width:250px" xmlns:py="http://purl.org/kid/ns#">
66 <input type="text" id="${field_id}_nuevo" size="10" />
67 <img src="/static/images/loading.gif" align="baseline" style="visibility:hidden;" id="${name}_loading" width="16px" height="16px" />
68 <input type="button" id="_agregar" value="Agregar"
69 onClick=" ${on_add}('${field_id}_nuevo', '${field_id}', '${name}_loading'); " />
76 class="${field_class}"
81 <optgroup py:for="group, options in grouped_options"
85 <option py:for="value, desc, attrs in options"
94 <input type="button" id="_sacar" value="Borrar" style="width:100%;"
95 onClick="sacar_de_la_lista('${field_id}'); " />
99 javascript = [widgets.JSSource(MultiSelectAjax)]
100 on_add = "alert('Not defined action');"
102 def __init__(self, **kw):
103 self.params.append('on_add')
104 self.on_add = "alert('Not defined action');"
105 widgets.MultipleSelectField.__init__(self, **kw)