mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-13 08:27:42 +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') : '');
|
||||
});
|
||||
|
||||
}]);
|
||||
|
Reference in New Issue
Block a user