Commit 55223196b88f07f68f40531b45d1bb12a1d54021

Authored by Andrew Buss
1 parent fc88fb81de

let's step back a little

Showing 5 changed files with 244 additions and 319 deletions Side-by-side Diff

scripts/CardGridController.js View file @ 5522319
... ... @@ -6,7 +6,7 @@
6 6 $scope.affectedCards = []; // cards affected by a position change move
7 7 $scope.numCols = 0;
8 8 $scope.height = 0; // height of a card
9   - $scope.section = $rootScope.SectionResource.get({sectionId: sectionId});
  9 + $scope.section = $rootScope.SectionResource.get({sectionId: sectionId});
10 10 $scope.deck = new Deck(sectionId, {
11 11 cardHideCallback: function(card) {
12 12 $scope.hideCardFromGrid(card);
... ... @@ -44,7 +44,7 @@
44 44 $('.cardColumn .card.flashy i.medium').css({
45 45 'font-size': 400 * width / 250 + '%'
46 46 });
47   - $scope.height = width * 3 / 5;
  47 + $scope.height = width * 3 / 5;
48 48 };
49 49  
50 50 $scope.refreshLayout = function() {
scripts/FeedController.js View file @ 5522319
... ... @@ -6,243 +6,242 @@
6 6 'flashy.DeckFactory']).controller('FeedController',
7 7 function($scope, $rootScope, $state, $http, $window, $timeout, $stateParams, $websocket, $interval, UserService, Flashcard, Deck) {
8 8 angular.module('flashy.CardGridController').CardGridController.apply(this, arguments);
9   - var promise;
10   - $rootScope.debugFlashcard = false;
  9 + var promise;
  10 + sectionId = parseInt($stateParams.sectionId);
11 11  
12 12 $scope.updateCardScore = function(card, scoreChange) {
13 13 console.log('update card score');
14 14 // if no colNum is attached, then this doesn't exist on the feed yet
15 15 if (!card.colNum) return;
16 16  
17   - card.score += scoreChange;
18   - var col = card.colNum;
19   - var rank = card.colRank;
20   - var s = Math.sign(scoreChange);
21   -
22   - rank -= s;
23   - if (rank < 0) return;
24   - if (rank == $scope.cardCols[col].length) return;
25   -
26   - $scope.affectedCards = [];
27   - while (s * $scope.cardCols[col][rank].score < s * card.score) {
28   - $scope.affectedCards.push($scope.cardCols[col][rank]);
29   - rank -= s;
30   - if (rank < 0) break;
31   - if (rank == $scope.cardCols[col].length) break;
32   - }
33   - rank += s;
34   -
35   - var upMove = $scope.height;
36   - var downMove = $scope.height;
37   - if (s > 0) {
38   - card.moveUp = true;
39   - upMove *= $scope.affectedCards.length;
40   - /*for (i=0; i<$scope.affectedCards.length; i++) {
41   - $scope.affectedCards[i].moveDown = true;
42   - }*/
43   - } else {
44   - card.moveDown = true;
45   - downMove *= $scope.affectedCards;
46   - /*for (i=0; i<$scope.affectedCards.length; i++) {
47   - $scope.affectedCards[i].moveUp = true;
48   - }*/
49   - }
50   -
51   - $('.card.flashy.card-moveUp').css({
  17 + card.score += scoreChange;
  18 + var col = card.colNum;
  19 + var rank = card.colRank;
  20 + var s = Math.sign(scoreChange);
  21 +
  22 + rank -= s;
  23 + if (rank < 0) return;
  24 + if (rank == $scope.cardCols[col].length) return;
  25 +
  26 + $scope.affectedCards = [];
  27 + while (s * $scope.cardCols[col][rank].score < s * card.score) {
  28 + $scope.affectedCards.push($scope.cardCols[col][rank]);
  29 + rank -= s;
  30 + if (rank < 0) break;
  31 + if (rank == $scope.cardCols[col].length) break;
  32 + }
  33 + rank += s;
  34 +
  35 + var upMove = $scope.height;
  36 + var downMove = $scope.height;
  37 + if (s > 0) {
  38 + card.moveUp = true;
  39 + upMove *= $scope.affectedCards.length;
  40 + /*for (i=0; i<$scope.affectedCards.length; i++) {
  41 + $scope.affectedCards[i].moveDown = true;
  42 + }*/
  43 + } else {
  44 + card.moveDown = true;
  45 + downMove *= $scope.affectedCards;
  46 + /*for (i=0; i<$scope.affectedCards.length; i++) {
  47 + $scope.affectedCards[i].moveUp = true;
  48 + }*/
  49 + }
  50 +
  51 + $('.card.flashy.card-moveUp').css({
52 52 'margin-top': 300 + 'px', // how much moveUp moves
53   - 'z-index': '99'
  53 + 'z-index': '99'
54 54 });
55   -
56   - $('.card.flashy.card-moveDown').css({
  55 +
  56 + $('.card.flashy.card-moveDown').css({
57 57 'margin-top': 300 + 'px', // how much moveDown moves
58 58 });
59   -
60   - $timeout(function() {
61   - $('.card.flashy.card-moveUp').css({
62   - 'margin-top': '6px',
63   - });
64   -
65   - $('.card.flashy.card-moveDown').css({
66   - 'margin-top': '6px',
67   - });
68   - if (s > 0) {
69   - card.moveUp = false;
70   - for (i=0; i<$scope.affectedCards.length; i++) {
71   - $scope.affectedCards[i].moveDown = false;
72   - }
73   - } else {
74   - card.moveDown = false;
75   - for (i=0; i<$scope.affectedCards.length; i++) {
76   - $scope.affectedCards[i].moveUp = false;
77   - }
78   - }
79   - $scope.cardCols[col].splice(rank, 0, $scope.cardCols[col].splice(card.colRank, 1)[0]);
80   - }, 1000);
81   -
  59 +
  60 + $timeout(function() {
  61 + $('.card.flashy.card-moveUp').css({
  62 + 'margin-top': '6px',
  63 + });
  64 +
  65 + $('.card.flashy.card-moveDown').css({
  66 + 'margin-top': '6px',
  67 + });
  68 + if (s > 0) {
  69 + card.moveUp = false;
  70 + for (i = 0; i < $scope.affectedCards.length; i++) {
  71 + $scope.affectedCards[i].moveDown = false;
  72 + }
  73 + } else {
  74 + card.moveDown = false;
  75 + for (i = 0; i < $scope.affectedCards.length; i++) {
  76 + $scope.affectedCards[i].moveUp = false;
  77 + }
  78 + }
  79 + $scope.cardCols[col].splice(rank, 0, $scope.cardCols[col].splice(card.colRank, 1)[0]);
  80 + }, 1000);
  81 +
82 82 $scope.updateColRanks($scope.cardCols[card.colNum]); // can be optimized out
83 83 };
84 84  
85 85  
86   -
87   - $scope.feed_ws = $websocket($scope.ws_host + '/ws/feed/' + $scope.sectionId + '?subscribe-broadcast');
  86 + $scope.feed_ws = $websocket($scope.ws_host + '/ws/feed/' + sectionId + '?subscribe-broadcast');
88 87 $scope.feed_ws.onMessage(function(e) {
  88 + console.log('oh yeaaaaaaaaaaaaaaaaaaa');
89 89  
90   -
91   - console.log('oh yeaaaaaaaaaaaaaaaaaaa');
92   -
93 90 data = JSON.parse(e.data);
94 91 console.log('message', data);
95 92 if (data.event_type == 'new_card') {
96   - $scope.addCardToGrid(new Flashcard(data.flashcard, $scope.deck));
  93 + $scope.addCardToGrid(new Flashcard(data.flashcard, $scope.deck));
97 94 } else if (data.event_type == 'score_change') {
98   - card = new Flashcard(data.flashcard); // doesnt create a card if it exists
99   - console.log('score change');
100   - $scope.updateCardScore(card, data.flashcard.score - card.score);
  95 + card = new Flashcard(data.flashcard); // doesnt create a card if it exists
  96 + card.score = data.flashcard.score;
  97 + console.log('score change');
  98 + $scope.updateCardScore(card, data.flashcard.score - card.score);
101 99 }
102   - });
  100 + });
103 101  
104   - $scope.pushCard = function() {
  102 + $scope.pushCard = function() {
105 103 var myCard = {
106   - // we can't trim this string because it'd mess up the blanks. Something to fix.
107   - 'text': $('#new-card-input').text(),
108   - 'mask': $scope.newCardBlanks,
109   - section: $scope.section.id
  104 + // we can't trim this string because it'd mess up the blanks. Something to fix.
  105 + 'text': $('#new-card-input').text(),
  106 + 'mask': $scope.newCardBlanks,
  107 + section: $scope.section.id
110 108 };
111 109 if (myCard.text == '') {
112   - console.log('blank flashcard not pushed:' + myCard.text);
113   - return closeNewCard();
  110 + console.log('blank flashcard not pushed:' + myCard.text);
  111 + return closeNewCard();
114 112 }
115 113 $http.post('/api/flashcards/', myCard).
116 114 success(function(data) {
117   - console.log('flashcard pushed: ' + myCard.text);
118   - if (!UserService.hasVerifiedEmail()) {
119   - Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000);
120   - }
  115 + console.log('flashcard pushed: ' + myCard.text);
  116 + if (!UserService.hasVerifiedEmail()) {
  117 + Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000);
  118 + }
121 119 });
122 120 return $scope.closeNewCardModal();
123   - };
  121 + };
124 122  
125   - /* Key bindings for the whole feed window. Hotkey it up! */
126   - var listenForC = true;
  123 + /* Key bindings for the whole feed window. Hotkey it up! */
  124 + var listenForC = true;
127 125  
128   - // Need to pass these options into openmodal and leanmodal,
129   - // otherwise the ready handler doesn't get called
  126 + // Need to pass these options into openmodal and leanmodal,
  127 + // otherwise the ready handler doesn't get called
130 128  
131   - modal_options = {
  129 + modal_options = {
132 130 dismissible: true, // Modal can be dismissed by clicking outside of the modal
133 131 opacity: 0, // Opacity of modal background
134 132 in_duration: 300, // Transition in duration
135 133 out_duration: 200, // Transition out duration
136 134 ready: function() {
137   - $('#new-card-input').focus();
138   - document.execCommand('selectAll', false, null);
  135 + $('#new-card-input').focus();
  136 + document.execCommand('selectAll', false, null);
139 137 }
140   - };
  138 + };
141 139  
142   - $(document).keydown(function(e) {
  140 + $(document).keydown(function(e) {
143 141 var keyed = e.which;
144 142 if (keyed == 67 && listenForC) { // "c" for compose
145   - $scope.openNewCardModal();
146   - e.preventDefault();
147   - return false;
  143 + $scope.openNewCardModal();
  144 + e.preventDefault();
  145 + return false;
148 146 } else if (keyed == 27) { // clear on ESC
149   - $scope.closeNewCardModal();
  147 + $scope.closeNewCardModal();
150 148 }
151   - });
  149 + });
152 150  
153   - $scope.openNewCardModal = function() {
  151 + $scope.openNewCardModal = function() {
154 152 $('#newCard').openModal(modal_options);
155 153 listenForC = false;
156 154 $('#new-card-input').html('Write a flashcard!');
157   - };
  155 + };
158 156  
159   - $scope.closeNewCardModal = function() {
  157 + $scope.closeNewCardModal = function() {
160 158 listenForC = true;
161 159 $('#new-card-input').html('').blur();
162 160 $('#newCard').closeModal(modal_options);
163   - };
  161 + };
164 162  
165   - $('.tooltipped').tooltip({delay: 50});
166   - // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
167   - $('.modal-trigger').leanModal(modal_options);
168   - $('#new-card-input').on('keydown', function(e) {
  163 + $('.tooltipped').tooltip({delay: 50});
  164 + // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
  165 + $('.modal-trigger').leanModal(modal_options);
  166 + $('#editCardA').leanModal(modal_options);
  167 + $('#new-card-input').on('keydown', function(e) {
169 168 if (e.which == 13) {
170   - e.preventDefault();
171   - if ($scope.submit_enabled) {
172   - $scope.pushCard();
173   - listenForC = true;
174   - }
175   - return false;
  169 + e.preventDefault();
  170 + if ($scope.submit_enabled) {
  171 + $scope.pushCard();
  172 + listenForC = true;
  173 + }
  174 + return false;
176 175 } else {
177 176  
178 177 }
179   - });
180   - $('button#blank-selected').click(function() {
  178 + });
  179 + $('button#blank-selected').click(function() {
181 180 console.log(window.getSelection());
182 181 document.execCommand('bold');
183   - });
184   - $scope.newCardBlanks = [];
185   - $scope.refreshNewCardInput = function() {
  182 + });
  183 + $scope.newCardBlanks = [];
  184 + $scope.refreshNewCardInput = function() {
186 185 $scope.newCardText = $('#new-card-input').text();
187 186 $scope.submit_enabled = $scope.newCardText.length >= 5 && $scope.newCardText.length <= 160;
188 187 var i = 0;
189 188 $scope.newCardBlanks = [];
190 189 $('#new-card-input')[0].childNodes.forEach(function(node) {
191   - node = $(node)[0];
192   - if (node.tagName == 'B') {
193   - var text = $(node).text();
194   - var leftspaces = 0, rightspaces = 0;
195   - // awful way to find the first non-space character from the left or the right. thanks.js
196   - while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++;
197   - while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++;
198   - console.log(leftspaces, text.length);
199   - if (leftspaces != text.length) $scope.newCardBlanks.push([i + leftspaces, i + text.length - rightspaces]);
200   - i += text.length;
201   - } else if (!node.data) {
202   - i += $(node).text().length;
203   - } else {
204   - i += node.data.length;
205   - }
  190 + node = $(node)[0];
  191 + if (node.tagName == 'B') {
  192 + var text = $(node).text();
  193 + var leftspaces = 0, rightspaces = 0;
  194 + // awful way to find the first non-space character from the left or the right. thanks.js
  195 + while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++;
  196 + while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++;
  197 + console.log(leftspaces, text.length);
  198 + if (leftspaces != text.length) $scope.newCardBlanks.push([i + leftspaces, i + text.length - rightspaces]);
  199 + i += text.length;
  200 + } else if (!node.data) {
  201 + i += $(node).text().length;
  202 + } else {
  203 + i += node.data.length;
  204 + }
206 205 });
207 206 $scope.newCardBlanks.sort(function(a, b) {
208   - return a[0] - b[0];
  207 + return a[0] - b[0];
209 208 });
210 209 i = 0;
211 210 newtext = '';
212 211 $scope.newCardBlanks.forEach(function(blank) {
213   - newtext += $scope.newCardText.slice(i, blank[0]);
214   - newtext += '<b>' + $scope.newCardText.slice(blank[0], blank[1]) + '</b>';
215   - i = blank[1];
  212 + newtext += $scope.newCardText.slice(i, blank[0]);
  213 + newtext += '<b>' + $scope.newCardText.slice(blank[0], blank[1]) + '</b>';
  214 + i = blank[1];
216 215 });
217 216 newtext += $scope.newCardText.slice(i);
218 217 //$scope.newCardFormattedText = newtext;
219   - };
220   - $scope.shuffleCards = function() {
  218 + };
  219 + $scope.shuffleCards = function() {
221 220 $timeout(function() {
222   - (function(o) {
223   - for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
224   - return o;
225   - })($scope.cardCols[0]);
  221 + (function(o) {
  222 + for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
  223 + return o;
  224 + })($scope.cardCols[0]);
226 225 });
227   - };
228   - $scope.$on('$destroy', function() {
  226 + };
  227 + $scope.$on('$destroy', function() {
229 228 $scope.feed_ws.close();
230 229 $interval.cancel(promise);
231   - });
232   - return $http.get('/api/sections/' + sectionId + '/feed/').
233   - success(function(data) {
  230 + });
  231 + return $http.get('/api/sections/' + sectionId + '/feed/').
  232 + success(function(data) {
234 233 console.log(data);
235 234 $scope.cards = data.map(function(card) {
236   - return new Flashcard(card, $scope.deck);
  235 + return new Flashcard(card, $scope.deck);
237 236 });
238 237 $scope.refreshLayout().then(function() {
239   - $timeout($scope.refreshColumnWidth).then(function() {
240   - $scope.showGrid = true;
241   - });
242   - console.log('layout done');
  238 + $timeout($scope.refreshColumnWidth).then(function() {
  239 + $scope.showGrid = true;
  240 + });
  241 + console.log('layout done');
243 242 });
244   - });
  243 + });
245 244  
246 245  
247   - });
  246 + });
