{"version":3,"sources":["angular-block-ui-header.js","angular-block-ui.js","config.js","directive.js","interceptor.js","service.js","utils.js","angular-block-ui-templates.js","angular-block-ui-footer.js"],"names":[],"mappings":"AAAA;GACA;GACA;GACA;AACA;AACA;;ACLA;;AAEA,aAAA,8BAAA;;EAEA;IACA;MACA;;MAEA;;QAEA;;QAEA;UACA;UACA;QACA;;QAEA;MACA;IACA;EACA;;EAEA;AACA,CAAA,CAAA;;AAEA,UAAA,+BAAA;EACA;IACA;EACA;AACA,CAAA,CAAA;;AC7BA;;EAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;EACA;;EAEA;IACA;EACA;;EAEA;IACA;EACA;;EAEA;IACA;EACA;;EAEA;IACA;EACA;;EAEA;IACA;EACA;;EAEA;IACA;EACA;;EAEA;IACA;EACA;;EAEA;IACA;EACA;;EAEA;IACA;EACA;AACA;;AC/CA,2BAAA,8CAAA;EACA;IACA;IACA;IACA;IACA;IACA;EACA;AACA,CAAA,CAAA,2BAAA,4BAAA;;EAEA;;IAEA;;IAEA;;IAEA;;MAEA;;MAEA;;MAEA;QACA;;UAEA;UACA;;UAEA;UACA;YACA;cACA;YACA;UACA;QACA;MACA;;QAEA;;QAEA;;QAEA;;QAEA;;QAEA;;QAEA;;QAEA;;QAEA;;UAEA;;UAEA;QACA;;QAEA;;QAEA;;QAEA;UACA;UACA;QACA;;QAEA;;QAEA;UACA;QACA;;QAEA;;QAEA;MACA;;MAEA;MACA;MACA;;MAEA;QACA;MACA;IACA;EACA;AACA,CAAA,CAAA;;ACvFA,wCAAA,qCAAA;;EAEA;;EAEA;IACA;EACA;;EAEA;IACA;MACA;MACA;IACA;EACA;;EAEA;IACA;IACA;EACA;;EAEA;IACA;;MAEA;;QAEA;;QAEA;UACA;UACA;QACA;UACA;;UAEA;UACA;QACA;MACA;;MAEA;IACA;;IAEA;;IAEA;MACA;MACA;IACA;;IAEA;EACA;;AAEA,CAAA,CAAA;;ACnDA,yBAAA,2DAAA;;EAEA;;EAEA;;IAEA;;IAEA;MACA;MACA;MACA;MACA;IACA;;IAEA;;IAEA;;MAEA;QACA;MACA;QACA;MACA;;MAEA;;MAEA;;MAEA;;MAEA;;MAEA;;QAEA;QACA;;QAEA;;QAEA;QACA;QACA;;QAEA;UACA;UACA;YACA;UACA;QACA;MACA;;MAEA;QACA;UACA;UACA;QACA;MACA;IACA;;IAEA;MACA;QACA;QACA;MACA;IACA;;IAEA;MACA;;MAEA;QACA;MACA;IACA;;IAEA;MACA;IACA;;IAEA;MACA;QACA;MACA;;MAEA;IACA;;IAEA;;MAEA;MACA;MACA;;MAEA;MACA;MACA;;MAEA;SACA;QACA;QACA;MACA;;MAEA;QACA;UACA;YACA;UACA;QACA;MACA;QACA;MACA;IACA;;IAEA;MACA;IACA;;IAEA;MACA;IACA;;IAEA;MACA;IACA;;IAEA;MACA;QACA;MACA;IACA;EACA;;EAEA;;EAEA;IACA;;IAEA;MACA;MACA;IACA;;IAEA;EACA;;EAEA;IACA;MACA;IACA;;IAEA;MACA;MACA;MACA;MACA;QACA;UACA;UACA;QACA;MACA;IACA;EACA;;EAEA;;IAEA;;IAEA;IACA;;IAEA;IACA;;IAEA;;IAEA;MACA;MACA;;MAEA;QACA;MACA;IACA;;IAEA;MACA;IACA;;IAEA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;;EAEA;AACA,CAAA,CAAA;;;ACzMA;;EAEA;IACA;MACA;;MAEA;QACA;MACA;QACA;MACA;;MAEA;IACA;IACA;MACA;MACA;QACA;QACA;MACA;IACA;IACA;MACA;QACA;MACA;IACA;IACA;MACA;;MAEA;QACA;UACA;QACA;;QAEA;MACA;;MAEA;IACA;EACA;;EAEA;;AAEA;AC5CA;AACA;AACA;AACA;EACA;AACA;ACLA","sourcesContent":["/*!\n angular-block-ui v0.0.12\n (c) 2014 (null) McNull https://github.com/McNull/angular-block-ui\n License: MIT\n*/\n(function(angular) {\n","var blkUI = angular.module('blockUI', []);\n\nblkUI.config(function($provide, $httpProvider) {\n\n $provide.decorator('$exceptionHandler', ['$delegate', '$injector',\n function($delegate, $injector) {\n var blockUI, blockUIConfig;\n\n return function(exception, cause) {\n\n blockUIConfig = blockUIConfig || $injector.get('blockUIConfig');\n\n if (blockUIConfig.resetOnException) {\n blockUI = blockUI || $injector.get('blockUI');\n blockUI.instances.reset();\n }\n\n $delegate(exception, cause);\n };\n }\n ]);\n\n $httpProvider.interceptors.push('blockUIHttpInterceptor');\n});\n\nblkUI.run(function($document, blockUIConfig) {\n if(blockUIConfig.autoInjectBodyBlock) {\n $document.find('body').append('
');\n }\n});\n","blkUI.provider('blockUIConfig', function() {\n\n var _config = {\n templateUrl: 'angular-block-ui/angular-block-ui.ng.html',\n delay: 250,\n message: \"Loading ...\",\n autoBlock: true,\n resetOnException: true,\n requestFilter: angular.noop,\n autoInjectBodyBlock: true\n };\n\n this.templateUrl = function(url) {\n _config.templateUrl = url;\n };\n\n this.template = function(template) {\n _config.template = template;\n };\n\n this.delay = function(delay) {\n _config.delay = delay;\n };\n\n this.message = function(message) {\n _config.message = message;\n };\n\n this.autoBlock = function(enabled) {\n _config.autoBlock = enabled;\n };\n\n this.resetOnException = function(enabled) {\n _config.resetOnException = enabled;\n };\n\n this.requestFilter = function(filter) {\n _config.requestFilter = filter;\n };\n\n this.autoInjectBodyBlock = function(enabled) {\n _config.autoInjectBodyBlock = enabled;\n };\n\n this.$get = function() {\n return _config;\n };\n});\n","blkUI.directive('blockUi', function(blockUI, blockUIConfig, blockUiLinkFn) {\n return {\n scope: true,\n restrict: 'A',\n templateUrl: blockUIConfig.template ? undefined : blockUIConfig.templateUrl,\n template: blockUIConfig.template,\n link: blockUiLinkFn\n };\n}).factory('blockUiLinkFn', function(blockUI, blockUIUtils) {\n\n return function($scope, $element, $attrs) {\n \n var $parent = $element.parent();\n\n // Locate the parent element \n\n if ($parent.length) {\n \n var srvInstance = blockUI;\n \n // If the parent is the body element, hook into the view loaded event\n\n if ($parent[0].tagName === 'BODY') {\n var fn = $scope.$on('$viewContentLoaded', function($event) {\n \n // Unhook the view loaded and hook a function that will prevent\n // location changes while the block is active.\n\n fn();\n $scope.$on('$locationChangeStart', function(event) {\n if ($scope.state.blockCount > 0) {\n event.preventDefault();\n }\n });\n });\n } else {\n\n // Ensure that the parent position is set to relative \n\n $parent.css('position', 'relative');\n\n // Create the blockUI instance\n\n var instanceId = !$attrs.blockUi ? '_' + $scope.$id : $attrs.blockUi;\n\n srvInstance = blockUI.instances.get(instanceId);\n\n // Locate the parent blockUI instance\n\n var parentInstance = $element.inheritedData('block-ui');\n\n if(parentInstance) {\n\n // TODO: assert if parent is already set to something else\n \n srvInstance._parent = parentInstance;\n }\n\n // If a pattern is provided assign it to the state\n\n var pattern = $attrs.blockUiPattern;\n\n if(pattern) {\n var regExp = blockUIUtils.buildRegExp(pattern);\n srvInstance.pattern(regExp);\n }\n\n // Ensure the instance is released when the scope is destroyed\n\n $scope.$on('$destroy', function() {\n srvInstance.release();\n });\n\n // Increase the reference count\n\n srvInstance.addRef();\n }\n \n $element.addClass('block-ui');\n $parent.data('block-ui', srvInstance);\n $scope.state = srvInstance.state();\n \n $scope.$watch('state.blocking', function(value){\n $parent.attr('aria-busy', value);\n });\n }\n };\n});\n","blkUI.factory('blockUIHttpInterceptor', function($q, $injector, blockUIConfig) {\n\n var blockUI;\n\n function injectBlockUI() {\n blockUI = blockUI || $injector.get('blockUI');\n }\n\n function stopBlockUI(config) {\n if (blockUIConfig.autoBlock && !config.$_noBlock && config.$_blocks) {\n injectBlockUI();\n config.$_blocks.stop();\n }\n }\n\n function error(rejection) {\n stopBlockUI(rejection.config);\n return $q.reject(rejection);\n }\n\n return {\n request: function(config) {\n\n if (blockUIConfig.autoBlock) {\n\n // Don't block excluded requests\n\n if (blockUIConfig.requestFilter(config) === false) {\n // Tag the config so we don't unblock this request\n config.$_noBlock = true;\n } else {\n injectBlockUI();\n\n config.$_blocks = blockUI.instances.locate(config);\n config.$_blocks.start();\n }\n }\n\n return config;\n },\n\n requestError: error,\n\n response: function(response) {\n stopBlockUI(response.config);\n return response;\n },\n\n responseError: error\n };\n\n});\n","blkUI.factory('blockUI', function(blockUIConfig, $timeout, blockUIUtils, $document) {\n\n var $body = $document.find('body');\n\n function BlockUI(id) {\n\n var self = this;\n\n var state = {\n id: id,\n blockCount: 0,\n message: blockUIConfig.message,\n blocking: false\n }, startPromise, doneCallbacks = [];\n\n this._refs = 0;\n\n this.start = function(message) {\n\n if(state.blockCount > 0) {\n message = message || state.message || blockUIConfig.message;\n } else {\n message = message || blockUIConfig.message;\n }\n\n state.message = message;\n\n state.blockCount++;\n\n // Check if the focused element is part of the block scope\n\n var $ae = angular.element($document[0].activeElement);\n\n if($ae.length && blockUIUtils.isElementInBlockScope($ae, self)) {\n\n // Let the active element lose focus and store a reference \n // to restore focus when we're done (reset)\n\n self._restoreFocus = $ae[0];\n\n // https://github.com/McNull/angular-block-ui/issues/13\n // http://stackoverflow.com/questions/22698058/apply-already-in-progress-error-when-using-typeahead-plugin-found-to-be-relate\n // Queue the blur after any ng-blur expression.\n\n $timeout(function() {\n // Ensure we still need to blur\n if(self._restoreFocus) {\n self._restoreFocus.blur();\n }\n });\n }\n\n if (!startPromise) {\n startPromise = $timeout(function() {\n startPromise = null;\n state.blocking = true;\n }, blockUIConfig.delay);\n }\n };\n\n this._cancelStartTimeout = function() {\n if (startPromise) {\n $timeout.cancel(startPromise);\n startPromise = null;\n }\n };\n\n this.stop = function() {\n state.blockCount = Math.max(0, --state.blockCount);\n\n if (state.blockCount === 0) {\n self.reset(true);\n }\n };\n\n this.message = function(value) {\n state.message = value;\n };\n\n this.pattern = function(regexp) {\n if (regexp !== undefined) {\n self._pattern = regexp;\n }\n\n return self._pattern;\n };\n\n this.reset = function(executeCallbacks) {\n \n self._cancelStartTimeout();\n state.blockCount = 0;\n state.blocking = false;\n\n // Restore the focus to the element that was active\n // before the block start, but not if the user has \n // focused something else while the block was active.\n\n if(self._restoreFocus && \n (!$document[0].activeElement || $document[0].activeElement === $body[0])) {\n self._restoreFocus.focus();\n self._restoreFocus = null;\n }\n \n try {\n if (executeCallbacks) {\n angular.forEach(doneCallbacks, function(cb) {\n cb();\n });\n }\n } finally {\n doneCallbacks.length = 0;\n }\n };\n\n this.done = function(fn) {\n doneCallbacks.push(fn);\n };\n\n this.state = function() {\n return state;\n };\n\n this.addRef = function() {\n self._refs += 1;\n };\n\n this.release = function() {\n if(--self._refs <= 0) {\n mainBlock.instances._destroy(self);\n }\n };\n }\n\n var instances = [];\n\n instances.get = function(id) {\n var instance = instances[id];\n\n if(!instance) {\n instance = instances[id] = new BlockUI(id);\n instances.push(instance);\n }\n\n return instance;\n };\n\n instances._destroy = function(idOrInstance) {\n if (angular.isString(idOrInstance)) {\n idOrInstance = instances[idOrInstance];\n }\n\n if (idOrInstance) {\n idOrInstance.reset();\n delete instances[idOrInstance.state().id];\n var i = instances.length;\n while(--i) {\n if(instances[i] === idOrInstance) {\n instances.splice(i, 1);\n break;\n }\n }\n }\n };\n \n instances.locate = function(request) {\n\n var result = [];\n\n // Add function wrappers that will be executed on every item\n // in the array.\n \n blockUIUtils.forEachFnHook(result, 'start');\n blockUIUtils.forEachFnHook(result, 'stop');\n\n var i = instances.length;\n\n while(i--) {\n var instance = instances[i];\n var pattern = instance._pattern;\n\n if(pattern && pattern.test(request.url)) {\n result.push(instance);\n }\n }\n\n if(result.length === 0) {\n result.push(mainBlock);\n }\n\n return result;\n };\n\n // Propagate the reset to all instances\n\n blockUIUtils.forEachFnHook(instances, 'reset');\n\n var mainBlock = instances.get('main');\n\n mainBlock.addRef();\n mainBlock.instances = instances;\n\n return mainBlock;\n});\n","\nblkUI.factory('blockUIUtils', function() {\n\n var utils = {\n buildRegExp: function(pattern) {\n var match = pattern.match(/^\\/(.*)\\/([gim]*)$/), regExp;\n\n if(match) {\n regExp = new RegExp(match[1], match[2]);\n } else {\n throw Error('Incorrect regular expression format: ' + pattern);\n }\n\n return regExp;\n },\n forEachFn: function(arr, fnName, args) {\n var i = arr.length;\n while(i--) {\n var t = arr[i];\n t[fnName].apply(t, args);\n }\n },\n forEachFnHook: function(arr, fnName) {\n arr[fnName] = function() {\n utils.forEachFn(this, fnName, arguments);\n }\n },\n isElementInBlockScope: function($element, blockScope) {\n var c = $element.inheritedData('block-ui');\n\n while(c) {\n if(c === blockScope) {\n return true;\n }\n\n c = c._parent;\n }\n\n return false;\n }\n };\n\n return utils;\n\n});","// Automatically generated.\n// This file is already embedded in your main javascript output, there's no need to include this file\n// manually in the index.html. This file is only here for your debugging pleasures.\nangular.module('blockUI').run(['$templateCache', function($templateCache){\n $templateCache.put('angular-block-ui/angular-block-ui.ng.html', '