(function () { 'use strict'; angular.module('app.service') .service('indicator', ['$document', function ($document) { this.busy = false; this.list = []; var normalizeId = function (id) { return 'string' === typeof id ? id : null; }; this.has = function (id) { return -1 !== this.list.indexOf(normalizeId(id)); }; this.refreshBusy = function () { this.busy = this.list.length > 0; $document[0].documentElement.style.cursor = this.busy ? 'progress' : ''; return this; }; this.start = function (id) { this.list.push(normalizeId(id)); this.refreshBusy(); return this; }; this.stop = function (id) { var idx = this.list.lastIndexOf(normalizeId(id)); if (-1 !== idx) { this.list.splice(idx, 1); } this.refreshBusy(); return this; }; }]); })();