308 |
308 |
309 |
309 |
310 # basic html widgets ########################################################### |
310 # basic html widgets ########################################################### |
311 |
311 |
312 class TextInput(Input): |
312 class TextInput(Input): |
313 """Simple <input type='text'>, will return an unicode string.""" |
313 """Simple <input type='text'>, will return a unicode string.""" |
314 type = 'text' |
314 type = 'text' |
315 |
315 |
316 |
316 |
317 class PasswordSingleInput(Input): |
317 class PasswordSingleInput(Input): |
318 """Simple <input type='password'>, will return an utf-8 encoded string. |
318 """Simple <input type='password'>, will return an utf-8 encoded string. |
371 # ignore value which makes no sense here (XXX even on form validation error?) |
371 # ignore value which makes no sense here (XXX even on form validation error?) |
372 return ('',) |
372 return ('',) |
373 |
373 |
374 |
374 |
375 class HiddenInput(Input): |
375 class HiddenInput(Input): |
376 """Simple <input type='hidden'> for hidden value, will return an unicode |
376 """Simple <input type='hidden'> for hidden value, will return a unicode |
377 string. |
377 string. |
378 """ |
378 """ |
379 type = 'hidden' |
379 type = 'hidden' |
380 setdomid = False # by default, don't set id attribute on hidden input |
380 setdomid = False # by default, don't set id attribute on hidden input |
381 settabindex = False |
381 settabindex = False |
382 |
382 |
383 |
383 |
384 class ButtonInput(Input): |
384 class ButtonInput(Input): |
385 """Simple <input type='button'>, will return an unicode string. |
385 """Simple <input type='button'>, will return a unicode string. |
386 |
386 |
387 If you want a global form button, look at the :class:`Button`, |
387 If you want a global form button, look at the :class:`Button`, |
388 :class:`SubmitButton`, :class:`ResetButton` and :class:`ImgButton` below. |
388 :class:`SubmitButton`, :class:`ResetButton` and :class:`ImgButton` below. |
389 """ |
389 """ |
390 type = 'button' |
390 type = 'button' |
391 |
391 |
392 |
392 |
393 class TextArea(FieldWidget): |
393 class TextArea(FieldWidget): |
394 """Simple <textarea>, will return an unicode string.""" |
394 """Simple <textarea>, will return a unicode string.""" |
395 |
395 |
396 def _render(self, form, field, renderer): |
396 def _render(self, form, field, renderer): |
397 values, attrs = self.values_and_attributes(form, field) |
397 values, attrs = self.values_and_attributes(form, field) |
398 attrs.setdefault('onkeyup', 'autogrow(this)') |
398 attrs.setdefault('onkeyup', 'autogrow(this)') |
399 if not values: |
399 if not values: |
411 return tags.textarea(value, name=field.input_name(form, self.suffix), |
411 return tags.textarea(value, name=field.input_name(form, self.suffix), |
412 **attrs) |
412 **attrs) |
413 |
413 |
414 |
414 |
415 class FCKEditor(TextArea): |
415 class FCKEditor(TextArea): |
416 """FCKEditor enabled <textarea>, will return an unicode string containing |
416 """FCKEditor enabled <textarea>, will return a unicode string containing |
417 HTML formated text. |
417 HTML formated text. |
418 """ |
418 """ |
419 def __init__(self, *args, **kwargs): |
419 def __init__(self, *args, **kwargs): |
420 super(FCKEditor, self).__init__(*args, **kwargs) |
420 super(FCKEditor, self).__init__(*args, **kwargs) |
421 self.attrs['cubicweb:type'] = 'wysiwyg' |
421 self.attrs['cubicweb:type'] = 'wysiwyg' |
425 return super(FCKEditor, self)._render(form, field, renderer) |
425 return super(FCKEditor, self)._render(form, field, renderer) |
426 |
426 |
427 |
427 |
428 class Select(FieldWidget): |
428 class Select(FieldWidget): |
429 """Simple <select>, for field having a specific vocabulary. Will return |
429 """Simple <select>, for field having a specific vocabulary. Will return |
430 an unicode string, or a list of unicode strings. |
430 a unicode string, or a list of unicode strings. |
431 """ |
431 """ |
432 vocabulary_widget = True |
432 vocabulary_widget = True |
433 default_size = 10 |
433 default_size = 10 |
434 |
434 |
435 def __init__(self, attrs=None, multiple=False, **kwargs): |
435 def __init__(self, attrs=None, multiple=False, **kwargs): |
621 |
621 |
622 # javascript widgets ########################################################### |
622 # javascript widgets ########################################################### |
623 |
623 |
624 class DateTimePicker(TextInput): |
624 class DateTimePicker(TextInput): |
625 """<input type='text'> + javascript date/time picker for date or datetime |
625 """<input type='text'> + javascript date/time picker for date or datetime |
626 fields. Will return the date or datetime as an unicode string. |
626 fields. Will return the date or datetime as a unicode string. |
627 """ |
627 """ |
628 monthnames = ('january', 'february', 'march', 'april', |
628 monthnames = ('january', 'february', 'march', 'april', |
629 'may', 'june', 'july', 'august', |
629 'may', 'june', 'july', 'august', |
630 'september', 'october', 'november', 'december') |
630 'september', 'october', 'november', 'december') |
631 daynames = ('monday', 'tuesday', 'wednesday', 'thursday', |
631 daynames = ('monday', 'tuesday', 'wednesday', 'thursday', |
663 form._cw._('calendar'), helperid) ) |
663 form._cw._('calendar'), helperid) ) |
664 |
664 |
665 |
665 |
666 class JQueryDatePicker(FieldWidget): |
666 class JQueryDatePicker(FieldWidget): |
667 """Use jquery.ui.datepicker to define a date picker. Will return the date as |
667 """Use jquery.ui.datepicker to define a date picker. Will return the date as |
668 an unicode string. |
668 a unicode string. |
669 """ |
669 """ |
670 needs_js = ('jquery.ui.js', ) |
670 needs_js = ('jquery.ui.js', ) |
671 needs_css = ('jquery.ui.css',) |
671 needs_css = ('jquery.ui.css',) |
672 default_size = 10 |
672 default_size = 10 |
673 |
673 |