First Commit

This commit is contained in:
Luke Vella 2015-01-10 15:43:05 +01:00
commit 2630cc237a
527 changed files with 104273 additions and 0 deletions

View file

@ -0,0 +1,18 @@
angular.module('rallly')
.controller('EventCtrl', function($scope, $http, $state, Event, Participant){
var id = $state.params.id;
$scope.event = Event.get({id:id});
$scope.deleteParticipant = function(pid){
Participant.remove({ id : id , pid : pid }, function(event){
$scope.event = event;
});
}
$scope.save = function(participant){
var participant = new Participant(participant);
participant.$save({id:id}, function(event){
$scope.event = event;
$scope.participant = {};
});
}
});

View file

@ -0,0 +1,65 @@
angular.module('rallly')
.controller('NewEventCtrl', function($scope, $http, $state){
$scope.event = {};
$scope.templates = {
modal : 'templates/modal.html'
};
$scope.submit = function(){
$http.post('/api/event', $scope.event)
.success(function(event, status, headers, config){
$scope.event = event;
$scope.eventUrl = $state.href('event', {
id: $scope.event._id
}, {
absolute : true
});
// $state.go('event',{id : data.event._id});
})
.error(function(data, status, headers, config){
$scope.errors = data.errors;
console.log(data.errors);
})
}
$scope.clearDates = null
})
.directive('datepicker', function(){
return {
restrict : 'A',
require : 'ngModel',
link : function(scope, el, attrs, ngModel){
$(el).datepicker({
multidate : true,
todayHighlight: true,
format : 'dd/mm/yyyy'
})
.on('changeDate', function(e){
var dates = e.dates;
dates.sort(function(a, b){
if (a.getTime() > b.getTime()) return true;
return false;
});
ngModel.$setViewValue(dates, e);
});
scope.clearDates = function(){
$(el).datepicker('setDate', null)
};
scope.unsetDate = function(date){
$(el).datepicker('setDates', scope.event.dates.filter(function(el){
return el != date;
}));
};
}
}
})
.directive('rallly-error', function(){
return {
restrict : 'A',
scope: {
'message': '='
},
controller : function($scope){
console.log($scope.message);
}
}
});

30
public/js/main.js Normal file
View file

@ -0,0 +1,30 @@
angular.module('rallly', ['ui.router','ngResource','ngFx'])
.config(function($stateProvider, $urlRouterProvider, $locationProvider){
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise("/notfound")
$stateProvider
.state('index',{
url : '/',
templateUrl : 'templates/new.html',
controller : 'NewEventCtrl'
})
.state('about', {
url : '/about',
templateUrl : 'templates/about.html'
})
.state('notfound', {
url : '/notfound',
templateUrl : 'templates/notfound.html'
})
.state('event',{
url : '/:id',
templateUrl : 'templates/event.html',
controller : 'EventCtrl'
})
})
.factory('Event', function($resource){
return $resource('/api/event/:id', { id : '@_id' });
})
.factory('Participant', function($resource){
return $resource('/api/event/:id/participant/:pid', { id: '@_id', pid : '@pid'});
});