aboutsummaryrefslogtreecommitdiffstats
path: root/admin/template
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2008-10-10 21:52:00 +0000
committerrub <rub@piwigo.org>2008-10-10 21:52:00 +0000
commit650a40bf78263cced01e9a1101a4d8bd944b388c (patch)
tree2a89d1aae58e18c5f8daa62d756e0a5e1f894fb1 /admin/template
parentc7523041643b30ceea65ce945a8678c8728a1616 (diff)
jQuery Datepicker:
Move code source to template-common in order to use datepicker on version after butterfly Merge trunk 2703:2704 into branch 2.0 git-svn-id: http://piwigo.org/svn/branches/2.0@2705 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/template/goto/include/datepicker.inc.tpl187
1 files changed, 5 insertions, 182 deletions
diff --git a/admin/template/goto/include/datepicker.inc.tpl b/admin/template/goto/include/datepicker.inc.tpl
index 4b3f4214c..812bf9632 100644
--- a/admin/template/goto/include/datepicker.inc.tpl
+++ b/admin/template/goto/include/datepicker.inc.tpl
@@ -3,194 +3,17 @@
{known_script id="jquery.ui" src=$ROOT_URL|@cat:"template-common/lib/ui/ui.core.packed.js"}
{known_script id="jquery.ui.datepicker" src=$ROOT_URL|@cat:"template-common/lib/ui/ui.datepicker.packed.js"}
{known_script id="jquery.ui.datepicker-$lang_info.code" src=$ROOT_URL|@cat:"template-common/lib/ui/i18n/ui.datepicker-"|@cat:$lang_info.code|@cat:".js"}
+{known_script id="datepicker.js" src=$ROOT_URL|@cat:"template-common/datepicker.js"}
{html_head}
<link rel="stylesheet" type="text/css" href="{$ROOT_URL}template-common/lib/ui/ui.datepicker.css">
{/html_head}
-{literal}
<script type="text/javascript">
-// return formated date with control values
-// day, month, year: selectors of visible date controls
-function pwg_get_fmt_datepicker(day, month, year)
-{
- return $(year).val() + "-" + $(month).val() + "-" + $(day).val();
-}
-
-// initialize controls
-// day, month, year: selectors of visible date controls
-// linked_date: selector of hidden linked dates control
-// checked_on_change: selector of control to change "checked" attribut
-// min_linked_date: selector of hidden linked date control witch give min value
-// max_linked_date: selector of hidden linked date control witch give max value
function pwg_initialization_datepicker(day, month, year, linked_date, checked_on_change, min_linked_date, max_linked_date)
-{
- // Action on change date value
- function pwg_on_date_change()
- {
- pwg_check_date();
- if (checked_on_change != null)
- {
- $(checked_on_change).attr("checked", "true");
- }
- }
-
- // 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];
-
- // 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));
-
- if ((min_linked_date != null) && ($(min_linked_date).datepicker("getDate") != null))
- {
- cancel = ($(min_linked_date).datepicker("getDate") > $(linked_date).datepicker("getDate"));
- }
- else if ((max_linked_date != null) && ($(max_linked_date).datepicker("getDate") != null))
- {
- cancel = ($(max_linked_date).datepicker("getDate") < $(linked_date).datepicker("getDate"));
- }
- else
- {
- cancel = false;
- }
-
- if (cancel)
- {
- 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();
- }
- }
-
- jQuery().ready(function(){
- // Init hidden value
- $(linked_date).val(pwg_get_fmt_datepicker(day, month, year));
-
- // Init Datepicker
- jQuery(linked_date).datepicker({
- dateFormat:'yy-m-d',
- beforeShow:
- // Prepare to show a date picker linked to three select controls
- function readLinked(input) {
- //$(linked_date).val(pwg_get_fmt_datepicker(day, month, year));
- if (min_linked_date != null)
- {
- return {minDate: $(min_linked_date).datepicker("getDate")};
- }
- else if (max_linked_date != null)
- {
- return {maxDate: $(max_linked_date).datepicker("getDate")};
- }
- else
- {
- return {};
- }
- },
- onSelect:
- // Update three select controls to match a date picker selection
- function updateLinked(date) {
- if (date.length == 0)
- {
- $(year).val("");
- $(month).val("0");
- $(day).val("0");
- }
- else
- {
- array_date = date.split('-');
- $(year).val(array_date[0]);
- $(month).val(array_date[1]);
- $(day).val(array_date[2]);
- }
- pwg_on_date_change();
- },
- showOn: "both",
-{/literal}
- buttonImage: "{$ROOT_URL}admin/template/{$themeconf.template}/icon/datepicker.png",
-{literal}
- buttonImageOnly: true,
- buttonText: ""
- });
-
- // Check showed controls
- jQuery(day + ", " + month + ", " + year).change(
- function ()
- {
- pwg_on_date_change();
- });
-
- // Check showed controls
- jQuery(day + ", " + month + ", " + year).focus(
- function ()
- {
- pwg_disabled_selection();
- });
-
- // In order to init linked input
- pwg_check_date();
- });
-
+{ldelim}
+ return pwg_common_initialization_datepicker(
+ "{$ROOT_URL}admin/template/{$themeconf.template}/icon/datepicker.png",
+ day, month, year, linked_date, checked_on_change, min_linked_date, max_linked_date);
}
</script>
-{/literal}