Commit a2c4eb4fdf73cc4aecc8e5a9fcaa371079102d4d
1 parent
59806c3da4
Exists in
master
and in
1 other branch
Added Angular Material for class add autocomplete. May be broken. Time to test
Showing 4 changed files with 53 additions and 23 deletions Inline Diff
home.html
View file @
a2c4eb4
<!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> | |
<link type="text/css" rel="stylesheet" href="styles/materialize.min.css" media="screen,projection"/> | 5 | 5 | <link type="text/css" rel="stylesheet" href="styles/materialize.min.css" media="screen,projection"/> | |
<!--<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css"/>--> | 6 | 6 | <!--<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css"/>--> | |
<link rel="stylesheet" href="flashy.css"/> | 7 | 7 | <link rel="stylesheet" href="flashy.css"/> | |
</head> | 8 | 8 | </head> | |
9 | 9 | |||
<body ng-controller="RootController"> | 10 | 10 | <body ng-controller="RootController"> | |
11 | 11 | |||
<ul id="nav" class="side-nav fixed"> | 12 | 12 | <ul id="nav" class="side-nav fixed"> | |
<li class="bold"><a ui-sref="login">Login</a></li> | 13 | 13 | <li class="bold"><a ui-sref="login">Login</a></li> | |
<li class="bold"><a ui-sref="addclass">Add Class</a></li> | 14 | 14 | <li class="bold"><a ui-sref="addclass">Add Class</a></li> | |
</ul> | 15 | 15 | </ul> | |
<div class="container" ui-view></div> | 16 | 16 | <div class="container" ui-view></div> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 17 | 17 | <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> | 18 | 18 | <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> | 19 | 19 | <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> | 20 | 20 | <script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script type="text/javascript" src="scripts/materialize.min.js"></script> | 21 | 21 | <script type="text/javascript" src="scripts/materialize.min.js"></script> | |
22 | <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script> | |||
23 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script> | |||
24 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> | |||
22 | 25 | |||
<script src="config.js"></script> | 23 | 26 | <script src="config.js"></script> | |
24 | 27 | |||
<script src="scripts/FeedController.js"></script> | 25 | 28 | <script src="scripts/FeedController.js"></script> | |
<script src="scripts/RootController.js"></script> | 26 | 29 | <script src="scripts/RootController.js"></script> | |
<script src="scripts/LoginController.js"></script> | 27 | 30 | <script src="scripts/LoginController.js"></script> | |
<script src="scripts/LogoutController.js"></script> | 28 | 31 | <script src="scripts/LogoutController.js"></script> | |
<script src="scripts/DeckController.js"></script> | 29 | 32 | <script src="scripts/DeckController.js"></script> | |
<script src="scripts/RequestResetController.js"></script> | 30 | 33 | <script src="scripts/RequestResetController.js"></script> | |
<script src="scripts/ClassAddController.js"></script> | 31 | 34 | <script src="scripts/ClassAddController.js"></script> | |
<script src="scripts/StudyController.js"></script> | 32 | 35 | <script src="scripts/StudyController.js"></script> | |
<script src="scripts/UserService.js"></script> | 33 | 36 | <script src="scripts/UserService.js"></script> |
scripts/ClassAddController.js
View file @
a2c4eb4
angular.module('flashy.ClassAddController', ['ui.router', 'angucomplete-alt']). | 1 | 1 | angular.module('flashy.ClassAddController', ['ui.router', 'angucomplete-alt', 'ngMaterial']). | |
2 | 2 | |||
controller('ClassAddController', ['$scope', '$state', function($scope, $state) { | 3 | 3 | controller('ClassAddController', ['$scope', '$state', '$http', function($scope, $state, $http) { | |
4 | 4 | |||
$scope.remoteUrlRequestFn = function(str) { | 5 | 5 | $scope.trySearch = function() { | |
return {q: str}; | 6 | 6 | return $http.get('/api/sections/search').then(function(response){ | |
}; | 7 | 7 | return response.data; | |
$(document).ready(function() { | 8 | 8 | })}; | |
}); | 9 | 9 | ||
10 | $scope.searchText = ""; | |||
11 | ||||
12 | /*$scope.trySearch = function() { | |||
13 | $http.get('/api/sections/search', [$scope.searchText]). | |||
14 | success(function(data) { | |||
15 | return data; | |||
16 | }). | |||
17 | error(function(err) { | |||
18 | console.log('you eejit'); | |||
19 | }); | |||
20 | };*/ | |||
10 | 21 | |||
}]); | 11 | 22 | }]); | |
12 | 23 | |||
scripts/FeedController.js
View file @
a2c4eb4
angular.module('flashy.FeedController', ['ui.router']). | 1 | 1 | angular.module('flashy.FeedController', ['ui.router']). | |
2 | 2 | |||
controller('FeedController', ['$scope', '$state', function($scope, $state) { | 3 | 3 | controller('FeedController', ['$scope', '$state', '$http', function($scope, $state, $http) { | |
console.log('Hello from feed'); | 4 | 4 | console.log('Hello from feed'); | |
5 | 5 | |||
$scope.viewDeck = function() { | 6 | 6 | $scope.viewDeck = function() { | |
$state.go('deck'); | 7 | 7 | $state.go('deck'); | |
console.log('go to deck'); | 8 | 8 | console.log('go to deck'); | |
}; | 9 | 9 | }; | |
10 | 10 | |||
$scope.pullCard = function() { | 11 | 11 | $scope.pullCard = function() { | |
console.log('card clicked'); | 12 | 12 | console.log('card clicked'); | |
}; | 13 | 13 | }; | |
14 | 14 | |||
$scope.create = false; // show make flashcard | 15 | 15 | $scope.create = false; // show make flashcard | |
16 | 16 | |||
$scope.pushCard = function() { | 17 | 17 | $scope.pushCard = function() { | |
console.log('make! card content:' + $scope.text); | 18 | 18 | console.log('make! card content:' + $scope.text); | |
var pushed = Date.now(); | 19 | 19 | var pushed = new Date(Date.now()); | |
console.log(pushed); | 20 | 20 | console.log(pushed.toString()); | |
21 | ||||
22 | // attempt to make card :( | |||
23 | $http.post('/api/flashcards/', {"text": $scope.text, "pushed": pushed, "mask": []}). | |||
24 | success(function(data) { | |||
25 | console.log("No way, really?"); | |||
26 | }). | |||
27 | error(function(error) { | |||
28 | console.log("haha, n00b"); | |||
29 | }); | |||
30 | ||||
$scope.create = false; // hide make flashcard | 21 | 31 | $scope.create = false; // hide make flashcard | |
$scope.text = ""; | 22 | 32 | $scope.text = ""; | |
}; | 23 | 33 | }; | |
24 | 34 |
templates/addclass.html
View file @
a2c4eb4
<div angucomplete-alt id="classes" | 1 | 1 | <!DOCTYPE html> | |
placeholder="Search classes" | 2 | 2 | <div layout="column"> | |
pause="100" | 3 | 3 | <md-content layout-padding layout="column"> | |
selected-object="selectedClass" | 4 | 4 | <form> | |
remote-url="/api/sections/search/" | 5 | 5 | <md-autocomplete flex | |
remote-url-request-formatter="remoteUrlRequestFn" , | 6 | 6 | nd-no-cache="noCache" | |
remote-url-data-field="" , | 7 | 7 | md-selected-item="selectedItem" | |
title-field="short_name" , | 8 | 8 | md-search-text="searchText" | |
description-field="long_name" , | 9 | 9 | md-items="item in trySearch(searchText)" | |
minlength="2" , | 10 | 10 | md-item-text="item.display" | |
pause="0" , | 11 | 11 | md-floating-label="Search Classes"> | |
input-class="form-control"/> | 12 | 12 | <span md-highlight-text="searchText">{{item.display}}</span> | |
13 | <md-not-found> | |||
14 | No matches found. | |||
15 | </md-not-found> | |||
16 | </md-autocomplete> | |||
17 | </form> | |||
18 | </md-content> | |||
19 | </div> | |||
13 | 20 | |||
14 | ||||