scripts/FlashcardFactory.js View file @ 5522319
... ... @@ -22,13 +22,30 @@
22 22 p = this.textPieces[i];
23 23 this.formatted_text += p.blank ? '<b>' + p.text + '</b>' : p.text;
24 24 }
25   - this.moveUp = false;
26   - this.moveDown = false;
27   - this.colNum = 0;
28   - this.colRank = 0;
  25 + this.moveUp = false;
  26 + this.moveDown = false;
  27 + this.colNum = 0;
  28 + this.colRank = 0;
29 29 FlashcardCache[this.id] = this;
30 30 };
31 31  
  32 + Flashcard.editModalOptions = {
  33 + dismissible: true, // Modal can be dismissed by clicking outside of the modal
  34 + opacity: 0, // Opacity of modal background
  35 + in_duration: 300, // Transition in duration
  36 + out_duration: 200, // Transition out duration
  37 + ready: function () {
  38 +
  39 + $('#edit-card-input').html(editableText);
  40 + console.log('opening card edit');
  41 +
  42 + },
  43 + complete: function () {
  44 +
  45 + console.log("EDIT MODAL CLOSED");
  46 +
  47 + }
  48 + };
32 49 Flashcard.prototype.isInDeck = function () {
33 50 return !(typeof Deck.contains(this.id) === 'undefined');
34 51 };
35 52  
36 53  
37 54  
38 55  
39 56  
40 57  
41 58  
42 59  
43 60  
44 61  
45 62  
46 63  
47 64  
48 65  
49 66  
... ... @@ -54,115 +71,92 @@
54 71 Deck = null;
55 72 FlashcardCache = [];
56 73 };
57   - Flashcard.linkDeck = function(deck){
  74 + Flashcard.linkDeck = function (deck) {
58 75 Deck = deck;
59 76 }
60 77  
61 78 Flashcard.prototype.edit = function () {
62   -
63   -
64   - var editableText = this.formatted_text;
65   -
66   - $('.modal-trigger').leanModal({
67   - dismissible: true, // Modal can be dismissed by clicking outside of the modal
68   - opacity: .5, // Opacity of modal background
69   - in_duration: 300, // Transition in duration
70   - out_duration: 200, // Transition out duration
71   - ready: function () {
72   -
73   - $('#edit-card-input').html(editableText);
74   -
75   -
76   - }, // Callback for Modal open
77   - complete: function () {
78   -
79   - console.log("EDIT MODAL CLOSED");
80   -
81   - } // Callback for Modal close
82   - });
83   -
  79 + var editableText = this.formatted_text;
  80 + $('#editModalA').leanModal(Flashcard.modal_options);
  81 + $('#editModalA').openModal(Flashcard.modal_options);
84 82 };
85 83  
86 84 Flashcard.prototype.refreshEditCardInput = function () {
87 85  
88   - this.editCardText = $('#edit-card-input').text();
  86 + this.editCardText = $('#edit-card-input').text();
89 87  
90   - this.submit_enabled = this.editCardText.length >= 5 && this.editCardText.length <= 160;
  88 + this.submit_enabled = this.editCardText.length >= 5 && this.editCardText.length <= 160;
91 89  
  90 + var i = 0;
  91 + this.editCardBlanks = [];
  92 + $('#edit-card-input')[0].childNodes.forEach(function (node) {
  93 + node = $(node)[0];
  94 + if (node.tagName == 'B') {
  95 + var text = $(node).text();
  96 + var leftspaces = 0, rightspaces = 0;
  97 + // awful way to find the first non-space character from the left or the right. thanks.js
  98 + while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++;
  99 + while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++;
  100 + console.log(leftspaces, text.length);
  101 + if (leftspaces != text.length) $scope.editCardBlanks.push([i + leftspaces, i + text.length - rightspaces]);
  102 + i += text.length;
  103 + } else if (!node.data) {
  104 + i += $(node).text().length;
  105 + } else {
  106 + i += node.data.length;
  107 + }
  108 + });
  109 + this.editCardBlanks.sort(function (a, b) {
  110 + return a[0] - b[0];
  111 + });
  112 + i = 0;
  113 + newtext = '';
  114 + this.editCardBlanks.forEach(function (blank) {
  115 + newtext += this.editCardText.slice(i, blank[0]);
  116 + newtext += '<b>' + this.editCardText.slice(blank[0], blank[1]) + '</b>';
  117 + i = blank[1];
  118 + });
  119 + newtext += this.editCardText.slice(i);
  120 + //$scope.newCardFormattedText = newtext;*/
92 121  
93 122  
94   - var i = 0;
95   - this.editCardBlanks = [];
96   - $('#edit-card-input')[0].childNodes.forEach(function (node) {
97   - node = $(node)[0];
98   - if (node.tagName == 'B') {
99   - var text = $(node).text();
100   - var leftspaces = 0, rightspaces = 0;
101   - // awful way to find the first non-space character from the left or the right. thanks.js
102   - while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++;
103   - while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++;
104   - console.log(leftspaces, text.length);
105   - if (leftspaces != text.length) $scope.editCardBlanks.push([i + leftspaces, i + text.length - rightspaces]);
106   - i += text.length;
107   - } else if (!node.data) {
108   - i += $(node).text().length;
109   - } else {
110   - i += node.data.length;
111   - }
112   - });
113   - this.editCardBlanks.sort(function (a, b) {
114   - return a[0] - b[0];
115   - });
116   - i = 0;
117   - newtext = '';
118   - this.editCardBlanks.forEach(function (blank) {
119   - newtext += this.editCardText.slice(i, blank[0]);
120   - newtext += '<b>' + this.editCardText.slice(blank[0], blank[1]) + '</b>';
121   - i = blank[1];
122   - });
123   - newtext += this.editCardText.slice(i);
124   - //$scope.newCardFormattedText = newtext;*/
125   -
126   -
127 123 };
128 124  
129   -
130   -
131 125  
132 126 Flashcard.prototype.pushCard = function () {
133 127  
134   - //console.log()
  128 + //console.log()
135 129  
136   - var myCard = {
137   - 'text': $('#edit-card-input').text(),
138   - 'mask': this.editCardBlanks,
139   - //section: this.section.id
140   - };
141   - if (myCard.text == '') {
142   - console.log('blank flashcard not pushed:' + myCard.text);
143   - //return closeNewCard();
  130 + var myCard = {
  131 + 'text': $('#edit-card-input').text(),
  132 + 'mask': this.editCardBlanks,
  133 + //section: this.section.id
  134 + };
  135 + if (myCard.text == '') {
  136 + console.log('blank flashcard not pushed:' + myCard.text);
  137 + //return closeNewCard();
144 138  
145   - $('#editModal').closeModal(modal_options);
  139 + $('#editModal').closeModal(modal_options);
146 140  
147   - }
148   - $http.patch('/api/flashcards/' + this.id, myCard).
149   - success(function (data) {
150   - console.log('flashcard pushed: ' + myCard.text);
151   - if (!UserService.hasVerifiedEmail()) {
152   - Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000);
153   - }
154   - });
  141 + }
  142 + $http.patch('/api/flashcards/' + this.id, myCard).
  143 + success(function (data) {
  144 + console.log('flashcard pushed: ' + myCard.text);
  145 + if (!UserService.hasVerifiedEmail()) {
  146 + Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000);
  147 + }
  148 + });
