Commit 090c0fefdf80f334ebea5e9dac6c983d0fba4d2a

Authored by Zambom
1 parent ee025b06

Adding bootstrap datepicker to poll [Issue: #226]

poll/templates/poll/create.html
@@ -99,7 +99,7 @@ @@ -99,7 +99,7 @@
99 <div class="row form-group {% if form.has_error %} has-error {% endif %}"> 99 <div class="row form-group {% if form.has_error %} has-error {% endif %}">
100 <label for="{{ form.limit_date.auto_id }}">{{ form.limit_date.label }}</label> 100 <label for="{{ form.limit_date.auto_id }}">{{ form.limit_date.label }}</label>
101 {# {% render_field form.limit_date class="form-control" form="form"%} #} 101 {# {% render_field form.limit_date class="form-control" form="form"%} #}
102 - <input form="form" class="form-control" type="date" name="{{form.limit_date.name}}" {% if form.limit_date.value != None %}value="{{form.limit_date.value|date:'SHORT_DATE_FORMAT'}}"{% endif %}> 102 + <input form="form" class="form-control date-picker" type="text" name="{{form.limit_date.name}}" {% if form.limit_date.value != None %}value="{{form.limit_date.value|date:'SHORT_DATE_FORMAT'}}"{% endif %}>
103 {% if form.limit_date.errors %} 103 {% if form.limit_date.errors %}
104 <div class="not_submited"> 104 <div class="not_submited">
105 </br> 105 </br>
@@ -166,6 +166,12 @@ @@ -166,6 +166,12 @@
166 </script> 166 </script>
167 {% block script_poll %} 167 {% block script_poll %}
168 <script type="text/javascript"> 168 <script type="text/javascript">
  169 + var locale = navigator.language || navigator.userLanguage;
  170 +
  171 + $('.date-picker').datepicker({
  172 + language: locale,
  173 + });
  174 +
169 // Este js tem que ficar aqui se não o button add não vai funcionar 175 // Este js tem que ficar aqui se não o button add não vai funcionar
170 $("#add").click(function (){ 176 $("#add").click(function (){
171 Answer.init('{% url "course:poll:answer_poll" %}'); 177 Answer.init('{% url "course:poll:answer_poll" %}');
poll/templates/poll/update.html
@@ -14,6 +14,11 @@ @@ -14,6 +14,11 @@
14 14
15 {% block script_poll %} 15 {% block script_poll %}
16 <script type="text/javascript"> 16 <script type="text/javascript">
  17 + var locale = navigator.language || navigator.userLanguage;
  18 +
  19 + $('.date-picker').datepicker({
  20 + language: locale,
  21 + });
17 // Este js tem que ficar aqui se não o button add não vai funcionar 22 // Este js tem que ficar aqui se não o button add não vai funcionar
18 $("#add").click(function (){ 23 $("#add").click(function (){
19 Answer.init('{% url "course:poll:answer_poll" %}'); 24 Answer.init('{% url "course:poll:answer_poll" %}');