Sha256: f86ab910d4bc6b6c075d6c76d0bc4fdda6c542409490797755f7b56b9e40354d

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

//= require intl-tel-input
//= require intl-tel-utils

(function() {
  "use strict";

  function activateBehavior() {
    $('.input.phone').each(function() {
      var container = $(this);
      var input = container.find('input');
      var label = container.find('label');

      // Set the container's class when the input field receives focus.
      input.focus(function() {
        container.addClass('focused');
      });

      // Set the container class based on whether or not the
      // input field has a value and remove the focused class.
      function setContainerCssClass() {
        if (input.val().replace('+', '').trim() === '' ) {
          container.removeClass('has-value');
          container.addClass('blank');
        } else {
          container.removeClass('blank');
          container.addClass('has-value');
        }
      }

      input.blur(function() {
        setContainerCssClass();
        container.removeClass('focused');
      });

      setContainerCssClass();
      container.addClass('animate');
    });

    $('.input.phone input[type="text"]').intlTelInput({
      preferredCountries: ['us'],
      responsiveDropdown: true
    });
  }

  App.register('component').enter(function() {
    activateBehavior();
    $('.has_many_add').click(function() {
      setTimeout(function() {
        activateBehavior();
      }, 0);
    });
  });
})();

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active_admin_pro-0.2.4 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.2.3 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.2.2 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.2.1 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.2.0 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.1.8 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.1.7 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.1.6 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.1.5 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.1.4 app/assets/javascripts/active_admin_pro/components/phone_input.js
active_admin_pro-0.1.3 app/assets/javascripts/active_admin_pro/components/phone_input.js