bitcoin-atm

bitcoin atm for pyc inc.

git clone https://9o.is/git/bitcoin-atm.git

disabler.js

(754B)


      1 /**
      2  * Disables button and displays loading. (Useful for Ajax)
      3  * Depends on FontAwesome's spinning icon.
      4  * 
      5  * Usage:
      6  * 
      7  * <button type="submit" disabler ng-model="loading">Submit</button>
      8  * 
      9  * Set $scope.loading to true in javascript code to display 
     10  * the button as loading.
     11  */
     12 angular.module("disabler", [])
     13   .directive('disabler', ['$compile', function($compile) {
     14 	return {
     15 		link: function(scope, elm, attrs) {
     16 			var btnContents = $compile(elm.contents())(scope);
     17 			scope.$watch(attrs.ngModel, function(value) {
     18 				if (value) {
     19 					elm.html("<i class='fa fa-spinner fa-spin'></i> Loading");
     20 					elm.attr('disabled',true);
     21 				} else {
     22 					elm.html('').append(btnContents);
     23 					elm.attr('disabled',false);
     24 				}
     25 			});
     26 		}
     27 	};
     28   }]);