Commit 344b499fae1fb2d8b06e7b998d9a1f2a919e7d85

Authored by Andrew Buss

merge

Showing 2 changed files Inline Diff

scripts/DeckController.js View file @ 344b499
var app = angular.module('flashy.DeckController', ['ui.router']); 1 1 var app = angular.module('flashy.DeckController', ['ui.router']);
2 2
app.controller('DeckController', ['$scope', '$http', function($scope, $http) { 3 3 app.controller('DeckController', ['$scope', '$http', '$stateParams',
4 4 function($scope, $http, $stateParams) {
5
6
7
8
9
// cards array 10 5 // cards array
6 sectionId = $stateParams.sectionId;
$scope.cards = []; 11 7 $scope.cards = [];
12 8
$scope.cards[0] = { 'content': 'abc' }; 13 9 $http.get('/api/sections/' + sectionId + '/deck/').
$scope.cards[1] = { 'content': 'xyz' }; 14 10 success(function(data) {
$scope.cards[2] = { 'content': 'qwe' }; 15 11 console.log(data);
12 $scope.cards = data;
13 }).
14 error(function(err) {
15 console.log('pulling feed failed');
16 });
16 17
17 18
// reorganize cards in array based on time 18 19 // reorganize cards in array based on time
$scope.filter = function(card) { 19 20 $scope.filter = function(card) {
20 21
// get index of card 21 22 // get index of card
var index = $scope.cards.indexOf(card); 22 23 var index = $scope.cards.indexOf(card);
23 24
//$scope.cards[index]; 24 25 //$scope.cards[index];
25 26
26 27
}; 27 28 };
28 29
// remove card from deck 29 30 // remove card from deck
$scope.removeCard = function(card) { 30 31 $scope.removeCard = function(card) {
31 32
// get index of card 32 33 // get index of card
var index = $scope.cards.indexOf(card); 33 34 var index = $scope.cards.indexOf(card);
34 35
$scope.cards.splice(index, 1); 35 36 $scope.cards.splice(index, 1);
36 37
alert('Removed card!'); 37 38 alert('Removed card!');
}; 38 39 };
39 40
40 41
$scope.editCard = function(card) { 41 42 $scope.editCard = function(card) {
42 43
var index = $scope.cards.indexOf(card); 43 44 var index = $scope.cards.indexOf(card);
44 45
$('.modal-trigger').leanModal({ 45 46 $('.modal-trigger').leanModal({
dismissible: true, // Modal can be dismissed by clicking outside of the modal 46 47 dismissible: true, // Modal can be dismissed by clicking outside of the modal
opacity: .5, // Opacity of modal background 47 48 opacity: .5, // Opacity of modal background
in_duration: 300, // Transition in duration 48 49 in_duration: 300, // Transition in duration
out_duration: 200, // Transition out duration 49 50 out_duration: 200, // Transition out duration
ready: function() { 50 51 ready: function() {
51 52
52 53
$scope.editableContent = $scope.cards[index].content; 53 54 $scope.editableContent = $scope.cards[index].content;
}, // Callback for Modal open 54 55 }, // Callback for Modal open
complete: function() { 55 56 complete: function() {
56 57
$scope.cards[index].content = $scope.editableContent; 57 58 $scope.cards[index].content = $scope.editableContent;
58 59
} // Callback for Modal close 59 60 } // Callback for Modal close
} 60 61 }
); 61 62 );
62 63
scripts/RootController.js View file @ 344b499
angular.module('flashy.RootController', ['ui.router']). 1 1 angular.module('flashy.RootController', ['ui.router']).
2 2
controller('RootController', ['$rootScope', '$scope', '$state', 'UserService', function($rootScope, $scope, $state, UserService) { 3 3 controller('RootController', ['$rootScope', '$scope', '$state', 'UserService', function($rootScope, $scope, $state, UserService) {
//UserService.getUserData(); 4 4 //UserService.getUserData();
//$('#top').collapsible('accordion'); 5 5 //$('#top').collapsible('accordion');
$('.button-collapse').sideNav(); 6 6 $('.button-collapse').sideNav();
if (UserService.isLoggedIn()) $state.go('login'); 7 7 if (UserService.isLoggedIn()) $state.go('login');
else $state.go('addclass'); 8 8 else $state.go('addclass');
$rootScope.isLoggedIn = false; 9 9 $rootScope.isLoggedIn = false;
console.log(UserService._user); 10 10 console.log(UserService._user);
UserService.getUserData().then(function(data) { 11 11 UserService.getUserData().then(function(data) {
console.log(data); 12 12 console.log(data);
$rootScope.user = data; 13 13 $rootScope.user = data;
}); 14 14 });
15
16 $('.button-collapse').sideNav({
17 menuWidth: 300, // Default is 240
18 edge: 'right', // Choose the horizontal origin
19 closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor
20 }
21 );