{"size": 1228, "ext": "js", "max_stars_repo_path": "modules/directives/itcSpinner.js", "max_stars_repo_name": "maxio89/angularjs-itc-utils", "max_stars_repo_stars_event_min_datetime": "2020-05-24T18:28:24.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-24T18:28:24.000Z", "max_issues_repo_path": "modules/directives/itcSpinner.js", "max_issues_repo_name": "maxio89/angularjs-itc-utils", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/directives/itcSpinner.js", "max_forks_repo_name": "maxio89/angularjs-itc-utils", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.9512195122, "max_line_length": 94, "alphanum_fraction": 0.3778501629}
/*global Spinner*/
(function ()
{
    'use strict';

    function itcSpinner()
    {
        return {
            restrict: 'A',
            link: function (scope, element, attrs)
            {
                var spinner;
                var start = function ()
                {
                    var height = element.height(), opts = {
                        length: Math.round(height / 8),
                        radius: Math.round(height / 5),
                        width: Math.round(height / 10),
                        color: element.css('color'),
                        className: 'spinner'
                    };
                    attrs.$set('disabled', true);
                    spinner = new Spinner(opts).spin(element[0]);
                };

                scope.$watch(attrs.itcSpinner, function (newVal)
                {
                    if (newVal) {
                        start();
                    } else if (spinner) {
                        attrs.$set('disabled', false);
                        spinner.stop();
                    }
                });
            }
        };
    }

    angular.module('pl.itcrowd.directives').directive('itcSpinner', ['$timeout', itcSpinner]);
})();