155 149  
156   - $('#editModal').closeModal(modal_options);
  150 + $('#editModal').closeModal(modal_options);
157 151  
158   - }
  152 + };
159 153  
160 154  
161   - Flashcard.prototype.discardChanges = function() {
  155 + Flashcard.prototype.discardChanges = function () {
162 156  
163   - $('#editModal').closeModal(modal_options);
  157 + $('#editModal').closeModal(modal_options);
164 158  
165   - }
  159 + };
166 160  
167 161  
168 162 return Flashcard;
templates/feed.html View file @ 5522319
  1 +<a id="editModalA" href="#" data-target="newCard"></a>
1 2 <div id="editModal" class="modal row" style="max-height:none;">
2 3 <form id="edit-card-form">
3 4 <div class="modal-content col">
templates/flashcard.html View file @ 5522319
... ... @@ -16,18 +16,12 @@
16 16 </div>
17 17 <div class="bottom-box no-user-select">
18 18  
19   - <div class="left-box tooltipped" data-position=" bottom" data-tooltip="Edit">
20   - <div class="center-me modal-trigger" href="#editModal" ng-click="flashcard.edit()"><i class="mdi-editor-border-color small"></i></div>
  19 + <div class="left-box tooltipped">
  20 + <div class="center-me modal-trigger" ng-click="flashcard.edit()"><i
  21 + class="mdi-editor-border-color small"></i></div>
