Commit 807399a02054ed60bccc5e853e21b7a59d42423a

Authored by Andrew Buss
1 parent a0d3b9b1dd

push dialog hopefully focuses properly now?

Showing 3 changed files with 30 additions and 25 deletions Side-by-side Diff

... ... @@ -14,7 +14,7 @@
14 14 <header>
15 15 <a href="#" style="position:absolute;top:0;left:0;" data-activates="sidebar" class="button-collapse"><i
16 16 class="medium mdi-navigation-menu"></i></a>
17   - <ul ng-show="isLoggedIn" id="sidebar" class="side-nav fixed">
  17 + <ul ng-show="isLoggedIn" id="sidebar" class="side-nav fixed ng-cloak">
18 18 <li class="logo"><a href="//flashy.cards/" id="logo-container">
19 19  
20 20 <h1>Flashy</h1>
... ... @@ -56,7 +56,7 @@
56 56 <script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script>
57 57 <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.js"></script>
58 58 <script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
59   -<script type="text/javascript" src="scripts/materialize.min.js"></script>
  59 +<script type="text/javascript" src="scripts/materialize.js"></script>
60 60 <script type="text/javascript" src="scripts/jquery.collapsible.js"></script>
61 61 <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script>
62 62 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script>
scripts/FeedController.js View file @ 807399a
... ... @@ -57,12 +57,10 @@
57 57 $http.post('/api/flashcards/', myCard).
58 58 success(function(data) {
59 59 console.log('pushed a card!');
60   - $scope.cards.unshift(myCard); // Add right away
61   - $scope.refreshCards(); // Refresh list
62 60 listenForC = true;
63 61 }).
64 62 error(function(error) {
65   - console.log('haha, n00b');
  63 + console.log('something went wrong pushing a card!');
66 64 });
67 65  
68 66 $scope.text = '';
69 67  
... ... @@ -82,10 +80,32 @@
82 80  
83 81 /* Key bindings for the whole feed window. Hotkey it up! */
84 82 var listenForC = true;
  83 +
  84 + // Need to pass these options into openmodal and leanmodal,
  85 + // otherwise the ready handler doesn't get called
  86 +
  87 + modal_options = {
  88 + dismissible: true, // Modal can be dismissed by clicking outside of the modal
  89 + opacity: 0, // Opacity of modal background
  90 + in_duration: 300, // Transition in duration
  91 + out_duration: 200, // Transition out duration
  92 + ready: function() {
  93 + listenForC = false;
  94 + console.log('modal OPENING');
  95 + $('#new-card-input').focus();
  96 + },
  97 + complete: function() {
  98 + listenForC = true;
  99 + console.log('modal done, closing');
  100 + $('#new-card-input').blur();
  101 + }
  102 + };
  103 +
85 104 $(document).keydown(function(e) {
86 105 var keyed = e.which;
87 106 if (keyed == 67 && listenForC) { // "c" or "C" for compose
88   - $('#newCard').openModal();
  107 + $('#newCard').openModal(modal_options);
  108 + e.preventDefault();
89 109 listenForC = false;
90 110 return false;
91 111 } else if (keyed == 13 || keyed == 27) { // enter or esc, respectively
... ... @@ -99,22 +119,7 @@
99 119  
100 120 $(document).ready(function() {
101 121 // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
102   - $('.modal-trigger').leanModal({
103   - dismissible: true, // Modal can be dismissed by clicking outside of the modal
104   - opacity: 0, // Opacity of modal background
105   - in_duration: 300, // Transition in duration
106   - out_duration: 200, // Transition out duration
107   - ready: function() {
108   - listenForC = false;
109   - console.log('modal OPENING');
110   - $('#new-card-input').focus();
111   - },
112   - complete: function() {
113   - listenForC = true;
114   - console.log('modal done, closing');
115   - }
116   - }
117   - );
  122 + $('.modal-trigger').leanModal(modal_options);
118 123 });
119 124  
120 125 $scope.$on('$destroy', function() {
templates/feed.html View file @ 807399a
... ... @@ -11,7 +11,7 @@
11 11  
12 12  
13 13 <!--Lil plus button in corner-->
14   -<div class="fixed-action-btn" style="bottom: 45px; right: 24px;">
  14 +<div class="fixed-action-btn" style="bottom: 24px; right: 24px;">
15 15 <a data-target="newCard" class="btn-floating btn-large modal-trigger" href="#newCard">
16 16 <i class="large mdi-content-add"></i>
17 17 </a>
... ... @@ -23,8 +23,8 @@
23 23 <div class="row">
24 24 <div class="input-field">
25 25 <i class="mdi-editor-mode-edit prefix"></i>
26   - <input id="new-card-input" class="materialize-textarea" ng-model="text" type="text" maxlength="255" autofocus/>
27   - <label id="newCardSign" for="newCard">New Flashcard Description</label>
  26 + <input id="new-card-input" class="materialize-textarea" ng-model="text" type="text" maxlength="255"/>
  27 + <label id="newCardSign" for="newCard">New Flashcard Text</label>
28 28 </div>
29 29 </div>
30 30 </div>