Commit 510a00ef authored by Randall Leeds's avatar Randall Leeds

Turn authentication into a controller

This code doesn't do any DOM manipulation so its better kept as a
controller.
parent 6dd1fe1d
......@@ -695,6 +695,31 @@ class Annotation
$scope.model.highlightText.replace regexp, annotator.highlighter
class Auth
scope:
username: null
email: null
password: null
code: null
this.$inject = [
'$scope', 'authentication',
]
constructor: (
$scope, authentication
) ->
_reset = => angular.copy @scope, $scope.model
$scope.$on '$reset', _reset
$scope.submit = (form) ->
angular.extend authentication, $scope.model
return unless form.$valid
authentication["$#{form.$name}"] ->
_reset()
$scope.$emit 'success', form.$name
class Editor
this.$inject = [
'$location', '$routeParams', '$sce', '$scope',
......@@ -1035,6 +1060,7 @@ class Notification
angular.module('h.controllers', ['bootstrap', 'h.streamfilter'])
.controller('AppController', App)
.controller('AnnotationController', Annotation)
.controller('AuthController', Auth)
.controller('EditorController', Editor)
.controller('ViewerController', Viewer)
.controller('SearchController', Search)
......
authentication = ->
base =
username: null
email: null
password: null
code: null
link: (scope, elem, attr, ctrl) ->
angular.copy base, scope.model
controller: [
'$scope', 'authentication',
($scope, authentication) ->
$scope.$on '$reset', => angular.copy base, $scope.model
$scope.submit = (form) ->
angular.extend authentication, $scope.model
return unless form.$valid
authentication["$#{form.$name}"] ->
$scope.$emit 'success', form.$name
]
restrict: 'ACE'
markdown = ['$filter', '$timeout', ($filter, $timeout) ->
link: (scope, elem, attr, ctrl) ->
return unless ctrl?
......@@ -446,7 +423,6 @@ whenscrolled = ['$window', ($window) ->
]
angular.module('h.directives', ['ngSanitize'])
.directive('authentication', authentication)
.directive('fuzzytime', fuzzytime)
.directive('markdown', markdown)
.directive('privacy', privacy)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment