xcmailr-webapp/src/main/java/assets/js/controllers.js
// the dialog is injected in the specified controller
the dialog is injected in the specified controller
the dialog is injected in the specified controller
function AddEditDialogController($scope, $http, $modalInstance, currentBox,
		domains, contextPath) {
	$scope.domains = domains;
	$scope.initialData = angular.copy(currentBox);
	$scope.contextPath = contextPath;
	$scope.currentBox = currentBox;
	$scope.setValues = function() {
		if ($scope.currentBox === undefined) {
			$http.get($scope.contextPath + '/mail/addAddressData').success(
					function(returnedData) {
						$scope.checkForLogin(returnedData);
						$scope.currentBox = returnedData.currentBox;
						$scope.initialData = angular.copy($scope.currentBox);
					});
		}
	};
	$scope.setValues();
	$scope.close = function(data) {
		var chkBoxIdString = '#chkUnlimited' + data.id;
		if ($(chkBoxIdString).is(':checked')) {
			data.datetime = "0";
		} else {
			var idString = '#datetimepicker' + data.id;
			console.log($(idString))
			var newDateTime = $(idString).data("DateTimePicker").getDate()
					.format("YYYY-MM-DD HH:mm");
			data.datetime = newDateTime;
		}
		$modalInstance.close(data);
	};
	$scope.setBoxDate = function(timestamp, lang) {
		var now = new Date();
		if (timestamp === "unlimited") {
			var sDate = new Date();
		} else {
			var sDate = moment(timestamp, "YYYY-MM-DD HH:mm");
			if (sDate < now) {
				sDate = new Date();
				sDate.setTime(sDate.getTime() + (3600 * 1000));
			}
		}
		$('.pickrBoxEdit').datetimepicker({
			language : lang,
			pick12HourFormat : false,
			minDate : now,
			defaultDate : sDate
		});
	};
	$scope.dismiss = function() { 
		$modalInstance.close();
	};
	$scope.checkForLogin = function(input) {
		if (input.error == 'nologin') {
			$window.location.href = $scope.contextPath + "/login";
		}
	};
	$scope.reset = function() {
		$scope.currentBox = angular.copy($scope.initialData);
		if ($scope.unlimitedBoxChecked
				&& !($scope.initialData.datetime == 'unlimited')) {
			$scope.unlimitedBoxChecked = false;
		}
		if ($scope.initialData.datetime == 'unlimited') {
			$scope.unlimitedBoxChecked = true;
		}
		$scope.form.$setPristine();
	};
}
function AddEditDialogController ( $scope , $http , $modalInstance , currentBox , domains , contextPath ) { $scope . domains = domains ; $scope . initialData = angular . copy ( currentBox ) ; $scope . contextPath = contextPath ; $scope . currentBox = currentBox ; $scope . setValues = function ( ) { if ( $scope . currentBox === undefined ) { $http . get ( $scope . contextPath + '/mail/addAddressData' ) . success ( function ( returnedData ) { $scope . checkForLogin ( returnedData ) ; $scope . currentBox = returnedData . currentBox ; $scope . initialData = angular . copy ( $scope . currentBox ) ; } ) ; } } ; $scope . setValues ( ) ; $scope . close = function ( data ) { var chkBoxIdString = '#chkUnlimited' + data . id ; if ( $ ( chkBoxIdString ) . is ( ':checked' ) ) { data . datetime = "0" ; } else { var idString = '#datetimepicker' + data . id ; console . log ( $ ( idString ) ) var newDateTime = $ ( idString ) . data ( "DateTimePicker" ) . getDate ( ) . format ( "YYYY-MM-DD HH:mm" ) ; data . datetime = newDateTime ; } $modalInstance . close ( data ) ; } ; $scope . setBoxDate = function ( timestamp , lang ) { var now = new Date ( ) ; if ( timestamp === "unlimited" ) { var sDate = new Date ( ) ; } else { var sDate = moment ( timestamp , "YYYY-MM-DD HH:mm" ) ; if ( sDate < now ) { sDate = new Date ( ) ; sDate . setTime ( sDate . getTime ( ) + ( 3600 * 1000 ) ) ; } } $ ( '.pickrBoxEdit' ) . datetimepicker ( { language : lang , pick12HourFormat : false , minDate : now , defaultDate : sDate } ) ; } ; $scope . dismiss = function ( ) { $modalInstance . close ( ) ; } ; $scope . checkForLogin = function ( input ) { if ( input . error == 'nologin' ) { $window . location . href = $scope . contextPath + "/login" ; } } ; $scope . reset = function ( ) { $scope . currentBox = angular . copy ( $scope . initialData ) ; if ( $scope . unlimitedBoxChecked && ! ( $scope . initialData . datetime == 'unlimited' ) ) { $scope . unlimitedBoxChecked = false ; } if ( $scope . initialData . datetime == 'unlimited' ) { $scope . unlimitedBoxChecked = true ; } $scope . form . $setPristine ( ) ; } ; }
the dialog is injected in the specified controller
the dialog is injected in the specified controller
// var newTime = $(idString).val(); // ignore changes, just close the dialog /*
	 * Handles the Session-Timeout (or user is not logged in)
	 */