Patch in the datepicker popup for RTL languages
[openemr.git] / library / js / xl / jquery-datetimepicker-2-5-4.js.php
blobdd0c1d15ffec81192cc4949c3b9a2b8681ca8f55
1 <?php
2 /**
4 * This is to allow internationalization by OpenEMR of the jquery-datetimepicker.
5 * (with and without a time selector)
7 * Example code in script:
8 * $('.datetimepicker').datetimepicker({
9 * $datetimepicker_timepicker = true; (php variable)
10 * $datetimepicker_showseconds = false; (php variable)
11 * $datetimepicker_formatInput = false; (php variable)
12 * require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); (php command)
13 * can add any additional settings to datetimepicker here; need to prepend first setting with a comma
14 * });
15 * $('.datepicker').datetimepicker({
16 * $datetimepicker_timepicker = false; (php variable)
17 * $datetimepicker_showseconds = false; (php variable)
18 * $datetimepicker_formatInput = false; (php variable)
19 * require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); (php command)
20 * can add any additional settings to datetimepicker here; need to prepend first setting with a comma
21 * });
23 * $datetimepicker_timepicker - this will set whether to use the timepicker
24 * $datetimepicker_showseconds - this will show seconds if using the timepicker
25 * $datetimepicker_formatInput - this will set whether to format the input to
26 * the user selected date format within globals. (This works with the following functions to fully
27 * support internationalization of dates; note this setting does not yet work with the timepicker yet)
28 * -oeFormatShortDate() function for when placing a default formatted date in the field
29 * -DateToYYYYMMDD() function when insert the formatted date into database or codebase works on it
32 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
34 * LICENSE: This program is free software; you can redistribute it and/or
35 * modify it under the terms of the GNU General Public License
36 * as published by the Free Software Foundation; either version 3
37 * of the License, or (at your option) any later version.
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
42 * You should have received a copy of the GNU General Public License
43 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
45 * @package OpenEMR
46 * @author Brady Miller <brady.g.miller@gmail.com>
47 * @link http://www.open-emr.org
50 i18n:{
51 en: {
52 months: [
53 "<?php echo xla('January'); ?>", "<?php echo xla('February'); ?>", "<?php echo xla('March'); ?>", "<?php echo xla('April'); ?>", "<?php echo xla('May'); ?>", "<?php echo xla('June'); ?>", "<?php echo xla('July'); ?>", "<?php echo xla('August'); ?>", "<?php echo xla('September'); ?>", "<?php echo xla('October'); ?>", "<?php echo xla('November'); ?>", "<?php echo xla('December'); ?>"
55 dayOfWeekShort: [
56 "<?php echo xla('Sun'); ?>", "<?php echo xla('Mon'); ?>", "<?php echo xla('Tue'); ?>", "<?php echo xla('Wed'); ?>", "<?php echo xla('Thu'); ?>", "<?php echo xla('Fri'); ?>", "<?php echo xla('Sat'); ?>"
58 dayOfWeek: ["<?php echo xla('Sunday'); ?>", "<?php echo xla('Monday'); ?>", "<?php echo xla('Tuesday'); ?>", "<?php echo xla('Wednesday'); ?>", "<?php echo xla('Thursday'); ?>", "<?php echo xla('Friday'); ?>", "<?php echo xla('Saturday'); ?>"
62 <?php if ($_SESSION['language_direction'] == 'rtl') { ?>
63 /**
64 * In RTL languages a datepicker popup is opened in left and it's cutted by the edge of the window
65 * This patch resolves that and moves a datepicker popup to right side.
67 onGenerate:function(current_time,$input){
68 //position of input
69 var position = $($input).offset()
70 //width of date picke popup
71 var datepickerPopupWidth = $('.xdsoft_datetimepicker').width();
73 if(position.left < datepickerPopupWidth){
74 $('.xdsoft_datetimepicker').offset({left:position.left});
75 } else {
76 //put a popup in the regular position
77 $('.xdsoft_datetimepicker').offset({left:position.left - datepickerPopupWidth + $($input).innerWidth()});
80 <?php } ?>
81 yearStart: '1900',
82 scrollInput: false,
83 scrollMonth: false,
84 rtl: <?php echo ($_SESSION['language_direction'] == 'rtl') ? "true" : "false"; ?>,
85 <?php if ($datetimepicker_timepicker) { ?>
86 <?php if ($datetimepicker_showseconds) { ?>
87 format: 'Y-m-d H:i:s',
88 <?php } else { ?>
89 format: 'Y-m-d H:i',
90 <?php } ?>
91 timepicker:true,
92 step: '30'
93 <?php } else { ?>
94 <?php if ($datetimepicker_formatInput) { ?>
95 format: '<?php echo DateFormatRead("jquery-datetimepicker"); ?>',
96 <?php } else { ?>
97 format: 'Y-m-d',
98 <?php } ?>
99 timepicker:false
100 <?php } ?>