Commit 9b3926ff authored by chris's avatar chris

Choice are datetime objects. Adapt javascripts.

parent 8cdc2ef0
......@@ -8,7 +8,7 @@ class PollForm(forms.ModelForm):
fields = ('title','description')
class ChoiceForm(forms.ModelForm):
choice = forms.DateTimeField(widget=forms.DateTimeInput(format='%d-%m-%Y %H:%M',attrs={'class':'hasdatepicker','size':'20',}),input_formats=['%d-%m-%Y %H:%M'])
choice = forms.DateTimeField(widget=forms.DateTimeInput(format='%d-%m-%Y %H:%M',attrs={'class':'hasdatepicker','size':'18',}),input_formats=['%d-%m-%Y %H:%M'])
details = forms.CharField(required=False,max_length='200',widget=forms.TextInput(attrs={'size':'32',}))
class Meta:
model = Choice
......
jQuery Timepicker Addon
=======================
Use
---
- To use this plugin you must include jQuery and jQuery UI with datepicker and slider
- Include timepicker-addon script
- now use timepicker with $('#selector').datetimepicker() or $('#selector').timepicker()
Contributing Code - Please Read!
--------------------------------
All code contributions and bug reports are much appreciated. Please be sure to apply your fixes to the "dev" branch.
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; }
.ui-timepicker-div dl dd { margin: -25px 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
/* Catalan translation for the jQuery Timepicker Addon */
/* Written by Sergi Faber */
(function($) {
$.timepicker.regional['ca'] = {
timeOnlyTitle: 'Escollir una hora',
timeText: 'Hora',
hourText: 'Hores',
minuteText: 'Minuts',
secondText: 'Segons',
millisecText: 'Milisegons',
timezoneText: 'Fus horari',
currentText: 'Ara',
closeText: 'Tancar',
timeFormat: 'hh:mm',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['ca']);
})(jQuery);
/* Czech translation for the jQuery Timepicker Addon */
/* Written by Ondřej Vodáček */
(function($) {
$.timepicker.regional['cs'] = {
timeOnlyTitle: 'Vyberte čas',
timeText: 'Čas',
hourText: 'Hodiny',
minuteText: 'Minuty',
secondText: 'Vteřiny',
millisecText: 'Milisekundy',
timezoneText: 'Časové pásmo',
currentText: 'Nyní',
closeText: 'Zavřít',
timeFormat: 'h:m',
amNames: ['dop.', 'AM', 'A'],
pmNames: ['odp.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['cs']);
})(jQuery);
/* German translation for the jQuery Timepicker Addon */
/* Written by Marvin */
(function($) {
$.timepicker.regional['de'] = {
timeOnlyTitle: 'Zeit Wählen',
timeText: 'Zeit',
hourText: 'Stunde',
minuteText: 'Minute',
secondText: 'Sekunde',
millisecText: 'Millisekunde',
timezoneText: 'Zeitzone',
currentText: 'Jetzt',
closeText: 'Fertig',
timeFormat: 'hh:mm tt',
amNames: ['vorm.', 'AM', 'A'],
pmNames: ['nachm.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['de']);
})(jQuery);
/* Hellenic translation for the jQuery Timepicker Addon */
/* Written by Christos Pontikis */
(function($) {
$.timepicker.regional['el'] = {
timeOnlyTitle: 'Επιλογή ώρας',
timeText: 'Ώρα',
hourText: 'Ώρες',
minuteText: 'Λεπτά',
secondText: 'Δευτερόλεπτα',
millisecText: 'μιλιδευτερόλεπτο',
timezoneText: 'Ζώνη ώρας',
currentText: 'Τώρα',
closeText: 'Κλείσιμο',
timeFormat: 'hh:mm',
amNames: ['π.μ.', 'AM', 'A'],
pmNames: ['μ.μ.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['el']);
})(jQuery);
/* Spanish translation for the jQuery Timepicker Addon */
/* Written by Ianaré Sévi */
(function($) {
$.timepicker.regional['es'] = {
timeOnlyTitle: 'Elegir una hora',
timeText: 'Hora',
hourText: 'Horas',
minuteText: 'Minutos',
secondText: 'Segundos',
millisecText: 'Milisegundos',
timezoneText: 'Huso horario',
currentText: 'Ahora',
closeText: 'Cerrar',
timeFormat: 'hh:mm',
amNames: ['a.m.', 'AM', 'A'],
pmNames: ['p.m.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['es']);
})(jQuery);
/* Estonian translation for the jQuery Timepicker Addon */
/* Written by Karl Sutt (karl@sutt.ee) */
(function($) {
$.timepicker.regional['et'] = {
timeOnlyTitle: 'Vali aeg',
timeText: 'Aeg',
hourText: 'Tund',
minuteText: 'Minut',
secondText: 'Sekund',
millisecText: 'Millisekundis',
timezoneText: 'Ajavöönd',
currentText: 'Praegu',
closeText: 'Valmis',
timeFormat: 'hh:mm tt',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['et']);
})(jQuery);
/* Finnish translation for the jQuery Timepicker Addon */
/* Written by Juga Paazmaya (http://github.com/paazmaya) */
(function($) {
$.timepicker.regional['fi'] = {
timeOnlyTitle: 'Valitse aika',
timeText: 'Aika',
hourText: 'Tunti',
minuteText: 'Minuutti',
secondText: 'Sekunti',
millisecText: 'Millisekunnin',
timezoneText: 'Aikavyöhyke',
currentText: 'Nyt',
closeText: 'Sulje',
timeFormat: 'hh:mm',
amNames: ['ap.', 'AM', 'A'],
pmNames: ['ip.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['fi']);
})(jQuery);
/* French translation for the jQuery Timepicker Addon */
/* Written by Thomas Lété */
(function($) {
$.timepicker.regional['fr'] = {
timeOnlyTitle: 'Choisir une heure',
timeText: 'Heure',
hourText: 'Heures',
minuteText: 'Minutes',
secondText: 'Secondes',
millisecText: 'Millisecondes',
timezoneText: 'Fuseau horaire',
currentText: 'Maintenant',
closeText: 'Terminé',
timeFormat: 'hh:mm',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['fr']);
})(jQuery);
/* Hebrew translation for the jQuery Timepicker Addon */
/* Written by Lior Lapid */
(function($) {
$.timepicker.regional["he"] = {
timeOnlyTitle: "בחרית זמן",
timeText: "שעה",
hourText: "שעות",
minuteText: "דקות",
secondText: "שניות",
millisecText: "אלפית השנייה",
timezoneText: "אזור זמן",
currentText: "עכשיו",
closeText:"סגור",
timeFormat: "hh:mm tt",
amNames: ['לפנה"צ', 'AM', 'A'],
pmNames: ['אחה"צ', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional["he"]);
})(jQuery);
/* Hungarian translation for the jQuery Timepicker Addon */
/* Written by Vas Gábor */
(function($) {
$.timepicker.regional['hu'] = {
timeOnlyTitle: 'Válasszon időpontot',
timeText: 'Idő',
hourText: 'Óra',
minuteText: 'Perc',
secondText: 'Másodperc',
millisecText: 'Milliszekundumos',
timezoneText: 'Időzóna',
currentText: 'Most',
closeText: 'Kész',
timeFormat: 'hh:mm tt',
amNames: ['de.', 'AM', 'A'],
pmNames: ['du.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['hu']);
})(jQuery);
/* Indonesian translation for the jQuery Timepicker Addon */
/* Written by Nia */
(function($) {
$.timepicker.regional['id'] = {
timeOnlyTitle: 'Pilih Waktu',
timeText: 'Waktu',
hourText: 'Pukul',
minuteText: 'Menit',
secondText: 'Detik',
millisecText: 'Milidetik',
timezoneText: 'Zona Waktu',
currentText: 'Sekarang',
closeText: 'OK',
timeFormat: 'hh:mm tt',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['id']);
})(jQuery);
/* Italian translation for the jQuery Timepicker Addon */
/* Written by Marco "logicoder" Del Tongo */
(function($) {
$.timepicker.regional['it'] = {
timeOnlyTitle: 'Scegli orario',
timeText: 'Orario',
hourText: 'Ora',
minuteText: 'Minuto',
secondText: 'Secondo',
millisecText: 'Millisecondo',
timezoneText: 'Fuso orario',
currentText: 'Adesso',
closeText: 'Chiudi',
timeFormat: 'hh:mm',
amNames: ['m.', 'AM', 'A'],
pmNames: ['p.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['it']);
})(jQuery);
/* Japanese translation for the jQuery Timepicker Addon */
/* Written by Jun Omae */
(function($) {
$.timepicker.regional['ja'] = {
timeOnlyTitle: '時間を選択',
timeText: '時間',
hourText: '',
minuteText: '',
secondText: '',
millisecText: 'ミリ秒',
timezoneText: 'タイムゾーン',
currentText: '現時刻',
closeText: '閉じる',
timeFormat: 'hh:mm tt',
amNames: ['午前', 'AM', 'A'],
pmNames: ['午後', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['ja']);
})(jQuery);
/* Lithuanian translation for the jQuery Timepicker Addon */
/* Written by Irmantas Šiupšinskas */
(function($) {
$.timepicker.regional['lt'] = {
timeOnlyTitle: 'Pasirinkite laiką',
timeText: 'Laikas',
hourText: 'Valandos',
minuteText: 'Minutės',
secondText: 'Sekundės',
millisecText: 'Milisekundės',
timezoneText: 'Laiko zona',
currentText: 'Dabar',
closeText: 'Uždaryti',
timeFormat: 'hh:mm',
amNames: ['priešpiet', 'AM', 'A'],
pmNames: ['popiet', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['lt']);
})(jQuery);
/* Dutch translation for the jQuery Timepicker Addon */
/* Written by Martijn van der Lee */
(function($) {
$.timepicker.regional['nl'] = {
timeOnlyTitle: 'Tijdstip',
timeText: 'Tijd',
hourText: 'Uur',
minuteText: 'Minuut',
secondText: 'Seconde',
millisecText: 'Milliseconde',
timezoneText: 'Tijdzone',
currentText: 'Vandaag',
closeText: 'Sluiten',
timeFormat: 'hh:mm tt',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['nl']);
})(jQuery);
/* Polish translation for the jQuery Timepicker Addon */
/* Written by Michał Pena */
(function($) {
$.timepicker.regional['pl'] = {
timeOnlyTitle: 'Wybierz godzinę',
timeText: 'Czas',
hourText: 'Godzina',
minuteText: 'Minuta',
secondText: 'Sekunda',
millisecText: 'Milisekunda',
timezoneText: 'Strefa czasowa',
currentText: 'Teraz',
closeText: 'Gotowe',
timeFormat: 'hh:mm tt',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['pl']);
})(jQuery);
/* Brazilian Portuguese translation for the jQuery Timepicker Addon */
/* Written by Diogo Damiani (diogodamiani@gmail.com) */
(function ($) {
$.timepicker.regional['pt-BR'] = {
timeOnlyTitle: 'Escolha a hora',
timeText: 'Hora',
hourText: 'Horas',
minuteText: 'Minutos',
secondText: 'Segundos',
millisecText: 'Milissegundos',
timezoneText: 'Fuso horrio',
currentText: 'Agora',
closeText: 'Fechar',
timeFormat: 'hh:mm',
amNames: ['a.m.', 'AM', 'A'],
pmNames: ['p.m.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['pt-BR']);
})(jQuery);
/* Portuguese translation for the jQuery Timepicker Addon */
/* Written by Luan Almeida */
(function($) {
$.timepicker.regional['pt'] = {
timeOnlyTitle: 'Escolha uma hora',
timeText: 'Hora',
hourText: 'Horas',
minuteText: 'Minutos',
secondText: 'Segundos',
millisecText: 'Milissegundos',
timezoneText: 'Fuso horário',
currentText: 'Agora',
closeText: 'Fechar',
timeFormat: 'hh:mm',
amNames: ['a.m.', 'AM', 'A'],
pmNames: ['p.m.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['pt']);
})(jQuery);
/* Romanian translation for the jQuery Timepicker Addon */
/* Written by Romeo Adrian Cioaba */
(function($) {
$.timepicker.regional['ro'] = {
timeOnlyTitle: 'Alegeţi o oră',
timeText: 'Timp',
hourText: 'Ore',
minuteText: 'Minute',
secondText: 'Secunde',
millisecText: 'Milisecunde',
timezoneText: 'Fus orar',
currentText: 'Acum',
closeText: 'Închide',
timeFormat: 'hh:mm',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['ro']);
})(jQuery);
/* Russian translation for the jQuery Timepicker Addon */
/* Written by Trent Richardson */
(function($) {
$.timepicker.regional['ru'] = {
timeOnlyTitle: 'Выберите время',
timeText: 'Время',
hourText: 'Часы',
minuteText: 'Минуты',
secondText: 'Секунды',
millisecText: 'Миллисекунды',
timezoneText: 'Время зоны',
currentText: 'Теперь',
closeText: 'Закрыть',
timeFormat: 'hh:mm tt',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['ru']);
})(jQuery);
/* Slovak translation for the jQuery Timepicker Addon */
/* Written by David Vallner */
(function($) {
$.timepicker.regional['sk'] = {
timeOnlyTitle: 'Zvoľte čas',
timeText: 'Čas',
hourText: 'Hodiny',
minuteText: 'Minuty',
secondText: 'Sekundy',
millisecText: 'Milisekundy',
timezoneText: 'Časové pásmo',
currentText: 'Teraz',
closeText: 'Zavřít',
timeFormat: 'h:m',
amNames: ['dop.', 'AM', 'A'],
pmNames: ['odp.', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['sk']);
})(jQuery);
/* Turkish translation for the jQuery Timepicker Addon */
/* Written by Fehmi Can Saglam */
(function($) {
$.timepicker.regional['tr'] = {
timeOnlyTitle: 'Zaman Seçiniz',
timeText: 'Zaman',
hourText: 'Saat',
minuteText: 'Dakika',
secondText: 'Saniye',
millisecText: 'Milisaniyelik',
timezoneText: 'Zaman Dilimi',
currentText: 'Şu an',
closeText: 'Tamam',
timeFormat: 'hh:mm',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['tr']);
})(jQuery);
/* Vietnamese translation for the jQuery Timepicker Addon */
/* Written by Nguyen Dinh Trung */
(function($) {
$.timepicker.regional['vi'] = {
timeOnlyTitle: 'Chọn giờ',
timeText: 'Thời gian',
hourText: 'Giờ',
minuteText: 'Phút',
secondText: 'Giây',
millisecText: 'Phần nghìn giây',
timezoneText: 'Múi giờ',
currentText: 'Hiện thời',
closeText: 'Đóng'
timeFormat: 'h:m',
amNames: ['SA', 'AM', 'A'],
pmNames: ['CH', 'PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['vi']);
})(jQuery);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Dutch/Belgian (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Mathias Bynens <http://mathiasbynens.be/> */
jQuery(function($){
$.datepicker.regional['nl-BE'] = {
closeText: 'Sluiten',
prevText: '',
nextText: '',
currentText: 'Vandaag',
monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
weekHeader: 'Wk',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['nl-BE']);
});
\ No newline at end of file
/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Mathias Bynens <http://mathiasbynens.be/> */
jQuery(function($){
$.datepicker.regional['nl'] = {
closeText: 'Sluiten',
prevText: '',
nextText: '',
currentText: 'Vandaag',
monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
weekHeader: 'Wk',
dateFormat: 'dd-mm-yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['nl']);
});
\ No newline at end of file
......@@ -5,29 +5,35 @@
{% block head %}
<script type="text/javascript" src="/static/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/static/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/static/js/jquery.formset.js"></script>
<script type="text/javascript" src="/static/js/jquery.formset-{{ language_code }}.js"></script>
<script type="text/javascript" src="/static/js/jquery-ui-1.8.1.custom.min.js"></script>
<script type="text/javascript" src="/static/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="/static/js/jquery.ui.datepicker-{{ language_code }}.js"></script>
<link type="text/css" href="/static/css/smoothness/jquery-ui-1.8.1.custom.css" rel="stylesheet" />
<link type="text/css" href="/static/css/smoothness/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/static/js/jQuery-Timepicker-Addon/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="/static/js/jQuery-Timepicker-Addon/localization/jquery-ui-timepicker-{{ language_code }}.js"></script>
<script type="text/javascript">
String.prototype.convertToDate = function() {
var arr = this.split("-"),
day, month, year;
minutes, hours, day, month, year;
day = parseInt(arr[0], 10);
month = parseInt(arr[1], 10);
year = parseInt(arr[2], 10);
return new Date(year, month - 1, day);
ee1 = arr[2].split(" ");
year = parseInt(ee1[0], 10);
hours = ee1[1].split(':')[0];
minutes = ee1[1].split(':')[1];
return new Date(year, month - 1, day, hours, minutes);
}
function fill_date() {
lastinput = $('input[name*=-choice]').eq(-2).val();
if (lastinput) {
lastday = lastinput.convertToDate();
nextday = new Date(lastday.getFullYear(),lastday.getMonth(),lastday.getDate()+1);
nextinput = nextday.getDate() + '-' + (nextday.getMonth() + 1) + '-' + nextday.getFullYear();
nextday = new Date(lastday.getFullYear(),lastday.getMonth(),lastday.getDate()+1,lastday.getHours(),lastday.getMinutes());
nextinput = nextday.getDate() + '-' + (nextday.getMonth() + 1) + '-' + nextday.getFullYear() + ' ' + nextday.getHours() + ':' + + nextday.getMinutes();
//return lastinput + "\n\n" + nextday + '\n\n' + nextinput;
$('input[name*=-choice]').eq(-1).val(nextinput);
}
......@@ -40,8 +46,9 @@
var this_id = $(this).attr("id"); // current inputs id
var new_id = this_id +1; // a new id
$(this).attr("id", new_id); // change to new id
$(this).datepicker({
$(this).datetimepicker({
dateFormat: 'dd-mm-yy',
timeFormat: 'hh:mm',
//showButtonPanel: true,
showOn: 'button', //both
buttonImage: '/static/images/calendar.png',
......
......@@ -25,7 +25,7 @@
<td class='names'></td>
{% for choice in object.choice_set.all %}
<td> {{ choice.choice|date:"d/m" }} <span class="tooltip"><b> {{ choice.choice|date:'l d F'}} </b> <br />
{{ choice.choice|date:'P'}} <br />
{{ choice.choice|date:'H:i a'}} <br />
<font class="blue">{{ choice.details }}</font></span><div class="subl"><!-- --></div></td>
{% endfor %}
</tr>
......@@ -86,7 +86,7 @@
<h3>Details</h3>
{% for choice in object.choice_set.all %}
<p class="indent" id='info-{{ choice }}'>
<span class="da">{{ choice.choice|date:"l d F, P"}} </span> -
<span class="da">{{ choice.choice|date:"l d F, H:i a"}} </span> -
<span class="blue">{{ choice.de