Commit ad12ea2cddda7b0e36269ee192479827196c4b0f
1 parent
f71cb843b1
Exists in
master
and in
1 other branch
progress bar on feed
Showing 3 changed files with 16 additions and 9 deletions Inline Diff
home.html
View file @
ad12ea2
<!DOCTYPE html> | 1 | 1 | <!DOCTYPE html> | |
<html ng-app="flashy"> | 2 | 2 | <html ng-app="flashy"> | |
<base href="/app/"> | 3 | 3 | <base href="/app/"> | |
<head> | 4 | 4 | <head> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> | 5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> | |
<link rel="stylesheet" | 6 | 6 | <link rel="stylesheet" | |
href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css"> | 7 | 7 | href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css"> | |
8 | 8 | |||
<link rel="stylesheet" href="styles/flashier.css"/> | 9 | 9 | <link rel="stylesheet" href="styles/flashier.css"/> | |
<link rel="stylesheet" href="styles/flashy.css"/> | 10 | 10 | <link rel="stylesheet" href="styles/flashy.css"/> | |
<link href='https://fonts.googleapis.com/css?family=Titillium+Web:200,200italic,300,600,400,900,700,400italic,700italic,300italic,600italic' | 11 | 11 | <link href='https://fonts.googleapis.com/css?family=Titillium+Web:200,200italic,300,600,400,900,700,400italic,700italic,300italic,600italic' | |
rel='stylesheet' type='text/css'> | 12 | 12 | rel='stylesheet' type='text/css'> | |
<title>Flashy</title> | 13 | 13 | <title>Flashy</title> | |
</head> | 14 | 14 | </head> | |
<body ng-controller="RootController"> | 15 | 15 | <body ng-controller="RootController"> | |
<header> | 16 | 16 | <header> | |
<nav> | 17 | 17 | <nav> | |
<div class="nav-wrapper"> | 18 | 18 | <div class="nav-wrapper" ng-cloak> | |
<a ng-show="UserService.isLoggedIn()" href="#" data-activates="mobile-demo" class="left button-collapse hide-on-med-and-up"><i | 19 | 19 | <a ng-show="UserService.isLoggedIn()" href="#" data-activates="mobile-demo" | |
20 | class="left button-collapse hide-on-med-and-up"><i | |||
class="mdi-navigation-menu"></i></a> | 20 | 21 | class="mdi-navigation-menu"></i></a> | |
<ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> | 21 | 22 | <ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> | |
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | 22 | 23 | <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 23 | 24 | data-position="bottom" | |
data-delay="50" data-tooltip="Feed"><i | 24 | 25 | data-delay="50" data-tooltip="Feed"><i | |
class="mdi-action-view-module"></i></a></li> | 25 | 26 | class="mdi-action-view-module"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | 26 | 27 | <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 27 | 28 | data-position="bottom" | |
data-delay="50" data-tooltip="Deck"><i | 28 | 29 | data-delay="50" data-tooltip="Deck"><i | |
class="mdi-action-view-carousel"></i></a></li> | 29 | 30 | class="mdi-action-view-carousel"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | 30 | 31 | <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 31 | 32 | data-position="bottom" | |
data-delay="50" data-tooltip="Card List"><i | 32 | 33 | data-delay="50" data-tooltip="Card List"><i | |
class="mdi-action-view-list"></i></a></li> | 33 | 34 | class="mdi-action-view-list"></i></a></li> | |
</ul> | 34 | 35 | </ul> | |
<a href="#" class="brand-logo center">Flashy</a> | 35 | 36 | <a href="#" class="brand-logo center">Flashy</a> | |
36 | 37 | |||
<ul ng-show="UserService.isLoggedIn()" id="nav-mobile" class="right hide-on-small-and-down"> | 37 | 38 | <ul ng-show="UserService.isLoggedIn()" id="nav-mobile" class="right hide-on-small-and-down"> | |
<!-- User's classes dropdown --> | 38 | 39 | <!-- User's classes dropdown --> | |
<ul id="dropdown1" class="dropdown-content"> | 39 | 40 | <ul id="dropdown1" class="dropdown-content"> | |
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | 40 | 41 | <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | |
<a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | 41 | 42 | <a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
</li> | 42 | 43 | </li> | |
<li class="divider"></li> | 43 | 44 | <li class="divider"></li> | |
<li><a ui-sref="addclass">Add Class</a></li> | 44 | 45 | <li><a ui-sref="addclass">Add Class</a></li> | |
</ul> | 45 | 46 | </ul> | |
<li><a class="dropdown-button ng-cloak" href="#!" data-activates="dropdown1">{{currentSection.id?currentSection.short_name:"Classes"}}<i | 46 | 47 | <li><a class="dropdown-button ng-cloak" href="#!" data-activates="dropdown1">{{currentSection.id?currentSection.short_name:"Classes"}}<i | |
class="mdi-navigation-arrow-drop-down right"></i></a></li> | 47 | 48 | class="mdi-navigation-arrow-drop-down right"></i></a></li> | |
<li><a ui-sref="study">Study</a></li> | 48 | 49 | <li><a ui-sref="study">Study</a></li> | |
<li><a ui-sref="logout">Logout</a></li> | 49 | 50 | <li><a ui-sref="logout">Logout</a></li> | |
</ul> | 50 | 51 | </ul> | |
51 | 52 | |||
<!-- Slide-in side-nav for small screens --> | 52 | 53 | <!-- Slide-in side-nav for small screens --> | |
<ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> | 53 | 54 | <ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> | |
<span ng-show="currentSection.id"> | 54 | 55 | <span ng-show="currentSection.id"> | |
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | 55 | 56 | <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | |
><i | 56 | 57 | ><i | |
class="mdi-action-view-module left"></i>Feed</a></li> | 57 | 58 | class="mdi-action-view-module left"></i>Feed</a></li> | |
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | 58 | 59 | <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | |
><i | 59 | 60 | ><i | |
class="mdi-action-view-carousel left"></i>Deck</a></li> | 60 | 61 | class="mdi-action-view-carousel left"></i>Deck</a></li> | |
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | 61 | 62 | <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | |
><i | 62 | 63 | ><i | |
class="mdi-action-view-list left"></i>Card List</a> | 63 | 64 | class="mdi-action-view-list left"></i>Card List</a> | |
</li> | 64 | 65 | </li> | |
<hr> | 65 | 66 | <hr> | |
</span> | 66 | 67 | </span> | |
<!-- Collapsible menu for all the User's classes --> | 67 | 68 | <!-- Collapsible menu for all the User's classes --> | |
<ul class="collapsible" data-collapsible="accordion"> | 68 | 69 | <ul class="collapsible" data-collapsible="accordion"> | |
<li class="bold"> | 69 | 70 | <li class="bold"> | |
<a class="collapsible-header black-text"> | 70 | 71 | <a class="collapsible-header black-text"> | |
Classes<i | 71 | 72 | Classes<i | |
class="mdi-navigation-arrow-drop-down right"></i> | 72 | 73 | class="mdi-navigation-arrow-drop-down right"></i> | |
</a> | 73 | 74 | </a> | |
</li> | 74 | 75 | </li> | |
<div class="collapsible-body" style="display: block"> | 75 | 76 | <div class="collapsible-body" style="display: block"> | |
<ul> | 76 | 77 | <ul> | |
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | 77 | 78 | <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | |
<a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | 78 | 79 | <a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
</li> | 79 | 80 | </li> | |
<hr> | 80 | 81 | <hr> | |
<li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> | 81 | 82 | <li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> | |
</ul> | 82 | 83 | </ul> | |
</div> | 83 | 84 | </div> | |
</ul> | 84 | 85 | </ul> | |
<li><a ui-sref="study">Study</a></li> | 85 | 86 | <li><a ui-sref="study">Study</a></li> | |
<li><a ui-sref="logout">Logout</a></li> | 86 | 87 | <li><a ui-sref="logout">Logout</a></li> | |
</ul> | 87 | 88 | </ul> | |
</div> | 88 | 89 | </div> | |
</nav> | 89 | 90 | </nav> | |
90 | 91 | |||
</header> | 91 | 92 | </header> | |
92 | 93 | |||
93 | 94 | |||
<!-- Menu Bar --> | 94 | 95 | <!-- Menu Bar --> | |
<main ui-view></main> | 95 | 96 | <main ui-view></main> | |
96 | 97 | |||
97 | 98 | |||
<footer class="page-footer"> | 98 | 99 | <footer class="page-footer"> | |
<div class="footer-copyright"> | 99 | 100 | <div class="footer-copyright"> | |
<div class="container"> | 100 | 101 | <div class="container"> | |
© 2015 Team Swag | 101 | 102 | © 2015 Team Swag | |
<a class="grey-text text-lighten-4 right" href="mailto:halp@flashy.cards">Concerns? Contact us by email</a>! | 102 | 103 | <a class="grey-text text-lighten-4 right" href="mailto:halp@flashy.cards">Concerns? Contact us by email!</a> | |
</div> | 103 | 104 | </div> | |
</div> | 104 | 105 | </div> | |
</footer> | 105 | 106 | </footer> | |
106 | 107 | |||
</body> | 107 | 108 | </body> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 108 | 109 | <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script> | 109 | 110 | <script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.js"></script> | 110 | 111 | <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.js"></script> | |
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | 111 | 112 | <script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script type="text/javascript" src="scripts/materialize.js"></script> | 112 | 113 | <script type="text/javascript" src="scripts/materialize.js"></script> | |
<script type="text/javascript" src="scripts/jquery.collapsible.js"></script> | 113 | 114 | <script type="text/javascript" src="scripts/jquery.collapsible.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script> | 114 | 115 | <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script> | 115 | 116 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> | 116 | 117 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-resource.min.js"></script> | 117 | 118 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-resource.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script> | 118 | 119 | <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script> | |
119 | 120 | |||
120 | 121 | |||
<script src="config.js"></script> | 121 | 122 | <script src="config.js"></script> | |
122 | 123 | |||
<!-- Controllers --> | 123 | 124 | <!-- Controllers --> | |
<script src="scripts/FeedController.js"></script> | 124 | 125 | <script src="scripts/FeedController.js"></script> | |
<script src="scripts/RootController.js"></script> | 125 | 126 | <script src="scripts/RootController.js"></script> | |
<script src="scripts/LoginController.js"></script> | 126 | 127 | <script src="scripts/LoginController.js"></script> | |
<script src="scripts/LogoutController.js"></script> | 127 | 128 | <script src="scripts/LogoutController.js"></script> | |
<script src="scripts/DeckController.js"></script> | 128 | 129 | <script src="scripts/DeckController.js"></script> | |
<script src="scripts/RequestResetController.js"></script> | 129 | 130 | <script src="scripts/RequestResetController.js"></script> | |
<script src="scripts/ClassAddController.js"></script> | 130 | 131 | <script src="scripts/ClassAddController.js"></script> | |
<script src="scripts/StudyController.js"></script> | 131 | 132 | <script src="scripts/StudyController.js"></script> | |
<script src="scripts/ResetPasswordController.js"></script> | 132 | 133 | <script src="scripts/ResetPasswordController.js"></script> | |
<script src="scripts/CardListController.js"></script> | 133 | 134 | <script src="scripts/CardListController.js"></script> | |
<script src="scripts/VerifyEmailController.js"></script> | 134 | 135 | <script src="scripts/VerifyEmailController.js"></script> |
scripts/FeedController.js
View file @
ad12ea2
angular.module('flashy.FeedController', ['ui.router']). | 1 | 1 | angular.module('flashy.FeedController', ['ui.router']). | |
controller('FeedController', function($scope, $rootScope, $stateParams, $state, $http, UserService) { | 2 | 2 | controller('FeedController', function($scope, $rootScope, $stateParams, $state, $http, UserService) { | |
console.log('Hello from feed'); | 3 | 3 | console.log('Hello from feed'); | |
sectionId = $stateParams.sectionId; | 4 | 4 | sectionId = $stateParams.sectionId; | |
$rootScope.currentSection = $rootScope.SectionResource.get({sectionId: sectionId}); | 5 | 5 | $rootScope.currentSection = $rootScope.SectionResource.get({sectionId: sectionId}); | |
$scope.cards = []; | 6 | 6 | $scope.cards = false; | |
7 | 7 | |||
var loc = window.location, new_uri; | 8 | 8 | var loc = window.location, new_uri; | |
if (loc.protocol === 'https:') { | 9 | 9 | if (loc.protocol === 'https:') { | |
new_uri = 'wss:'; | 10 | 10 | new_uri = 'wss:'; | |
} else { | 11 | 11 | } else { | |
new_uri = 'ws:'; | 12 | 12 | new_uri = 'ws:'; | |
} | 13 | 13 | } | |
new_uri += '//' + loc.host; | 14 | 14 | new_uri += '//' + loc.host; | |
var ws = new WebSocket(new_uri + '/ws/feed/' + sectionId + '?subscribe-broadcast'); | 15 | 15 | var ws = new WebSocket(new_uri + '/ws/feed/' + sectionId + '?subscribe-broadcast'); | |
16 | 16 | |||
ws.onopen = function() { | 17 | 17 | ws.onopen = function() { | |
console.log('websocket connected'); | 18 | 18 | console.log('websocket connected'); | |
}; | 19 | 19 | }; | |
ws.onmessage = function(e) { | 20 | 20 | ws.onmessage = function(e) { | |
console.log('got websocket message ' + e.data); | 21 | 21 | console.log('got websocket message ' + e.data); | |
data = JSON.parse(e.data); | 22 | 22 | data = JSON.parse(e.data); | |
if (data.event_type == 'new_card') { | 23 | 23 | if (data.event_type == 'new_card') { | |
addCardToFeed(data.flashcard); | 24 | 24 | addCardToFeed(data.flashcard); | |
} | 25 | 25 | } | |
}; | 26 | 26 | }; | |
ws.onerror = function(e) { | 27 | 27 | ws.onerror = function(e) { | |
console.error(e); | 28 | 28 | console.error(e); | |
}; | 29 | 29 | }; | |
ws.onclose = function(e) { | 30 | 30 | ws.onclose = function(e) { | |
console.log('connection closed'); | 31 | 31 | console.log('connection closed'); | |
}; | 32 | 32 | }; | |
33 | 33 | |||
$http.get('/api/sections/' + sectionId + '/feed/'). | 34 | 34 | $http.get('/api/sections/' + sectionId + '/feed/'). | |
success(function(data) { | 35 | 35 | success(function(data) { | |
console.log(data); | 36 | 36 | console.log(data); | |
$scope.cards = data; | 37 | 37 | $scope.cards = data; | |
38 | 38 | |||
}). | 39 | 39 | }). | |
error(function(err) { | 40 | 40 | error(function(err) { | |
console.log('pulling feed failed'); | 41 | 41 | console.log('pulling feed failed'); | |
}); | 42 | 42 | }); | |
43 | 43 | |||
var addCardToFeed = function(card) { | 44 | 44 | var addCardToFeed = function(card) { | |
$scope.cards.unshift(card); | 45 | 45 | $scope.cards.unshift(card); | |
}; | 46 | 46 | }; | |
47 | 47 | |||
$scope.pushCard = function() { | 48 | 48 | $scope.pushCard = function() { | |
var i = 0; | 49 | 49 | var i = 0; | |
var blanks = []; | 50 | 50 | var blanks = []; | |
$('#new-card-input')[0].childNodes.forEach(function(node) { | 51 | 51 | $('#new-card-input')[0].childNodes.forEach(function(node) { | |
node = $(node)[0]; | 52 | 52 | node = $(node)[0]; | |
console.log(node); | 53 | 53 | console.log(node); | |
if (node.tagName == 'B') { | 54 | 54 | if (node.tagName == 'B') { | |
text = $(node).text(); | 55 | 55 | text = $(node).text(); | |
blanks.push([i, i + text.length]); | 56 | 56 | blanks.push([i, i + text.length]); | |
i += text.length; | 57 | 57 | i += text.length; | |
} else { | 58 | 58 | } else { | |
i += node.data.length; | 59 | 59 | i += node.data.length; | |
} | 60 | 60 | } | |
}); | 61 | 61 | }); | |
console.log(blanks); | 62 | 62 | console.log(blanks); | |
text = $('#new-card-input').text(); | 63 | 63 | text = $('#new-card-input').text(); | |
var myCard = { | 64 | 64 | var myCard = { | |
'text': text, | 65 | 65 | 'text': text, | |
'mask': blanks, | 66 | 66 | 'mask': blanks, | |
section: sectionId | 67 | 67 | section: sectionId | |
}; | 68 | 68 | }; | |
$http.post('/api/flashcards/', myCard). | 69 | 69 | $http.post('/api/flashcards/', myCard). | |
success(function(data) { | 70 | 70 | success(function(data) { | |
console.log('flashcard push succeeded'); | 71 | 71 | console.log('flashcard push succeeded'); | |
if (!UserService.hasVerifiedEmail()) { | 72 | 72 | if (!UserService.hasVerifiedEmail()) { | |
Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000); | 73 | 73 | Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000); | |
} | 74 | 74 | } | |
}). | 75 | 75 | }). | |
error(function(error) { | 76 | 76 | error(function(error) { | |
console.log('something went wrong pushing a card!'); | 77 | 77 | console.log('something went wrong pushing a card!'); | |
}); | 78 | 78 | }); | |
listenForC = true; | 79 | 79 | listenForC = true; | |
$('#new-card-input').html(''); | 80 | 80 | $('#new-card-input').html(''); | |
}; | 81 | 81 | }; | |
82 | 82 | |||
$http.get('/api/sections/' + sectionId + '/feed/'). | 83 | 83 | $http.get('/api/sections/' + sectionId + '/feed/'). | |
success(function(data) { | 84 | 84 | success(function(data) { | |
console.log(data); | 85 | 85 | console.log(data); | |
$scope.cards = data; | 86 | 86 | $scope.cards = data; | |
}). | 87 | 87 | }). | |
error(function(err) { | 88 | 88 | error(function(err) { | |
console.log("couldn't get cards!"); | 89 | 89 | console.log("couldn't get cards!"); | |
}); | 90 | 90 | }); | |
91 | 91 | |||
/* Key bindings for the whole feed window. Hotkey it up! */ | 92 | 92 | /* Key bindings for the whole feed window. Hotkey it up! */ | |
var listenForC = true; | 93 | 93 | var listenForC = true; | |
94 | 94 | |||
// Need to pass these options into openmodal and leanmodal, | 95 | 95 | // Need to pass these options into openmodal and leanmodal, | |
// otherwise the ready handler doesn't get called | 96 | 96 | // otherwise the ready handler doesn't get called | |
97 | 97 | |||
modal_options = { | 98 | 98 | modal_options = { | |
dismissible: true, // Modal can be dismissed by clicking outside of the modal | 99 | 99 | dismissible: true, // Modal can be dismissed by clicking outside of the modal | |
opacity: 0, // Opacity of modal background | 100 | 100 | opacity: 0, // Opacity of modal background | |
in_duration: 300, // Transition in duration | 101 | 101 | in_duration: 300, // Transition in duration | |
out_duration: 200, // Transition out duration | 102 | 102 | out_duration: 200, // Transition out duration | |
ready: function() { | 103 | 103 | ready: function() { | |
listenForC = false; | 104 | 104 | listenForC = false; | |
console.log('modal OPENING'); | 105 | 105 | console.log('modal OPENING'); | |
$('#new-card-input').focus(); | 106 | 106 | $('#new-card-input').focus(); | |
}, | 107 | 107 | }, | |
complete: function() { | 108 | 108 | complete: function() { | |
listenForC = true; | 109 | 109 | listenForC = true; | |
console.log('modal done, closing'); | 110 | 110 | console.log('modal done, closing'); | |
$('#new-card-input').blur(); | 111 | 111 | $('#new-card-input').blur(); | |
} | 112 | 112 | } | |
}; | 113 | 113 | }; | |
114 | 114 | |||
$(document).keydown(function(e) { | 115 | 115 | $(document).keydown(function(e) { | |
console.log(e.which); | 116 | 116 | console.log(e.which); | |
var keyed = e.which; | 117 | 117 | var keyed = e.which; | |
if (keyed == 67 && listenForC) { // "c" or "C" for compose | 118 | 118 | if (keyed == 67 && listenForC) { // "c" or "C" for compose | |
$('#newCard').openModal(modal_options); | 119 | 119 | $('#newCard').openModal(modal_options); | |
e.preventDefault(); | 120 | 120 | e.preventDefault(); | |
listenForC = false; | 121 | 121 | listenForC = false; | |
return false; | 122 | 122 | return false; | |
} else if (keyed == 27) { // enter or esc, respectively | 123 | 123 | } else if (keyed == 27) { // enter or esc, respectively | |
listenForC = true; | 124 | 124 | listenForC = true; | |
document.getElementById('new-card-input').value = ''; | 125 | 125 | document.getElementById('new-card-input').value = ''; | |
} | 126 | 126 | } | |
}); | 127 | 127 | }); | |
$scope.flashcard = ''; | 128 | 128 | $scope.flashcard = ''; | |
$scope.text = ''; | 129 | 129 | $scope.text = ''; | |
var selected_start = 0; | 130 | 130 | var selected_start = 0; | |
var selected_end = 0; | 131 | 131 | var selected_end = 0; | |
$(document).ready(function() { | 132 | 132 | $(document).ready(function() { | |
$('.tooltipped').tooltip({delay: 50}); | 133 | 133 | $('.tooltipped').tooltip({delay: 50}); | |
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | 134 | 134 | // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | |
$('.modal-trigger').leanModal(modal_options); | 135 | 135 | $('.modal-trigger').leanModal(modal_options); | |
$('#new-card-input').on('keydown', function(e) { | 136 | 136 | $('#new-card-input').on('keydown', function(e) { | |
if (e.which == 13) { | 137 | 137 | if (e.which == 13) { | |
e.preventDefault(); | 138 | 138 | e.preventDefault(); | |
$scope.pushCard(); | 139 | 139 | $scope.pushCard(); | |
$('#newCard').closeModal(modal_options); | 140 | 140 | $('#newCard').closeModal(modal_options); | |
return false; | 141 | 141 | return false; | |
} | 142 | 142 | } | |
}); | 143 | 143 | }); | |
$('#new-card-input').on('mouseup', function() { | 144 | 144 | $('#new-card-input').on('mouseup', function() { | |
console.log('got selection: ' + selected_start); | 145 | 145 | console.log('got selection: ' + selected_start); | |
}); | 146 | 146 | }); | |
$('button#blank-selected').click(function() { | 147 | 147 | $('button#blank-selected').click(function() { |
templates/feed.html
View file @
ad12ea2
<div class="row"> | 1 | 1 | <div class="row"> | |
2 | <h2 ng-cloak ng-show="cards.length == 0">No cards. Be the first one to add a card!</h2> | |||
3 | ||||
4 | <div class="progress center-align" style="margin: 32px auto auto;width:50%;" ng-show="!cards"> | |||
5 | <div class="indeterminate"></div> | |||
6 | </div> | |||
<div ng-repeat="card in cards"> | 2 | 7 | <div ng-repeat="card in cards"> | |
<flashcard flashcard-obj="card" refresh="refreshCards()"/> | 3 | 8 | <flashcard flashcard-obj="card" refresh="refreshCards()"/> | |
</div> | 4 | 9 | </div> | |
</div> | 5 | 10 | </div> | |
6 | 11 | |||
<h2 ng-show="cards.length == 0">No cards. Be the first one to add a card!</h2> | 7 | |||
8 | 12 | |||
<!--Lil plus button in corner--> | 9 | 13 | <!--Lil plus button in corner--> | |
<div class="fixed-action-btn" style="bottom: 96px; right: 24px;"> | 10 | 14 | <div class="fixed-action-btn" style="bottom: 96px; right: 24px;"> | |
<a data-target="newCard" class="btn-floating btn-large modal-trigger tooltipped" href="#newCard" data-position="left" data-delay="50" | 11 | 15 | <a data-target="newCard" class="btn-floating btn-large modal-trigger tooltipped" href="#newCard" data-position="left" | |
data-tooltip="(C)ompose"> | 12 | 16 | data-delay="50" | |
17 | data-tooltip="(C)ompose"> | |||
<i class="large mdi-content-add"></i> | 13 | 18 | <i class="large mdi-content-add"></i> | |
</a> | 14 | 19 | </a> | |
</div> | 15 | 20 | </div> | |
16 | 21 | |||
<div id="newCard" class="modal bottom-sheet"> | 17 | 22 | <div id="newCard" class="modal bottom-sheet"> | |
<form id="new-card-form"> | 18 | 23 | <form id="new-card-form"> | |
<div class="modal-content"> | 19 | 24 | <div class="modal-content"> | |
<div class="input-field"> | 20 | 25 | <div class="input-field"> | |
<!--<label id="newCardSign" for="newCard">New Flashcard Text</label>--> | 21 | 26 | <!--<label id="newCardSign" for="newCard">New Flashcard Text</label>--> | |
<div id="new-card-input" contenteditable style="outline:0px solid transparent;"> | 22 | 27 | <div id="new-card-input" contenteditable style="outline:0px solid transparent;"> | |
23 | 28 | |||
</div> | 24 | 29 | </div> | |
</div> | 25 | 30 | </div> | |
</div> | 26 | 31 | </div> | |
<div class="modal-footer"> | 27 | 32 | <div class="modal-footer"> | |
<button class="btn modal-close tooltipped" type="submit" ng-click="pushCard()" data-position="left" data-delay="50" | 28 | 33 | <button class="btn modal-close tooltipped" type="submit" ng-click="pushCard()" data-position="left" | |
34 | data-delay="50" | |||
data-tooltip="Enter">Submit | 29 | 35 | data-tooltip="Enter">Submit | |
<i class="mdi-hardware-keyboard-return right"></i> | 30 | 36 | <i class="mdi-hardware-keyboard-return right"></i> | |
</button> | 31 | 37 | </button> | |
<button id="blank-selected" style="float:left" class="btn tooltipped" data-position="right" data-delay="50" | 32 | 38 | <button id="blank-selected" style="float:left" class="btn tooltipped" data-position="right" data-delay="50" | |
data-tooltip="Ctrl-B">Blank Selected Text | 33 | 39 | data-tooltip="Ctrl-B">Blank Selected Text | |
</button> | 34 | 40 | </button> | |
</div> | 35 | 41 | </div> | |
</form> | 36 | 42 | </form> |