21 22 </div>
22 23  
23 24  
24   - <div class="right-box tooltipped" ng-click="flashcard.hide()" data-position="bottom" data-tooltip="Hide">
25   - <div class="left-box">
26   - <a class="center-me modal-trigger" href="#editModal" ng-click="flashcard.edit()"><i
27   - class="mdi-editor-border-color small"></i></a>
28   - </div>
29   -
30   -
31 25 <div class="right-box" ng-click="flashcard.hide()">
32 26 <div class="center-me"><i class="mdi-action-delete small"></i></div>
33 27 </div>
... ... @@ -35,69 +29,6 @@
35 29 </div>
36 30 </div>
37 31  
38   - <!-- Edit Modal -->
39   - <div id="editModal" class="modal row" style="max-height:none;">
40   - <form id="edit-card-form">
41   - <div class="modal-content col">
42   - <div class="row" style="margin-bottom:0">
43   - <div class="card cyan-text text-darken-2"
44   - style="width:300px; height:180px; margin-bottom:0; font-size:120%;">
45   - <div class="valign-wrapper">
46   - <div id="edit-card-input" ng-model="newCardFormattedText" style="outline:0px solid transparent;"
47   - class="card-content valign center-align"
48   - contenteditable select-non-editable="true" ng-change="flashcard.refreshEditCardInput()">
49   - </div>
50   - </div>
51   - </div>
52   - </div>
53   - </div>
54   - <div class="col">
55   - <div class="row">
56   - </div>
57   - <div class="row">
58   - <button class="btn modal-close tooltipped" type="submit" ng-click="flashcard.pushCard()"
59   - data-position="left"
60   - data-delay="50" ng-class="flashcard.submit_enabled?{}:'disabled'"
61   - data-tooltip="Enter">
62   - Edit
63   - <i class="mdi-action-done right"></i>
64   - </button>
65   - </div>
66   -
67   -
68   - <div class="row">
69   - <button class="btn modal-close" ng-click="flashcard.discardChanges()"
70   - data-position="left"
71   - data-delay="50">
72   - Discard Changes
73   - <i class="mdi-content-clear right"></i>
74   - </button>
75   - </div>
76   -
77   - <!--<div class="row">
78   - <button id="blank-selected" style="float:left" class="btn tooltipped" data-position="right" data-delay="50"
79   - data-tooltip="Ctrl-B">
80   - Blank Selected Text
81   - </button>
82   - </div>-->
83   -
84   -
85   - <div class="row" ng-show="flashcard.editCardText" ng-style="(flashcard.editCardText.length>160)?{color:'red'}:{}">
86   - {{flashcard.editCardText.length}}/160 characters
87   - </div>
88   - <div class="row" ng-show="flashcard.editCardText.length < 5">
89   - Please write a little more!
90   - </div>
91   - <div class="row" ng-show="flashcard.editCardText.length > 140">
92   - Good flashcards have a<br>
93   - single atomic fact
94   - </div>
95   - </div>
96   - </form>
97   - </div>
98   -
99   -
100   -
101 32 <!--<div id="editModal" class="modal">
102 33 <div class="modal-content">
103 34 <h4 id="flashcardEditText"></h4>
... ... @@ -112,7 +43,7 @@
112 43 <div class="center-me"><i
113 44 class="mdi-action-done small"></i></div>
114 45 </div>
115   - <div ng-show="rootScope.debug_flashcards" style="position:absolute; bottom:0px; right:5px;">
  46 + <div ng-show="false" style="position:absolute; bottom:0px; right:5px;">
116 47 <span class="center-me">score:{{flashcard.score}}</span>
117 48 </div>
118 49