From a7ee2b64a02a810844606fbe142bddfd712b319b Mon Sep 17 00:00:00 2001 From: Andrew Buss Date: Sun, 31 May 2015 23:11:54 -0700 Subject: [PATCH] new flashcard creation dialog --- scripts/CardGridController.js | 4 ++-- scripts/FeedController.js | 45 +++++++++++++++++++++++-------------------- styles/flashy.css | 10 ++++++++-- templates/deck.html | 45 ++++--------------------------------------- templates/feed.html | 19 +++++++++--------- 5 files changed, 48 insertions(+), 75 deletions(-) diff --git a/scripts/CardGridController.js b/scripts/CardGridController.js index 2053914..35c0316 100644 --- a/scripts/CardGridController.js +++ b/scripts/CardGridController.js @@ -17,8 +17,6 @@ angular.module('flashy.CardGridController', ['ui.router', 'ngAnimate', 'ngWebSoc return $state.go('addclass'); } - angular.element($window).bind('resize', $scope.refreshLayout); - $scope.refreshColumnWidth = function() { console.log('refreshing column width'); avail = $window.innerWidth - 17; @@ -56,6 +54,8 @@ angular.module('flashy.CardGridController', ['ui.router', 'ngAnimate', 'ngWebSoc }; + angular.element($window).bind('resize', $scope.refreshLayout); + $scope.ws_host = window.location.origin.replace('http', 'ws'); $scope.deck_ws = $websocket($scope.ws_host + '/ws/deck/' + $scope.sectionId + '?subscribe-user'); $scope.deck_ws.onOpen(function() { diff --git a/scripts/FeedController.js b/scripts/FeedController.js index 24aed2a..069f579 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -91,20 +91,25 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket' $('#new-card-input')[0].childNodes.forEach(function(node) { if (typeof node.data == 'undefined') { console.log('undefined node'); - return resetModal(); + //return resetModal(); } node = $(node)[0]; - console.log(node); if (node.tagName == 'B') { - text = $(node).text(); - blanks.push([i, i + text.length]); + var text = $(node).text(); + console.log(text.length, text); + var leftspaces = 0, rightspaces = 0; + // awful way to find the first non-space character from the left or the right. thanks.js + while (text[leftspaces] == ' ' || text[leftspaces] == '\xa0') leftspaces++; + while (text[text.length - 1 - rightspaces] == ' ' || text[text.length - 1 - rightspaces] == '\xa0') rightspaces++; + if (leftspaces != text.length) blanks.push([i + leftspaces, i + text.length - rightspaces]); i += text.length; } else { i += node.data.length; } }); var myCard = { - 'text': $('#new-card-input').text().trim(), + // we can't trim this string because it'd mess up the blanks. Something to fix. + 'text': $('#new-card-input').text(), 'mask': blanks, section: $scope.section.id }; @@ -161,22 +166,20 @@ angular.module('flashy.FeedController', ['ui.router', 'ngAnimate', 'ngWebSocket' document.getElementById('new-card-input').value = ''; } }); - $(document).ready(function() { - $('.tooltipped').tooltip({delay: 50}); - // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered - $('.modal-trigger').leanModal(modal_options); - $('#new-card-input').on('keydown', function(e) { - if (e.which == 13) { - e.preventDefault(); - $scope.pushCard(); - listenForC = true; - return false; - } - }); - $('button#blank-selected').click(function() { - console.log(window.getSelection()); - document.execCommand('bold'); - }); + $('.tooltipped').tooltip({delay: 50}); + // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered + $('.modal-trigger').leanModal(modal_options); + $('#new-card-input').on('keydown', function(e) { + if (e.which == 13) { + e.preventDefault(); + $scope.pushCard(); + listenForC = true; + return false; + } + }); + $('button#blank-selected').click(function() { + console.log(window.getSelection()); + document.execCommand('bold'); }); $scope.refreshCards(); diff --git a/styles/flashy.css b/styles/flashy.css index da53739..8b316dd 100644 --- a/styles/flashy.css +++ b/styles/flashy.css @@ -373,7 +373,6 @@ md-content.md-default-theme { opacity: 0; } - /* Animation CSS END */ /* Footer */ @@ -452,8 +451,15 @@ md-content.md-default-theme { } .st-accordion--content { - background-color: rgba(0,0,0,0.03); + background-color: rgba(0, 0, 0, 0.03); border-bottom: 1px solid #ddd; display: none; padding: 10px 20px; } + +#new-card-input > b { + /*font-weight: ;*/ + border-bottom: 2px solid black; + border-radius: 2px; + opacity: 0.5; +} \ No newline at end of file diff --git a/templates/deck.html b/templates/deck.html index 339d422..22e5a2f 100644 --- a/templates/deck.html +++ b/templates/deck.html @@ -1,50 +1,13 @@ - -
-

Add a card from the feed to see it here!

+
+

This is your deck, but it's blank! Add a card from the feed to see it here!

-
- -
-
-
-
- -
\ No newline at end of file diff --git a/templates/feed.html b/templates/feed.html index 81785f5..5d046e4 100644 --- a/templates/feed.html +++ b/templates/feed.html @@ -4,15 +4,12 @@
+
- +
- -
@@ -25,16 +22,20 @@
-