Test coverage report: calendarium.widgets

# calendarium.widgets: 13 total statements, 60.0% covered

Generated: Thu 2013-05-02 12:21 SGT

Source file: /Users/martin/Repos/django-calendarium/calendarium/widgets.py

Stats: 6 executed, 4 missed, 3 excluded, 29 ignored

1. `"""Widgets for the ``calendarium`` app."""`
2. `from django import forms`
3. `from django.conf import settings`
4. `from django.utils.safestring import mark_safe`
5. ``
6. ``
7. `class ColorPickerWidget(forms.TextInput):`
8. `class Media:`
9. `css = {`
10. `'all': (`
11. `settings.STATIC_URL + 'calendarium/css/colorpicker.css',`
12. `)`
13. `}`
14. `js = (`
15. `'//ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js',`
16. `settings.STATIC_URL + 'calendarium/js/colorpicker.js',`
17. `settings.STATIC_URL + 'calendarium/js/colorpicker_list.js',`
18. `settings.STATIC_URL + 'calendarium/js/eye.js',`
19. `settings.STATIC_URL + 'calendarium/js/layout.js',`
20. `settings.STATIC_URL + 'calendarium/js/utils.js',`
21. `)`
22. ``
23. `def __init__(self, language=None, attrs=None):`
24. `self.language = language or settings.LANGUAGE_CODE[:2]`
25. `super(ColorPickerWidget, self).__init__(attrs=attrs)`
26. ``
27. `def render(self, name, value, attrs=None):`
28. `rendered = super(ColorPickerWidget, self).render(name, value, attrs)`
29. `return rendered + mark_safe(`
30. `u'''<script type="text/javascript">`
31. `$('#id_%s').ColorPicker({`
32. `onSubmit: function(hsb, hex, rgb, el) {`
33. `$(el).val(hex);`
34. `$(el).ColorPickerHide();`
35. `},`
36. `onBeforeShow: function () {`
37. `$(this).ColorPickerSetColor(this.value);`
38. `}`
39. `}).bind('keyup', function(){`
40. `$(this).ColorPickerSetColor(this.value);`
41. `});`
42. `</script>''' % name)`