Sha256: 2af9a18ebaca2eaa4e880147f3ca997306fa61d64154b625dd82d3069f7cb462

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

(function() {
  'use strict';

  voxality.controller('RegistrationsController', [
    '$scope',
    function ($scope) {
      $scope.months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
      $scope.years = Array.apply(null, Array(11)).map(function(_, i) {
        return String(new Date().getFullYear() + i)
      });

      //Jquery is used because angular doesn't play nice
      //with refreshing or changing pages (when there's a validation error)
      var autoRealm = false;
      var init = function() {
        $scope.errors = [];

        $('input#company').on('input', updateDomain);
        $('input#realm').on('input', shutoffAutoRealm);
      };

      var shutoffAutoRealm = function() {
        autoRealm = false;
      };

      var updateDomain = function() {
        var realm = $('input#realm').val();
        var domain = $('input#company').val().toLowerCase().replace(/[^a-zA-Z\d]/g, '');
        if (realm.length == 0) {
          autoRealm = true;
        }
        if (autoRealm == true) {
          $('input#realm').val(domain);
          $('input#realm').blur();
        }
      };

      init();
    }])
}).call(this)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
voxality_core-0.1.0.1 lib/generators/voxality_core/templates/app/assets/javascripts/controllers/RegistrationsController.js