Commit 44ba1fb7b8c5b7fac860cd7b04762368b848b80b
1 parent
a15945bde1
Exists in
master
and in
1 other branch
took out the annoying alert
Showing 2 changed files with 10 additions and 4 deletions Inline Diff
home.html
View file @
44ba1fb
<!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"> | |
<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" class="left button-collapse hide-on-med-and-up"><i | |
class="mdi-navigation-menu"></i></a> | 20 | 20 | class="mdi-navigation-menu"></i></a> | |
<ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> | 21 | 21 | <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 | 22 | <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 23 | 23 | data-position="bottom" | |
data-delay="50" data-tooltip="Feed"><i | 24 | 24 | data-delay="50" data-tooltip="Feed"><i | |
class="mdi-action-view-module"></i></a></li> | 25 | 25 | class="mdi-action-view-module"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | 26 | 26 | <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 27 | 27 | data-position="bottom" | |
data-delay="50" data-tooltip="Deck"><i | 28 | 28 | data-delay="50" data-tooltip="Deck"><i | |
class="mdi-action-view-carousel"></i></a></li> | 29 | 29 | class="mdi-action-view-carousel"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | 30 | 30 | <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 31 | 31 | data-position="bottom" | |
data-delay="50" data-tooltip="Card List"><i | 32 | 32 | data-delay="50" data-tooltip="Card List"><i | |
class="mdi-action-view-list"></i></a></li> | 33 | 33 | class="mdi-action-view-list"></i></a></li> | |
</ul> | 34 | 34 | </ul> | |
<a href="#" class="brand-logo center">Flashy</a> | 35 | 35 | <a href="#" class="brand-logo center">Flashy</a> | |
36 | 36 | |||
<ul ng-show="UserService.isLoggedIn()" id="nav-mobile" class="right hide-on-small-and-down"> | 37 | 37 | <ul ng-show="UserService.isLoggedIn()" id="nav-mobile" class="right hide-on-small-and-down"> | |
<!-- User's classes dropdown --> | 38 | 38 | <!-- User's classes dropdown --> | |
<ul id="dropdown1" class="dropdown-content"> | 39 | 39 | <ul id="dropdown1" class="dropdown-content"> | |
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | 40 | 40 | <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 | 41 | <a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
</li> | 42 | 42 | </li> | |
<li class="divider"></li> | 43 | 43 | <li class="divider"></li> | |
<li><a ui-sref="addclass">Add Class</a></li> | 44 | 44 | <li><a ui-sref="addclass">Add Class</a></li> | |
</ul> | 45 | 45 | </ul> | |
<li><a class="dropdown-button ng-cloak" href="#!" data-activates="dropdown1">{{currentSection.id?currentSection.short_name:"Classes"}}<i | 46 | 46 | <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 | 47 | class="mdi-navigation-arrow-drop-down right"></i></a></li> | |
<li><a ui-sref="study">Study</a></li> | 48 | 48 | <li><a ui-sref="study">Study</a></li> | |
<li><a ui-sref="logout">Logout</a></li> | 49 | 49 | <li><a ui-sref="logout">Logout</a></li> | |
</ul> | 50 | 50 | </ul> | |
51 | 51 | |||
<!-- Slide-in side-nav for small screens --> | 52 | 52 | <!-- Slide-in side-nav for small screens --> | |
<ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> | 53 | 53 | <ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> | |
<span ng-show="currentSection.id"> | 54 | 54 | <span ng-show="currentSection.id"> | |
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | 55 | 55 | <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | |
><i | 56 | 56 | ><i | |
class="mdi-action-view-module left"></i>Feed</a></li> | 57 | 57 | 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 | 58 | <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | |
><i | 59 | 59 | ><i | |
class="mdi-action-view-carousel left"></i>Deck</a></li> | 60 | 60 | 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 | 61 | <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | |
><i | 62 | 62 | ><i | |
class="mdi-action-view-list left"></i>Card List</a> | 63 | 63 | class="mdi-action-view-list left"></i>Card List</a> | |
</li> | 64 | 64 | </li> | |
<hr> | 65 | 65 | <hr> | |
</span> | 66 | 66 | </span> | |
<!-- Collapsible menu for all the User's classes --> | 67 | 67 | <!-- Collapsible menu for all the User's classes --> | |
<ul class="collapsible" data-collapsible="accordion"> | 68 | 68 | <ul class="collapsible" data-collapsible="accordion"> | |
<li class="bold"> | 69 | 69 | <li class="bold"> | |
<a class="collapsible-header black-text"> | 70 | 70 | <a class="collapsible-header black-text"> | |
Classes<i | 71 | 71 | Classes<i | |
class="mdi-navigation-arrow-drop-down right"></i> | 72 | 72 | class="mdi-navigation-arrow-drop-down right"></i> | |
</a> | 73 | 73 | </a> | |
</li> | 74 | 74 | </li> | |
<div class="collapsible-body" style="display: block"> | 75 | 75 | <div class="collapsible-body" style="display: block"> | |
<ul> | 76 | 76 | <ul> | |
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | 77 | 77 | <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 | 78 | <a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
</li> | 79 | 79 | </li> | |
<hr> | 80 | 80 | <hr> | |
<li><a ui-sref="addclass"><i class="tiny mdi-content-add"> Add Class</i></a></li> | 81 | 81 | <li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> | |
</ul> | 82 | 82 | </ul> | |
</div> | 83 | 83 | </div> | |
</ul> | 84 | 84 | </ul> | |
<li><a ui-sref="study">Study</a></li> | 85 | 85 | <li><a ui-sref="study">Study</a></li> | |
<li><a ui-sref="logout">Logout</a></li> | 86 | 86 | <li><a ui-sref="logout">Logout</a></li> | |
</ul> | 87 | 87 | </ul> | |
</div> | 88 | 88 | </div> | |
</nav> | 89 | 89 | </nav> | |
90 | 90 | |||
</header> | 91 | 91 | </header> | |
92 | 92 | |||
93 | 93 | |||
<!-- Menu Bar --> | 94 | 94 | <!-- Menu Bar --> | |
<main ui-view></main> | 95 | 95 | <main ui-view></main> | |
96 | 96 | |||
97 | 97 | |||
<footer class="page-footer"> | 98 | 98 | <footer class="page-footer"> | |
<div class="footer-copyright"> | 99 | 99 | <div class="footer-copyright"> | |
<div class="container"> | 100 | 100 | <div class="container"> | |
© 2015 Team Swag | 101 | 101 | © 2015 Team Swag | |
<a class="grey-text text-lighten-4 right" href="mailto:halp@flashy.cards">Concerns? Contact us by email</a>! | 102 | 102 | <a class="grey-text text-lighten-4 right" href="mailto:halp@flashy.cards">Concerns? Contact us by email</a>! | |
</div> | 103 | 103 | </div> | |
</div> | 104 | 104 | </div> | |
</footer> | 105 | 105 | </footer> | |
106 | 106 | |||
</body> | 107 | 107 | </body> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 108 | 108 | <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 | 109 | <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 | 110 | <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 | 111 | <script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script type="text/javascript" src="scripts/materialize.js"></script> | 112 | 112 | <script type="text/javascript" src="scripts/materialize.js"></script> | |
<script type="text/javascript" src="scripts/jquery.collapsible.js"></script> | 113 | 113 | <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 | 114 | <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 | 115 | <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 | 116 | <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 | 117 | <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 | 118 | <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script> | |
119 | 119 | |||
120 | 120 | |||
<script src="config.js"></script> | 121 | 121 | <script src="config.js"></script> | |
122 | 122 | |||
<!-- Controllers --> | 123 | 123 | <!-- Controllers --> | |
<script src="scripts/FeedController.js"></script> | 124 | 124 | <script src="scripts/FeedController.js"></script> | |
<script src="scripts/RootController.js"></script> | 125 | 125 | <script src="scripts/RootController.js"></script> | |
<script src="scripts/LoginController.js"></script> | 126 | 126 | <script src="scripts/LoginController.js"></script> | |
<script src="scripts/LogoutController.js"></script> | 127 | 127 | <script src="scripts/LogoutController.js"></script> | |
<script src="scripts/DeckController.js"></script> | 128 | 128 | <script src="scripts/DeckController.js"></script> | |
<script src="scripts/RequestResetController.js"></script> | 129 | 129 | <script src="scripts/RequestResetController.js"></script> | |
<script src="scripts/ClassAddController.js"></script> | 130 | 130 | <script src="scripts/ClassAddController.js"></script> | |
<script src="scripts/StudyController.js"></script> | 131 | 131 | <script src="scripts/StudyController.js"></script> |
scripts/FeedController.js
View file @
44ba1fb
angular.module('flashy.FeedController', ['ui.router']). | 1 | 1 | angular.module('flashy.FeedController', ['ui.router']). | |
controller('FeedController', function($scope, $rootScope, $stateParams, $state, $http) { | 2 | 2 | controller('FeedController', function($scope, $rootScope, $stateParams, $state, $http) { | |
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 = []; | |
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); | |
$scope.refreshCards(); | 22 | 22 | $scope.refreshCards(); | |
}; | 23 | 23 | }; | |
ws.onerror = function(e) { | 24 | 24 | ws.onerror = function(e) { | |
console.error(e); | 25 | 25 | console.error(e); | |
}; | 26 | 26 | }; | |
ws.onclose = function(e) { | 27 | 27 | ws.onclose = function(e) { | |
console.log('connection closed'); | 28 | 28 | console.log('connection closed'); | |
}; | 29 | 29 | }; | |
30 | 30 | |||
$http.get('/api/sections/' + sectionId + '/feed/'). | 31 | 31 | $http.get('/api/sections/' + sectionId + '/feed/'). | |
success(function(data) { | 32 | 32 | success(function(data) { | |
console.log(data); | 33 | 33 | console.log(data); | |
$scope.cards = data; | 34 | 34 | $scope.cards = data; | |
35 | 35 | |||
$scope.noCards = function () { | 36 | 36 | $scope.noCards = function () { | |
37 | 37 | |||
alert(data.length); | 38 | |||
39 | 38 | |||
if (data.length == 0) { | 40 | 39 | /*if (data.length == 0) { | |
return true; | 41 | 40 | return true; | |
} else { | 42 | 41 | } else { | |
return false; | 43 | 42 | return false; | |
} | 44 | 43 | }*/ | |
45 | 44 | |||
} | 46 | 45 | } | |
47 | 46 | |||
48 | 47 | |||
49 | 48 | |||
50 | 49 | |||
}). | 51 | 50 | }). | |
error(function(err) { | 52 | 51 | error(function(err) { | |
console.log('pulling feed failed'); | 53 | 52 | console.log('pulling feed failed'); | |
}); | 54 | 53 | }); | |
55 | 54 | |||
$scope.viewDeck = function() { | 56 | 55 | $scope.viewDeck = function() { | |
$state.go('deck', {sectionId: sectionId}); | 57 | 56 | $state.go('deck', {sectionId: sectionId}); | |
console.log('go to deck'); | 58 | 57 | console.log('go to deck'); | |
}; | 59 | 58 | }; | |
60 | 59 | |||
$scope.pushCard = function() { | 61 | 60 | $scope.pushCard = function() { | |
var pushed = new Date(Date.now()); | 62 | 61 | var pushed = new Date(Date.now()); | |
var i = 0; | 63 | 62 | var i = 0; | |
var blanks = []; | 64 | 63 | var blanks = []; | |
$('#new-card-input')[0].childNodes.forEach(function(node) { | 65 | 64 | $('#new-card-input')[0].childNodes.forEach(function(node) { | |
node = $(node)[0]; | 66 | 65 | node = $(node)[0]; | |
console.log(node); | 67 | 66 | console.log(node); | |
if (node.tagName == 'B') { | 68 | 67 | if (node.tagName == 'B') { | |
text = $(node).text(); | 69 | 68 | text = $(node).text(); | |
blanks.push([i, i + text.length]); | 70 | 69 | blanks.push([i, i + text.length]); | |
i += text.length; | 71 | 70 | i += text.length; | |
} else { | 72 | 71 | } else { | |
i += node.data.length; | 73 | 72 | i += node.data.length; | |
} | 74 | 73 | } | |
}); | 75 | 74 | }); | |
console.log(blanks); | 76 | 75 | console.log(blanks); | |
text = $('#new-card-input').text(); | 77 | 76 | text = $('#new-card-input').text(); | |
var myCard = { | 78 | 77 | var myCard = { | |
'text': text, | 79 | 78 | 'text': text, | |
'material_date': pushed, | 80 | 79 | 'material_date': pushed, | |
'mask': blanks, | 81 | 80 | 'mask': blanks, | |
section: sectionId | 82 | 81 | section: sectionId | |
}; | 83 | 82 | }; | |
$http.post('/api/flashcards/', myCard). | 84 | 83 | $http.post('/api/flashcards/', myCard). | |
success(function(data) { | 85 | 84 | success(function(data) { | |
console.log('pushed a card!'); | 86 | 85 | console.log('pushed a card!'); | |
listenForC = true; | 87 | 86 | listenForC = true; | |
}). | 88 | 87 | }). | |
error(function(error) { | 89 | 88 | error(function(error) { | |
console.log('something went wrong pushing a card!'); | 90 | 89 | console.log('something went wrong pushing a card!'); | |
}); | 91 | 90 | }); | |
92 | 91 | |||
$('#new-card-input').html(''); | 93 | 92 | $('#new-card-input').html(''); | |
}; | 94 | 93 | }; | |
95 | 94 | |||
$scope.refreshCards = function() { | 96 | 95 | $scope.refreshCards = function() { | |
$http.get('/api/sections/' + sectionId + '/feed/'). | 97 | 96 | $http.get('/api/sections/' + sectionId + '/feed/'). | |
success(function(data) { | 98 | 97 | success(function(data) { | |
console.log(data); | 99 | 98 | console.log(data); | |
$scope.cards = data; | 100 | 99 | $scope.cards = data; | |
100 | ||||
101 | /*if (data.length == 0) { | |||
102 | return true; | |||
103 | } else { | |||
104 | return false; | |||
105 | }*/ | |||
106 | ||||
console.log('success in refresh cards...'); | 101 | 107 | console.log('success in refresh cards...'); | |
}). | 102 | 108 | }). | |
error(function(err) { | 103 | 109 | error(function(err) { | |
console.log('refresh fail'); | 104 | 110 | console.log('refresh fail'); | |
}); | 105 | 111 | }); | |
}; | 106 | 112 | }; | |
107 | 113 | |||
/* Key bindings for the whole feed window. Hotkey it up! */ | 108 | 114 | /* Key bindings for the whole feed window. Hotkey it up! */ | |
var listenForC = true; | 109 | 115 | var listenForC = true; | |
110 | 116 | |||
// Need to pass these options into openmodal and leanmodal, | 111 | 117 | // Need to pass these options into openmodal and leanmodal, | |
// otherwise the ready handler doesn't get called | 112 | 118 | // otherwise the ready handler doesn't get called | |
113 | 119 | |||
modal_options = { | 114 | 120 | modal_options = { | |
dismissible: true, // Modal can be dismissed by clicking outside of the modal | 115 | 121 | dismissible: true, // Modal can be dismissed by clicking outside of the modal | |
opacity: 0, // Opacity of modal background | 116 | 122 | opacity: 0, // Opacity of modal background | |
in_duration: 300, // Transition in duration | 117 | 123 | in_duration: 300, // Transition in duration | |
out_duration: 200, // Transition out duration | 118 | 124 | out_duration: 200, // Transition out duration | |
ready: function() { | 119 | 125 | ready: function() { | |
listenForC = false; | 120 | 126 | listenForC = false; | |
console.log('modal OPENING'); | 121 | 127 | console.log('modal OPENING'); | |
$('#new-card-input').focus(); | 122 | 128 | $('#new-card-input').focus(); | |
}, | 123 | 129 | }, | |
complete: function() { | 124 | 130 | complete: function() { | |
listenForC = true; | 125 | 131 | listenForC = true; | |
console.log('modal done, closing'); | 126 | 132 | console.log('modal done, closing'); | |
$('#new-card-input').blur(); | 127 | 133 | $('#new-card-input').blur(); | |
} | 128 | 134 | } | |
}; | 129 | 135 | }; | |
130 | 136 | |||
$(document).keydown(function(e) { | 131 | 137 | $(document).keydown(function(e) { | |
console.log(e.which); | 132 | 138 | console.log(e.which); | |
var keyed = e.which; | 133 | 139 | var keyed = e.which; | |
if (keyed == 67 && listenForC) { // "c" or "C" for compose | 134 | 140 | if (keyed == 67 && listenForC) { // "c" or "C" for compose | |
$('#newCard').openModal(modal_options); | 135 | 141 | $('#newCard').openModal(modal_options); | |
e.preventDefault(); | 136 | 142 | e.preventDefault(); | |
listenForC = false; | 137 | 143 | listenForC = false; | |
return false; | 138 | 144 | return false; | |
} else if (keyed == 27) { // enter or esc, respectively | 139 | 145 | } else if (keyed == 27) { // enter or esc, respectively | |
listenForC = true; | 140 | 146 | listenForC = true; | |
document.getElementById('new-card-input').value = ''; | 141 | 147 | document.getElementById('new-card-input').value = ''; | |
} | 142 | 148 | } | |
}); | 143 | 149 | }); | |
$scope.flashcard = ''; | 144 | 150 | $scope.flashcard = ''; | |
$scope.text = ''; | 145 | 151 | $scope.text = ''; | |
var selected_start = 0; | 146 | 152 | var selected_start = 0; | |
var selected_end = 0; | 147 | 153 | var selected_end = 0; | |
$(document).ready(function() { | 148 | 154 | $(document).ready(function() { | |
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | 149 | 155 | // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | |
$('.modal-trigger').leanModal(modal_options); | 150 | 156 | $('.modal-trigger').leanModal(modal_options); | |
$('#new-card-input').on('keydown', function(e) { | 151 | 157 | $('#new-card-input').on('keydown', function(e) { | |
if (e.which == 13) { | 152 | 158 | if (e.which == 13) { | |
e.preventDefault(); | 153 | 159 | e.preventDefault(); | |
$scope.pushCard(); | 154 | 160 | $scope.pushCard(); | |
$('#newCard').closeModal(modal_options); | 155 | 161 | $('#newCard').closeModal(modal_options); |