This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | myApp.directive('ngFocus', function( $timeout ) { | |
| return function( scope, elem, attrs ) { | |
| scope.$watch(attrs.ngFocus, function( newval ) { | |
| if ( newval ) { | |
| $timeout(function() { | |
| elem[0].focus(); | |
| }, 0, false); | |
| } | |
| }); | |
| }; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | angular.module('myApp', []).directive('ngDatePicker', function() { | |
| return { | |
| require: 'ngModel', | |
| link: function(scope, element, attrs, ctrl) { | |
| element.datepicker({ | |
| changeYear: true, | |
| changeMonth: true, | |
| appendText: '(yyyy-mm-dd)', | |
| dateFormat: 'yy-mm-dd', | |
| onSelect: function(dateText, inst) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | app.directive('ngRightClick', function($parse) { | |
| return function(scope, element, attrs) { | |
| var fn = $parse(attrs.ngRightClick); | |
| element.bind('contextmenu', function(event) { | |
| scope.$apply(function() { | |
| event.preventDefault(); | |
| fn(scope, {$event:event}); | |
| }); | |
| }); | |
| }; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <button class="btn" ng-click="showForm=true; focusInput=true">show form and focus input</button> | |
| <div ng-show="showForm"> | |
| <input type="text" focus-me="focusInput"> | |
| <button class="btn" ng-click="showForm=false">hide form</button> | |
| </div> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // | |
| // ToolTip | |
| // | |
| // source: http://sixrevisions.com/tutorials/javascript_tutorial/create_lightweight_javascript_tooltip/ | |
| var tooltip = function () { | |
| var id = 'tt'; | |
| var top = 3; | |
| var left = 3; | |
| var maxw = 300; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | app.directive('ngEnter', function() { | |
| return function(scope, element, attrs) { | |
| element.bind("keydown keypress", function(event) { | |
| if(event.which === 13) { | |
| scope.$apply(function(){ | |
| scope.$eval(attrs.ngEnter); | |
| }); | |
| event.preventDefault(); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | app.directive('ngPlaceholder', function() { | |
| return { | |
| restrict: 'A', | |
| require: 'ngModel', | |
| link: function(scope, element, attr, ctrl) { | |
| var value; | |
| var placehold = function () { | |
| element.val(attr.placehold) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | angular.module('app', []).directive('ngInitFocus', function() { | |
| var timer; | |
| return function(scope, elm, attr) { | |
| if (timer) clearTimeout(timer); | |
| timer = setTimeout(function() { | |
| elm.focus(); | |
| }, 0); | |
| }; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | myApp.directive('ngBlur', function() { | |
| return function( scope, elem, attrs ) { | |
| elem.bind('blur', function() { | |
| scope.$apply(attrs.ngBlur); | |
| }); | |
| }; | |
| }); |