Commit 2f199068c8c9e391f3cee8447f4d519db9bff854
1 parent
8e5fad9456
Exists in
master
and in
1 other branch
focus input on card push
Showing 4 changed files with 65 additions and 61 deletions Side-by-side Diff
scripts/FeedController.js
View file @
2f19906
1 | 1 | angular.module('flashy.FeedController', ['ui.router']). |
2 | 2 | |
3 | - controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function ($scope, $stateParams, $state, $http) { | |
3 | + controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) { | |
4 | 4 | console.log('Hello from feed'); |
5 | 5 | sectionId = $stateParams.sectionId; |
6 | 6 | $scope.cards = []; |
7 | 7 | |
8 | 8 | $http.get('/api/sections/' + sectionId + '/feed/'). |
9 | - success(function (data) { | |
9 | + success(function(data) { | |
10 | 10 | console.log(data); |
11 | 11 | $scope.cards = data; |
12 | 12 | }). |
13 | - error(function (err) { | |
13 | + error(function(err) { | |
14 | 14 | console.log('pulling feed failed'); |
15 | 15 | }); |
16 | 16 | |
17 | - $scope.viewDeck = function () { | |
17 | + $scope.viewDeck = function() { | |
18 | 18 | $state.go('deck', {sectionId: sectionId}); |
19 | 19 | console.log('go to deck'); |
20 | 20 | }; |
21 | 21 | |
22 | 22 | $scope.pullCard = function(card) { |
23 | 23 | /* |
24 | - $http.post('/api/flashcards/' + card + '/pull', | |
25 | - {} | |
26 | - */ | |
24 | + $http.post('/api/flashcards/' + card + '/pull', | |
25 | + {} | |
26 | + */ | |
27 | 27 | var index = $scope.cards.indexOf(card); |
28 | 28 | |
29 | 29 | console.log($scope.cards[index]); |
30 | 30 | }; |
31 | - | |
32 | - $scope.pushCard = function () { | |
31 | + | |
32 | + $scope.pushCard = function() { | |
33 | 33 | console.log('make! card content:' + $scope.text); |
34 | 34 | var pushed = new Date(Date.now()); |
35 | 35 | console.log(pushed.toString()); |
36 | 36 | |
37 | 37 | |
... | ... | @@ -40,13 +40,13 @@ |
40 | 40 | 'material_date': pushed, |
41 | 41 | 'mask': '[]', |
42 | 42 | section: sectionId |
43 | - } | |
43 | + }; | |
44 | 44 | $http.post('/api/flashcards/', myCard). |
45 | - success(function (data) { | |
45 | + success(function(data) { | |
46 | 46 | console.log('pushed a card!'); |
47 | 47 | $scope.cards.push(myCard); |
48 | 48 | }). |
49 | - error(function (error) { | |
49 | + error(function(error) { | |
50 | 50 | console.log('haha, n00b'); |
51 | 51 | }); |
52 | 52 | |
53 | 53 | |
54 | 54 | |
... | ... | @@ -54,18 +54,21 @@ |
54 | 54 | }; |
55 | 55 | |
56 | 56 | $scope.flashcard = 'hi i am a flashcard. I need to be really long and awesome I ain\'t ' + |
57 | - 'know how long I am right now. Is it good enough now?????????? Howz about now???'; | |
57 | + 'know how long I am right now. Is it good enough now?????????? Howz about now???'; | |
58 | 58 | $scope.text = ''; |
59 | 59 | |
60 | - $(document).ready(function () { | |
60 | + $(document).ready(function() { | |
61 | 61 | // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered |
62 | 62 | $('.modal-trigger').leanModal({ |
63 | 63 | dismissible: true, // Modal can be dismissed by clicking outside of the modal |
64 | 64 | opacity: 0, // Opacity of modal background |
65 | 65 | in_duration: 300, // Transition in duration |
66 | 66 | out_duration: 200, // Transition out duration |
67 | - /*ready: function() { alert('Ready'); }, // Callback for Modal open | |
68 | - complete: function() { alert('Closed'); } // Callback for Modal close*/ | |
67 | + ready: function() { | |
68 | + $('input:text:visible:first').focus(); | |
69 | + }, | |
70 | + complete: function() { | |
71 | + } // Callback for Modal close*/ | |
69 | 72 | } |
70 | 73 | ); |
71 | 74 | }); |
scripts/FlashcardDirective.js
View file @
2f19906
... | ... | @@ -7,9 +7,10 @@ |
7 | 7 | scope: { |
8 | 8 | flashcard: '=flashcardObj' // flashcard-obj in html |
9 | 9 | }, |
10 | - link: function(scope) { | |
11 | - console.log("HELLO FROM FLASHCARD DIRECTIVE"); | |
10 | + link: function(scope, element) { | |
11 | + console.log('HELLO FROM FLASHCARD DIRECTIVE'); | |
12 | 12 | console.log(scope.flashcard); |
13 | + console.log(element); | |
13 | 14 | |
14 | 15 | // Put flashcard-specific functions here. |
15 | 16 | // This will probably include add/hide/modals/etc. |
scripts/StudyController.js
View file @
2f19906
... | ... | @@ -2,8 +2,8 @@ |
2 | 2 | |
3 | 3 | controller('StudyController', ['$scope', '$state', |
4 | 4 | function($scope, $state) { |
5 | - console.log("Flashy study controller content in this file. also hell0"); | |
6 | - | |
5 | + console.log('Flashy study controller content in this file. also hell0'); | |
6 | + | |
7 | 7 | // Flashcard content |
8 | 8 | $scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk '; |
9 | 9 | $scope.samples = [ |
templates/feed.html
View file @
2f19906
1 | 1 | <body> |
2 | - <div class="col s12"> | |
3 | - <div class="row"> | |
4 | - <a class="btn" ng-click="viewDeck()" style="margin-top: 15px">View Deck</a> | |
5 | - </div> | |
2 | +<div class="col s12"> | |
3 | + <div class="row"> | |
4 | + <a class="btn" ng-click="viewDeck()" style="margin-top: 15px">View Deck</a> | |
5 | + </div> | |
6 | 6 | |
7 | - <!--cards--> | |
8 | - <div class="row"> | |
9 | - <div ng-repeat="card in cards"> | |
10 | - <flashcard flashcard-obj="card"/> | |
11 | - </div> | |
12 | - </div> | |
7 | + <!--cards--> | |
8 | + <div class="row"> | |
9 | + <div ng-repeat="card in cards"> | |
10 | + <flashcard flashcard-obj="card"/> | |
11 | + </div> | |
12 | + </div> | |
13 | 13 | |
14 | 14 | |
15 | - <!--Lil plus button in corner--> | |
16 | - <div class="fixed-action-btn" style="bottom: 45px; right: 24px;"> | |
17 | - <a data-target="newCard" class="btn-floating btn-large modal-trigger" href="#newCard"> | |
18 | - <i class="large mdi-content-add"></i> | |
19 | - </a> | |
20 | - <!--Maybe this will come in handy later? Floating bubbles on mouseover--> | |
21 | - <ul> | |
22 | - <li><a class="btn-floating red"><i class="large mdi-editor-insert-chart"></i></a></li> | |
23 | - <li><a class="btn-floating yellow darken-1"><i class="large mdi-editor-format-quote"></i></a></li> | |
24 | - <li><a class="btn-floating green"><i class="large mdi-editor-publish"></i></a></li> | |
25 | - <li><a class="btn-floating blue"><i class="large mdi-editor-attach-file"></i></a></li> | |
26 | - </ul> | |
27 | - </div> | |
28 | - </div> | |
15 | + <!--Lil plus button in corner--> | |
16 | + <div class="fixed-action-btn" style="bottom: 45px; right: 24px;"> | |
17 | + <a data-target="newCard" class="btn-floating btn-large modal-trigger" href="#newCard"> | |
18 | + <i class="large mdi-content-add"></i> | |
19 | + </a> | |
20 | + <!--Maybe this will come in handy later? Floating bubbles on mouseover--> | |
21 | + <ul> | |
22 | + <li><a class="btn-floating red"><i class="large mdi-editor-insert-chart"></i></a></li> | |
23 | + <li><a class="btn-floating yellow darken-1"><i class="large mdi-editor-format-quote"></i></a></li> | |
24 | + <li><a class="btn-floating green"><i class="large mdi-editor-publish"></i></a></li> | |
25 | + <li><a class="btn-floating blue"><i class="large mdi-editor-attach-file"></i></a></li> | |
26 | + </ul> | |
27 | + </div> | |
28 | +</div> | |
29 | 29 | |
30 | - <form> | |
31 | - <div id="newCard" class="modal bottom-sheet"> | |
32 | - <div class="modal-content"> | |
33 | - <div class="row"> | |
34 | - <div class="input-field"> | |
35 | - <i class="mdi-editor-mode-edit prefix"></i> | |
36 | - <input class="materialize-textarea" ng-model="text" type="text"/> | |
37 | - <label id="newCardSign" for="newCard">New Flashcard</label> | |
38 | - </div> | |
39 | - </div> | |
40 | - </div> | |
41 | - <div class="modal-footer"> | |
42 | - <button class="btn modal-close" type="submit" ng-click="pushCard()">Submit | |
43 | - <i class="mdi-content-send right"></i> | |
44 | - </button> | |
45 | - </div> | |
30 | +<form> | |
31 | + <div id="newCard" class="modal bottom-sheet"> | |
32 | + <div class="modal-content"> | |
33 | + <div class="row"> | |
34 | + <div class="input-field"> | |
35 | + <i class="mdi-editor-mode-edit prefix"></i> | |
36 | + <input class="materialize-textarea" ng-model="text" type="text"/> | |
37 | + <label id="newCardSign" for="newCard">New Flashcard</label> | |
46 | 38 | </div> |
47 | - </form> | |
39 | + </div> | |
40 | + </div> | |
41 | + <div class="modal-footer"> | |
42 | + <button class="btn modal-close" type="submit" ng-click="pushCard()">Submit | |
43 | + <i class="mdi-content-send right"></i> | |
44 | + </button> | |
45 | + </div> | |
46 | + </div> | |
47 | +</form> | |
48 | 48 | </body> |