From 362cfb056dc4688d77976dbc9fd4a22e55bc7619 Mon Sep 17 00:00:00 2001 From: Melody Date: Thu, 28 May 2015 20:57:59 -0700 Subject: [PATCH] Flag cards and back to top --- scripts/CardListController.js | 37 +++++++++- templates/cardlist.html | 165 +++++++++++++++++++++++------------------- 2 files changed, 127 insertions(+), 75 deletions(-) diff --git a/scripts/CardListController.js b/scripts/CardListController.js index 1a60012..f2ed02f 100644 --- a/scripts/CardListController.js +++ b/scripts/CardListController.js @@ -7,7 +7,6 @@ angular.module('flashy.CardListController', ['ui.router', 'angular.filter']). $http.get('/api/sections/' + sectionId + '/flashcards/?hidden=yes'). success(function(data) { - console.log(data); $scope.cards = data; }). error(function(err) { @@ -79,6 +78,20 @@ angular.module('flashy.CardListController', ['ui.router', 'angular.filter']). }); }; + // unpull card + $scope.flag = function(card) { + $http.post('/api/flashcards/' + card.id + '/report/'). + success(function(data) { + console.log(card.text + ' reported'); + + // local change for display purposes + Materialize.toast('Card Flagged', 3000, 'rounded'); + }). + error(function(err) { + console.log('no hide for you'); + }); + }; + // toggle button text from show to hide $(function() { $('#showHidden').click(function() { @@ -92,7 +105,29 @@ angular.module('flashy.CardListController', ['ui.router', 'angular.filter']). $(document).off('keydown'); }); + // Tooltips! + $(document).ready(function(){ + $('.tooltipped').tooltip({delay: 50}); + + //back to top + var offset = 300; + var duration = 300; + $(window).scroll(function() { + if ($(this).scrollTop() > offset) { + $('.back-to-top').fadeIn(duration); + } else { + $('.back-to-top').fadeOut(duration); + } + }); + + jQuery('.back-to-top').click(function(event) { + event.preventDefault(); + jQuery('html, body').animate({scrollTop: 0}, duration); + return false; + }) + }); + // to display day of the week badges $scope.dayofweek = function(item) { var date = new Date(item.material_date); switch(date.getDay()) { diff --git a/templates/cardlist.html b/templates/cardlist.html index d0595c9..ec10d2d 100644 --- a/templates/cardlist.html +++ b/templates/cardlist.html @@ -1,80 +1,97 @@ -
- Show Hidden + +
+ Show Hidden -
- - - +
+ + + +
-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
-
- - +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
-
- - -
-
- -
+ +
-
-
    -
  • Week {{weeknum}}

  • -
  • -
    {{card.text}} - {{dayofweek(card)}} -

    - - - - -

    -
    -
  • -
-
+
+
    +
  • Week {{weeknum}}

  • +
  • +
    {{card.text}} + {{dayofweek(card)}} +

    + + + + + + +

    +
    +
  • +
+
+ + + + -- 1.9.1