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);
36 function _on_alumno_get_error(loading, results)
39 load = MochiKit.DOM.getElement(loading);
40 load.style.visibility = 'hidden';
43 function sacar_de_la_lista(lista)
45 l = MochiKit.DOM.getElement(lista);
46 if (l.selectedIndex < 0) return;
48 /* caso especial, 1 solo item */
49 if (l.options.length == 1) {
54 for (i=l.selectedIndex; i<l.options.length-1;i++)
55 l.options[i] = l.options[i+1];
58 function _do_add(callback, texto, lista, loading)
60 url = callback(texto, lista);
61 t = MochiKit.DOM.getElement(texto);
63 load = MochiKit.DOM.getElement(loading);
64 load.style.visibility = 'visible';
65 var d = loadJSONDoc(url);
66 d.addCallbacks(partial(_on_alumno_get_result, lista, loading), partial(_on_alumno_get_error, loading));
70 class AjaxMultiSelect(widgets.MultipleSelectField):
72 <div style="width:250px" xmlns:py="http://purl.org/kid/ns#">
74 <input type="text" id="${field_id}_nuevo" size="10" value="padron"
76 onfocus="this.style.color='#000'; if (this.value =='padron') { this.value=''; }"
77 onblur="if (this.value == '') { this.style.color='#aaa'; this.value='padron'; }" />
78 <img src="/static/images/loading.gif" align="baseline" style="visibility:hidden;" id="${name}_loading" width="16px" height="16px" />
79 <input type="button" id="_agregar" value="Agregar"
80 onClick=" _do_add(${on_add}, '${field_id}_nuevo', '${field_id}', '${name}_loading'); " />
87 class="${field_class}"
92 <optgroup py:for="group, options in grouped_options"
96 <option py:for="value, desc, attrs in options"
105 <input type="button" id="_sacar" value="Borrar" style="width:100%;"
106 onClick="sacar_de_la_lista('${field_id}'); " />
110 javascript = [widgets.JSSource(MultiSelectAjax)]
111 on_add = "alert('Not defined action');"
113 def __init__(self, **kw):
114 self.params.append('on_add')
115 self.on_add = "alert('Not defined action');"
116 widgets.MultipleSelectField.__init__(self, **kw)