Commit a2c4eb4fdf73cc4aecc8e5a9fcaa371079102d4d

Authored by Melody
1 parent 59806c3da4

Added Angular Material for class add autocomplete. May be broken. Time to test

Showing 4 changed files with 53 additions and 23 deletions Side-by-side Diff

... ... @@ -19,6 +19,9 @@
19 19 <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.js"></script>
20 20 <script src="//code.jquery.com/jquery-2.1.4.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  
23 26 <script src="config.js"></script>
24 27  
scripts/ClassAddController.js View file @ a2c4eb4
1   -angular.module('flashy.ClassAddController', ['ui.router', 'angucomplete-alt']).
  1 +angular.module('flashy.ClassAddController', ['ui.router', 'angucomplete-alt', 'ngMaterial']).
2 2  
3   - controller('ClassAddController', ['$scope', '$state', function($scope, $state) {
  3 + controller('ClassAddController', ['$scope', '$state', '$http', function($scope, $state, $http) {
4 4  
5   - $scope.remoteUrlRequestFn = function(str) {
6   - return {q: str};
7   - };
8   - $(document).ready(function() {
9   - });
  5 + $scope.trySearch = function() {
  6 + return $http.get('/api/sections/search').then(function(response){
  7 + return response.data;
  8 + })};
  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 }]);
scripts/FeedController.js View file @ a2c4eb4
1 1 angular.module('flashy.FeedController', ['ui.router']).
2 2  
3   - controller('FeedController', ['$scope', '$state', function($scope, $state) {
  3 + controller('FeedController', ['$scope', '$state', '$http', function($scope, $state, $http) {
4 4 console.log('Hello from feed');
5 5  
6 6 $scope.viewDeck = function() {
... ... @@ -16,8 +16,18 @@
16 16  
17 17 $scope.pushCard = function() {
18 18 console.log('make! card content:' + $scope.text);
19   - var pushed = Date.now();
20   - console.log(pushed);
  19 + var pushed = new Date(Date.now());
  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 +
21 31 $scope.create = false; // hide make flashcard
22 32 $scope.text = "";
23 33 };
templates/addclass.html View file @ a2c4eb4
1   -<div angucomplete-alt id="classes"
2   - placeholder="Search classes"
3   - pause="100"
4   - selected-object="selectedClass"
5   - remote-url="/api/sections/search/"
6   - remote-url-request-formatter="remoteUrlRequestFn" ,
7   - remote-url-data-field="" ,
8   - title-field="short_name" ,
9   - description-field="long_name" ,
10   - minlength="2" ,
11   - pause="0" ,
12   - input-class="form-control"/>
  1 +<!DOCTYPE html>
  2 +<div layout="column">
  3 + <md-content layout-padding layout="column">
  4 + <form>
  5 + <md-autocomplete flex
  6 + nd-no-cache="noCache"
  7 + md-selected-item="selectedItem"
  8 + md-search-text="searchText"
  9 + md-items="item in trySearch(searchText)"
  10 + md-item-text="item.display"
  11 + md-floating-label="Search Classes">
  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>