Commit 0c65d0c072d5ce92d4070e1fdd3d964f816724c8
1 parent
2d0860665d
Exists in
master
and in
1 other branch
try to fix behavior when the account is locked
Showing 7 changed files with 72 additions and 79 deletions Inline Diff
config.js
View file @
0c65d0c
angular.module('flashy', [ | 1 | 1 | angular.module('flashy', [ | |
'flashy.LogoutController', | 2 | 2 | 'flashy.LogoutController', | |
'flashy.LoginController', | 3 | 3 | 'flashy.LoginController', | |
'flashy.RootController', | 4 | 4 | 'flashy.RootController', | |
'flashy.FeedController', | 5 | 5 | 'flashy.FeedController', | |
'flashy.DeckController', | 6 | 6 | 'flashy.DeckController', | |
'flashy.ClassAddController', | 7 | 7 | 'flashy.ClassAddController', | |
'flashy.RequestResetController', | 8 | 8 | 'flashy.RequestResetController', | |
'flashy.StudyController', | 9 | 9 | 'flashy.StudyController', | |
'flashy.UserService', | 10 | 10 | 'flashy.UserService', | |
'flashy.FlashcardDirective', | 11 | 11 | 'flashy.FlashcardDirective', | |
//'flashy.SelectDirective', | 12 | 12 | //'flashy.SelectDirective', | |
// DOESNT WORK RN | 13 | 13 | // DOESNT WORK RN | |
'flashy.ResetPasswordController', | 14 | 14 | 'flashy.ResetPasswordController', | |
'flashy.VerifyEmailController', | 15 | 15 | 'flashy.VerifyEmailController', | |
'flashy.CardListController', | 16 | 16 | 'flashy.CardListController', | |
'flashy.HelpController', | 17 | 17 | 'flashy.HelpController', | |
'flashy.SettingsController', | 18 | 18 | 'flashy.SettingsController', | |
'ngCookies']). | 19 | 19 | 'ngCookies']). | |
config(function($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) { | 20 | 20 | config(function($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) { | |
'use strict'; | 21 | 21 | 'use strict'; | |
$httpProvider.defaults.withCredentials = true; | 22 | 22 | $httpProvider.defaults.withCredentials = true; | |
$httpProvider.defaults.xsrfCookieName = 'csrftoken'; | 23 | 23 | $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | 24 | 24 | $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
$resourceProvider.defaults.stripTrailingSlashes = false; | 25 | 25 | $resourceProvider.defaults.stripTrailingSlashes = false; | |
var arrayMethods = Object.getOwnPropertyNames(Array.prototype); | 26 | 26 | var arrayMethods = Object.getOwnPropertyNames(Array.prototype); | |
arrayMethods.forEach(attachArrayMethodsToNodeList); | 27 | 27 | arrayMethods.forEach(attachArrayMethodsToNodeList); | |
function attachArrayMethodsToNodeList(methodName) { | 28 | 28 | function attachArrayMethodsToNodeList(methodName) { | |
if (methodName !== 'length') { | 29 | 29 | if (methodName !== 'length') { | |
NodeList.prototype[methodName] = Array.prototype[methodName]; | 30 | 30 | NodeList.prototype[methodName] = Array.prototype[methodName]; | |
} | 31 | 31 | } | |
} | 32 | 32 | } | |
33 | 33 | |||
$httpProvider.interceptors.push(function($q, $rootScope) { | 34 | 34 | $httpProvider.interceptors.push(function($q, $rootScope) { | |
return { | 35 | 35 | return { | |
'responseError': function(rejection) { // need a better redirect | 36 | 36 | 'responseError': function(rejection) { // need a better redirect | |
if (rejection.status >= 500) { | 37 | 37 | if (rejection.status >= 500) { | |
console.log('got error'); | 38 | 38 | console.log('got error'); | |
console.log(rejection); | 39 | 39 | console.log(rejection); | |
$rootScope.$broadcast('server_error', rejection); | 40 | 40 | $rootScope.$broadcast('server_error', rejection); | |
} | 41 | 41 | } | |
if (rejection.status == 403) { | 42 | 42 | if (rejection.status == 403) { | |
console.log(rejection); | 43 | 43 | console.log(rejection); | |
if (rejection.data && rejection.data.detail == 'Please verify your email before continuing') { | 44 | 44 | if (rejection.data && rejection.data.detail == 'Please verify your email before continuing') { | |
$rootScope.$broadcast('account_locked'); | 45 | 45 | UserService.showLockedMessage(); | |
46 | UserService.logout(); | |||
} | 46 | 47 | } | |
} | 47 | 48 | } | |
return $q.reject(rejection); | 48 | 49 | return $q.reject(rejection); | |
} | 49 | 50 | } | |
}; | 50 | 51 | }; | |
}); | 51 | 52 | }); | |
$locationProvider.html5Mode(true); | 52 | 53 | $locationProvider.html5Mode(true); | |
$urlRouterProvider.otherwise('/404'); | 53 | 54 | $urlRouterProvider.otherwise('/404'); | |
var auth_resolve = { | 54 | 55 | var auth_resolve = { | |
authorize: function($q, $state, $stateParams, UserService) { | 55 | 56 | authorize: function($q, $state, $stateParams, UserService) { | |
if (UserService.noAuthRequired($state)) { | 56 | 57 | if (UserService.noAuthRequired($state)) { | |
console.log('no auth state ' + $state.name); | 57 | 58 | return console.log('no auth state ' + $state.name); | |
return $state.go(state.name); | 58 | 59 | } | |
} | 59 | |||
console.log('resolving user before continuing for ' + $state.name); | 60 | 60 | console.log('resolving user before continuing for ' + $state.name); | |
var redirectAsNeeded = function() { | 61 | 61 | var redirectAsNeeded = function() { | |
if (!UserService.isLoggedIn()) { | 62 | 62 | if (!UserService.isLoggedIn()) { | |
console.log(UserService.getUserData()); | 63 | 63 | console.log(UserService.getUserData()); | |
console.log('making the user log in'); | 64 | 64 | console.log('making the user log in'); | |
$state.go('login'); | 65 | 65 | $state.go('login'); | |
} | 66 | 66 | } | |
if (!UserService.authorizedFor($state, $stateParams)) { | 67 | 67 | if (!UserService.authorizedFor($state, $stateParams)) { | |
console.log('user not authorized for ' + $state.name); | 68 | 68 | console.log('user not authorized for ' + $state.name); | |
$state.go('addclass'); | 69 | 69 | $state.go('addclass'); | |
} | 70 | 70 | } | |
}; | 71 | 71 | }; | |
if (UserService.isResolved()) return redirectAsNeeded(); | 72 | 72 | if (UserService.isResolved()) return redirectAsNeeded(); | |
return UserService.getUserData().then(redirectAsNeeded); | 73 | 73 | return UserService.getUserData().then(redirectAsNeeded); | |
} | 74 | 74 | } | |
}; | 75 | 75 | }; | |
$stateProvider. | 76 | 76 | $stateProvider. | |
state('login', { | 77 | 77 | state('login', { | |
url: '/login', | 78 | 78 | url: '/login', | |
templateUrl: 'templates/login.html', | 79 | 79 | templateUrl: 'templates/login.html', | |
controller: 'LoginController' | 80 | 80 | controller: 'LoginController' | |
}). | 81 | 81 | }). | |
state('logout', { | 82 | 82 | state('logout', { | |
resolve: auth_resolve, | 83 | 83 | resolve: auth_resolve, | |
url: '/logout', | 84 | 84 | url: '/logout', | |
templateUrl: 'templates/logout.html', | 85 | 85 | templateUrl: 'templates/logout.html', | |
controller: 'LogoutController' | 86 | 86 | controller: 'LogoutController' | |
}). | 87 | 87 | }). | |
state('root', { | 88 | 88 | state('root', { | |
resolve: auth_resolve, | 89 | 89 | resolve: auth_resolve, | |
url: '', | 90 | 90 | url: '', | |
controller: 'RootController' | 91 | 91 | controller: 'RootController' | |
}). | 92 | 92 | }). | |
state('feed', { | 93 | 93 | state('feed', { | |
resolve: auth_resolve, | 94 | 94 | resolve: auth_resolve, | |
url: '/feed/{sectionId}', | 95 | 95 | url: '/feed/{sectionId}', | |
templateUrl: 'templates/feed.html', | 96 | 96 | templateUrl: 'templates/feed.html', | |
controller: 'FeedController' | 97 | 97 | controller: 'FeedController' | |
}). | 98 | 98 | }). | |
state('cardlist', { | 99 | 99 | state('cardlist', { | |
resolve: auth_resolve, | 100 | 100 | resolve: auth_resolve, | |
url: '/cards/{sectionId}', | 101 | 101 | url: '/cards/{sectionId}', | |
templateUrl: 'templates/cardlist.html', | 102 | 102 | templateUrl: 'templates/cardlist.html', | |
controller: 'CardListController' | 103 | 103 | controller: 'CardListController' | |
}). | 104 | 104 | }). | |
state('addclass', { | 105 | 105 | state('addclass', { | |
resolve: auth_resolve, | 106 | 106 | resolve: auth_resolve, | |
url: '/addclass', | 107 | 107 | url: '/addclass', | |
templateUrl: 'templates/addclass.html', | 108 | 108 | templateUrl: 'templates/addclass.html', | |
controller: 'ClassAddController' | 109 | 109 | controller: 'ClassAddController' | |
}). | 110 | 110 | }). | |
state('deck', { | 111 | 111 | state('deck', { | |
resolve: auth_resolve, | 112 | 112 | resolve: auth_resolve, | |
url: '/deck/{sectionId}', | 113 | 113 | url: '/deck/{sectionId}', | |
templateUrl: 'templates/deck.html', | 114 | 114 | templateUrl: 'templates/deck.html', | |
controller: 'DeckController' | 115 | 115 | controller: 'DeckController' | |
}). | 116 | 116 | }). | |
state('study', { | 117 | 117 | state('study', { | |
resolve: auth_resolve, | 118 | 118 | resolve: auth_resolve, | |
url: '/study', | 119 | 119 | url: '/study', | |
templateUrl: 'templates/study.html', | 120 | 120 | templateUrl: 'templates/study.html', | |
controller: 'StudyController' | 121 | 121 | controller: 'StudyController' | |
}). | 122 | 122 | }). | |
state('flashcard', { | 123 | 123 | state('flashcard', { | |
resolve: auth_resolve, | 124 | 124 | resolve: auth_resolve, | |
url: '/flashcard', | 125 | 125 | url: '/flashcard', | |
templateUrl: 'templates/flashcard.html', | 126 | 126 | templateUrl: 'templates/flashcard.html', | |
controller: 'FlashcardController' | 127 | 127 | controller: 'FlashcardController' | |
}). | 128 | 128 | }). | |
state('settings', { | 129 | 129 | state('settings', { | |
resolve: auth_resolve, | 130 | 130 | resolve: auth_resolve, | |
url: '/settings', | 131 | 131 | url: '/settings', | |
templateUrl: 'templates/settings.html', | 132 | 132 | templateUrl: 'templates/settings.html', | |
controller: 'SettingsController' | 133 | 133 | controller: 'SettingsController' | |
}). | 134 | 134 | }). | |
state('requestpasswordreset', { | 135 | 135 | state('requestpasswordreset', { | |
url: '/requestpasswordreset', | 136 | 136 | url: '/requestpasswordreset', | |
templateUrl: 'templates/requestpasswordreset.html', | 137 | 137 | templateUrl: 'templates/requestpasswordreset.html', | |
controller: 'RequestResetController' | 138 | 138 | controller: 'RequestResetController' | |
}). | 139 | 139 | }). | |
state('resetpassword', { | 140 | 140 | state('resetpassword', { | |
url: '/resetpassword/{uid}/{token}', | 141 | 141 | url: '/resetpassword/{uid}/{token}', | |
templateUrl: 'templates/resetpassword.html', | 142 | 142 | templateUrl: 'templates/resetpassword.html', | |
controller: 'ResetPasswordController' | 143 | 143 | controller: 'ResetPasswordController' | |
}). | 144 | 144 | }). | |
state('verifyemail', { | 145 | 145 | state('verifyemail', { | |
url: '/verifyemail/{key}', | 146 | 146 | url: '/verifyemail/{key}', | |
templateUrl: 'templates/verifyemail.html', | 147 | 147 | templateUrl: 'templates/verifyemail.html', | |
controller: 'VerifyEmailController' | 148 | 148 | controller: 'VerifyEmailController' | |
}). | 149 | 149 | }). | |
state('404', { | 150 | 150 | state('404', { | |
url: '/404', | 151 | 151 | url: '/404', | |
template: "<h1>This page doesn't exist!</h1>" | 152 | 152 | template: "<h1>This page doesn't exist!</h1>" | |
}). | 153 | 153 | }). | |
state('help', { | 154 | 154 | state('help', { | |
resolve: auth_resolve, | 155 | 155 | resolve: auth_resolve, | |
url: '/help', | 156 | 156 | url: '/help', | |
templateUrl: 'templates/help.html', | 157 | 157 | templateUrl: 'templates/help.html', | |
controller: 'HelpController' | 158 | 158 | controller: 'HelpController' | |
}); | 159 | 159 | }); | |
}). | 160 | 160 | }). | |
run(function($rootScope, $state, $stateParams, $location, UserService) { | 161 | 161 | run(function($rootScope, $state, $stateParams, $location, UserService) { | |
$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) { | 162 | 162 | $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) { | |
console.log('failed to change state: ' + error); | 163 | 163 | console.log('failed to change state: ' + error); | |
$state.go('login'); | 164 | 164 | $state.go('login'); | |
}); | 165 | 165 | }); | |
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { | 166 | 166 | $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { | |
if (['feed', 'deck', 'cardlist'].indexOf(toState.name) >= 0) { | 167 | 167 | if (['feed', 'deck', 'cardlist'].indexOf(toState.name) >= 0) { | |
localStorage.setItem('last_state', toState.name); | 168 | 168 | localStorage.setItem('last_state', toState.name); | |
localStorage.setItem('last_state_params', JSON.stringify(toParams)); | 169 | 169 | localStorage.setItem('last_state_params', JSON.stringify(toParams)); | |
} | 170 | 170 | } | |
}); | 171 | 171 | }); | |
}); | 172 | 172 | }); | |
173 | 173 | |||
home.html
View file @
0c65d0c
<!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" | 19 | 19 | <a ng-show="UserService.isLoggedIn()" href="#" data-activates="mobile-demo" | |
class="left button-collapse hide-on-med-and-up"><i | 20 | 20 | class="left button-collapse hide-on-med-and-up"><i | |
class="mdi-navigation-menu"></i></a> | 21 | 21 | class="mdi-navigation-menu"></i></a> | |
<!-- User's classes dropdown --> | 22 | 22 | <!-- User's classes dropdown --> | |
<ul id="classDropdown" class="dropdown-content"> | 23 | 23 | <ul id="classDropdown" class="dropdown-content"> | |
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | 24 | 24 | <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | |
<a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | 25 | 25 | <a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
</li> | 26 | 26 | </li> | |
<li class="divider"></li> | 27 | 27 | <li class="divider"></li> | |
<li><a ui-sref="addclass">Add Class</a></li> | 28 | 28 | <li><a ui-sref="addclass">Add Class</a></li> | |
</ul> | 29 | 29 | </ul> | |
<ul> | 30 | 30 | <ul ng-show="UserService.isLoggedIn()" class="left hide-on-small-and-down"> | |
<li><a style="font-size:20px; font-weight:700" class="dropdown-button ng-cloak hide-on-small-and-down" | 31 | 31 | <li><a style="font-size:20px; font-weight:700" class="dropdown-button ng-cloak hide-on-small-and-down" | |
href="#!" | 32 | 32 | href="#!" | |
data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i | 33 | 33 | data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i | |
class="mdi-navigation-arrow-drop-down right"></i></a></li> | 34 | 34 | class="mdi-navigation-arrow-drop-down right"></i></a></li> | |
</ul> | 35 | 35 | <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" | |
<ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> | 36 | 36 | class="tooltipped" | |
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | 37 | 37 | data-position="bottom" | |
data-position="bottom" | 38 | 38 | data-delay="50" data-tooltip="Feed"><i | |
data-delay="50" data-tooltip="Feed"><i | 39 | |||
class="mdi-action-view-module"></i></a></li> | 40 | 39 | class="mdi-action-view-module"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | 41 | 40 | <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" | |
data-position="bottom" | 42 | 41 | class="tooltipped" | |
data-delay="50" data-tooltip="Deck"><i | 43 | 42 | data-position="bottom" | |
43 | data-delay="50" data-tooltip="Deck"><i | |||
class="mdi-action-view-carousel"></i></a></li> | 44 | 44 | class="mdi-action-view-carousel"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | 45 | 45 | <li ng-show="currentSection.id" ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" | |
data-position="bottom" | 46 | 46 | class="tooltipped" | |
data-delay="50" data-tooltip="Card List"><i | 47 | 47 | data-position="bottom" | |
48 | data-delay="50" data-tooltip="Card List"><i | |||
class="mdi-action-view-list"></i></a></li> | 48 | 49 | class="mdi-action-view-list"></i></a></li> | |
</ul> | 49 | 50 | </ul> | |
<a href="#" class="brand-logo center">Flashy</a> | 50 | 51 | <a href="#" class="brand-logo center">Flashy</a> | |
51 | 52 | |||
<ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down"> | 52 | 53 | <ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down"> | |
53 | 54 | |||
<li ui-sref-active="active"><a ui-sref="study" class="tooltipped" data-position="bottom" data-delay="50" | 54 | 55 | <li ui-sref-active="active"><a ui-sref="study" class="tooltipped" data-position="bottom" data-delay="50" | |
data-tooltip="Study"> | 55 | 56 | data-tooltip="Study"> | |
<i class="tiny mdi-action-pageview"></i></a></li> | 56 | 57 | <i class="tiny mdi-action-pageview"></i></a></li> | |
57 | 58 | |||
<!-- Settings Dropdown --> | 58 | 59 | <!-- Settings Dropdown --> | |
<ul id="settingsDropdown" class="dropdown-content"> | 59 | 60 | <ul id="settingsDropdown" class="dropdown-content"> | |
60 | 61 | |||
61 | 62 | |||
</ul> | 62 | 63 | </ul> | |
63 | 64 | |||
<li ui-sref-active="active"><a ui-sref="help"><i class="tiny mdi-action-help tooltipped" | 64 | 65 | <li ui-sref-active="active"><a ui-sref="help"><i class="tiny mdi-action-help tooltipped" | |
data-position="bottom" | 65 | 66 | data-position="bottom" | |
data-delay="50" data-tooltip="Help"></i></a></li> | 66 | 67 | data-delay="50" data-tooltip="Help"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="settings"><i data-position="bottom" data-delay="50" | 67 | 68 | <li ui-sref-active="active"><a ui-sref="settings"><i data-position="bottom" data-delay="50" | |
data-tooltip="Settings" | 68 | 69 | data-tooltip="Settings" | |
class="mdi-action-settings tooltipped"></i></a></li> | 69 | 70 | class="mdi-action-settings tooltipped"></i></a></li> | |
<li><a ui-sref="logout"><i data-position="bottom" data-delay="50" data-tooltip="Logout" | 70 | 71 | <li><a ui-sref="logout"><i data-position="bottom" data-delay="50" data-tooltip="Logout" | |
class="mdi-content-forward tooltipped"></i></a></li> | 71 | 72 | class="mdi-content-forward tooltipped"></i></a></li> | |
72 | 73 | |||
73 | 74 | |||
</ul> | 74 | 75 | </ul> | |
75 | 76 | |||
<!-- Slide-in side-nav for small screens --> | 76 | 77 | <!-- Slide-in side-nav for small screens --> | |
<ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> | 77 | 78 | <ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> | |
<span ng-show="currentSection.id"> | 78 | 79 | <span ng-show="currentSection.id"> | |
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped"> | 79 | 80 | <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped"> | |
<i class="mdi-action-view-module left"></i> | 80 | 81 | <i class="mdi-action-view-module left"></i> | |
Feed</a> | 81 | 82 | Feed</a> | |
</li> | 82 | 83 | </li> | |
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped"> | 83 | 84 | <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped"> | |
<i class="mdi-action-view-carousel left"> </i> | 84 | 85 | <i class="mdi-action-view-carousel left"> </i> | |
Deck | 85 | 86 | Deck | |
</a> | 86 | 87 | </a> | |
</li> | 87 | 88 | </li> | |
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped"> | 88 | 89 | <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped"> | |
<i class="mdi-action-view-list left"></i> | 89 | 90 | <i class="mdi-action-view-list left"></i> | |
Card List | 90 | 91 | Card List | |
</a> | 91 | 92 | </a> | |
</li> | 92 | 93 | </li> | |
<hr> | 93 | 94 | <hr> | |
</span> | 94 | 95 | </span> | |
<!-- Collapsible menu for all the User's classes --> | 95 | 96 | <!-- Collapsible menu for all the User's classes --> | |
<ul class="collapsible" data-collapsible="accordion"> | 96 | 97 | <ul class="collapsible" data-collapsible="accordion"> | |
<li class="bold"> | 97 | 98 | <li class="bold"> | |
<a class="collapsible-header black-text"> | 98 | 99 | <a class="collapsible-header black-text"> | |
Classes | 99 | 100 | Classes | |
<i class="mdi-navigation-arrow-drop-down right"></i> | 100 | 101 | <i class="mdi-navigation-arrow-drop-down right"></i> | |
</a> | 101 | 102 | </a> | |
</li> | 102 | 103 | </li> | |
<div class="collapsible-body" style="display: block"> | 103 | 104 | <div class="collapsible-body" style="display: block"> | |
<ul> | 104 | 105 | <ul> | |
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | 105 | 106 | <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> | 106 | 107 | <a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
</li> | 107 | 108 | </li> | |
<hr> | 108 | 109 | <hr> | |
<li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> | 109 | 110 | <li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> | |
</ul> | 110 | 111 | </ul> | |
</div> | 111 | 112 | </div> | |
</ul> | 112 | 113 | </ul> | |
<li><a ui-sref="study">Study</a></li> | 113 | 114 | <li><a ui-sref="study">Study</a></li> | |
<li><a ui-sref="settings">Settings</a></li> | 114 | 115 | <li><a ui-sref="settings">Settings</a></li> | |
<li><a ui-sref="logout">Logout</a></li> | 115 | 116 | <li><a ui-sref="logout">Logout</a></li> | |
</ul> | 116 | 117 | </ul> | |
</div> | 117 | 118 | </div> | |
</nav> | 118 | 119 | </nav> | |
119 | 120 | |||
</header> | 120 | 121 | </header> | |
121 | 122 | |||
122 | 123 | |||
<!-- Menu Bar --> | 123 | 124 | <!-- Menu Bar --> | |
124 | 125 | |||
<div class="wrapper"> | 125 | 126 | <div class="wrapper"> | |
126 | 127 | |||
<main ui-view></main> | 127 | 128 | <main ui-view></main> | |
128 | 129 | |||
<div class="push"></div> | 129 | 130 | <div class="push"></div> | |
</div> | 130 | 131 | </div> | |
131 | 132 | |||
132 | 133 | |||
<footer class="page-footer"> | 133 | 134 | <footer class="page-footer"> | |
<div class="footer-copyright"> | 134 | 135 | <div class="footer-copyright"> | |
<div class="container"> | 135 | 136 | <div class="container"> | |
© 2015 Team Swag | 136 | 137 | © 2015 Team Swag | |
<a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by | 137 | 138 | <a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by | |
email!</a> | 138 | 139 | email!</a> | |
</div> | 139 | 140 | </div> | |
140 | 141 | |||
</div> | 141 | 142 | </div> | |
</footer> | 142 | 143 | </footer> | |
143 | 144 | |||
</body> | 144 | 145 | </body> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 145 | 146 | <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> | 146 | 147 | <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> | 147 | 148 | <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> | 148 | 149 | <script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script type="text/javascript" src="scripts/materialize.js"></script> | 149 | 150 | <script type="text/javascript" src="scripts/materialize.js"></script> | |
<script type="text/javascript" src="scripts/jquery.collapsible.js"></script> | 150 | 151 | <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> | 151 | 152 | <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> | 152 | 153 | <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> | 153 | 154 | <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> | 154 | 155 | <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> | 155 | 156 | <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script> | |
156 | 157 | |||
157 | 158 | |||
<script src="config.js"></script> | 158 | 159 | <script src="config.js"></script> | |
159 | 160 | |||
<!-- Controllers --> | 160 | 161 | <!-- Controllers --> | |
<script src="scripts/FeedController.js"></script> | 161 | 162 | <script src="scripts/FeedController.js"></script> | |
<script src="scripts/RootController.js"></script> | 162 | 163 | <script src="scripts/RootController.js"></script> | |
<script src="scripts/SettingsController.js"></script> | 163 | 164 | <script src="scripts/SettingsController.js"></script> | |
<script src="scripts/LoginController.js"></script> | 164 | 165 | <script src="scripts/LoginController.js"></script> | |
<script src="scripts/LogoutController.js"></script> | 165 | 166 | <script src="scripts/LogoutController.js"></script> | |
<script src="scripts/DeckController.js"></script> | 166 | 167 | <script src="scripts/DeckController.js"></script> | |
<script src="scripts/RequestResetController.js"></script> | 167 | 168 | <script src="scripts/RequestResetController.js"></script> | |
<script src="scripts/ClassAddController.js"></script> | 168 | 169 | <script src="scripts/ClassAddController.js"></script> | |
<script src="scripts/StudyController.js"></script> | 169 | 170 | <script src="scripts/StudyController.js"></script> |
scripts/FeedController.js
View file @
0c65d0c
angular.module('flashy.FeedController', ['ui.router', 'ngAnimate']). | 1 | 1 | angular.module('flashy.FeedController', ['ui.router', 'ngAnimate']). | |
2 | 2 | |||
controller('FeedController', function($scope, $rootScope, $stateParams, $state, $http, $window, $timeout, UserService) { | 3 | 3 | controller('FeedController', function($scope, $rootScope, $stateParams, $state, $http, $window, $timeout, UserService) { | |
console.log('Hello from feed'); | 4 | 4 | console.log('Hello from feed'); | |
sectionId = parseInt($stateParams.sectionId); | 5 | 5 | sectionId = parseInt($stateParams.sectionId); | |
if (!UserService.isInSection(sectionId)) { | 6 | 6 | if (!UserService.isInSection(sectionId)) { | |
console.log('user is not enrolled in ' + sectionId); | 7 | 7 | console.log('user is not enrolled in ' + sectionId); | |
return $state.go('addclass'); | 8 | 8 | return $state.go('addclass'); | |
} | 9 | 9 | } | |
$rootScope.currentSection = $rootScope.SectionResource.get({sectionId: sectionId}); | 10 | 10 | $rootScope.currentSection = $rootScope.SectionResource.get({sectionId: sectionId}); | |
$rootScope.debug_flashcard = false; | 11 | 11 | $rootScope.debug_flashcard = false; | |
$scope.cards = false; | 12 | 12 | $scope.cards = false; | |
$scope.cardCols = []; // organized data | 13 | 13 | $scope.cardCols = []; // organized data | |
$scope.numCols = 0; | 14 | 14 | $scope.numCols = 0; | |
$scope.cardTable = {}; // look up table of cards, {'colNum':col, 'obj':card} | 15 | 15 | $scope.cardTable = {}; // look up table of cards, {'colNum':col, 'obj':card} | |
16 | 16 | |||
function calculate_cols() { | 17 | 17 | function calculate_cols() { | |
var avail = $window.innerWidth - 17; | 18 | 18 | var avail = $window.innerWidth - 17; | |
return Math.max(1, Math.floor(avail / 250)); | 19 | 19 | return Math.max(1, Math.floor(avail / 250)); | |
} | 20 | 20 | } | |
21 | 21 | |||
$scope.refreshColumnWidth = function() { | 22 | 22 | $scope.refreshColumnWidth = function() { | |
console.log('refreshing column width'); | 23 | 23 | console.log('refreshing column width'); | |
avail = $window.innerWidth - 17; | 24 | 24 | avail = $window.innerWidth - 17; | |
width = Math.floor(avail / Math.floor(avail / 250)); | 25 | 25 | width = Math.floor(avail / Math.floor(avail / 250)); | |
$('.cardColumn').css({ | 26 | 26 | $('.cardColumn').css({ | |
width: width + 'px', | 27 | 27 | width: width + 'px', | |
'font-size': 100 * width / 250 + '%' | 28 | 28 | 'font-size': 100 * width / 250 + '%' | |
}); | 29 | 29 | }); | |
$('.cardColumn .card.flashy').css({ | 30 | 30 | $('.cardColumn .card.flashy').css({ | |
width: width - 12 + 'px', | 31 | 31 | width: width - 12 + 'px', | |
height: (width * 3 / 5) + 'px' | 32 | 32 | height: (width * 3 / 5) + 'px' | |
}); | 33 | 33 | }); | |
}; | 34 | 34 | }; | |
35 | 35 | |||
$scope.refreshLayout = function() { | 36 | 36 | $scope.refreshLayout = function() { | |
// check if we actually need to refresh the whole layout | 37 | 37 | // check if we actually need to refresh the whole layout | |
if (calculate_cols() == $scope.numCols) return $scope.refreshColumnWidth(); | 38 | 38 | if (calculate_cols() == $scope.numCols) return $scope.refreshColumnWidth(); | |
$scope.numCols = calculate_cols(); | 39 | 39 | $scope.numCols = calculate_cols(); | |
console.log('refreshing layout for ' + $scope.numCols + ' columns'); | 40 | 40 | console.log('refreshing layout for ' + $scope.numCols + ' columns'); | |
$scope.cardCols = []; | 41 | 41 | $scope.cardCols = []; | |
var cols = []; | 42 | 42 | var cols = []; | |
for (i = 0; i < $scope.numCols; i++) cols.push([]); | 43 | 43 | for (i = 0; i < $scope.numCols; i++) cols.push([]); | |
$scope.cards.forEach(function(card, i) { | 44 | 44 | $scope.cards.forEach(function(card, i) { | |
cols[i % $scope.numCols].push(card); | 45 | 45 | cols[i % $scope.numCols].push(card); | |
$scope.cardTable[card.id] = {'colNum': (i % $scope.numCols), 'obj': card}; | 46 | 46 | $scope.cardTable[card.id] = {'colNum': (i % $scope.numCols), 'obj': card}; | |
}); | 47 | 47 | }); | |
// wait until the next digest cycle to update cardCols | 48 | 48 | // wait until the next digest cycle to update cardCols | |
49 | 49 | |||
$timeout(function() { | 50 | 50 | $timeout(function() { | |
$scope.cardCols = cols; | 51 | 51 | $scope.cardCols = cols; | |
$timeout($scope.refreshColumnWidth); | 52 | 52 | $timeout($scope.refreshColumnWidth); | |
}); | 53 | 53 | }); | |
54 | 54 | |||
}; | 55 | 55 | }; | |
56 | 56 | |||
angular.element($window).bind('resize', $scope.refreshLayout); | 57 | 57 | angular.element($window).bind('resize', $scope.refreshLayout); | |
58 | 58 | |||
$scope.refreshCards = function() { | 59 | 59 | $scope.refreshCards = function() { | |
$http.get('/api/sections/' + sectionId + '/feed/'). | 60 | 60 | $http.get('/api/sections/' + sectionId + '/feed/'). | |
success(function(data) { | 61 | 61 | success(function(data) { | |
console.log(data); | 62 | 62 | console.log(data); | |
$scope.cards = data; | 63 | 63 | $scope.cards = data; | |
$scope.refreshLayout(); | 64 | 64 | $scope.refreshLayout(); | |
console.log('success in refresh cards...'); | 65 | 65 | console.log('success in refresh cards...'); | |
}). | 66 | 66 | }). | |
error(function(err) { | 67 | 67 | error(function(err) { | |
console.log('refresh fail'); | 68 | 68 | console.log('refresh fail'); | |
console.log(err); | 69 | 69 | console.log(err); | |
}); | 70 | 70 | }); | |
}; | 71 | 71 | }; | |
72 | 72 | |||
$scope.add = function(card) { | 73 | 73 | $scope.add = function(card) { | |
var colNum = 0; | 74 | 74 | var colNum = 0; | |
var lowestCol = $scope.cardCols[0]; | 75 | 75 | var lowestCol = $scope.cardCols[0]; | |
var lowestColNum = 0; | 76 | 76 | var lowestColNum = 0; | |
while (colNum < $scope.numCols) { | 77 | 77 | while (colNum < $scope.numCols) { | |
if ($scope.cardCols[colNum].length == 0) { | 78 | 78 | if ($scope.cardCols[colNum].length == 0) { | |
lowestCol = $scope.cardCols[colNum]; | 79 | 79 | lowestCol = $scope.cardCols[colNum]; | |
break; | 80 | 80 | break; | |
} else if ($scope.cardCols[colNum].length < lowestCol.length) { | 81 | 81 | } else if ($scope.cardCols[colNum].length < lowestCol.length) { | |
lowestCol = $scope.cardCols[colNum]; | 82 | 82 | lowestCol = $scope.cardCols[colNum]; | |
lowestColNum = colNum; | 83 | 83 | lowestColNum = colNum; | |
lowestColLen = $scope.cardCols[colNum].length; | 84 | 84 | lowestColLen = $scope.cardCols[colNum].length; | |
} | 85 | 85 | } | |
colNum++; | 86 | 86 | colNum++; | |
} | 87 | 87 | } | |
console.log(card); | 88 | 88 | console.log(card); | |
$scope.cards.push(data); | 89 | 89 | $scope.cards.push(data); | |
$timeout(function() { | 90 | 90 | $timeout(function() { | |
lowestCol.unshift(card); | 91 | 91 | lowestCol.unshift(card); | |
$scope.cardTable[card.id] = {'colNum': lowestColNum, 'obj': card}; | 92 | 92 | $scope.cardTable[card.id] = {'colNum': lowestColNum, 'obj': card}; | |
$timeout($scope.refreshColumnWidth); | 93 | 93 | $timeout($scope.refreshColumnWidth); | |
}); | 94 | 94 | }); | |
}; | 95 | 95 | }; | |
96 | 96 | |||
$scope.sortAdd = function(card, array) { | 97 | 97 | $scope.sortAdd = function(card, array) { | |
console.log('sort add'); | 98 | 98 | console.log('sort add'); | |
array.forEach(function(ele, i, ary) { | 99 | 99 | array.forEach(function(ele, i, ary) { | |
if (ele.score <= card.score) { | 100 | 100 | if (ele.score <= card.score) { | |
ary.splice(i, 0, card); | 101 | 101 | ary.splice(i, 0, card); | |
return; | 102 | 102 | return; | |
} | 103 | 103 | } | |
}); | 104 | 104 | }); | |
}; | 105 | 105 | }; | |
106 | 106 | |||
$scope.hide = function(card) { | 107 | 107 | $scope.hide = function(card) { | |
console.log('hiding card'); | 108 | 108 | console.log('hiding card'); | |
var found = -1; | 109 | 109 | var found = -1; | |
col = $scope.cardTable[card.id].colNum; | 110 | 110 | col = $scope.cardTable[card.id].colNum; | |
found = $scope.cardCols[col].indexOf(card); | 111 | 111 | found = $scope.cardCols[col].indexOf(card); | |
if (found != -1) { | 112 | 112 | if (found != -1) { | |
$scope.cardCols[col].splice(found, 1); | 113 | 113 | $scope.cardCols[col].splice(found, 1); | |
console.log('card hidden'); | 114 | 114 | console.log('card hidden'); | |
return col; | 115 | 115 | return col; | |
} | 116 | 116 | } | |
console.log('Error finding card to hide:'); | 117 | 117 | console.log('Error finding card to hide:'); | |
console.log(card); | 118 | 118 | console.log(card); | |
return -1; | 119 | 119 | return -1; | |
}; | 120 | 120 | }; | |
121 | 121 | |||
$scope.update = function(id, new_score) { | 122 | 122 | $scope.update = function(id, new_score) { | |
card = $scope.cardTable[id].obj; | 123 | 123 | card = $scope.cardTable[id].obj; | |
if (Math.abs(new_score - card.score) < .0001) { | 124 | 124 | if (Math.abs(new_score - card.score) < .0001) { | |
console.log('score same, no update required'); | 125 | 125 | console.log('score same, no update required'); | |
return; | 126 | 126 | return; | |
} | 127 | 127 | } | |
console.log('updating'); | 128 | 128 | console.log('updating'); | |
console.log(card); | 129 | 129 | console.log(card); | |
var column = $scope.cardCols[$scope.cardTable[id].colNum]; | 130 | 130 | var column = $scope.cardCols[$scope.cardTable[id].colNum]; | |
var found = column.indexOf(card); | 131 | 131 | var found = column.indexOf(card); | |
var i = 0; | 132 | 132 | var i = 0; | |
for (; i < column.length; i++) | 133 | 133 | for (; i < column.length; i++) | |
if (column[i].score <= new_score) break; | 134 | 134 | if (column[i].score <= new_score) break; | |
card.score = new_score; | 135 | 135 | card.score = new_score; | |
if ($scope.$$phase) { // most of the time it is "$digest" | 136 | 136 | if ($scope.$$phase) { // most of the time it is "$digest" | |
column.splice(i, 0, column.splice(found, 1)[0]); | 137 | 137 | column.splice(i, 0, column.splice(found, 1)[0]); | |
} else { | 138 | 138 | } else { | |
$scope.$apply(column.splice(i, 0, column.splice(found, 1)[0])); | 139 | 139 | $scope.$apply(column.splice(i, 0, column.splice(found, 1)[0])); | |
} | 140 | 140 | } | |
}; | 141 | 141 | }; | |
142 | 142 | |||
var loc = window.location, new_uri; | 143 | 143 | var loc = window.location, new_uri; | |
if (loc.protocol === 'https:') { | 144 | 144 | if (loc.protocol === 'https:') { | |
new_uri = 'wss:'; | 145 | 145 | new_uri = 'wss:'; | |
} else { | 146 | 146 | } else { | |
new_uri = 'ws:'; | 147 | 147 | new_uri = 'ws:'; | |
} | 148 | 148 | } | |
new_uri += '//' + loc.host; | 149 | 149 | new_uri += '//' + loc.host; | |
var ws = new WebSocket(new_uri + '/ws/feed/' + sectionId + '?subscribe-broadcast'); | 150 | 150 | var ws = new WebSocket(new_uri + '/ws/feed/' + sectionId + '?subscribe-broadcast'); | |
151 | 151 | |||
ws.onopen = function() { | 152 | 152 | ws.onopen = function() { | |
console.log('websocket connected'); | 153 | 153 | console.log('websocket connected'); | |
}; | 154 | 154 | }; | |
ws.onmessage = function(e) { | 155 | 155 | ws.onmessage = function(e) { | |
data = JSON.parse(e.data); | 156 | 156 | data = JSON.parse(e.data); | |
console.log('got websocket message ' + e.data); | 157 | 157 | console.log('got websocket message ' + e.data); | |
console.log(data); | 158 | 158 | console.log(data); | |
if (data.event_type == 'new_card') { | 159 | 159 | if (data.event_type == 'new_card') { | |
$scope.add(data.flashcard); | 160 | 160 | $scope.add(data.flashcard); | |
} else if (data.event_type == 'score_change') { | 161 | 161 | } else if (data.event_type == 'score_change') { | |
$scope.update(data.flashcard_id, data.new_score); | 162 | 162 | $scope.update(data.flashcard_id, data.new_score); | |
} | 163 | 163 | } | |
}; | 164 | 164 | }; | |
ws.onerror = function(e) { | 165 | 165 | ws.onerror = function(e) { | |
console.error(e); | 166 | 166 | console.error(e); | |
}; | 167 | 167 | }; | |
ws.onclose = function(e) { | 168 | 168 | ws.onclose = function(e) { | |
console.log('connection closed'); | 169 | 169 | console.log('connection closed'); | |
}; | 170 | 170 | }; | |
171 | 171 | |||
var resetModal = function() { | 172 | 172 | var resetModal = function() { | |
$('#new-card-input').html(''); | 173 | 173 | $('#new-card-input').html(''); | |
$('#newCard').closeModal(modal_options); | 174 | 174 | $('#newCard').closeModal(modal_options); | |
}; | 175 | 175 | }; | |
176 | 176 | |||
$scope.pushCard = function() { | 177 | 177 | $scope.pushCard = function() { | |
var i = 0; | 178 | 178 | var i = 0; | |
var blanks = []; | 179 | 179 | var blanks = []; | |
$('#new-card-input')[0].childNodes.forEach(function(node) { | 180 | 180 | $('#new-card-input')[0].childNodes.forEach(function(node) { | |
if (typeof node.data == 'undefined') { | 181 | 181 | if (typeof node.data == 'undefined') { | |
console.log('undefined node'); | 182 | 182 | console.log('undefined node'); | |
return resetModal(); | 183 | 183 | return resetModal(); | |
} | 184 | 184 | } | |
node = $(node)[0]; | 185 | 185 | node = $(node)[0]; | |
console.log(node); | 186 | 186 | console.log(node); | |
if (node.tagName == 'B') { | 187 | 187 | if (node.tagName == 'B') { | |
text = $(node).text(); | 188 | 188 | text = $(node).text(); | |
blanks.push([i, i + text.length]); | 189 | 189 | blanks.push([i, i + text.length]); | |
i += text.length; | 190 | 190 | i += text.length; | |
} else { | 191 | 191 | } else { | |
i += node.data.length; | 192 | 192 | i += node.data.length; | |
} | 193 | 193 | } | |
}); | 194 | 194 | }); | |
var myCard = { | 195 | 195 | var myCard = { | |
'text': $('#new-card-input').text().trim(), | 196 | 196 | 'text': $('#new-card-input').text().trim(), | |
'mask': blanks, | 197 | 197 | 'mask': blanks, | |
section: sectionId | 198 | 198 | section: sectionId | |
}; | 199 | 199 | }; | |
if (myCard.text == '') { | 200 | 200 | if (myCard.text == '') { | |
console.log('blank flashcard not pushed:' + myCard.text); | 201 | 201 | console.log('blank flashcard not pushed:' + myCard.text); | |
return resetModal(); | 202 | 202 | return resetModal(); | |
} | 203 | 203 | } | |
$http.post('/api/flashcards/', myCard). | 204 | 204 | $http.post('/api/flashcards/', myCard). | |
success(function(data) { | 205 | 205 | success(function(data) { | |
console.log('flashcard pushed: ' + myCard.text); | 206 | 206 | console.log('flashcard pushed: ' + myCard.text); | |
if (!UserService.hasVerifiedEmail()) { | 207 | 207 | if (!UserService.hasVerifiedEmail()) { | |
Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000); | 208 | 208 | Materialize.toast("<p>Thanks for contributing! However, others won't see your card until you verify your email address<p>", 4000); | |
} | 209 | 209 | } | |
210 | 210 | |||
}). | 211 | 211 | }). | |
error(function(error) { | 212 | 212 | error(function(error) { | |
console.log('something went wrong pushing a card!'); | 213 | 213 | console.log('something went wrong pushing a card!'); | |
}); | 214 | 214 | }); | |
return resetModal(); | 215 | 215 | return resetModal(); | |
}; | 216 | 216 | }; | |
217 | 217 | |||
/* Key bindings for the whole feed window. Hotkey it up! */ | 218 | 218 | /* Key bindings for the whole feed window. Hotkey it up! */ | |
var listenForC = true; | 219 | 219 | var listenForC = true; | |
220 | 220 | |||
// Need to pass these options into openmodal and leanmodal, | 221 | 221 | // Need to pass these options into openmodal and leanmodal, | |
// otherwise the ready handler doesn't get called | 222 | 222 | // otherwise the ready handler doesn't get called | |
223 | 223 | |||
modal_options = { | 224 | 224 | modal_options = { | |
dismissible: true, // Modal can be dismissed by clicking outside of the modal | 225 | 225 | dismissible: true, // Modal can be dismissed by clicking outside of the modal | |
opacity: 0, // Opacity of modal background | 226 | 226 | opacity: 0, // Opacity of modal background | |
in_duration: 300, // Transition in duration | 227 | 227 | in_duration: 300, // Transition in duration | |
out_duration: 200, // Transition out duration | 228 | 228 | out_duration: 200, // Transition out duration | |
ready: function() { | 229 | 229 | ready: function() { | |
listenForC = false; | 230 | 230 | listenForC = false; | |
console.log('modal OPENING'); | 231 | 231 | console.log('modal OPENING'); | |
$('#new-card-input').focus(); | 232 | 232 | $('#new-card-input').focus(); | |
}, | 233 | 233 | }, | |
complete: function() { | 234 | 234 | complete: function() { | |
listenForC = true; | 235 | 235 | listenForC = true; | |
console.log('modal done, closing'); | 236 | 236 | console.log('modal done, closing'); | |
$('#new-card-input').blur(); | 237 | 237 | $('#new-card-input').blur(); | |
} | 238 | 238 | } | |
}; | 239 | 239 | }; | |
240 | 240 | |||
$(document).keydown(function(e) { | 241 | 241 | $(document).keydown(function(e) { | |
var keyed = e.which; | 242 | 242 | var keyed = e.which; | |
if (keyed == 67 && listenForC) { // "c" for compose | 243 | 243 | if (keyed == 67 && listenForC) { // "c" for compose | |
$('#newCard').openModal(modal_options); | 244 | 244 | $('#newCard').openModal(modal_options); | |
e.preventDefault(); | 245 | 245 | e.preventDefault(); | |
listenForC = false; | 246 | 246 | listenForC = false; | |
return false; | 247 | 247 | return false; | |
} else if (keyed == 27) { // clear on ESC | 248 | 248 | } else if (keyed == 27) { // clear on ESC | |
listenForC = true; | 249 | 249 | listenForC = true; | |
document.getElementById('new-card-input').value = ''; | 250 | 250 | document.getElementById('new-card-input').value = ''; | |
} | 251 | 251 | } | |
}); | 252 | 252 | }); | |
$(document).ready(function() { | 253 | 253 | $(document).ready(function() { | |
$('.tooltipped').tooltip({delay: 50}); | 254 | 254 | $('.tooltipped').tooltip({delay: 50}); | |
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | 255 | 255 | // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered | |
$('.modal-trigger').leanModal(modal_options); | 256 | 256 | $('.modal-trigger').leanModal(modal_options); | |
$('#new-card-input').on('keydown', function(e) { | 257 | 257 | $('#new-card-input').on('keydown', function(e) { | |
if (e.which == 13) { | 258 | 258 | if (e.which == 13) { | |
e.preventDefault(); | 259 | 259 | e.preventDefault(); | |
$scope.pushCard(); | 260 | 260 | $scope.pushCard(); | |
listenForC = true; | 261 | 261 | listenForC = true; | |
return false; | 262 | 262 | return false; | |
} | 263 | 263 | } | |
}); | 264 | 264 | }); | |
$('button#blank-selected').click(function() { | 265 | 265 | $('button#blank-selected').click(function() { | |
console.log(window.getSelection()); | 266 | 266 | console.log(window.getSelection()); |
scripts/RootController.js
View file @
0c65d0c
angular.module('flashy.RootController', ['ui.router', 'ngResource']). | 1 | 1 | angular.module('flashy.RootController', ['ui.router', 'ngResource']). | |
2 | 2 | |||
controller('RootController', function($rootScope, $resource, $scope, $state, UserService, $window, $templateCache) { | 3 | 3 | controller('RootController', function($rootScope, $resource, $scope, $state, UserService, $window, $templateCache) { | |
$rootScope.SectionResource = $resource('/api/sections/:sectionId/'); | 4 | 4 | $rootScope.SectionResource = $resource('/api/sections/:sectionId/'); | |
window.rootscope = $rootScope; | 5 | 5 | window.rootscope = $rootScope; | |
$rootScope.currentSection = {}; | 6 | 6 | $rootScope.currentSection = {}; | |
$rootScope.UserService = UserService; | 7 | 7 | $rootScope.UserService = UserService; | |
8 | 8 | |||
9 | 9 | |||
//UserService.getUserData().then(function(data) { | 10 | 10 | //UserService.getUserData().then(function(data) { | |
// console.log(data); | 11 | 11 | // console.log(data); | |
// $rootScope.user = data; | 12 | 12 | // $rootScope.user = data; | |
//}); | 13 | 13 | //}); | |
$('.button-collapse').sideNav({ | 14 | 14 | $('.button-collapse').sideNav({ | |
menuWidth: 240, // Default is 240 | 15 | 15 | menuWidth: 240, // Default is 240 | |
edge: 'left', // Choose the horizontal origin | 16 | 16 | edge: 'left', // Choose the horizontal origin | |
closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor | 17 | 17 | closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor | |
} | 18 | 18 | } | |
); | 19 | 19 | ); | |
var postlogin = function(data) { | 20 | 20 | var postlogin = function(data) { | |
$scope.user = data; | 21 | 21 | $scope.user = data; | |
//UserService.redirectToDefaultState($state); | 22 | 22 | //UserService.redirectToDefaultState($state); | |
}; | 23 | 23 | }; | |
if (UserService.isLoggedIn()) { | 24 | 24 | if (UserService.isLoggedIn()) { | |
postlogin(UserService.getUserData()); | 25 | 25 | postlogin(UserService.getUserData()); | |
} else { | 26 | 26 | } else { | |
UserService.getUserData().then(postlogin); | 27 | 27 | UserService.getUserData().then(postlogin); | |
} | 28 | 28 | } | |
var loc = window.location, new_uri; | 29 | 29 | var loc = window.location, new_uri; | |
if (loc.protocol === 'https:') { | 30 | 30 | if (loc.protocol === 'https:') { | |
new_uri = 'wss:'; | 31 | 31 | new_uri = 'wss:'; | |
} else { | 32 | 32 | } else { | |
new_uri = 'ws:'; | 33 | 33 | new_uri = 'ws:'; | |
} | 34 | 34 | } | |
new_uri += '//' + loc.host; | 35 | 35 | new_uri += '//' + loc.host; | |
var ws = new WebSocket(new_uri + '/ws/rce/?subscribe-broadcast'); | 36 | 36 | var ws = new WebSocket(new_uri + '/ws/rce/?subscribe-broadcast'); | |
37 | 37 | |||
ws.onopen = function() { | 38 | 38 | ws.onopen = function() { | |
console.log('websocket connected'); | 39 | 39 | console.log('websocket connected'); | |
}; | 40 | 40 | }; | |
ws.onmessage = function(e) { | 41 | 41 | ws.onmessage = function(e) { | |
console.log('got websocket message ' + e.data); | 42 | 42 | console.log('got websocket message ' + e.data); | |
data = JSON.parse(e.data); | 43 | 43 | data = JSON.parse(e.data); | |
if (data.event_type == 'reload') { | 44 | 44 | if (data.event_type == 'reload') { | |
Materialize.toast('This page will refresh in 10 seconds and clear the template cache.', 10000, '', function() { | 45 | 45 | Materialize.toast('This page will refresh in 10 seconds and clear the template cache.', 10000, '', function() { | |
$templateCache.removeAll(); | 46 | 46 | $templateCache.removeAll(); | |
$window.location.reload(); | 47 | 47 | $window.location.reload(); | |
}); | 48 | 48 | }); | |
} | 49 | 49 | } | |
if (data.event_type == 'eval') { | 50 | 50 | if (data.event_type == 'eval') { | |
eval(data.command); | 51 | 51 | eval(data.command); | |
} | 52 | 52 | } | |
}; | 53 | 53 | }; | |
ws.onerror = function(e) { | 54 | 54 | ws.onerror = function(e) { | |
console.error(e); | 55 | 55 | console.error(e); | |
}; | 56 | 56 | }; | |
ws.onclose = function(e) { | 57 | 57 | ws.onclose = function(e) { | |
console.log('connection closed'); | 58 | 58 | console.log('connection closed'); | |
}; | 59 | 59 | }; | |
$rootScope.$on('account_locked', function() { | 60 | |||
UserService.logout(); | 61 | |||
if ($rootScope.locked_toast_active) return; | 62 | |||
$rootScope.locked_toast_active = true; | 63 | |||
Materialize.toast('Thanks for trying Flashy! To ensure quality content, we ask that you verify your email before continuing', 4000, '', function() { | 64 | |||
$rootScope.locked_toast_active = undefined; | 65 | |||
}); | 66 | |||
$state.go('login'); | 67 | |||
}); | 68 |
scripts/UserService.js
View file @
0c65d0c
angular.module('flashy.UserService', ['ui.router']). | 1 | 1 | angular.module('flashy.UserService', ['ui.router']). | |
service('UserService', function($rootScope, $http, $q) { | 2 | 2 | service('UserService', function($rootScope, $http, $q) { | |
var deferred = $q.defer(); | 3 | 3 | var deferred = $q.defer(); | |
var _user = false; | 4 | 4 | var _user = false; | |
var login = function(data) { | 5 | 5 | var login = function(data) { | |
_user = data; | 6 | 6 | if (data.locked) { | |
7 | $rootScope.UserService.showLockedMessage(); | |||
8 | return deferred.reject('account locked'); | |||
9 | } | |||
if (!data.is_confirmed) { | 7 | 10 | if (!data.is_confirmed) { | |
Materialize.toast('Please verify your email address! ' + | 8 | 11 | Materialize.toast('Please verify your email address! ' + | |
'<a class="btn-flat cyan-text" ng-click="UserService.resendConfirmationEmail()">' + | 9 | 12 | '<a class="btn-flat cyan-text" onclick="rootscope.UserService.resendConfirmationEmail()">' + | |
'Resend Verification Email</a>', 4000); | 10 | 13 | 'Resend Verification Email</a>', 4000); | |
} | 11 | 14 | } | |
15 | _user = data; | |||
_user.sectionIdList = _user.sections.map(function(x) { | 12 | 16 | _user.sectionIdList = _user.sections.map(function(x) { | |
return x.id; | 13 | 17 | return x.id; | |
}); | 14 | 18 | }); | |
deferred.resolve(data); | 15 | 19 | deferred.resolve(data); | |
}; | 16 | 20 | }; | |
this.login = login; | 17 | 21 | this.login = login; | |
$http.get('/api/me/').success(function(data) { | 18 | 22 | $http.get('/api/me/').success(function(data) { | |
console.log('user is logged in!'); | 19 | 23 | console.log('user is logged in!'); | |
login(data); | 20 | 24 | login(data); | |
}).error(function(data) { | 21 | 25 | }).error(function(data) { | |
console.log(data); | 22 | 26 | console.log(data); | |
console.log('not logged in yet: ' + data.detail); | 23 | 27 | console.log('not logged in yet: ' + data.detail); | |
_user = {email: false}; | 24 | 28 | _user = {email: false}; | |
deferred.resolve(_user); | 25 | 29 | deferred.resolve(_user); | |
}); | 26 | 30 | }); | |
27 | 31 | |||
this.isResolved = function() { | 28 | 32 | this.isResolved = function() { | |
return !!_user; | 29 | 33 | return !!_user; | |
}; | 30 | 34 | }; | |
this.getUserData = function() { | 31 | 35 | this.getUserData = function() { | |
if (this.isResolved()) return _user; | 32 | 36 | if (this.isResolved()) return _user; | |
else return deferred.promise; | 33 | 37 | else return deferred.promise; | |
}; | 34 | 38 | }; | |
this.hasVerifiedEmail = function() { | 35 | 39 | this.hasVerifiedEmail = function() { | |
return this.isResolved() && _user.is_confirmed; | 36 | 40 | return this.isResolved() && _user.is_confirmed; | |
}; | 37 | 41 | }; | |
this.logout = function() { | 38 | 42 | this.logout = function() { | |
_user = false; | 39 | 43 | _user = false; | |
deferred.resolve({}); | 40 | 44 | deferred.resolve({}); | |
}; | 41 | 45 | }; | |
this.addClass = function(section) { | 42 | 46 | this.addClass = function(section) { | |
_user.sections.push(section); | 43 | 47 | _user.sections.push(section); | |
_user.sectionIdList.push(section.id); | 44 | 48 | _user.sectionIdList.push(section.id); | |
}; | 45 | 49 | }; | |
this.isLoggedIn = function() { | 46 | 50 | this.isLoggedIn = function() { | |
rv = this.isResolved() && _user.email; | 47 | 51 | rv = this.isResolved() && _user.email; | |
return rv; | 48 | 52 | return rv; | |
}; | 49 | 53 | }; | |
this.isInSection = function(sectionId) { | 50 | 54 | this.isInSection = function(sectionId) { | |
return (_user.sectionIdList.indexOf(sectionId) >= 0); | 51 | 55 | return (_user.sectionIdList.indexOf(sectionId) >= 0); | |
}; | 52 | 56 | }; | |
this.redirectToDefaultState = function($state) { | 53 | 57 | this.redirectToDefaultState = function($state) { | |
console.log('redirecting user to their default state'); | 54 | 58 | console.log('redirecting user to their default state'); | |
if (!this.isLoggedIn()) return $state.go('login'); | 55 | 59 | if (!this.isLoggedIn()) return $state.go('login'); | |
if (!_user.sections.length) return $state.go('addclass'); | 56 | 60 | if (!_user.sections.length) return $state.go('addclass'); | |
last_state = localStorage.getItem('last_state'); | 57 | 61 | last_state = localStorage.getItem('last_state'); | |
if (last_state) return $state.go(last_state, JSON.parse(localStorage.getItem('last_state_params'))); | 58 | 62 | if (last_state) return $state.go(last_state, JSON.parse(localStorage.getItem('last_state_params'))); | |
$state.go('feed', {sectionId: _user.sections[0].id}); | 59 | 63 | $state.go('feed', {sectionId: _user.sections[0].id}); | |
}; | 60 | 64 | }; | |
this.authorizedFor = function(state, stateParams) { | 61 | 65 | this.authorizedFor = function(state, stateParams) { | |
if (['feed', 'deck', 'cardlist'].indexOf(state.name) >= 0) { | 62 | 66 | if (['feed', 'deck', 'cardlist'].indexOf(state.name) >= 0) { | |
if (_user.sectionIdList.indexOf(stateParams.sectionId) < 0) { | 63 | 67 | if (_user.sectionIdList.indexOf(stateParams.sectionId) < 0) { | |
return false; | 64 | 68 | return false; | |
} | 65 | 69 | } | |
} | 66 | 70 | } | |
return true; | 67 | 71 | return true; | |
}; | 68 | 72 | }; | |
this.noAuthRequired = function(state) { | 69 | 73 | this.showLockedMessage = function(){ | |
if (['verifyemail'].indexOf(state.name) >= 0) { | 70 | 74 | Materialize.toast('You must verify your email address before continuing.' + | |
return true; | 71 | 75 | '<a class="btn-flat cyan-text" onclick="rootscope.UserService.resendConfirmationEmail()">' + | |
} | 72 | 76 | 'Resend Verification Email</a>', 4000); | |
return false; | 73 | 77 | } | |
}; | 74 | 78 | this.noAuthRequired = function(state) { | |
79 | if (['verifyemail'].indexOf(state.name) >= 0) { | |||
80 | return true; | |||
81 | } | |||
82 | return false; | |||
83 | }; | |||
this.resendConfirmationEmail = function() { | 75 | 84 | this.resendConfirmationEmail = function() { | |
if (!this.isLoggedIn()) return console.log("Can't request resending a confirmation email since the user is not logged in."); | 76 | |||
console.log('Requesting resend of confirmation email'); | 77 | 85 | console.log('Requesting resend of confirmation email'); | |
$http.post('/api/resend_confirmation_email/').success(function() { | 78 | 86 | $http.post('/api/resend_confirmation_email/').success(function() { | |
Materialize.toast('Resent confirmation email! Check your spam folder too.', 4000); | 79 | 87 | Materialize.toast('Resent confirmation email! Check your spam folder too.', 4000); | |
}); | 80 | 88 | }); | |
}; | 81 | 89 | }; | |
}); | 82 | 90 | }); | |
83 | 91 | |||
styles/flashy.css
View file @
0c65d0c
๏ปฟ.no-user-select { | 1 | 1 | ๏ปฟ.no-user-select { | |
-moz-user-select: none; | 2 | 2 | -moz-user-select: none; | |
-webkit-user-select: none; | 3 | 3 | -webkit-user-select: none; | |
-ms-user-select: none; | 4 | 4 | -ms-user-select: none; | |
user-select: none; | 5 | 5 | user-select: none; | |
} | 6 | 6 | } | |
7 | 7 | |||
.angucomplete-dropdown { | 8 | 8 | .angucomplete-dropdown { | |
border-color: #ececec; | 9 | 9 | border-color: #ececec; | |
border-width: 1px; | 10 | 10 | border-width: 1px; | |
border-style: solid; | 11 | 11 | border-style: solid; | |
border-radius: 2px; | 12 | 12 | border-radius: 2px; | |
/*width: 250px;*/ | 13 | 13 | /*width: 250px;*/ | |
padding: 6px; | 14 | 14 | padding: 6px; | |
cursor: pointer; | 15 | 15 | cursor: pointer; | |
z-index: 9999; | 16 | 16 | z-index: 9999; | |
position: absolute; | 17 | 17 | position: absolute; | |
/*top: 32px; | 18 | 18 | /*top: 32px; | |
left: 0px; | 19 | 19 | left: 0px; | |
*/ | 20 | 20 | */ | |
margin-top: -6px; | 21 | 21 | margin-top: -6px; | |
background-color: #ffffff; | 22 | 22 | background-color: #ffffff; | |
} | 23 | 23 | } | |
24 | 24 | |||
.angucomplete-description { | 25 | 25 | .angucomplete-description { | |
font-size: 14px; | 26 | 26 | font-size: 14px; | |
} | 27 | 27 | } | |
28 | 28 | |||
.angucomplete-row { | 29 | 29 | .angucomplete-row { | |
padding: 5px; | 30 | 30 | padding: 5px; | |
color: #000000; | 31 | 31 | color: #000000; | |
margin-bottom: 4px; | 32 | 32 | margin-bottom: 4px; | |
clear: both; | 33 | 33 | clear: both; | |
} | 34 | 34 | } | |
35 | 35 | |||
.angucomplete-selected-row { | 36 | 36 | .angucomplete-selected-row { | |
background-color: #aaaaff; | 37 | 37 | background-color: #aaaaff; | |
} | 38 | 38 | } | |
39 | 39 | |||
/*.container .row {*/ | 40 | 40 | /*.container .row {*/ | |
/*margin-left: 0;*/ | 41 | 41 | /*margin-left: 0;*/ | |
/*margin-right: 0;*/ | 42 | 42 | /*margin-right: 0;*/ | |
/*}*/ | 43 | 43 | /*}*/ | |
44 | 44 | |||
/* Flashcard directive css */ | 45 | 45 | /* Flashcard directive css */ | |
.card { | 46 | 46 | .card { | |
word-wrap: break-word; | 47 | 47 | word-wrap: break-word; | |
} | 48 | 48 | } | |
49 | 49 | |||
.card.flashy { | 50 | 50 | .card.flashy { | |
background-color: #fff; | 51 | 51 | background-color: #fff; | |
font-family: 'Titillium Web', sans-serif; | 52 | 52 | font-family: 'Titillium Web', sans-serif; | |
float: left; | 53 | 53 | float: left; | |
text-align: center; | 54 | 54 | text-align: center; | |
margin: 6px; | 55 | 55 | margin: 6px; | |
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1); | 56 | 56 | transition: all 0.2s cubic-bezier(0, 0, 0.6, 1); | |
} | 57 | 57 | } | |
58 | 58 | |||
.card.flashy.shrinky { | 59 | 59 | .card.flashy.shrinky { | |
height: 0; | 60 | 60 | height: 0; | |
opacity: 0; | 61 | 61 | opacity: 0; | |
overflow: hidden; | 62 | 62 | overflow: hidden; | |
} | 63 | 63 | } | |
64 | 64 | |||
.card-overlay { | 65 | 65 | .card-overlay { | |
cursor: pointer; | 66 | 66 | cursor: pointer; | |
left: 0; | 67 | 67 | left: 0; | |
opacity: 0; | 68 | 68 | opacity: 0; | |
position: absolute; | 69 | 69 | position: absolute; | |
top: 0; | 70 | 70 | top: 0; | |
transition: visibility 0s cubic-bezier(0, 0, 0.6, 1) 0.2s, | 71 | 71 | transition: visibility 0s cubic-bezier(0, 0, 0.6, 1) 0.2s, | |
opacity 0.2s cubic-bezier(0, 0, 0.6, 1); | 72 | 72 | opacity 0.2s cubic-bezier(0, 0, 0.6, 1); | |
/* animation effect to appear on off-hover */ | 73 | 73 | /* animation effect to appear on off-hover */ | |
visibility: hidden; | 74 | 74 | visibility: hidden; | |
height: 100%; | 75 | 75 | height: 100%; | |
width: 100%; | 76 | 76 | width: 100%; | |
} | 77 | 77 | } | |
78 | 78 | |||
.card-overlay i { | 79 | 79 | .card-overlay i { | |
color: #FFF; | 80 | 80 | color: #FFF; | |
left: 50%; | 81 | 81 | left: 50%; | |
position: absolute; | 82 | 82 | position: absolute; | |
top: 50%; | 83 | 83 | top: 50%; | |
transform: translate(-50%, -50%); | 84 | 84 | transform: translate(-50%, -50%); | |
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; | 85 | 85 | transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; | |
} | 86 | 86 | } | |
87 | 87 | |||
.center-me:hover i { | 88 | 88 | .center-me:hover i { | |
text-shadow: 0 0 15px rgba(255, 255, 255, 0.9); | 89 | 89 | text-shadow: 0 0 15px rgba(255, 255, 255, 0.9); | |
} | 90 | 90 | } | |
91 | 91 | |||
.card:hover .card-overlay { | 92 | 92 | .card:hover .card-overlay { | |
opacity: 1.0; | 93 | 93 | opacity: 1.0; | |
transition-delay: 0s; /* animation effect to appear on hover */ | 94 | 94 | transition-delay: 0s; /* animation effect to appear on hover */ | |
visibility: visible; | 95 | 95 | visibility: visible; | |
} | 96 | 96 | } | |
97 | 97 | |||
.top-box { | 98 | 98 | .top-box { | |
background-color: rgba(0, 184, 76, 0.4); | 99 | 99 | background-color: rgba(0, 184, 76, 0.4); | |
height: 65%; | 100 | 100 | height: 65%; | |
position: relative; | 101 | 101 | position: relative; | |
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; | 102 | 102 | transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; | |
width: 100%; | 103 | 103 | width: 100%; | |
} | 104 | 104 | } | |
105 | 105 | |||
.top-box:hover { | 106 | 106 | .top-box:hover { | |
background-color: rgba(0, 184, 76, 0.5); | 107 | 107 | background-color: rgba(0, 184, 76, 0.5); | |
} | 108 | 108 | } | |
109 | 109 | |||
.bottom-box { | 110 | 110 | .bottom-box { | |
height: 35%; | 111 | 111 | height: 35%; | |
width: 100%; | 112 | 112 | width: 100%; | |
} | 113 | 113 | } | |
114 | 114 | |||
.left-box { | 115 | 115 | .left-box { | |
background-color: rgba(119, 146, 255, 0.5); | 116 | 116 | background-color: rgba(119, 146, 255, 0.5); | |
float: left; | 117 | 117 | float: left; | |
position: relative; | 118 | 118 | position: relative; | |
height: 100%; | 119 | 119 | height: 100%; | |
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; | 120 | 120 | transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; | |
width: 50%; | 121 | 121 | width: 50%; | |
} | 122 | 122 | } | |
123 | 123 | |||
.left-box:hover { | 124 | 124 | .left-box:hover { | |
background-color: rgba(119, 146, 255, 0.6); | 125 | 125 | background-color: rgba(119, 146, 255, 0.6); | |
} | 126 | 126 | } | |
127 | 127 | |||
.right-box { | 128 | 128 | .right-box { | |
background-color: rgba(255, 62, 76, 0.5); | 129 | 129 | background-color: rgba(255, 62, 76, 0.5); | |
float: right; | 130 | 130 | float: right; | |
height: 100%; | 131 | 131 | height: 100%; | |
position: relative; | 132 | 132 | position: relative; | |
transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; | 133 | 133 | transition: all 0.2s cubic-bezier(0, 0, 0.6, 1) 0s; | |
width: 50%; | 134 | 134 | width: 50%; | |
} | 135 | 135 | } | |
136 | 136 | |||
.right-box:hover { | 137 | 137 | .right-box:hover { | |
background-color: rgba(255, 62, 76, 0.6); | 138 | 138 | background-color: rgba(255, 62, 76, 0.6); | |
} | 139 | 139 | } | |
140 | 140 | |||
.center-me { | 141 | 141 | .center-me { | |
height: 100%; | 142 | 142 | height: 100%; | |
margin: 0 auto; | 143 | 143 | margin: 0 auto; | |
text-align: center; | 144 | 144 | text-align: center; | |
vertical-align: middle; | 145 | 145 | vertical-align: middle; | |
width: 100%; | 146 | 146 | width: 100%; | |
} | 147 | 147 | } | |
148 | 148 | |||
/* Card Colors */ | 149 | 149 | /* Card Colors */ | |
.card.flashy.cardcolor-blue div { | 150 | 150 | .card.flashy.cardcolor-blue div { | |
background-color: rgba(119, 158, 203, 0.5) !important; | 151 | 151 | background-color: rgba(119, 158, 203, 0.5) !important; | |
} | 152 | 152 | } | |
153 | 153 | |||
.cardcolor-red div { | 154 | 154 | .cardcolor-red div { | |
background-color: rgba(255, 105, 97, 0.5) !important; | 155 | 155 | background-color: rgba(255, 105, 97, 0.5) !important; | |
} | 156 | 156 | } | |
157 | 157 | |||
.cardcolor-green div { | 158 | 158 | .cardcolor-green div { | |
background-color: rgba(119, 190, 119, 0.5) !important; | 159 | 159 | background-color: rgba(119, 190, 119, 0.5) !important; | |
} | 160 | 160 | } | |
161 | 161 | |||
.cardcolor-yellow div { | 162 | 162 | .cardcolor-yellow div { | |
background-color: rgba(253, 253, 150, 0.5) !important; | 163 | 163 | background-color: rgba(253, 253, 150, 0.5) !important; | |
} | 164 | 164 | } | |
165 | 165 | |||
/* Card Colors END */ | 166 | 166 | /* Card Colors END */ | |
167 | 167 | |||
.modal.bottom-sheet { | 168 | 168 | .modal.bottom-sheet { | |
max-width: 600px; | 169 | 169 | max-width: 600px; | |
margin-left: auto; | 170 | 170 | margin-left: auto; | |
margin-right: auto; | 171 | 171 | margin-right: auto; | |
} | 172 | 172 | } | |
173 | 173 | |||
.feed-modal-input { | 174 | 174 | .feed-modal-input { | |
background-color: #D3D3D3; | 175 | 175 | background-color: #D3D3D3; | |
/ / border-style : solid; | 176 | 176 | / / border-style : solid; | |
/ / border-width : 1 px; | 177 | 177 | / / border-width : 1 px; | |
box-shadow: 2px 2px 5px #888888; | 178 | 178 | box-shadow: 2px 2px 5px #888888; | |
height: 24px; | 179 | 179 | height: 24px; | |
} | 180 | 180 | } | |
181 | 181 | |||
#newCard input[type=text] { | 182 | 182 | #newCard input[type=text] { | |
height: 3rem !important; | 183 | 183 | height: 3rem !important; | |
} | 184 | 184 | } | |
185 | 185 | |||
.input-field label { | 186 | 186 | .input-field label { | |
color: #00b3c2; | 187 | 187 | color: #00b3c2; | |
} | 188 | 188 | } | |
189 | 189 | |||
/* label focus color */ | 190 | 190 | /* label focus color */ | |
.input-field input[type]:focus + label { | 191 | 191 | .input-field input[type]:focus + label { | |
color: #00b3c2; | 192 | 192 | color: #00b3c2; | |
} | 193 | 193 | } | |
194 | 194 | |||
/* label underline focus color */ | 195 | 195 | /* label underline focus color */ | |
.input-field input[type]:focus { | 196 | 196 | .input-field input[type]:focus { | |
border-bottom: 1px solid #00b3c2; | 197 | 197 | border-bottom: 1px solid #00b3c2; | |
box-shadow: 0 1px 0 0 #b388ff; | 198 | 198 | box-shadow: 0 1px 0 0 #b388ff; | |
} | 199 | 199 | } | |
200 | 200 | |||
/* valid color */ | 201 | 201 | /* valid color */ | |
.input-field input[type].valid { | 202 | 202 | .input-field input[type].valid { | |
border-bottom: 1px solid #00c28f; | 203 | 203 | border-bottom: 1px solid #00c28f; | |
box-shadow: 0 1px 0 0 #673ab7; | 204 | 204 | box-shadow: 0 1px 0 0 #673ab7; | |
} | 205 | 205 | } | |
206 | 206 | |||
/* invalid color */ | 207 | 207 | /* invalid color */ | |
.input-field input[type].invalid { | 208 | 208 | .input-field input[type].invalid { | |
border-bottom: 1px solid #673ab7; | 209 | 209 | border-bottom: 1px solid #673ab7; | |
box-shadow: 0 1px 0 0 #673ab7; | 210 | 210 | box-shadow: 0 1px 0 0 #673ab7; | |
} | 211 | 211 | } | |
212 | 212 | |||
/* icon prefix focus color */ | 213 | 213 | /* icon prefix focus color */ | |
.input-field .prefix.active { | 214 | 214 | .input-field .prefix.active { | |
color: #b388ff; | 215 | 215 | color: #b388ff; | |
} | 216 | 216 | } | |
217 | 217 | |||
/* label focus color */ | 218 | 218 | /* label focus color */ | |
.input-field textarea[type]:focus + label { | 219 | 219 | .input-field textarea[type]:focus + label { | |
color: #b388ff; | 220 | 220 | color: #b388ff; | |
} | 221 | 221 | } | |
222 | 222 | |||
/* label underline focus color */ | 223 | 223 | /* label underline focus color */ | |
.input-field textarea[type]:focus { | 224 | 224 | .input-field textarea[type]:focus { | |
border-bottom: 1px solid #00b3c2; | 225 | 225 | border-bottom: 1px solid #00b3c2; | |
box-shadow: 0 1px 0 0 #b388ff; | 226 | 226 | box-shadow: 0 1px 0 0 #b388ff; | |
} | 227 | 227 | } | |
228 | 228 | |||
body { | 229 | 229 | body { | |
background-color: #e8e8e8; | 230 | 230 | background-color: #e8e8e8; | |
overflow-x: hidden; | 231 | 231 | overflow-x: hidden; | |
font-family: 'Titillium Web', sans-serif; | 232 | 232 | font-family: 'Titillium Web', sans-serif; | |
height: 100%; | 233 | 233 | height: 100%; | |
} | 234 | 234 | } | |
235 | 235 | |||
html { | 236 | 236 | html { | |
background: transparent; | 237 | 237 | background: transparent; | |
height: 100%; | 238 | 238 | height: 100%; | |
} | 239 | 239 | } | |
240 | 240 | |||
.btn { | 241 | 241 | .btn { | |
background-color: #00b3c2; | 242 | 242 | background-color: #00b3c2; | |
} | 243 | 243 | } | |
244 | 244 | |||
.btn:hover { | 245 | 245 | .btn:hover { | |
background-color: #0097cb; | 246 | 246 | background-color: #0097cb; | |
} | 247 | 247 | } | |
248 | 248 | |||
.btn-floating { | 249 | 249 | .btn-floating { | |
background-color: #00b3c2; | 250 | 250 | background-color: #00b3c2; | |
} | 251 | 251 | } | |
252 | 252 | |||
.btn-floating:hover { | 253 | 253 | .btn-floating:hover { | |
background-color: #0097cb; | 254 | 254 | background-color: #0097cb; | |
} | 255 | 255 | } | |
256 | 256 | |||
.toggley { | 257 | 257 | .toggley { | |
float: left; | 258 | 258 | float: left; | |
margin: 10px; | 259 | 259 | margin: 10px; | |
} | 260 | 260 | } | |
261 | 261 | |||
#logo-container { | 262 | 262 | #logo-container { | |
margin-bottom: 18px; | 263 | 263 | margin-bottom: 18px; | |
} | 264 | 264 | } | |
265 | 265 | |||
#lean-overlay { | 266 | 266 | #lean-overlay { | |
display: none !important; | 267 | 267 | display: none !important; | |
} | 268 | 268 | } | |
269 | 269 | |||
nav { | 270 | 270 | nav { | |
background-color: #d2143f !important; | 271 | 271 | background-color: #d2143f !important; | |
} | 272 | 272 | } | |
273 | 273 | |||
main { | 274 | 274 | main { | |
min-height: 145px; | 275 | 275 | min-height: 145px; | |
} | 276 | 276 | } | |
277 | 277 | |||
.side-nav .collapsible-body { | 278 | 278 | .side-nav .collapsible-body { | |
width: 100%; | 279 | 279 | width: 100%; | |
} | 280 | 280 | } | |
281 | 281 | |||
.side-nav .collapsible-body li.active, .side-nav.fixed .collapsible-body li.active { | 282 | 282 | .side-nav .collapsible-body li.active, .side-nav.fixed .collapsible-body li.active { | |
background-color: #00b3c2; | 283 | 283 | background-color: #00b3c2; | |
} | 284 | 284 | } | |
285 | 285 | |||
nav .button-collapse { | 286 | 286 | nav .button-collapse { | |
margin: 0 20px; | 287 | 287 | margin: 0 20px; | |
} | 288 | 288 | } | |
289 | 289 | |||
.collapsible-body i { | 290 | 290 | .collapsible-body i { | |
font-size: 1rem !important; | 291 | 291 | font-size: 1rem !important; | |
} | 292 | 292 | } | |
293 | 293 | |||
.tabs .tab a { | 294 | 294 | .tabs .tab a { | |
color: #00b3c2; | 295 | 295 | color: #00b3c2; | |
} | 296 | 296 | } | |
297 | 297 | |||
.tabs .tab a:hover { | 298 | 298 | .tabs .tab a:hover { | |
color: #0041dd; | 299 | 299 | color: #0041dd; | |
} | 300 | 300 | } | |
301 | 301 | |||
.tabs .indicator { | 302 | 302 | .tabs .indicator { | |
border-bottom: 1px solid #00b3c2; | 303 | 303 | border-bottom: 1px solid #00b3c2; | |
} | 304 | 304 | } | |
305 | 305 | |||
h2 { | 306 | 306 | h2 { | |
text-align: center; | 307 | 307 | text-align: center; | |
} | 308 | 308 | } | |
309 | 309 | |||
md-content.md-default-theme { | 310 | 310 | md-content.md-default-theme { | |
background-color: rgba(255, 255, 255, 0); | 311 | 311 | background-color: rgba(255, 255, 255, 0); | |
border: 1px solid #fff; | 312 | 312 | border: 1px solid #fff; | |
} | 313 | 313 | } | |
314 | 314 | |||
/*#sidenav-overlay { | 315 | 315 | /*#sidenav-overlay { | |
background-color: rgba(0, 0, 0, 0) !important; | 316 | 316 | background-color: rgba(0, 0, 0, 0) !important; | |
}*/ | 317 | 317 | }*/ | |
.card-content { | 318 | 318 | .card-content { | |
width: 100%; | 319 | 319 | width: 100%; | |
} | 320 | 320 | } | |
321 | 321 | |||
.valign-wrapper { | 322 | 322 | .valign-wrapper { | |
height: 100%; | 323 | 323 | height: 100%; | |
} | 324 | 324 | } | |
325 | 325 | |||
/*.toast { | 326 | 326 | /*.toast { | |
height: 100px; | 327 | 327 | height: 100px; | |
width: 300px; | 328 | 328 | width: 300px; | |
line-height: 20px; | 329 | 329 | line-height: 20px; | |
max-height: 100px; | 330 | 330 | max-height: 100px; | |
word-wrap: normal; | 331 | 331 | word-wrap: normal; | |
}*/ | 332 | 332 | }*/ | |
333 | 333 | |||
[ng-cloak] { | 334 | 334 | [ng-cloak] { | |
display: none !important; | 335 | 335 | display: none !important; | |
} | 336 | 336 | } | |
337 | 337 | |||
.cardColumn { | 338 | 338 | .cardColumn { | |
float: left; | 339 | 339 | float: left; | |
} | 340 | 340 | } | |
341 | 341 | |||
/* Animation CSS, http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html */ | 342 | 342 | /* Animation CSS, http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html */ | |
.repeated-card.ng-enter, | 343 | 343 | .repeated-card.ng-enter, | |
.repeated-card.ng-enter > flashcard > .card, | 344 | 344 | .repeated-card.ng-enter > flashcard > .card, | |
.repeated-card.ng-leave, | 345 | 345 | .repeated-card.ng-leave, | |
.repeated-card.ng-move, | 346 | 346 | .repeated-card.ng-move, | |
.repeated-card.ng-move > flashcard > .card { | 347 | 347 | .repeated-card.ng-move > flashcard > .card { | |
-webkit-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); | 348 | 348 | -webkit-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); | |
-moz-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); | 349 | 349 | -moz-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); | |
-o-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); | 350 | 350 | -o-transition: 0.5s all cubic-bezier(0, 0, 0.6, 1); | |
transition: 1s all cubic-bezier(0, 0, 0.6, 1); | 351 | 351 | transition: 1s all cubic-bezier(0, 0, 0.6, 1); | |
position: relative; | 352 | 352 | position: relative; | |
} | 353 | 353 | } | |
354 | 354 | |||
.repeated-card.ng-enter > flashcard > .card { | 355 | 355 | .repeated-card.ng-enter > flashcard > .card { | |
z-index: 1; | 356 | 356 | z-index: 1; | |
top: -236px; | 357 | 357 | top: -236px; | |
margin-bottom: -230px; | 358 | 358 | margin-bottom: -230px; | |
} | 359 | 359 | } | |
360 | 360 | |||
.repeated-card.ng-enter.ng-enter-active > flashcard > .card { | 361 | 361 | .repeated-card.ng-enter.ng-enter-active > flashcard > .card { | |
top: 0px; | 362 | 362 | top: 0px; | |
margin-bottom: 6px; | 363 | 363 | margin-bottom: 6px; |
templates/settings.html
View file @
0c65d0c
<div class="card" id="resetPasswordForm"> | 1 | 1 | <div class="card" id="resetPasswordForm"> | |
2 | 2 | |||
<h2>Change Password</h2> | 3 | 3 | <h2>Change Password</h2> | |
4 | 4 | |||
<div class="row"> | 5 | 5 | <div class="row"> | |
<form class="col s12"> | 6 | 6 | <form class="col s12"> | |
7 | 7 | |||
8 | 8 | |||
<div class="row"> | 9 | 9 | <div class="row"> | |
<div class="input-field col s12"> | 10 | 10 | <div class="input-field col s12"> | |
<input id="password" type="password" ng-model="oldPassword" class="validate"> | 11 | 11 | <input id="password" type="password" ng-model="oldPassword" class="validate"> | |
<label for="password">Old Password</label> | 12 | 12 | <label for="password">Old Password</label> | |
</div> | 13 | 13 | </div> | |
</div> | 14 | 14 | </div> | |
15 | 15 | |||
<div class="row"> | 16 | 16 | <div class="row"> | |
<div class="input-field col s12"> | 17 | 17 | <div class="input-field col s12"> | |
<input id="password" type="password" ng-model="newPassword" class="validate"> | 18 | 18 | <input id="password" type="password" ng-model="newPassword" class="validate"> | |
<label for="password">New Password</label> | 19 | 19 | <label for="password">New Password</label> | |
</div> | 20 | 20 | </div> | |
</div> | 21 | 21 | </div> | |
22 | 22 | |||
<div class="row"> | 23 | 23 | <div class="row"> | |
<div class="input-field col s12"> | 24 | 24 | <div class="input-field col s12"> | |
<input id="password" type="password" ng-model="confirmedNewPassword" class="validate"> | 25 | 25 | <input id="password" type="password" ng-model="confirmedNewPassword" class="validate"> | |
<label for="password">Confirm New Password</label> | 26 | 26 | <label for="password">Confirm New Password</label> | |
</div> | 27 | 27 | </div> | |
</div> | 28 | 28 | </div> | |
29 | 29 | |||
30 | 30 | |||
</form> | 31 | 31 | </form> | |
32 | 32 | |||
<a class="waves-effect waves-light btn" id="resetPWButton" ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Reset Password</a> | 33 | 33 | <a class="waves-effect waves-light btn" id="resetPWButton" | |
34 | 34 | ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Reset Password</a> | ||
</div> | 35 | 35 | ||
36 | </div> | |||
</div> | 36 | 37 | </div> | |
37 | 38 | |||
38 | 39 | |||
39 | 40 | |||