diff --git a/home.html b/home.html index fb133ce..84cc792 100644 --- a/home.html +++ b/home.html @@ -150,6 +150,7 @@ + diff --git a/scripts/FeedController.js b/scripts/FeedController.js index 596b3be..9cc8ea5 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -1,4 +1,4 @@ -angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket']). +angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket', 'contenteditable']). controller('FeedController', function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, UserService) { angular.module('flashy.CardGridController').controller.apply(this, arguments); @@ -80,18 +80,12 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket' } }); - var resetModal = function() { - $('#new-card-input').html(''); - $('#newCard').closeModal(modal_options); - }; - $scope.pushCard = function() { var i = 0; var blanks = []; $('#new-card-input')[0].childNodes.forEach(function(node) { if (typeof node.data == 'undefined') { console.log('undefined node'); - //return resetModal(); } node = $(node)[0]; if (node.tagName == 'B') { @@ -118,7 +112,7 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket' }; if (myCard.text == '') { console.log('blank flashcard not pushed:' + myCard.text); - return resetModal(); + return closeNewCard(); } $http.post('/api/flashcards/', myCard). success(function(data) { @@ -126,12 +120,11 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket' if (!UserService.hasVerifiedEmail()) { Materialize.toast("
Thanks for contributing! However, others won't see your card until you verify your email address
", 4000); } - }). error(function(error) { console.log('something went wrong pushing a card!'); }); - return resetModal(); + return $scope.closeNewCardModal(); }; /* Key bindings for the whole feed window. Hotkey it up! */ @@ -146,29 +139,35 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket' 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.execCommand('selectAll', false, null); } }; $(document).keydown(function(e) { var keyed = e.which; if (keyed == 67 && listenForC) { // "c" for compose - $('#newCard').openModal(modal_options); + $scope.openNewCardModal(); e.preventDefault(); - listenForC = false; return false; } else if (keyed == 27) { // clear on ESC - listenForC = true; - document.getElementById('new-card-input').value = ''; + $scope.closeNewCardModal(); } }); + + $scope.openNewCardModal = function() { + $('#newCard').openModal(modal_options); + listenForC = false; + $('#new-card-input').html('Write a flashcard!'); + + }; + + $scope.closeNewCardModal = function() { + listenForC = true; + $('#new-card-input').html('').blur(); + $('#newCard').closeModal(modal_options); + }; + $('.tooltipped').tooltip({delay: 50}); // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered $('.modal-trigger').leanModal(modal_options); diff --git a/templates/feed.html b/templates/feed.html index 5d046e4..3ea235e 100644 --- a/templates/feed.html +++ b/templates/feed.html @@ -15,36 +15,56 @@
-