diff --git a/scripts/DeckController.js b/scripts/DeckController.js index c5e2e35..c2390fc 100644 --- a/scripts/DeckController.js +++ b/scripts/DeckController.js @@ -6,6 +6,7 @@ app.controller('DeckController', ['$scope', '$http', '$stateParams', sectionId = $stateParams.sectionId; $scope.cards = []; + // Populate our page with cards. $http.get('/api/sections/' + sectionId + '/deck/'). success(function(data) { console.log(data); @@ -15,7 +16,25 @@ app.controller('DeckController', ['$scope', '$http', '$stateParams', console.log('pulling feed failed'); }); - + /* Lets page refresh the cards shown on the page. */ + $scope.refreshCards = function() { + console.log('refreshing cards...'); + var myDelay = 350; // ms + setTimeout(function() { + $http.get('/api/sections/' + sectionId + '/deck/'). + success(function(data) { + console.log(data); + $scope.cards = data; + console.log('success in refresh cards...'); + }). + error(function(err) { + console.log('refresh fail'); + }); + }, myDelay); + } + + + /* all kmach's stuff below, do not touch */ // reorganize cards in array based on time $scope.filter = function(card) { @@ -27,20 +46,8 @@ app.controller('DeckController', ['$scope', '$http', '$stateParams', }; - // remove card from deck - $scope.removeCard = function(card) { - - // get index of card - var index = $scope.cards.indexOf(card); - - $scope.cards.splice(index, 1); - - alert('Removed card!'); - }; - $scope.editCard = function(card) { - var index = $scope.cards.indexOf(card); $('.modal-trigger').leanModal({ @@ -50,7 +57,6 @@ app.controller('DeckController', ['$scope', '$http', '$stateParams', out_duration: 200, // Transition out duration ready: function() { - $scope.editableContent = $scope.cards[index].content; }, // Callback for Modal open complete: function() { @@ -60,10 +66,6 @@ app.controller('DeckController', ['$scope', '$http', '$stateParams', } // Callback for Modal close } ); - - - - //alert($scope.cards[index].content); // post flashcard edits diff --git a/scripts/FlashcardDirective.js b/scripts/FlashcardDirective.js index a03dc0b..1eab770 100644 --- a/scripts/FlashcardDirective.js +++ b/scripts/FlashcardDirective.js @@ -1,22 +1,60 @@ angular.module('flashy.FlashcardDirective', []). -directive('flashcard', ['$http', function($http) { +directive('flashcard', ['$http', '$state', function($http, $state) { return { templateUrl: '/app/templates/flashcard.html', restrict: 'E', scope: { - flashcard: '=flashcardObj' // flashcard-obj in html + flashcard: '=flashcardObj', // flashcard-obj in parent html + refresh: '&' // eval refresh in parent html }, link: function(scope, element) { - console.log('HELLO FROM FLASHCARD DIRECTIVE'); - console.log(scope.flashcard); - console.log(element); - - // Put flashcard-specific functions here. - // This will probably include add/hide/modals/etc. + /* Pulls card from feed into deck */ scope.pullCard = function(flashcard) { - $http.post('/api/flashcards/' + flashcard.id + '/pull/', flashcard); - console.log('pulled flashcard #' + flashcard.id); + console.log('call pull card...') + if ($state.current.name == 'feed') { + $http.post('/api/flashcards/' + flashcard.id + '/pull/', flashcard). + success(function(data) { + console.log('pulled flashcard #' + flashcard.id); + }). + error(function(data) { + console.log('failed to pull flashcard #' + flashcard.id); + }); + } + }; + + /* Unpulls card from deck */ + scope.unpullCard = function(flashcard) { + console.log('call unpull card...') + if ($state.current.name == 'deck') { + console.log('unpulling card...') + + $http.post('/api/flashcards/' + flashcard.id + '/unpull/', + flashcard). + success(function(data) { + console.log('card unpull success') + }). + error(function(data) { + console.log('card unpull FAILURE') + }); + } + }; + + /* Hides card from feed */ + scope.hideCard = function(flashcard) { + console.log('call hide card...') + if ($state.current.name == 'feed') { + console.log('hiding card...') + + $http.post('/api/flashcards/' + flashcard.id + '/hide/', + flashcard). + success(function(data) { + console.log('card hide success') + }). + error(function(data) { + console.log('card hide FAILURE') + }); + } }; } }; diff --git a/styles/flashy.css b/styles/flashy.css index 4b20c35..7509a25 100644 --- a/styles/flashy.css +++ b/styles/flashy.css @@ -61,9 +61,28 @@ ul.side-nav.fixed li a { max-width: calc(5 * 60px); min-height: calc((992px / 4 - 6px * 2) * 3 / 5); /*min-width: calc(992px / 4 - 6px * 2);*/ + transition: all 0.3s cubic-bezier(0, 0, 0.6, 1); width: calc(992px / 4 - 6px * 2); } +.card.flashy.shrinky { + margin: 0; + opacity: 0; + overflow: hidden; + padding: 0; + width: 0; +} + +/* +.smallify { + height: 0; + opacity: 0; + overflow: hidden; + padding: 0; + width: 0; +} +*/ + .card-overlay { left: 0; opacity: 0; diff --git a/templates/deck.html b/templates/deck.html index 2770a0c..7f4b212 100644 --- a/templates/deck.html +++ b/templates/deck.html @@ -1,7 +1,7 @@