diff --git a/scripts/CardGridController.js b/scripts/CardGridController.js index 81b215c..7d3b0dd 100644 --- a/scripts/CardGridController.js +++ b/scripts/CardGridController.js @@ -1,6 +1,7 @@ angular.module('flashy.CardGridController', ['ui.router', 'ngAnimate', 'ngWebSocket', 'flashy.DeckFactory']).CardGridController = function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard, Deck) { sectionId = parseInt($stateParams.sectionId); + if (!UserService.isInSection(sectionId)) $state.go('addclass'); $scope.cards = []; // all cards $scope.cardCols = null; // organized data $scope.affectedCards = []; // cards affected by a position change move @@ -144,11 +145,11 @@ angular.module('flashy.CardGridController', ['ui.router', 'ngAnimate', 'ngWebSoc $scope.editCardFormattedText = card.formatted_text; console.log(card); $('#editModal').openModal(card.editModalOptions); - }; $scope.saveEditChanges = function() { if (!$scope.currentEditingCard) return; + if ($('#edit-card-input').text().length == 0) return; var myCard = { 'text': $('#edit-card-input').text(), 'mask': $scope.editCardBlanks, diff --git a/scripts/CardListController.js b/scripts/CardListController.js index 8b74750..8651efb 100644 --- a/scripts/CardListController.js +++ b/scripts/CardListController.js @@ -1,7 +1,8 @@ angular.module('flashy.CardListController', ['ui.router', 'angular.filter', 'ngSanitize', 'flashy.DeckFactory']). - controller('CardListController', function($scope, $rootScope, $state, $http, $stateParams, Flashcard, Deck) { + controller('CardListController', function($scope, $rootScope, $state, $http, $stateParams, Flashcard, UserService, Deck) { // cards array sectionId = parseInt($stateParams.sectionId); + if (!UserService.isInSection(sectionId)) $state.go('addclass'); $scope.deck = new Deck(sectionId, { cardPullCallback: function(card) { Materialize.toast('Pulled!', 3000); diff --git a/scripts/FeedController.js b/scripts/FeedController.js index 9232819..d3e62e4 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -266,12 +266,11 @@ angular.module('flashy.FeedController', $scope.cards = data.map(function(card) { return new Flashcard(card, $scope.deck); }); - $scope.refreshLayout().then(function() { - $timeout($scope.refreshColumnWidth).then(function() { - $scope.showGrid = true; - }); - console.log('layout done'); + $scope.refreshLayout(); + $timeout($scope.refreshColumnWidth).then(function() { + $scope.showGrid = true; }); + console.log('layout done'); }); });