Browse Source

#1305 Issue with date/time inputs on Chrome: losing focus as soon as the date has been correctly typed, preventing the user from typing the time.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4346 a333f486-631f-4898-b8df-5754b55c2be0
romainq 9 years ago
parent
commit
706bd3439c
1 changed files with 24 additions and 2 deletions
  1. 24 2
      application/itopwebpage.class.inc.php

+ 24 - 2
application/itopwebpage.class.inc.php

@@ -191,7 +191,8 @@ EOF;
 		$sJSDatePickerOptions = json_encode($aPickerOptions);
 		
 		// Time picker additional options
-		
+		$aPickerOptions['showOn'] = '';
+		$aPickerOptions['buttonImage'] = null;
 		$aPickerOptions['timeFormat'] = $oTimeFormat->ToDatePicker();
 		$aPickerOptions['controlType'] = 'select';
 		$aPickerOptions['closeText'] = 	Dict::S('UI:Button:Ok');
@@ -445,7 +446,28 @@ EOF
 	// End of Tabs handling
 
 	$(".date-pick").datepicker($sJSDatePickerOptions);
-	$(".datetime-pick").datetimepicker($sJSDateTimePickerOptions);	
+
+	// Hack for the date and time picker addon issue on Chrome (see #1305)
+	// The workaround is to instantiate the widget on demand
+	// It relies on the same markup, thus reverting to the original implementation should be straightforward
+	$(".datetime-pick").each(function(){
+		var oInput = this;
+		$('<img class="datetime-pick-button" src="../images/calendar.png">')
+			.insertAfter($(this))
+			.on('click', function(){
+				$(oInput)
+					.datetimepicker($sJSDateTimePickerOptions)
+					.datetimepicker('show')
+					.datetimepicker('option', 'onClose', function(dateText,inst){
+						$(oInput).datetimepicker('destroy');
+					})
+					.on('click keypress', function(){
+						$(oInput).datetimepicker('hide');
+					});
+				});
+		});
+
+	$(".datetime-pick-button")
 
 	// Make sortable, everything that claims to be sortable
 	$('.sortable').sortable( {axis: 'y', cursor: 'move', handle: '.drag_handle', stop: function()