// controllers function LoginFormController($scope) { $scope.$watch('loginForm', function() { $scope.loginForm.email.errors = {'filled' : true, 'valid' : true}; $scope.loginForm.password.errors = {'filled' : true, 'valid' : true}; }); $scope.submit = function() { $scope.$broadcast('event:force-model-update'); if (true === $scope.loginForm.$valid) { $scope.loginForm.email.errors = {'filled' : true, 'valid' : true}; $scope.loginForm.password.errors = {'filled' : true,'valid' : true}; // submit return true; } $scope.loginForm.email.errors.valid = $scope.loginForm.email.$valid; $scope.loginForm.email.errors.filled = !$scope.loginForm.email.$error.required; $scope.loginForm.password.errors.filled = !$scope.loginForm.password.$error.required; return false; }; $scope.getInputClass = function(name) { return _.every($scope.loginForm[name].errors, function(value) { return value === true; }) ? '' : 'input-table-error'; }; } function forgottenPasswordFormCtrl($scope) { $scope.$watch('forgottenPasswordForm', function() { $scope.forgottenPasswordForm.email.errors = {'filled' : true, 'valid' : true}; }); $scope.submit = function() { $scope.$broadcast('event:force-model-update'); if (true === $scope.forgottenPasswordForm.$valid) { $scope.forgottenPasswordForm.email.errors = {'filled' : true, 'valid' : true}; // submit return true; } $scope.forgottenPasswordForm.email.errors.valid = $scope.forgottenPasswordForm.email.$valid; $scope.forgottenPasswordForm.email.errors.filled = !$scope.forgottenPasswordForm.email.$error.required; return false; }; $scope.getInputClass = function(name) { return _.every($scope.forgottenPasswordForm[name].errors, function(value) { return value === true; }) ? '' : 'input-table-error'; }; } function passwordChangeFormCtrl($scope) { $scope.$watch('passwordChangeForm', function() { $scope.passwordChangeForm.password.errors = {'filled' : true, 'valid' : true}; $scope.passwordChangeForm.passwordConfirm.errors = {'filled' : true, 'valid' : true}; }); $scope.submit = function() { $scope.$broadcast('event:force-model-update'); if (true === $scope.passwordChangeForm.$valid) { $scope.passwordChangeForm.password.errors = {'filled' : true, 'valid' : true}; $scope.passwordChangeForm.passwordConfirm.errors = {'filled' : true, 'valid' : true}; // submit return true; } $scope.passwordChangeForm.password.errors.filled = !$scope.passwordChangeForm.password.$error.required; $scope.passwordChangeForm.passwordConfirm.errors.filled = !$scope.passwordChangeForm.passwordConfirm.$error.required; return false; }; $scope.getInputClass = function(name) { return _.every($scope.passwordChangeForm[name].errors, function(value) { return value === true; }) ? '' : 'input-table-error'; }; } // bootstrap angular angular.element(document).ready(function() { angular.bootstrap(document, ['phraseanetAuthentication']); }); // angular app angular.module('phraseanetAuthentication', ['ui']) // force model update for autofill inputs. Yuck. .directive('forceModelUpdate', function($compile) { return { restrict: 'A', require: 'ngModel', link: function(scope, element, attrs, ctrl) { scope.$on('event:force-model-update', function() { ctrl.$setViewValue(element.val()); }); } } }).directive('alert', function () { return { restrict:'EA', template: [ '
| ', ' | ', ' | × | ', '