From 2f199068c8c9e391f3cee8447f4d519db9bff854 Mon Sep 17 00:00:00 2001 From: Andrew Buss Date: Tue, 19 May 2015 11:08:27 -0700 Subject: [PATCH] focus input on card push --- scripts/FeedController.js | 35 +++++++++--------- scripts/FlashcardDirective.js | 5 +-- scripts/StudyController.js | 4 +-- templates/feed.html | 82 +++++++++++++++++++++---------------------- 4 files changed, 65 insertions(+), 61 deletions(-) diff --git a/scripts/FeedController.js b/scripts/FeedController.js index e0e5a01..f8327e3 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -1,35 +1,35 @@ angular.module('flashy.FeedController', ['ui.router']). - controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function ($scope, $stateParams, $state, $http) { + controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) { console.log('Hello from feed'); sectionId = $stateParams.sectionId; $scope.cards = []; $http.get('/api/sections/' + sectionId + '/feed/'). - success(function (data) { + success(function(data) { console.log(data); $scope.cards = data; }). - error(function (err) { + error(function(err) { console.log('pulling feed failed'); }); - $scope.viewDeck = function () { + $scope.viewDeck = function() { $state.go('deck', {sectionId: sectionId}); console.log('go to deck'); }; $scope.pullCard = function(card) { /* - $http.post('/api/flashcards/' + card + '/pull', - {} - */ + $http.post('/api/flashcards/' + card + '/pull', + {} + */ var index = $scope.cards.indexOf(card); console.log($scope.cards[index]); }; - - $scope.pushCard = function () { + + $scope.pushCard = function() { console.log('make! card content:' + $scope.text); var pushed = new Date(Date.now()); console.log(pushed.toString()); @@ -40,13 +40,13 @@ angular.module('flashy.FeedController', ['ui.router']). 'material_date': pushed, 'mask': '[]', section: sectionId - } + }; $http.post('/api/flashcards/', myCard). - success(function (data) { + success(function(data) { console.log('pushed a card!'); $scope.cards.push(myCard); }). - error(function (error) { + error(function(error) { console.log('haha, n00b'); }); @@ -54,18 +54,21 @@ angular.module('flashy.FeedController', ['ui.router']). }; $scope.flashcard = 'hi i am a flashcard. I need to be really long and awesome I ain\'t ' + - 'know how long I am right now. Is it good enough now?????????? Howz about now???'; + 'know how long I am right now. Is it good enough now?????????? Howz about now???'; $scope.text = ''; - $(document).ready(function () { + $(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() { alert('Ready'); }, // Callback for Modal open - complete: function() { alert('Closed'); } // Callback for Modal close*/ + ready: function() { + $('input:text:visible:first').focus(); + }, + complete: function() { + } // Callback for Modal close*/ } ); }); diff --git a/scripts/FlashcardDirective.js b/scripts/FlashcardDirective.js index 7244e1f..ba2529b 100644 --- a/scripts/FlashcardDirective.js +++ b/scripts/FlashcardDirective.js @@ -7,9 +7,10 @@ directive('flashcard', function() { scope: { flashcard: '=flashcardObj' // flashcard-obj in html }, - link: function(scope) { - console.log("HELLO FROM FLASHCARD DIRECTIVE"); + 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. diff --git a/scripts/StudyController.js b/scripts/StudyController.js index 2082b8d..ed38005 100644 --- a/scripts/StudyController.js +++ b/scripts/StudyController.js @@ -2,8 +2,8 @@ angular.module('flashy.StudyController', ['ui.router']). controller('StudyController', ['$scope', '$state', function($scope, $state) { - console.log("Flashy study controller content in this file. also hell0"); - + console.log('Flashy study controller content in this file. also hell0'); + // Flashcard content $scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk '; $scope.samples = [ diff --git a/templates/feed.html b/templates/feed.html index 375775d..2cb4b72 100644 --- a/templates/feed.html +++ b/templates/feed.html @@ -1,48 +1,48 @@ -
-
- View Deck -
+
+
+ View Deck +
- -
-
- -
-
+ +
+
+ +
+
- -
- - - - -
    -
  • -
  • -
  • -
  • -
-
-
+ +
+ + + + +
    +
  • +
  • +
  • +
  • +
+
+
-
-