Advertisement
Guest User

Untitled

a guest
Dec 12th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     directive('loginForm', function(){
  2.         return {
  3.             restrict: 'AC',
  4.             link: function(scope, el){
  5.  
  6.                 jQuery(el).find(".form-group:has(label)").each(function(i, el)
  7.                 {
  8.                     var $this = angular.element(el),
  9.                         $label = $this.find('label'),
  10.                         $input = $this.find('.form-control');
  11.  
  12.                         $input.on('focus', function()
  13.                         {
  14.                             $this.addClass('is-focused');
  15.                         });
  16.  
  17.                         $input.on('keydown', function()
  18.                         {
  19.                             $this.addClass('is-focused');
  20.                         });
  21.  
  22.                         $input.on('blur', function()
  23.                         {
  24.                             $this.removeClass('is-focused');
  25.  
  26.                             if($input.val().trim().length > 0)
  27.                             {
  28.                                 $this.addClass('is-focused');
  29.                             }
  30.                         });
  31.  
  32.                         $label.on('click', function()
  33.                         {
  34.                             $input.focus();
  35.                         });
  36.  
  37.                         if($input.val().trim().length > 0)
  38.                         {
  39.                             $this.addClass('is-focused');
  40.                         }
  41.                 });
  42.             }
  43.         };
  44.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement