mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 09:03:21 +00:00 
			
		
		
		
	GUAC-1213: Use HTML5 date/time input types.
This commit is contained in:
		| @@ -24,9 +24,38 @@ | ||||
| /** | ||||
|  * Controller for date fields. | ||||
|  */ | ||||
| angular.module('form').controller('dateFieldController', ['$scope', | ||||
|     function dateFieldController($scope) { | ||||
| angular.module('form').controller('dateFieldController', ['$scope', '$injector', | ||||
|     function dateFieldController($scope, $injector) { | ||||
|  | ||||
|     /* STUB */ | ||||
|     // Required services | ||||
|     var $filter = $injector.get('$filter'); | ||||
|  | ||||
|     /** | ||||
|      * Options which dictate the behavior of the input field model, as defined | ||||
|      * by https://docs.angularjs.org/api/ng/directive/ngModelOptions | ||||
|      * | ||||
|      * @type Object.<String, String> | ||||
|      */ | ||||
|     $scope.modelOptions = { | ||||
|  | ||||
|         /** | ||||
|          * The time zone to use when reading/writing the Date object of the | ||||
|          * model. | ||||
|          * | ||||
|          * @type String | ||||
|          */ | ||||
|         timezone : 'UTC' | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     // Update typed value when model is changed | ||||
|     $scope.$watch('model', function modelChanged(model) { | ||||
|         $scope.typedValue = (model ? new Date(model + 'T00:00Z') : null); | ||||
|     }); | ||||
|  | ||||
|     // Update string value in model when typed value is changed | ||||
|     $scope.$watch('typedValue', function typedValueChanged(typedValue) { | ||||
|         $scope.model = (typedValue ? $filter('date')(typedValue, 'yyyy-MM-dd', 'UTC') : ''); | ||||
|     }); | ||||
|  | ||||
| }]); | ||||
|   | ||||
| @@ -24,9 +24,38 @@ | ||||
| /** | ||||
|  * Controller for time fields. | ||||
|  */ | ||||
| angular.module('form').controller('timeFieldController', ['$scope', | ||||
|     function timeFieldController($scope) { | ||||
| angular.module('form').controller('timeFieldController', ['$scope', '$injector', | ||||
|     function timeFieldController($scope, $injector) { | ||||
|  | ||||
|     /* STUB */ | ||||
|     // Required services | ||||
|     var $filter = $injector.get('$filter'); | ||||
|  | ||||
|     /** | ||||
|      * Options which dictate the behavior of the input field model, as defined | ||||
|      * by https://docs.angularjs.org/api/ng/directive/ngModelOptions | ||||
|      * | ||||
|      * @type Object.<String, String> | ||||
|      */ | ||||
|     $scope.modelOptions = { | ||||
|  | ||||
|         /** | ||||
|          * The time zone to use when reading/writing the Date object of the | ||||
|          * model. | ||||
|          * | ||||
|          * @type String | ||||
|          */ | ||||
|         timezone : 'UTC' | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     // Update typed value when model is changed | ||||
|     $scope.$watch('model', function modelChanged(model) { | ||||
|         $scope.typedValue = (model ? new Date('1970-01-01T' + model + 'Z') : null); | ||||
|     }); | ||||
|  | ||||
|     // Update string value in model when typed value is changed | ||||
|     $scope.$watch('typedValue', function typedValueChanged(typedValue) { | ||||
|         $scope.model = (typedValue ? $filter('date')(typedValue, 'HH:mm:ss', 'UTC') : ''); | ||||
|     }); | ||||
|  | ||||
| }]); | ||||
|   | ||||
| @@ -1,3 +1,7 @@ | ||||
| <div class="date-field"> | ||||
|     <input type="text" ng-model="model" autocorrect="off" autocapitalize="off"/> | ||||
|     <input type="date" | ||||
|            ng-model="typedValue" | ||||
|            ng-model-options="modelOptions" | ||||
|            autocorrect="off" | ||||
|            autocapitalize="off"/> | ||||
| </div> | ||||
|   | ||||
| @@ -1,3 +1,7 @@ | ||||
| <div class="time-field"> | ||||
|     <input type="text" ng-model="model" autocorrect="off" autocapitalize="off"/> | ||||
|     <input type="time" | ||||
|            ng-model="typedValue" | ||||
|            ng-model-options="modelOptions" | ||||
|            autocorrect="off" | ||||
|            autocapitalize="off"/> | ||||
| </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user