[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15909] add support for alternative datetimepicker
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [15909] add support for alternative datetimepicker |
Date: |
Fri, 28 Oct 2016 12:31:16 +0000 (UTC) |
Revision: 15909
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15909
Author: sigurdne
Date: 2016-10-28 12:31:15 +0000 (Fri, 28 Oct 2016)
Log Message:
-----------
add support for alternative datetimepicker
Modified Paths:
--------------
trunk/phpgwapi/inc/class.jquery.inc.php
Added Paths:
-----------
trunk/phpgwapi/inc/class.jqcal2.inc.php
Added: trunk/phpgwapi/inc/class.jqcal2.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.jqcal2.inc.php (rev 0)
+++ trunk/phpgwapi/inc/class.jqcal2.inc.php 2016-10-28 12:31:15 UTC (rev
15909)
@@ -0,0 +1,101 @@
+<?php
+ /**
+ * jQuery datepicker wrapper-class
+ *
+ * @author Sigurd Nes
+ * @copyright Copyright (C) 2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.fsf.org/licenses/gpl.html GNU General Public
License
+ * @package phpgwapi
+ * @subpackage gui
+ * @version $Id: class.jqcal.inc.php 15194 2016-05-24 13:10:40Z
sigurdne $
+ */
+ /**
+ * Import the jQuery class
+ */
+ phpgw::import_class('phpgwapi.jquery');
+
+ /**
+ * jQuery datepicker wrapper-class
+ *
+ * @package phpgwapi
+ * @subpackage gui
+ */
+ class phpgwapi_jqcal2
+ {
+
+ public $img_cal;
+ public $dateformat;
+ private $lang_select_date;
+ private $userlang = 'en';
+
+ function __construct()
+ {
+ phpgwapi_jquery::load_widget('datetimepicker');
+
+ $this->img_cal =
$GLOBALS['phpgw']->common->image('phpgwapi', 'cal');
+ $this->dateformat =
str_ireplace(array('y'), array('Y'),
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ $this->lang_select_date = lang('select date');
+
+ if (
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']) )
+ {
+ $this->userlang =
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
+ }
+
+ }
+
+ function add_listener($name, $type = 'date', $value = '')
+ {
+ switch($type)
+ {
+ case 'datetime':
+ $_type = 'datetime';
+ $dateformat = "{$this->dateformat} H:i";
+ break;
+ case 'time':
+ $_type = 'time';
+ $dateformat = "H:i";
+ break;
+ default:
+ $_type = 'date';
+ $dateformat = "{$this->dateformat}";
+ }
+
+ $this->_input_modern($name, $_type, $dateformat);
+ return "<input id='{$name}' type='text'
value='{$value}' size='10' name='{$name}'/>";
+ }
+
+ /**
+ * Add an event listener to the trigger icon - used for XSLT
+ *
+ * @access private
+ * @param string $name the element ID
+ */
+ function _input_modern($id, $type, $dateformat)
+ {
+ $datepicker = $type == 'time' ? 0 : 1;
+ $timepicker = $type == 'date' ? 0 : 1;
+ $js = <<<JS
+ $(document).ready(function()
+ {
+ $( "#{$id}" ).attr('readonly', false);
+
+
jQuery.datetimepicker.setLocale('{$this->userlang}');
+ $( "#{$id}" ).datetimepicker(
+ {
+ format: '{$dateformat}',
+ datepicker:{$datepicker},
+ timepicker: {$timepicker},
+ step: 15,
+ weeks: true,
+ dayOfWeekStart:1,
+ // mask:true,
+ minDate:0
+ });
+//jQuery('#image_button').click(function(){
+// jQuery('#datetimepicker4').datetimepicker('show'); //support hide,show and
destroy command
+//});
+ });
+JS;
+ $GLOBALS['phpgw']->js->add_code('', $js);
+ }
+ }
Modified: trunk/phpgwapi/inc/class.jquery.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.jquery.inc.php 2016-10-28 12:30:48 UTC (rev
15908)
+++ trunk/phpgwapi/inc/class.jquery.inc.php 2016-10-28 12:31:15 UTC (rev
15909)
@@ -91,6 +91,29 @@
$GLOBALS['phpgw']->css->add_external_file("phpgwapi/js/jquery/css/jquery-ui-timepicker-addon.css");
break;
+// case 'datetimepicker2':
+// $load = array
+// (
+// "js/{$_jquery_core}{$_type}",
+// 'DateTimePicker' => array(
+// "js/DateTimePicker",
+//
"i18n/DateTimePicker-i18n"
+// )
+// );
+//
$GLOBALS['phpgw']->css->add_external_file("phpgwapi/js/DateTimePicker/css/DateTimePicker.css");
+// break;
+ case 'datetimepicker':
+ $load = array
+ (
+ "js/{$_jquery_core}{$_type}",
+ 'datetimepicker' => array(
+
"js/jquery.datetimepicker.full{$_type}",
+
"i18n/DateTimePicker-i18n"
+ )
+ );
+
$GLOBALS['phpgw']->css->add_external_file("phpgwapi/js/datetimepicker/css/jquery.datetimepicker.min.css");
+ break;
+
case 'validator':
$load = array
(
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15909] add support for alternative datetimepicker,
sigurdne <=