aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2008-10-08 05:22:24 +0000
committerrub <rub@piwigo.org>2008-10-08 05:22:24 +0000
commit0b1a237d352141bdb48af4b4b73dcf551404bdaa (patch)
treea7199919d9f825c0417aa0e2bffe015449a5fd3f /admin
parent3eecf04629ce2a48208e2f9fe3189eba535d6597 (diff)
jQuery Datepicker:
improve disabled elements on day and month lits (disable day for short months) (disable day and month for double selection) git-svn-id: http://piwigo.org/svn/trunk@2684 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/template/goto/include/datepicker.inc.tpl81
1 files changed, 68 insertions, 13 deletions
diff --git a/admin/template/goto/include/datepicker.inc.tpl b/admin/template/goto/include/datepicker.inc.tpl
index ef6829382..4b3f4214c 100644
--- a/admin/template/goto/include/datepicker.inc.tpl
+++ b/admin/template/goto/include/datepicker.inc.tpl
@@ -35,13 +35,67 @@ function pwg_initialization_datepicker(day, month, year, linked_date, checked_on
}
}
- // Prevent selection of invalid dates through the select controls
- function pwg_check_date()
+ // In order to desable element of list
+ function pwg_disabled_selection()
{
array_date = $(linked_date).val().split('-');
y = array_date[0];
m = array_date[1];
- d = array_date[2];
+
+ // Init list
+ $(day + " option").attr("disabled", "");
+ $(month + " option").attr("disabled", "");
+
+ var daysInMonth = 32 - new Date(y, m - 1, 32).getDate();
+ $(day + " option:gt(" + (daysInMonth) +")").attr("disabled", "disabled");
+
+ if ((min_linked_date != null) && ($(min_linked_date).datepicker("getDate") != null))
+ {
+ date_cmp = min_linked_date;
+ op_cmp = "lt";
+ }
+ else if ((max_linked_date != null) && ($(max_linked_date).datepicker("getDate") != null))
+ {
+ date_cmp = max_linked_date;
+ op_cmp = "gt";
+ }
+ else
+ {
+ date_cmp = null;
+ op_cmp = null;
+ }
+
+ if (op_cmp != null)
+ {
+ array_date = $(date_cmp).val().split('-');
+ y_cmp = array_date[0];
+ m_cmp = array_date[1];
+ d_cmp = array_date[2];
+
+ if (y == y_cmp)
+ {
+ $(month + " option:" + op_cmp + "(" + (m_cmp) +")").attr("disabled", "disabled");
+ if (op_cmp == "lt")
+ {
+ $(month + " option:eq(" + (0) +")").attr("disabled", "");
+ }
+
+ if (m == m_cmp)
+ {
+ $(day + " option:" + op_cmp + "(" + (d_cmp) +")").attr("disabled", "disabled");
+ if (op_cmp == "lt")
+ {
+ $(day + " option:eq(" + (0) +")").attr("disabled", "");
+ }
+ }
+ }
+ }
+ }
+
+ // Prevent selection of invalid dates through the select controls
+ function pwg_check_date()
+ {
+ last_date = $(linked_date).val();
$(linked_date).val(pwg_get_fmt_datepicker(day, month, year));
@@ -60,18 +114,13 @@ function pwg_initialization_datepicker(day, month, year, linked_date, checked_on
if (cancel)
{
- $(year).val(y);
- $(month).val(m);
- $(day).val(d);
+ array_date = last_date.split('-');
+ $(year).val(array_date[0]);
+ $(month).val(array_date[1]);
+ $(day).val(array_date[2]);
// check again
pwg_check_date();
}
- else
- {
- var daysInMonth = 32 - new Date($(year).val(), $(month).val() - 1, 32).getDate();
- $(day + " option").attr("disabled", "");
- $(day + " option:gt(" + (daysInMonth) +")").attr("disabled", "disabled");
- }
}
jQuery().ready(function(){
@@ -131,7 +180,13 @@ function pwg_initialization_datepicker(day, month, year, linked_date, checked_on
pwg_on_date_change();
});
- // In order to desable element of list
+ // Check showed controls
+ jQuery(day + ", " + month + ", " + year).focus(
+ function ()
+ {
+ pwg_disabled_selection();
+ });
+
// In order to init linked input
pwg_check_date();
});