diff --git a/home.html b/home.html index 90bce1c..61e7f27 100644 --- a/home.html +++ b/home.html @@ -14,7 +14,7 @@ - + Flashy @@ -56,7 +56,7 @@ - + diff --git a/scripts/FeedController.js b/scripts/FeedController.js index bab042e..de04f75 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -57,12 +57,10 @@ angular.module('flashy.FeedController', ['ui.router']). $http.post('/api/flashcards/', myCard). success(function(data) { console.log('pushed a card!'); - $scope.cards.unshift(myCard); // Add right away - $scope.refreshCards(); // Refresh list listenForC = true; }). error(function(error) { - console.log('haha, n00b'); + console.log('something went wrong pushing a card!'); }); $scope.text = ''; @@ -82,10 +80,32 @@ angular.module('flashy.FeedController', ['ui.router']). /* Key bindings for the whole feed window. Hotkey it up! */ var listenForC = true; + + // Need to pass these options into openmodal and leanmodal, + // otherwise the ready handler doesn't get called + + modal_options = { + dismissible: true, // Modal can be dismissed by clicking outside of the modal + opacity: 0, // Opacity of modal background + in_duration: 300, // Transition in duration + out_duration: 200, // Transition out duration + ready: function() { + listenForC = false; + console.log('modal OPENING'); + $('#new-card-input').focus(); + }, + complete: function() { + listenForC = true; + console.log('modal done, closing'); + $('#new-card-input').blur(); + } + }; + $(document).keydown(function(e) { var keyed = e.which; if (keyed == 67 && listenForC) { // "c" or "C" for compose - $('#newCard').openModal(); + $('#newCard').openModal(modal_options); + e.preventDefault(); listenForC = false; return false; } else if (keyed == 13 || keyed == 27) { // enter or esc, respectively @@ -99,22 +119,7 @@ angular.module('flashy.FeedController', ['ui.router']). $(document).ready(function() { // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered - $('.modal-trigger').leanModal({ - dismissible: true, // Modal can be dismissed by clicking outside of the modal - opacity: 0, // Opacity of modal background - in_duration: 300, // Transition in duration - out_duration: 200, // Transition out duration - ready: function() { - listenForC = false; - console.log('modal OPENING'); - $('#new-card-input').focus(); - }, - complete: function() { - listenForC = true; - console.log('modal done, closing'); - } - } - ); + $('.modal-trigger').leanModal(modal_options); }); $scope.$on('$destroy', function() { diff --git a/templates/feed.html b/templates/feed.html index 8752300..395c57e 100644 --- a/templates/feed.html +++ b/templates/feed.html @@ -11,7 +11,7 @@ - + @@ -23,8 +23,8 @@ - - New Flashcard Description + + New Flashcard Text