Qual: Move init of vars for old datepicker into new js script file.

This commit is contained in:
Laurent Destailleur 2011-10-30 18:34:36 +01:00
parent 7e1715d025
commit 415c04e827
2 changed files with 36 additions and 21 deletions

View File

@ -1,12 +1,24 @@
<?php
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
*
* Script javascript that contains functions for datepicker default options
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/js/datepicker.js.php
* \brief File that include javascript functions for datepicker default options
* \brief File that include javascript functions for datepickers
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
@ -23,9 +35,30 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
session_cache_limiter(FALSE);
require_once("../../main.inc.php");
// Define tradMonths javascript array (we define this in datepicker AND in parent page to avoid errors with IE8)
$tradMonths=array(
$langs->trans("January"),
$langs->trans("February"),
$langs->trans("March"),
$langs->trans("April"),
$langs->trans("May"),
$langs->trans("June"),
$langs->trans("July"),
$langs->trans("August"),
$langs->trans("September"),
$langs->trans("October"),
$langs->trans("November"),
$langs->trans("December")
);
?>
// For eldy date picker
var tradMonths = <?php echo json_encode($tradMonths) ?>;
// For JQuery date picker
$(document).ready(function() {
$.datepicker.setDefaults({
altField: '#timeStamp',

View File

@ -998,24 +998,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
}
}
// Define tradMonths javascript array (we define this in datepicker AND in parent page to avoid errors with IE8)
print '<script type="text/javascript">'."\n";
$tradMonths=array($langs->trans("January"),
$langs->trans("February"),
$langs->trans("March"),
$langs->trans("April"),
$langs->trans("May"),
$langs->trans("June"),
$langs->trans("July"),
$langs->trans("August"),
$langs->trans("September"),
$langs->trans("October"),
$langs->trans("November"),
$langs->trans("December")
);
print 'var tradMonths = '.json_encode($tradMonths).';'."\n";
print '</script>'."\n";
// Add datepicker default options
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n";