Sha256: 8de71a3d8b1b1b97c8e3b5ebca4721dbb3c82251f5df6503b93c5691e3e5d5e0

Contents?: true

Size: 1.7 KB

Versions: 30

Compression:

Stored size: 1.7 KB

Contents

module = angular.module('maestrano.components.mno-password',['maestrano.assets'])

module.directive('mnoPassword', ['TemplatePath', (TemplatePath) ->
  return {
      restrict: 'AE',
      scope: {
        baseObject: '=mnoPassword',
        form: '='
      },
      templateUrl: TemplatePath['mno_enterprise/maestrano-components/password.html'],
      link: (scope, element, attrs) ->
        scope.isShown = false
        scope.hasEightChars = false
        scope.hasOneNumber = false
        scope.hasOneUpper = false
        scope.hasOneLower = false

        scope.fieldName = "#{attrs.mnoPassword}[password]"

        scope.check = ->
          scope.hasEightChars = scope.baseObject.password? && (scope.baseObject.password.length >= 8)
          scope.hasOneNumber = false
          scope.hasOneUpper = false
          scope.hasOneLower = false

          if angular.isString(scope.baseObject.password)
            angular.forEach(scope.baseObject.password.split(""), (letter) ->
              scope.hasOneNumber = true if parseInt(letter)
              scope.hasOneUpper = true if (letter == letter.toUpperCase() && letter != letter.toLowerCase() && !parseInt(letter))
              scope.hasOneLower = true if (letter == letter.toLowerCase() && letter != letter.toUpperCase() && !parseInt(letter))
            )

            # Will raise an error is form is not defined when the directive is used (in this case, we can't modify the validity of the form)
            if scope.hasEightChars && scope.hasOneNumber && scope.hasOneUpper && scope.hasOneLower
              scope.form[scope.fieldName].$setValidity("password", true)
            else
              scope.form[scope.fieldName].$setValidity("password", false)

    }
])

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
mno-enterprise-frontend-3.4.0 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.3.3 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.3.2 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.2.1 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.3.1 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.3.0 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.2.0 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.1.4 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.0.7 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-2.0.9 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.1.3 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.0.6 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-2.0.8 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.1.2 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.0.5 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-2.0.7 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-2.0.6 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-2.0.5 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.1.1 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee
mno-enterprise-frontend-3.0.4 app/assets/javascripts/mno_enterprise/angular/directives/maestrano-components/mno-password.js.coffee