New Features

- added notifications
- added toggle switches
- added delete feature
- added email verification
This commit is contained in:
Luke Vella 2015-01-26 13:11:48 +01:00
parent e61ef151f6
commit 1b20a11bba
91 changed files with 6859 additions and 2756 deletions

View file

@ -1,5 +1,7 @@
angular.module('rallly')
.service('FormHelper', function(){
this.emailRegexString = '^([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})?$';
this.emailRegex = new RegExp(this.emailRegexString);
this.prettyError = function(errors, field){
if (errors.required) return field + " is required";
if (errors.pattern) return field + " is invalid" ;
@ -17,7 +19,7 @@ angular.module('rallly')
link : function(scope, el, attrs) {
scope.errors = {};
scope.emailRegex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
scope.emailRegex = FormHelper.emailRegex;
scope.$watchCollection('form.name.$error',function(errors){
scope.errors.name = FormHelper.prettyError(errors, "Name");
@ -59,12 +61,54 @@ angular.module('rallly')
templateUrl : 'templates/directives/eventForm/dateForm.html'
}
})
.directive('participantsForm', function(){
.directive('participantsForm', function(FormHelper){
return {
scope : {
event : '=',
form : '='
},
templateUrl : 'templates/directives/eventForm/participantsForm.html'
templateUrl : 'templates/directives/eventForm/participantsForm.html',
link : function(scope, el, attrs){
scope.emailRegex = FormHelper.emailRegexString;
}
}
})
.directive('settingsForm', function(Event){
return {
scope : {
event : '=',
form : '='
},
templateUrl : 'templates/directives/eventForm/settingsForm.html',
link : function(scope, el, attrs){
scope.deleteEvent = function(){
Event.delete({'id' : scope.event._id}, function(){
console.log('delete');
});
}
}
}
})
.directive('switchToggle', function(){
return {
scope : {
model : '=ngModel'
},
require : 'ngModel',
link : function(scope, el, attrs, ngModel) {
el.addClass('switch-toggle');
var setClass = function(){
if (scope.model ^ typeof(attrs.invert) !== 'undefined'){
el.addClass('active');
} else {
el.removeClass('active');
}
}
scope.$watch('model', setClass);
el.bind('click', function(e){
scope.model = !scope.model;
ngModel.$setViewValue(scope.model, e);
});
}
}
});