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

@ -46,7 +46,7 @@ else header('Cache-Control: no-cache');
?> ?>
/* /*
* ================================================================= * =================================================================
* Purpose: * Purpose:
* Pour la saisie des dates par calendrier Input: base "/theme/eldy" dateFieldID * Pour la saisie des dates par calendrier Input: base "/theme/eldy" dateFieldID
* "dateo" Nom du champ format "dd/MM/yyyy" Format issu de Dolibarr de * "dateo" Nom du champ format "dd/MM/yyyy" Format issu de Dolibarr de
@ -63,7 +63,7 @@ function showDP(base,dateFieldID,format,codelang)
showDP.datefieldID=dateFieldID; // Must be after the close showDP.datefieldID=dateFieldID; // Must be after the close
var dateField=getObjectFromID(dateFieldID); var dateField=getObjectFromID(dateFieldID);
// get positioning // get positioning
var thetop=getTop(dateField)+dateField.offsetHeight; var thetop=getTop(dateField)+dateField.offsetHeight;
@ -86,7 +86,7 @@ function showDP(base,dateFieldID,format,codelang)
showDP.box.style.position="absolute"; showDP.box.style.position="absolute";
showDP.box.style.top=thetop + "px"; showDP.box.style.top=thetop + "px";
showDP.box.style.left=theleft + "px"; showDP.box.style.left=theleft + "px";
if (dateField.value) // Si il y avait valeur initiale dans champ if (dateField.value) // Si il y avait valeur initiale dans champ
{ {
selDate=getDateFromFormat(dateField.value,format); selDate=getDateFromFormat(dateField.value,format);
@ -129,7 +129,7 @@ function resetDP(base,dateFieldID,format,codelang)
var dateField=getObjectFromID(dateFieldID); var dateField=getObjectFromID(dateFieldID);
dateField.value = formatDate(new Date(), format); dateField.value = formatDate(new Date(), format);
dpChangeDay(dateFieldID,format); dpChangeDay(dateFieldID,format);
var alreadybox=getObjectFromID("DPCancel"); var alreadybox=getObjectFromID("DPCancel");
if (alreadybox) showDP(base,dateFieldID,format,codelang); if (alreadybox) showDP(base,dateFieldID,format,codelang);
} }
@ -147,25 +147,26 @@ function loadMonth(base,month,year,ymd,codelang)
} }
var req=null; var req=null;
req=loadXMLDoc(theURL,null,false); req=loadXMLDoc(theURL,null,false);
if (req.responseText == '') alert('Failed to get URL '.theURL); if (req.responseText == '') alert('Failed to get URL '.theURL);
// alert(theURL+' - '+req.responseText); // L'url doit avoir la meme racine // alert(theURL+' - '+req.responseText); // L'url doit avoir la meme racine
// que la pages et elements sinon pb de securite. // que la pages et elements sinon pb de securite.
showDP.box.innerHTML=req.responseText; showDP.box.innerHTML=req.responseText;
} }
function closeDPBox() function closeDPBox()
{ {
document.body.removeChild(showDP.box); document.body.removeChild(showDP.box);
displaySelectBoxes(); displaySelectBoxes();
showDP.box=null; showDP.box=null;
showDP.datefieldID=null; showDP.datefieldID=null;
} }
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");
@ -200,7 +201,7 @@ function dpClickDay(year,month,day,format)
var thefieldmonth=getObjectFromID(showDP.datefieldID+"month"); var thefieldmonth=getObjectFromID(showDP.datefieldID+"month");
var thefieldyear=getObjectFromID(showDP.datefieldID+"year"); var thefieldyear=getObjectFromID(showDP.datefieldID+"year");
var dt = new Date(year, month-1, day); var dt = new Date(year, month-1, day);
thefield.value=formatDate(dt,format); thefield.value=formatDate(dt,format);
if(thefield.onchange) thefield.onchange.call(thefield); if(thefield.onchange) thefield.onchange.call(thefield);
@ -238,7 +239,7 @@ function getTop(theitem){
offsetTop += offsetTrail.offsetTop; offsetTop += offsetTrail.offsetTop;
offsetTrail = offsetTrail.offsetParent; offsetTrail = offsetTrail.offsetParent;
} }
if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined")
offsetTop += document.body.TopMargin; offsetTop += document.body.TopMargin;
return offsetTop; return offsetTop;
} }
@ -251,7 +252,7 @@ function getLeft(theitem){
offsetLeft += offsetTrail.offsetLeft; offsetLeft += offsetTrail.offsetLeft;
offsetTrail = offsetTrail.offsetParent; offsetTrail = offsetTrail.offsetParent;
} }
if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined")
offsetLeft += document.body.leftMargin; offsetLeft += document.body.leftMargin;
return offsetLeft; return offsetLeft;
} }
@ -260,16 +261,16 @@ function getLeft(theitem){
// Create XMLHttpRequest object and load url // Create XMLHttpRequest object and load url
// Used by calendar or other ajax processes // Used by calendar or other ajax processes
// Return req built or false if error // Return req built or false if error
function loadXMLDoc(url,readyStateFunction,async) function loadXMLDoc(url,readyStateFunction,async)
{ {
// req must be defined by caller with // req must be defined by caller with
// var req = false; // var req = false;
// branch for native XMLHttpRequest object (Mozilla, Safari...) // branch for native XMLHttpRequest object (Mozilla, Safari...)
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
{ {
req = new XMLHttpRequest(); req = new XMLHttpRequest();
// if (req.overrideMimeType) { // if (req.overrideMimeType) {
// req.overrideMimeType('text/xml'); // req.overrideMimeType('text/xml');
// } // }
@ -286,7 +287,7 @@ function loadXMLDoc(url,readyStateFunction,async)
try { try {
req = new ActiveXObject("Microsoft.XMLHTTP"); req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {} } catch (e) {}
} }
} }
// If XMLHttpRequestObject req is ok, call URL // If XMLHttpRequestObject req is ok, call URL
@ -321,9 +322,9 @@ function loadXMLDoc(url,readyStateFunction,async)
*/ */
function hideSelectBoxes() { function hideSelectBoxes() {
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1)
{ {
for(var i = 0; i < document.all.length; i++) for(var i = 0; i < document.all.length; i++)
{ {
if(document.all[i].tagName) if(document.all[i].tagName)
if(document.all[i].tagName == "SELECT") if(document.all[i].tagName == "SELECT")
@ -337,9 +338,9 @@ function hideSelectBoxes() {
*/ */
function displaySelectBoxes() { function displaySelectBoxes() {
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1)
{ {
for(var i = 0; i < document.all.length; i++) for(var i = 0; i < document.all.length; i++)
{ {
if(document.all[i].tagName) if(document.all[i].tagName)
if(document.all[i].tagName == "SELECT") if(document.all[i].tagName == "SELECT")
@ -351,7 +352,7 @@ function displaySelectBoxes() {
/* /*
* ================================================================= * =================================================================
* Function: * Function:
* formatDate (javascript object Date(), format) Purpose: Returns a date in the * formatDate (javascript object Date(), format) Purpose: Returns a date in the
* output format specified. The format string can use the following tags: Field | * output format specified. The format string can use the following tags: Field |
@ -366,10 +367,10 @@ function displaySelectBoxes() {
function formatDate(date,format) function formatDate(date,format)
{ {
// alert('formatDate date='+date+' format='+format); // alert('formatDate date='+date+' format='+format);
// Force parametres en chaine // Force parametres en chaine
format=format+""; format=format+"";
var result=""; var result="";
var year=date.getYear()+""; if (year.length < 4) { year=""+(year-0+1900); } var year=date.getYear()+""; if (year.length < 4) { year=""+(year-0+1900); }
@ -402,7 +403,7 @@ function formatDate(date,format)
else if (substr == 'mm') { result=result+(minute<0||minute>9?"":"0")+minute; } else if (substr == 'mm') { result=result+(minute<0||minute>9?"":"0")+minute; }
else if (substr == 'ss') { result=result+(seconde<0||seconde>9?"":"0")+seconde; } else if (substr == 'ss') { result=result+(seconde<0||seconde>9?"":"0")+seconde; }
else { result=result+substr; } else { result=result+substr; }
i+=substr.length; i+=substr.length;
} }
@ -412,22 +413,22 @@ function formatDate(date,format)
/* /*
* ================================================================= * =================================================================
* Function: * Function:
* getDateFromFormat(date_string, format_string) Purpose: This function takes a * getDateFromFormat(date_string, format_string) Purpose: This function takes a
* date string and a format string. It parses the date string with format and it * date string and a format string. It parses the date string with format and it
* returns the date as a javascript Date() object. If date does not match * returns the date as a javascript Date() object. If date does not match
* format, it returns 0. The format string can use the following tags: * format, it returns 0. The format string can use the following tags:
* Field | Tags * Field | Tags
* -------------+----------------------------------- * -------------+-----------------------------------
* Year | yyyy (4 digits), yy (2 digits) * Year | yyyy (4 digits), yy (2 digits)
* Month | MM (2 digits) * Month | MM (2 digits)
* Day of Month | dd (2 digits) * Day of Month | dd (2 digits)
* Hour (1-12) | hh (2 digits) * Hour (1-12) | hh (2 digits)
* Hour (0-23) | HH (2 digits) * Hour (0-23) | HH (2 digits)
* Minute | mm (2 digits) * Minute | mm (2 digits)
* Second | ss (2 digits) * Second | ss (2 digits)
* Author: Laurent Destailleur * Author: Laurent Destailleur
* Licence: GPL * Licence: GPL
* ================================================================== * ==================================================================
*/ */
@ -440,7 +441,7 @@ function getDateFromFormat(val,format)
format=format+""; format=format+"";
if (val == '') return 0; if (val == '') return 0;
var now=new Date(); var now=new Date();
var year=now.getYear(); if (year.length < 4) { year=""+(year-0+1900); } var year=now.getYear(); if (year.length < 4) { year=""+(year-0+1900); }
var month=now.getMonth()+1; var month=now.getMonth()+1;
@ -466,37 +467,37 @@ function getDateFromFormat(val,format)
} }
// alert('substr='+substr); // alert('substr='+substr);
if (substr == "yyyy") year=getIntegerInString(val,d,4,4); if (substr == "yyyy") year=getIntegerInString(val,d,4,4);
if (substr == "yy") year=""+(getIntegerInString(val,d,2,2)-0+1900); if (substr == "yy") year=""+(getIntegerInString(val,d,2,2)-0+1900);
if (substr == "MM" ||substr == "M") if (substr == "MM" ||substr == "M")
{ {
month=getIntegerInString(val,d,1,2); month=getIntegerInString(val,d,1,2);
d -= 2- month.length; d -= 2- month.length;
} }
if (substr == "dd") if (substr == "dd")
{ {
day=getIntegerInString(val,d,1,2); day=getIntegerInString(val,d,1,2);
d -= 2- day.length; d -= 2- day.length;
} }
if (substr == "HH" ||substr == "hh" ) if (substr == "HH" ||substr == "hh" )
{ {
hour=getIntegerInString(val,d,1,2); hour=getIntegerInString(val,d,1,2);
d -= 2- hour.length; d -= 2- hour.length;
} }
if (substr == "mm"){ if (substr == "mm"){
minute=getIntegerInString(val,d,1,2); minute=getIntegerInString(val,d,1,2);
d -= 2- minute.length; d -= 2- minute.length;
} }
if (substr == "ss") if (substr == "ss")
{ {
seconde=getIntegerInString(val,d,1,2); seconde=getIntegerInString(val,d,1,2);
d -= 2- seconde.length; d -= 2- seconde.length;
} }
i+=substr.length; i+=substr.length;
d+=substr.length; d+=substr.length;
} }
// Check if format param are ok // Check if format param are ok
if (year==null||year<1) { return 0; } if (year==null||year<1) { return 0; }
if (month==null||(month<1)||(month>12)) { return 0; } if (month==null||(month<1)||(month>12)) { return 0; }
@ -504,15 +505,15 @@ function getDateFromFormat(val,format)
if (hour==null||(hour<0)||(hour>24)) { return 0; } if (hour==null||(hour<0)||(hour>24)) { return 0; }
if (minute==null||(minute<0)||(minute>60)) { return 0; } if (minute==null||(minute<0)||(minute>60)) { return 0; }
if (seconde==null||(seconde<0)||(seconde>60)) { return 0; } if (seconde==null||(seconde<0)||(seconde>60)) { return 0; }
// alert(year+' '+month+' '+day+' '+hour+' '+minute+' '+seconde); // alert(year+' '+month+' '+day+' '+hour+' '+minute+' '+seconde);
return new Date(year,month-1,day,hour,minute,seconde); return new Date(year,month-1,day,hour,minute,seconde);
} }
/* /*
* ================================================================= * =================================================================
* Function: * Function:
* stringIsInteger(string) * stringIsInteger(string)
* Purpose: Return true if string is an integer * Purpose: Return true if string is an integer
* ================================================================== * ==================================================================
*/ */
@ -530,9 +531,9 @@ function stringIsInteger(str)
} }
/* /*
* ================================================================= * =================================================================
* Function: * Function:
* getIntegerInString(string,pos,minlength,maxlength) * getIntegerInString(string,pos,minlength,maxlength)
* Purpose: Return part of string from position i that is integer * Purpose: Return part of string from position i that is integer
* ================================================================== * ==================================================================
*/ */
@ -549,10 +550,10 @@ function getIntegerInString(str,i,minlength,maxlength)
/* /*
* ================================================================= * =================================================================
* Purpose: * Purpose:
* Clean string to have it url encoded * Clean string to have it url encoded
* Input: s * Input: s
* Author: Laurent Destailleur * Author: Laurent Destailleur
* Licence: GPL * Licence: GPL
* ================================================================== * ==================================================================
@ -566,11 +567,11 @@ function urlencode(s) {
/* /*
* ================================================================= * =================================================================
* Purpose: * Purpose:
* Applique un delai avant execution. Used for autocompletion of companies. * Applique un delai avant execution. Used for autocompletion of companies.
* Input: funct, delay * Input: funct, delay
* Author: Regis Houssin * Author: Regis Houssin
* Licence: GPL * Licence: GPL
* ================================================================== * ==================================================================
*/ */
@ -581,11 +582,11 @@ function urlencode(s) {
/* /*
* ================================================================= * =================================================================
* Purpose: * Purpose:
* Clean values of a "Sortable.serialize". Used by drag and drop. * Clean values of a "Sortable.serialize". Used by drag and drop.
* Input: expr * Input: expr
* Author: Regis Houssin * Author: Regis Houssin
* Licence: GPL * Licence: GPL
* ================================================================== * ==================================================================
*/ */
@ -599,12 +600,12 @@ function cleanSerialize(expr) {
/* /*
* ================================================================= * =================================================================
* Purpose: Display a temporary message in input text fields (For showing help message on * Purpose: Display a temporary message in input text fields (For showing help message on
* input field). * input field).
* Input: fieldId * Input: fieldId
* Input: message * Input: message
* Author: Regis Houssin * Author: Regis Houssin
* Licence: GPL * Licence: GPL
* ================================================================== * ==================================================================
*/ */
@ -617,11 +618,11 @@ function displayMessage(fieldId,message) {
} }
/* /*
* ================================================================= * =================================================================
* Purpose: Hide a temporary message in input text fields (For showing help message on * Purpose: Hide a temporary message in input text fields (For showing help message on
* input field). * input field).
* Input: fiedId * Input: fiedId
* Input: message * Input: message
* Author: Regis Houssin * Author: Regis Houssin
* Licence: GPL * Licence: GPL
* ================================================================== * ==================================================================
@ -673,7 +674,7 @@ function setConstant(url, code, input, entity, strict) {
$(newvalue).removeClass("butAction"); $(newvalue).removeClass("butAction");
$(newvalue).addClass("butActionRefused"); $(newvalue).addClass("butActionRefused");
} }
}); });
// Show another element // Show another element
} else if (type == "showhide" || type == "show") { } else if (type == "showhide" || type == "show") {
$.each(data, function(key, value) { $.each(data, function(key, value) {
@ -734,7 +735,7 @@ function delConstant(url, code, input, entity, strict) {
$(newvalue).removeClass("butActionRefused"); $(newvalue).removeClass("butActionRefused");
$(newvalue).addClass("butAction"); $(newvalue).addClass("butAction");
} }
}); });
// Hide another element // Hide another element
} else if (type == "showhide" || type == "hide") { } else if (type == "showhide" || type == "hide") {
$.each(data, function(key, value) { $.each(data, function(key, value) {
@ -816,13 +817,13 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
} }
} }
/* /*
* ================================================================= * =================================================================
* This is to allow to transform all select box into ajax autocomplete box * This is to allow to transform all select box into ajax autocomplete box
* with just one line: * with just one line:
* $(function() { $( "#idofmylist" ).combobox(); }); * $(function() { $( "#idofmylist" ).combobox(); });
* Do not use it on large combo boxes * Do not use it on large combo boxes
* ================================================================= * =================================================================
*/ */
(function( $ ) { (function( $ ) {
$.widget( "ui.combobox", { $.widget( "ui.combobox", {
@ -933,11 +934,11 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
/** /**
* Function to output a dialog bog for copy/paste * Function to output a dialog bog for copy/paste
* *
* @param string text Text to put into copy/paste area * @param string text Text to put into copy/paste area
* @param string text2 Text to put under the copy/paste area * @param string text2 Text to put under the copy/paste area
*/ */
function copyToClipboard(text,text2) function copyToClipboard(text,text2)
{ {
text = text.replace(/<br>/g,"\n"); text = text.replace(/<br>/g,"\n");
var newElem = '<textarea id="coordsforpopup" style="border: none; width: 90%; height: 120px;">'+text+'</textarea><br><br>'+text2; var newElem = '<textarea id="coordsforpopup" style="border: none; width: 90%; height: 120px;">'+text+'</textarea><br><br>'+text2;
@ -951,7 +952,7 @@ function copyToClipboard(text,text2)
/** /**
* Show a popup HTML page. Use the "window.open" function. * Show a popup HTML page. Use the "window.open" function.
* *
* @param string url Url * @param string url Url
* @param string title Title of popup * @param string title Title of popup
* @return boolean False * @return boolean False
@ -983,7 +984,7 @@ function document_preview(file, type, title)
{ {
var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"]; var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"];
console.log("document_preview A click was done. file="+file+", type="+type+", title="+title); console.log("document_preview A click was done. file="+file+", type="+type+", title="+title);
if ($.inArray(type, ValidImageTypes) < 0) { if ($.inArray(type, ValidImageTypes) < 0) {
var width='85%'; var width='85%';
var object_width='100%'; var object_width='100%';
@ -1034,13 +1035,13 @@ function document_preview(file, type, title)
} }
/* /*
* Provide a function to get an URL GET parameter in javascript * Provide a function to get an URL GET parameter in javascript
* *
* @param string name Name of parameter * @param string name Name of parameter
* @param mixed valueifnotfound Value if not found * @param mixed valueifnotfound Value if not found
* @return string Value * @return string Value
*/ */
function getParameterByName(name, valueifnotfound) function getParameterByName(name, valueifnotfound)
{ {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
@ -1098,7 +1099,7 @@ function getParameterByName(name, valueifnotfound)
} }
})(); })();
// Another solution, easier, to build a javascript rounding function // Another solution, easier, to build a javascript rounding function
function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); } function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); }
@ -1146,10 +1147,10 @@ function price2numjs(amount) {
amount = amount.replace(dec, '.'); amount = amount.replace(dec, '.');
//console.log("amount before="+amount+" rouding="+rounding) //console.log("amount before="+amount+" rouding="+rounding)
var res = Math.round10(amount, - rounding); var res = Math.round10(amount, - rounding);
// Other solution is // Other solution is
// var res = dolroundjs(amount, rounding) // var res = dolroundjs(amount, rounding)
console.log("res="+res) console.log("res="+res)
return res; return res;
} }

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 /)