NEW jquery date selector become default date selector

This commit is contained in:
Laurent Destailleur 2017-08-22 09:23:35 +02:00
parent 348a42542d
commit 731f826a55
3 changed files with 133 additions and 114 deletions

View File

@ -4729,8 +4729,8 @@ class Form
// You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery'
$usecalendar='combo'; $usecalendar='combo';
if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) $usecalendar=empty($conf->global->MAIN_POPUP_CALENDAR)?'eldy':$conf->global->MAIN_POPUP_CALENDAR; if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) $usecalendar=empty($conf->global->MAIN_POPUP_CALENDAR)?'jquery':$conf->global->MAIN_POPUP_CALENDAR;
if ($conf->browser->phone) $usecalendar='combo'; //if (! empty($conf->browser->phone)) $usecalendar='combo';
if ($d) if ($d)
{ {
@ -4772,9 +4772,21 @@ class Form
{ {
if (! $disabled) if (! $disabled)
{ {
print "<script type='text/javascript'>"; $retstring.="<script type='text/javascript'>";
print "$(function(){ $('#".$prefix."').datepicker({ dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."', autoclose: true, todayHighlight: true }) });"; $retstring.="$(function(){ $('#".$prefix."').datepicker({
print "</script>"; dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."',
autoclose: true,
todayHighlight: true,";
if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS))
{
$retstring.="
showOn: 'button',
buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png',
buttonImageOnly: true";
}
$retstring.="
}) });";
$retstring.="</script>";
} }
// Zone de saisie manuelle de la date // Zone de saisie manuelle de la date
@ -4786,14 +4798,20 @@ class Form
// Icone calendrier // Icone calendrier
if (! $disabled) if (! $disabled)
{ {
//$retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"'; /* Not required. Managed by option buttonImage of jquery
//$base=DOL_URL_ROOT.'/core/'; $retstring.=img_object($langs->trans("SelectDate"),'calendarday','id="'.$prefix.'id" class="datecallink"');
//$retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"'; $retstring.="<script type='text/javascript'>";
//$retstring.='>'; $retstring.="jQuery(document).ready(function() {";
$retstring.=img_object($langs->trans("SelectDate"),'calendarday','class="datecallink"'); $retstring.=' jQuery("#'.$prefix.'id").click(function() {';
//$retstring.='</button>'; $retstring.=" jQuery('#".$prefix."').focus();";
$retstring.=' });';
$retstring.='});';
$retstring.="</script>";*/
}
else
{
$retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"),'calendarday','class="datecallink"').'</button>';
} }
else $retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"),'calendarday','class="datecallink"').'</button>';
$retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n"; $retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
$retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n"; $retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
@ -4801,7 +4819,7 @@ class Form
} }
else else
{ {
print "Bad value of MAIN_POPUP_CALENDAR"; $retstring.="Bad value of MAIN_POPUP_CALENDAR";
} }
} }
// Show date with combo selects // Show date with combo selects

View File

@ -166,6 +166,7 @@ function closeDPBox()
function dpChangeDay(dateFieldID,format) function dpChangeDay(dateFieldID,format)
{ {
showDP.datefieldID=dateFieldID; showDP.datefieldID=dateFieldID;
console.log("Call dpChangeDay, we save date into detailed fields.");
var thefield=getObjectFromID(showDP.datefieldID); var thefield=getObjectFromID(showDP.datefieldID);
var thefieldday=getObjectFromID(showDP.datefieldID+"day"); var thefieldday=getObjectFromID(showDP.datefieldID+"day");

View File

@ -1318,7 +1318,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
// Add datepicker default options // Add datepicker default options
if (! defined('DISABLE_DATE_PICKER')) if (! defined('DISABLE_DATE_PICKER'))
{ {
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php'.($ext?'?'.$ext:'').'"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.($ext?'&'.$ext:'').'"></script>'."\n";
} }
// JS forced by modules (relative url starting with /) // JS forced by modules (relative url starting with /)