<commit_before>app.directive('signature', ['$state', '$uibModal', 'Modernizr', 'spinnerService', 'signatureRestService', 'base64BinaryConverterService', 'fileExtensionService', 'globalMessagesService',

function($state, $uibModal, Modernizr, spinnerService, signatureRestService, base64BinaryConverterService, fileExtensionService, globalMessagesService) {
	"use strict";

	return {
		restrict: 'E',
		replace: true,
		templateUrl: 'signature/signature.directive.tpl.html',
		scope: {
			isRegistration: '='
		},
		controller: function($scope) {
			$scope.postSignaturePath = signatureRestService.postSignaturePath();
			$scope.Modernizr = Modernizr;
			$scope.showUploadImage = false;
			$scope.showTouchInput = true;
			$scope.forceSignaturePad = false;
			$scope.flow = {};

			$scope.selectTouchTab = function() {
				$scope.showUploadImage = false;
				$scope.showTouchInput = true;
			};
			$scope.selectUploadTab = function() {
				$scope.showUploadImage = true;
				$scope.showTouchInput = false;
			};

			$scope.submitTouch = function(file) {
				$scope.flow.touch.addFile(file);
				$scope.flow.touch.upload();
			};

			$scope.showSpinner = function(spinnerId) {
				spinnerService.show(spinnerId);
			};

			$scope.showQR = function() {
				signatureRestService.postSignatureMobileToken().then(function(response) {
					var modalInstance = $uibModal.open({
						templateUrl : 'signature/signature-qr.tpl.html',
						controller : 'SignatureQRController',
						resolve : {
							token : function() {
								return response.data.uid;
							}
						}
					});

					modalInstance.result.then(function(response) {
						base64BinaryConverterService.toBase64FromJson(response.data, goToNextPage);
					});
				});
			};

			$scope.showUploadError = function(type) {
				spinnerService.hide('spinnerSignatureImage');
				spinnerService.hide('spinnerSignatureTouch');
				globalMessagesService.showGeneralError();
				if(type === 'image') {
					$scope.flow.image.cancel();
				}
				else {
					$scope.flow.touch.cancel();
				}
			};

			$scope.getImageAndGoToNextPage = function() {
				var fileWrapper = $scope.flow.image.files[0] || $scope.flow.touch.files[0];

				// file was not accepted by the validator
				if(typeof fileWrapper === "undefined" || typeof fileWrapper.file === "undefined") {
					globalMessagesService.showWarning("reimbursement.globalMessage.notAnImage.title", "reimbursement.globalMessage.notAnImage.message");
					spinnerService.hide("spinnerSignatureImage");
				}
				else {
					base64BinaryConverterService.toBase64(fileWrapper.file, goToNextPage);
				}
			};

			$scope.validateFile = function($file) {
				if(typeof $file !== "undefined" && typeof $file.name !== "undefined" && $file.name !== "") {
					return fileExtensionService.isImageFile($file.name);
				}
				else {
					return false;
				}
			};

			function goToNextPage(base64Image) {
				spinnerService.hide('spinnerSignatureImage');
				spinnerService.hide('spinnerSignatureTouch');

				var nextState;
				if($scope.isRegistration) {
					nextState = 'registrationCropping';
				}
				else {
					nextState = 'settingsCropping';
				}

				$state.go(nextState, {
					imageUri : base64Image
				});
			}
		}
	};

}]);<commit_msg>fix minification error in directive<commit_after>app.directive('signature', ['$state', '$uibModal', 'Modernizr', 'spinnerService', 'signatureRestService', 'base64BinaryConverterService', 'fileExtensionService', 'globalMessagesService',

function($state, $uibModal, Modernizr, spinnerService, signatureRestService, base64BinaryConverterService, fileExtensionService, globalMessagesService) {
	"use strict";

	return {
		restrict: 'E',
		replace: true,
		templateUrl: 'signature/signature.directive.tpl.html',
		scope: {
			isRegistration: '='
		},
		controller: ['$scope', function($scope) {
			$scope.postSignaturePath = signatureRestService.postSignaturePath();
			$scope.Modernizr = Modernizr;
			$scope.showUploadImage = false;
			$scope.showTouchInput = true;
			$scope.forceSignaturePad = false;
			$scope.flow = {};

			$scope.selectTouchTab = function() {
				$scope.showUploadImage = false;
				$scope.showTouchInput = true;
			};
			$scope.selectUploadTab = function() {
				$scope.showUploadImage = true;
				$scope.showTouchInput = false;
			};

			$scope.submitTouch = function(file) {
				$scope.flow.touch.addFile(file);
				$scope.flow.touch.upload();
			};

			$scope.showSpinner = function(spinnerId) {
				spinnerService.show(spinnerId);
			};

			$scope.showQR = function() {
				signatureRestService.postSignatureMobileToken().then(function(response) {
					var modalInstance = $uibModal.open({
						templateUrl : 'signature/signature-qr.tpl.html',
						controller : 'SignatureQRController',
						resolve : {
							token : function() {
								return response.data.uid;
							}
						}
					});

					modalInstance.result.then(function(response) {
						base64BinaryConverterService.toBase64FromJson(response.data, goToNextPage);
					});
				});
			};

			$scope.showUploadError = function(type) {
				spinnerService.hide('spinnerSignatureImage');
				spinnerService.hide('spinnerSignatureTouch');
				globalMessagesService.showGeneralError();
				if(type === 'image') {
					$scope.flow.image.cancel();
				}
				else {
					$scope.flow.touch.cancel();
				}
			};

			$scope.getImageAndGoToNextPage = function() {
				var fileWrapper = $scope.flow.image.files[0] || $scope.flow.touch.files[0];

				// file was not accepted by the validator
				if(typeof fileWrapper === "undefined" || typeof fileWrapper.file === "undefined") {
					globalMessagesService.showWarning("reimbursement.globalMessage.notAnImage.title", "reimbursement.globalMessage.notAnImage.message");
					spinnerService.hide("spinnerSignatureImage");
				}
				else {
					base64BinaryConverterService.toBase64(fileWrapper.file, goToNextPage);
				}
			};

			$scope.validateFile = function($file) {
				if(typeof $file !== "undefined" && typeof $file.name !== "undefined" && $file.name !== "") {
					return fileExtensionService.isImageFile($file.name);
				}
				else {
					return false;
				}
			};

			function goToNextPage(base64Image) {
				spinnerService.hide('spinnerSignatureImage');
				spinnerService.hide('spinnerSignatureTouch');

				var nextState;
				if($scope.isRegistration) {
					nextState = 'registrationCropping';
				}
				else {
					nextState = 'settingsCropping';
				}

				$state.go(nextState, {
					imageUri : base64Image
				});
			}
		}]
	};

}]);
{'fraction_non_alphanumeric': 0.14027010435850215, 'fraction_numerical': 0.0055248618784530384, 'mean_word_length': 3.7430858806404657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5700887', 'n_tokens_mistral': 2543, 'n_tokens_neox': 1959, 'n_words': 289}