From 0dfc7258627de8bcb7475af67c074e6ec0c10fd1 Mon Sep 17 00:00:00 2001 From: Andrew Buss Date: Tue, 2 Jun 2015 02:30:06 -0700 Subject: [PATCH] more refactoring; bugfixes; new border if in deck --- scripts/CardGridController.js | 1 + scripts/FeedController.js | 8 +++----- scripts/FlashcardDirective.js | 1 + scripts/FlashcardFactory.js | 8 ++++++-- scripts/StudyController.js | 2 +- styles/flashy.css | 17 ++++++++++++----- templates/flashcard.html | 13 +++++++------ 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/scripts/CardGridController.js b/scripts/CardGridController.js index 3823a15..dfeb67a 100644 --- a/scripts/CardGridController.js +++ b/scripts/CardGridController.js @@ -96,6 +96,7 @@ angular.module('flashy.CardGridController', ['ui.router', 'ngAnimate', 'ngWebSoc lowestCol.unshift(card); $scope.cardTable[card.id] = {'colNum': lowestColNum, 'obj': card}; $timeout($scope.refreshColumnWidth); + }; $scope.updateColRanks = function(col) { diff --git a/scripts/FeedController.js b/scripts/FeedController.js index 7dfe49e..530c80d 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -28,10 +28,7 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket' }; $scope.updateCardScore = function(card) { - console.log('old score', card.score); - card.score = flashcard.score; - console.log('new score', card.score); - $scope.cardCols[$scope.cardTable[card.id].colNum].sort(function(a, b) { + $scope.cardCols[card.colNum].sort(function(a, b) { return b.score - a.score; }); }; @@ -44,7 +41,8 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket' $scope.addCardToGrid(new Flashcard(data.flashcard), $scope.deck); } else if (data.event_type == 'score_change') { card = new Flashcard(data.flashcard.id); - $scope.updateCardScore(new Flashcard(data.flashcard.id)); + card.score = data.flashcard.score; + $scope.updateCardScore(card); } }); diff --git a/scripts/FlashcardDirective.js b/scripts/FlashcardDirective.js index eb22ba0..8ea1a1f 100644 --- a/scripts/FlashcardDirective.js +++ b/scripts/FlashcardDirective.js @@ -10,6 +10,7 @@ angular.module('flashy.FlashcardDirective', []). refresh: '&' // eval refresh in parent html }, link: function(scope, element) { + $('.tooltipped').tooltip(); /* Handles width of the card */ } }; diff --git a/scripts/FlashcardFactory.js b/scripts/FlashcardFactory.js index d612e30..397ddfe 100644 --- a/scripts/FlashcardFactory.js +++ b/scripts/FlashcardFactory.js @@ -9,7 +9,6 @@ angular.module('flashy.FlashcardFactory', ['ui.router']). this.mask.sort(function (a, b) { return a[0] - b[0]; }); - var i = 0; this.mask.forEach(function (blank) { this.textPieces.push({text: this.text.slice(i, blank[0])}); @@ -17,10 +16,15 @@ angular.module('flashy.FlashcardFactory', ['ui.router']). i = blank[1]; }, this); this.textPieces.push({text: this.text.slice(i)}); + this.formatted_text = ''; + for (i in this.textPieces) { + p = this.textPieces[i]; + this.formatted_text += p.blank ? '' + p.text + '' : p.text; + } FlashcardCache[this.id] = this; }; Flashcard.prototype.isInDeck = function () { - return this.deck[this.id]; + return !(typeof this.deck[this.id] === 'undefined'); }; Flashcard.prototype.pull = function () { if (this.deck[this.id]) return console.log('Not pulling', this.id, "because it's already in deck"); diff --git a/scripts/StudyController.js b/scripts/StudyController.js index ffc1998..07d13d0 100644 --- a/scripts/StudyController.js +++ b/scripts/StudyController.js @@ -37,7 +37,7 @@ controller('StudyController', ['$scope', '$stateParams', '$state', '$http', 'Use $('#content-x').slideDown(250).addClass('open'); } }; - + /* $scope.fetchQuiz = function(a, b) { diff --git a/styles/flashy.css b/styles/flashy.css index 6ed89b0..bc184b9 100644 --- a/styles/flashy.css +++ b/styles/flashy.css @@ -47,6 +47,10 @@ word-wrap: break-word; } +.card.flashy.in-deck { + border: 3px solid rgba(0, 184, 76, 0.4); +} + .card.flashy { background-color: #fff; font-family: 'Titillium Web', sans-serif; @@ -67,6 +71,7 @@ left: 0; opacity: 0; position: absolute; + /*pointer-events: none;*/ top: 0; transition: visibility 0s cubic-bezier(0, 0, 0.6, 1) 0.2s, opacity 0.2s cubic-bezier(0, 0, 0.6, 1); @@ -348,7 +353,8 @@ md-content.md-default-theme { -webkit-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); -moz-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); -o-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); - transition: 1s all cubic-bezier(0, 0, 0.6, 1); + transition: 1s cubic-bezier(0.6, 0.3, 0.7, 1.4); + /*1s all cubic-bezier(0, 0, 1, 0.3);*/ position: relative; } @@ -381,9 +387,9 @@ md-content.md-default-theme { } /*.wrapper {*/ - /*min-height: 100%;*/ - /*height: 100%;*/ - /*/!*margin: 0 auto -4em;*!/*/ +/*min-height: 100%;*/ +/*height: 100%;*/ +/*/!*margin: 0 auto -4em;*!/*/ /*}*/ .container, .push { @@ -457,7 +463,8 @@ md-content.md-default-theme { padding: 10px 20px; } -#new-card-input > b { +#new-card-input > b, +.card.flashy .card-content > b { /*font-weight: ;*/ border-bottom: 2px solid black; border-radius: 2px; diff --git a/templates/flashcard.html b/templates/flashcard.html index a71a37e..bf76ec5 100644 --- a/templates/flashcard.html +++ b/templates/flashcard.html @@ -1,9 +1,9 @@
+ ng-class="{'shrinky': startShrink, 'in-deck':flashcard.isInDeck()}">
-
- {{piece.text}} +
+ +
@@ -25,8 +25,9 @@
-
-
+
+
score:{{flashcard.score}} -- 1.9.1