Commit b69208eb authored by chris's avatar chris

Next date guessed when previous date exists

parent 7073e858
# Django settings for nuage project.
# Django settings for Nuages
# Shouldn't django autofind the templates folder in the project root folder?
import os
......
# Django settings for nuage project.
# Django settings for Nuages
import os
PROJECT_DIR = os.path.normpath(os.path.dirname(__file__))
......
{% extends "base.html" %}
{% block title %}nuage - Create an account{% endblock %}
{% block title %}Nuages - Create an account{% endblock %}
{% block chapeau %}
......
{% extends "base.html" %}
{% load i18n %}
{% block title %}nuage - {{object}}{% endblock %}
{% block title %}Nuages - {{object}}{% endblock %}
{% block head %}
......@@ -10,41 +10,64 @@
<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.datepicker-{{ language_code }}.js"></script>
<link type="text/css" href="/static/css/smoothness/jquery-ui-1.8.1.custom.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function(){
// new rows datepicker need to be re-initialized
function addcalls() {
$('form').find("input").each(function(){
//$("input").each(function(){
if($(this).hasClass("hasdatepicker")){ // if the current input has the hasDatpicker class
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).removeClass('hasdatepicker'); // remove hasDatepicker class
// re-init datepicker
$(this).datepicker({
dateFormat: 'dd-mm-yy',
//showButtonPanel: true,
showOn: 'button', //'both',
<script type="text/javascript">
String.prototype.convertToDate = function() {
var arr = this.split("-"),
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);
}
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();
//return lastinput + "\n\n" + nextday + '\n\n' + nextinput;
$('input[name*=-choice]').eq(-1).val(nextinput);
}
}
$(document).ready(function() {
function add_calls() {
$('form').find("input").each(function() {
if($(this).hasClass("hasdatepicker")){
//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({
dateFormat: 'dd-mm-yy',
//showButtonPanel: true,
showOn: 'button', //both
buttonImage: '/static/images/calendar.png',
buttonImageOnly: true,
minDate: '+1d',
});
}
});
};
$(function() {
$('#dateChoice tbody tr').formset({
//prefix: 'ordered_items';
prefix: 'choice_set',
added: addcalls,
});
});
});
// Remove hasDatepicker class: not to be touched next time function is called
$(this).removeClass('hasdatepicker');
}
});
}
// Enable client-side modifications of the formset
$('#dateChoice tbody tr').formset({
prefix: 'choice_set',
added: post_actions,
});
function post_actions() {
// New rows datepicker need to be re-initialized
add_calls();
// Auto-fill new date
fill_date();
}
addcalls();
//alert('This is what an alert message looks like.');
// Init calendars
add_calls();
});
</script>
......@@ -56,15 +79,15 @@
text-indent:20px;
background:url(/static/images/add.png) no-repeat left center;
}
.delete-row {
//float:right;
//display:block;
//margin:5px 0 0 7px;
//text-indent:20px;
//background:url(/static/images/delete.png) no-repeat left center;
//width:16px;
//height:16px;
}
/* .delete-row {
float:right;
display:block;
margin:5px 0 0 7px;
text-indent:20px;
background:url(/static/images/delete.png) no-repeat left center;
width:16px;
height:16px;
} */
</style>
{% endblock %}
......@@ -119,7 +142,5 @@
</form>
</div>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment