angular-busy
Advanced tools
Comparing version 3.0.2 to 4.0.0
@@ -1,51 +0,99 @@ | ||
angular.module('cgBusy',['ajoslin.promise-tracker']); | ||
angular.module('cgBusy',[]); | ||
angular.module('cgBusy').value('cgBusyTemplateName','angular-busy.html'); | ||
//loosely modeled after angular-promise-tracker | ||
angular.module('cgBusy').factory('_cgBusyTrackerFactory',['$timeout',function($timeout){ | ||
angular.module('cgBusy').directive('cgBusy',['promiseTracker','$compile','$templateCache','cgBusyTemplateName','$http','$animate', | ||
function(promiseTracker,$compile,$templateCache,cgBusyTemplateName,$http,$animate){ | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs, fn) { | ||
return function(){ | ||
var options = scope.$eval(attrs.cgBusy); | ||
var tracker = {}; | ||
tracker.promises = []; | ||
tracker.delayPromise = null; | ||
tracker.durationPromise = null; | ||
if (angular.isString(options) || angular.isArray(options)) { | ||
options = {tracker:options}; | ||
} | ||
tracker.reset = function(options){ | ||
tracker.minDuration = options.minDuration; | ||
if (angular.isUndefined(options) || angular.isUndefined(options.tracker)){ | ||
throw new Error('Options for cgBusy directive must be provided (tracker option is required).'); | ||
tracker.promises = []; | ||
angular.forEach(options.promises,function(p){ | ||
if (!p || p.$cgBusyFulfilled) { | ||
return; | ||
} | ||
addPromiseLikeThing(p); | ||
}); | ||
options.tracker = angular.isArray(options.tracker) ? options.tracker : [options.tracker]; | ||
if (tracker.promises.length === 0) { | ||
//if we have no promises then dont do the delay or duration stuff | ||
return; | ||
} | ||
if (!scope.$cgBusyTracker){ | ||
scope.$cgBusyTracker = {}; | ||
if (options.delay > 0) { | ||
tracker.delayPromise = $timeout(function(){ | ||
tracker.delayPromise = null; | ||
if (options.minDuration) { | ||
tracker.durationPromise = $timeout(function(){ | ||
tracker.durationPromise = null; | ||
},options.minDuration); | ||
} | ||
},options.delay); | ||
} | ||
}; | ||
tracker.getThen = function(promise){ | ||
var then = promise && (promise.then || promise.$then || | ||
(promise.$promise && promise.$promise.then)); | ||
return then; | ||
}; | ||
var addPromiseLikeThing = function(promise){ | ||
var then = tracker.getThen(promise); | ||
if (!then) { | ||
throw new Error('cgBusy expects a promise (or something that has a .promise or .$promise'); | ||
} | ||
if (tracker.promises.indexOf(promise) !== -1){ | ||
return; | ||
} | ||
tracker.promises.push(promise); | ||
then(function(){ | ||
promise.$cgBusyFulfilled = true; | ||
if (tracker.promises.indexOf(promise) === -1) { | ||
return; | ||
} | ||
tracker.promises.splice(tracker.promises.indexOf(promise),1); | ||
},function(){ | ||
promise.$cgBusyFulfilled = true; | ||
if (tracker.promises.indexOf(promise) === -1) { | ||
return; | ||
} | ||
tracker.promises.splice(tracker.promises.indexOf(promise),1); | ||
}); | ||
}; | ||
angular.forEach(options.tracker, function (tracker) { | ||
// Checking for a non-existent tracker throws an exception, | ||
// so we check for one first, then register it if it doesn't exist yet | ||
try { | ||
scope.$cgBusyTracker[tracker] = promiseTracker(tracker); | ||
} catch(error) { | ||
scope.$cgBusyTracker[tracker] = promiseTracker.register(tracker); | ||
} | ||
}); | ||
tracker.active = function(){ | ||
if (tracker.delayPromise){ | ||
return false; | ||
} | ||
if (tracker.durationPromise){ | ||
return true; | ||
} | ||
return tracker.promises.length > 0; | ||
}; | ||
//multiple cg-busy's can be active in the same scope so we have to be careful not to overwrite the | ||
//same isActive function. So lets name it uniquely by the trackers its watching. | ||
var isActiveFnName = 'isActive_' + options.tracker.join('_'); | ||
return tracker; | ||
scope[isActiveFnName] = function() { | ||
var active = false; | ||
angular.forEach(options.tracker, function (tracker) { | ||
if (scope.$cgBusyTracker[tracker].active()) { | ||
active = true; | ||
} | ||
}); | ||
return active; | ||
}; | ||
}; | ||
}]); | ||
angular.module('cgBusy').value('cgBusyDefaults',{}); | ||
angular.module('cgBusy').directive('cgBusy',['$compile','$templateCache','cgBusyDefaults','$http','_cgBusyTrackerFactory', | ||
function($compile,$templateCache,cgBusyDefaults,$http,_cgBusyTrackerFactory){ | ||
return { | ||
restrict: 'A', | ||
link: function(scope, element, attrs, fn) { | ||
//Apply position:relative to parent element if necessary | ||
var position = element.css('position'); | ||
@@ -56,23 +104,99 @@ if (position === 'static' || position === '' || typeof position === 'undefined'){ | ||
var indicatorTemplateName = options.template ? options.template : cgBusyTemplateName; | ||
var templateElement; | ||
var currentTemplate; | ||
var templateScope; | ||
var backdrop; | ||
var tracker = _cgBusyTrackerFactory(); | ||
$http.get(indicatorTemplateName,{cache: $templateCache}).success(function(indicatorTemplate){ | ||
var defaults = { | ||
templateUrl: 'angular-busy.html', | ||
delay:0, | ||
minDuration:0, | ||
backdrop: true, | ||
message:'Please Wait...' | ||
}; | ||
options.backdrop = typeof options.backdrop === 'undefined' ? true : options.backdrop; | ||
var backdrop = options.backdrop ? '<div class="cg-busy cg-busy-backdrop"></div>' : ''; | ||
angular.extend(defaults,cgBusyDefaults); | ||
var template = '<div class="cg-busy cg-busy-animation ng-hide" ng-show="'+isActiveFnName+'()">'+ backdrop + indicatorTemplate+'</div>'; | ||
var templateElement = $compile(template)(scope); | ||
scope.$watchCollection(attrs.cgBusy,function(options){ | ||
angular.element(templateElement.children()[options.backdrop?1:0]) | ||
.css('position','absolute') | ||
.css('top',0) | ||
.css('left',0) | ||
.css('right',0) | ||
.css('bottom',0); | ||
element.append(templateElement); | ||
if (!options) { | ||
options = {promise:null}; | ||
} | ||
}).error(function(data){ | ||
throw new Error('Template specified for cgBusy ('+options.template+') could not be loaded. ' + data); | ||
}); | ||
if (angular.isString(options)) { | ||
throw new Error('Invalid value for cg-busy. cgBusy no longer accepts string ids to represent promises/trackers.'); | ||
} | ||
//is it an array (of promises) or one promise | ||
if (angular.isArray(options) || tracker.getThen(options)) { | ||
options = {promise:options}; | ||
} | ||
options = angular.extend(angular.copy(defaults),options); | ||
if (!options.templateUrl){ | ||
options.templateUrl = defaults.templateUrl; | ||
} | ||
if (!angular.isArray(options.promise)){ | ||
options.promise = [options.promise]; | ||
} | ||
// options.promise = angular.isArray(options.promise) ? options.promise : [options.promise]; | ||
// options.message = options.message ? options.message : 'Please Wait...'; | ||
// options.template = options.template ? options.template : cgBusyTemplateName; | ||
// options.minDuration = options.minDuration ? options.minDuration : 0; | ||
// options.delay = options.delay ? options.delay : 0; | ||
if (!templateScope) { | ||
templateScope = scope.$new(); | ||
} | ||
templateScope.$message = options.message; | ||
if (!angular.equals(tracker.promises,options.promise)) { | ||
tracker.reset({ | ||
promises:options.promise, | ||
delay:options.delay, | ||
minDuration: options.minDuration | ||
}); | ||
} | ||
templateScope.$cgBusyIsActive = function() { | ||
return tracker.active(); | ||
}; | ||
if (!templateElement || currentTemplate !== options.templateUrl || backdrop !== options.backdrop) { | ||
if (templateElement) { | ||
templateElement.remove(); | ||
} | ||
currentTemplate = options.templateUrl; | ||
backdrop = options.backdrop; | ||
$http.get(currentTemplate,{cache: $templateCache}).success(function(indicatorTemplate){ | ||
options.backdrop = typeof options.backdrop === 'undefined' ? true : options.backdrop; | ||
var backdrop = options.backdrop ? '<div class="cg-busy cg-busy-backdrop"></div>' : ''; | ||
var template = '<div class="cg-busy cg-busy-animation ng-hide" ng-show="$cgBusyIsActive()">'+ backdrop + indicatorTemplate+'</div>'; | ||
templateElement = $compile(template)(templateScope); | ||
angular.element(templateElement.children()[options.backdrop?1:0]) | ||
.css('position','absolute') | ||
.css('top',0) | ||
.css('left',0) | ||
.css('right',0) | ||
.css('bottom',0); | ||
element.append(templateElement); | ||
}).error(function(data){ | ||
throw new Error('Template specified for cgBusy ('+options.templateUrl+') could not be loaded. ' + data); | ||
}); | ||
} | ||
},true); | ||
} | ||
@@ -79,0 +203,0 @@ }; |
{ | ||
"name": "angular-busy", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"main": [ | ||
@@ -10,3 +10,2 @@ "dist/angular-busy.js", | ||
"angular": "~1.2", | ||
"angular-promise-tracker": "~1.5", | ||
"angular-animate": "~1.2" | ||
@@ -30,4 +29,5 @@ }, | ||
"devDependencies": { | ||
"jquery": "~2.0.2" | ||
"angular-mocks": "~1.2.16", | ||
"jquery": "~2.1.0" | ||
} | ||
} |
@@ -1,18 +0,18 @@ | ||
angular.module('app', ['ngAnimate','ajoslin.promise-tracker','cgBusy']); | ||
angular.module('app', ['ngAnimate','cgBusy']); | ||
angular.module('app').controller('DemoCtrl',function($scope,promiseTracker,$q,$timeout){ | ||
angular.module('app').controller('DemoCtrl',function($scope,$http){ | ||
$scope.delay1 = $scope.delay2 = 2000; | ||
$scope.delay = 0; | ||
$scope.minDuration = 0; | ||
$scope.message = 'Please Wait...'; | ||
$scope.backdrop = true; | ||
$scope.promise = null; | ||
$scope.demoBusy = function(trackerName,delay){ | ||
$scope.demo = function(){ | ||
//For the demo we're using a simple promise not $http since thats easier to control | ||
var testPromise = $q.defer(); | ||
promiseTracker(trackerName).addPromise(testPromise.promise); | ||
$timeout(function(){ | ||
testPromise.resolve(); | ||
},delay); | ||
$scope.promise = $http.get('http://httpbin.org/delay/3'); | ||
}; | ||
}); |
100
Gruntfile.js
'use strict'; | ||
var path = require('path'); | ||
var folderMount = function folderMount(connect, point) { | ||
return connect.static(path.resolve(point)); | ||
}; | ||
module.exports = function (grunt) { | ||
module.exports = function (grunt) { | ||
// Project configuration. | ||
require('load-grunt-tasks')(grunt); | ||
grunt.initConfig({ | ||
connect: { | ||
livereload: { | ||
main: { | ||
options: { | ||
port: 8001, | ||
middleware: function(connect, options) { | ||
return [folderMount(connect, options.base)] | ||
} | ||
port: 9001 | ||
} | ||
} | ||
}, | ||
regarde: { | ||
all: { | ||
files: ['**/*','!node_modules/**/*'], | ||
tasks: ['livereload'] | ||
watch: { | ||
main: { | ||
options: { | ||
livereload: true, | ||
livereloadOnError: false, | ||
spawn: false | ||
}, | ||
files: ['angular-busy.html','angular-busy.js','angular-busy.css','dist/**/*','demo/**/*'], | ||
tasks: ['jshint','build'] | ||
} | ||
}, | ||
jshint: { | ||
options: { | ||
curly: true, | ||
eqeqeq: true, | ||
immed: true, | ||
latedef: true, | ||
newcap: true, | ||
noarg: true, | ||
sub: true, | ||
undef: true, | ||
boss: true, | ||
eqnull: true, | ||
browser: true, | ||
smarttabs: true, | ||
globals: { | ||
jQuery: true, | ||
angular: true, | ||
console: true, | ||
$: true | ||
} | ||
}, | ||
files: ['angular-busy.js'] | ||
main: { | ||
options: { | ||
jshintrc: '.jshintrc' | ||
}, | ||
src: 'angular-busy.js' | ||
} | ||
}, | ||
jasmine: { | ||
unit: { | ||
src: ['./bower_components/jquery/jquery.js','./bower_components/angular/angular.js','./bower_components/angular-animate/angular-animate.js','./lib/angular-mocks.js','./bower_components/angular-promise-tracker/promise-tracker.js','./dist/angular-busy.js','./demo/demo.js'], | ||
src: ['./bower_components/jquery/dist/jquery.js','./bower_components/angular/angular.js','./bower_components/angular-animate/angular-animate.js','./bower_components/angular-mocks/angular-mocks.js','./dist/angular-busy.js','./demo/demo.js'], | ||
options: { | ||
@@ -58,11 +42,4 @@ specs: 'test/*.js' | ||
}, | ||
copy: { | ||
ngtemplates: { | ||
main: { | ||
files: [ | ||
{src:'angular-busy.css',dest:'dist/'} | ||
] | ||
} | ||
}, | ||
ngtemplates: { | ||
main: { | ||
options: { | ||
@@ -75,4 +52,4 @@ module:'cgBusy', | ||
} | ||
}, | ||
concat: { | ||
}, | ||
concat: { | ||
main: { | ||
@@ -82,7 +59,14 @@ src: ['angular-busy.js', 'temp/templates.js'], | ||
} | ||
}, | ||
}, | ||
copy: { | ||
main: { | ||
files: [ | ||
{src:'angular-busy.css',dest:'dist/'} | ||
] | ||
} | ||
}, | ||
uglify: { | ||
main: { | ||
files: [ | ||
{src:'dist/angular-busy.js',dest:'dist/angular-busy.min.js'} | ||
{src:'dist/angular-busy.js',dest:'dist/angular-busy.min.js'} | ||
] | ||
@@ -97,19 +81,9 @@ } | ||
} | ||
} | ||
} | ||
}); | ||
grunt.loadNpmTasks('grunt-regarde'); | ||
grunt.loadNpmTasks('grunt-contrib-connect'); | ||
grunt.loadNpmTasks('grunt-contrib-livereload'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-jasmine'); | ||
grunt.loadNpmTasks('grunt-contrib-cssmin'); | ||
grunt.loadNpmTasks('grunt-contrib-concat'); | ||
grunt.loadNpmTasks('grunt-angular-templates'); | ||
grunt.registerTask('serve', ['jshint','connect', 'watch']); | ||
grunt.registerTask('build',['ngtemplates','concat','uglify','copy','cssmin']); | ||
grunt.registerTask('test',['build','jasmine']); | ||
grunt.registerTask('server', ['livereload-start','jshint','connect', 'regarde']); | ||
grunt.registerTask('build',['copy','ngtemplates','concat','uglify','cssmin']); | ||
grunt.registerTask('test',['build','jasmine']); | ||
}; |
{ | ||
"name": "angular-busy", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"description": "", | ||
@@ -11,12 +11,12 @@ "repository": { | ||
"grunt": "~0.4.1", | ||
"grunt-contrib-copy": "~0.4.1", | ||
"grunt-contrib-uglify": "~0.2.0", | ||
"grunt-contrib-jshint": "~0.4.1", | ||
"grunt-contrib-jasmine": "~0.4.2", | ||
"grunt-contrib-cssmin": "~0.6.0", | ||
"grunt-contrib-concat": "~0.2.0", | ||
"grunt-angular-templates": "~0.3.2", | ||
"grunt-regarde": "~0.1.1", | ||
"grunt-contrib-connect": "~0.3.0", | ||
"grunt-contrib-livereload": "~0.1.2" | ||
"grunt-contrib-connect": "~0.7.1", | ||
"grunt-contrib-watch": "~0.6.1", | ||
"grunt-contrib-jshint": "~0.10.0", | ||
"grunt-contrib-jasmine": "~0.6.3", | ||
"grunt-angular-templates": "~0.5.4", | ||
"grunt-contrib-concat": "~0.4.0", | ||
"grunt-contrib-copy": "~0.5.0", | ||
"grunt-contrib-uglify": "~0.4.0", | ||
"grunt-contrib-cssmin": "~0.9.0", | ||
"load-grunt-tasks": "~0.4.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "scripts": { |
# angular-busy [![Build Status](https://travis-ci.org/cgross/angular-busy.png?branch=master)](https://travis-ci.org/cgross/angular-busy) | ||
> Show busy/loading indicators on any element during $http requests (or any promise). | ||
> Show busy/loading indicators on any $http or $resource request, or on any promise. | ||
This library depends on v1.5 of [Andy Joslin's angular-promise-tracker](https://github.com/ajoslin/angular-promise-tracker). | ||
Annotate an `$http` request using `angular-promise-tracker` and add `cg-busy` on an element to display a busy | ||
indication on a specific element during the `$http` request. | ||
This library builds on Angular 1.2 and the new Angular animate module in `animate.js`. | ||
Supports IE 10, and recent versions of FF and Chrome. | ||
## Demo | ||
@@ -20,24 +11,36 @@ | ||
Add `dist/angular-busy.js` and `dist/angular-busy.css` to your index.html. Also add the `angular-promise-tracker` files as necessary. | ||
Install with Bower or download the the files directly from the dist folder in the repo. | ||
Add `cgBusy` as a module dependency for your module (in addition to `ajoslin.promise-tracker` and the Angular 1.2 `ngAnimate` module): | ||
```bash | ||
bower install angular-busy --save | ||
``` | ||
Add `dist/angular-busy.js` and `dist/angular-busy.css` to your index.html. | ||
Add `cgBusy` as a module dependency for your module. | ||
```js | ||
angular.module('your_app', ['ngAnimate','ajoslin.promise-tracker','cgBusy']); | ||
angular.module('your_app', ['cgBusy']); | ||
``` | ||
Add the promise trackers as you normally would using `angular-promise-tracker`: | ||
Add your promise to $scope and reference that in the `cg-busy` directive: | ||
```js | ||
function MyCtrl($scope) { | ||
function MyCtrl($scope,$http,User) { | ||
$scope.pizzaFlavor = $http.get('/pizzaFlavor', { tracker: 'pizza' }); | ||
//using $http | ||
$scope.myPromise = $http.get('...'); | ||
//if you have a User class based on $resource | ||
$scope.myPromise = User.$save(); | ||
} | ||
``` | ||
Add `cg-busy` to the elements you wish to be _busy_ during those requests: | ||
```html | ||
<!-- Use the simple syntax --> | ||
<div cg-busy="myPromise"></div> | ||
```html | ||
<div cg-busy="'pizza'"></div> | ||
<!-- Use the advanced syntax --> | ||
<div cg-busy="{promise:myPromise,message:'Loading Your Data',templateUrl:'mycustomtemplate.html'}"></div> | ||
``` | ||
@@ -47,4 +50,3 @@ | ||
The `cg-busy` directive expects a value that is interpreted as an expression. The value may be specified as an object literal | ||
or simply as a string if only the `tracker` value is provided. | ||
The `cg-busy` directive expects either a promise or a configuration object. | ||
@@ -54,3 +56,3 @@ In other words. You may do this: | ||
```html | ||
<div cg-busy="'my_tracker'"></div> <!-- Notice the extra single quotes because its an expression --> | ||
<div cg-busy="myPromise"></div> | ||
``` | ||
@@ -61,23 +63,41 @@ | ||
```html | ||
<div cg-busy="{tracker:'my_tracker',backdrop:false,template:'myAwesomeTemplate.html'}"></div> | ||
<div cg-busy="{promise:myPromise,message:'Loading',backdrop:false,templateUrl:'myAwesomeTemplate.html',delay:300,minDuration:700}"></div> | ||
``` | ||
* `tracker` - Required. The name(s) of the promise tracker. May either be a string or an array of strings if you wish to use the same indicator for multiple promises/trackers. | ||
* `promise` - Required. The promise (or array of promises) that will cause the busy indicator to show. | ||
* `message` - Optional. Defaults to 'Please Wait...'. The message to show in the indicator. This value may be updated while the promise is active. The indicator will reflect the updated values as they're changed. | ||
* `backdrop` - Optional. Boolean, default is true. If true a faded backdrop will be shown behind the progress indicator. | ||
* `template` - Optional. If provided, the given template will be shown in place of the default progress | ||
indicatory template. Use this to override the default UI and provide your own. | ||
* `templateUrl` - Optional. If provided, the given template will be shown in place of the default progress indicatory template. | ||
* `delay` - Optional. The amount of time to wait until showing the indicator. Defaults to 0. Specified in milliseconds. | ||
* `minDuration` - Optional. The amount of time to keep the indicator showing even if the promise was resolved quicker. Defaults to 0. Specified in milliseconds. | ||
## Providing Custom Templates | ||
The default progress template shows a spinner and a 'Please Wait...' message. But you can define custom templates per instance | ||
(as shown above) or change the global default template. To change the global default template just provide a new | ||
`$injector` value for `cgBusyTemplateName`. Ex: | ||
The angular-busy indicator is a regular Angular template. The templates have access to the scope where `cg-busy` was declared so you may reference your local scope variables in your custom templates. Additionally, the scope is augmented with a `$message` field containing the indicator message text. | ||
```js | ||
angular.module('yourapp').value('cgBusyTemplateName','your_custom_template_here.html'); | ||
## Overriding Defaults | ||
The defaut values for `message`, `backdrop`, `templateUrl`, `delay`, and `minDuration` may all be overriden by overriding the `$injector` value for `cgBusyDefaults`, like so: | ||
```js | ||
angular.module('your_app').value('cgBusyDefaults',{ | ||
message:'Loading Stuff', | ||
backdrop: false, | ||
templateUrl: 'my_custom_template.html', | ||
delay: 300, | ||
minDuration: 700 | ||
}); | ||
``` | ||
Templates are full, normal Angular partials with access to the scope of where the `cg-busy` was used. | ||
Only the values you'd like overriden need to be specified. | ||
## Release History | ||
* v4.0.0 - Big update | ||
* Dependency on angular-promise-tracker has been removed. We now track promises directly. | ||
* Message is now configurable. | ||
* The template options is now templateUrl. | ||
* The delay option has been added. | ||
* The minDuration option has been added. | ||
* Changing default template has been modified to be part of the new `cgBusyDefaults` value. | ||
* v3.0.2 - Reverting back to promise-tracker v1.5 due to changes in the api. | ||
@@ -84,0 +104,0 @@ * v3.0.1 - Fix for using cg-busy when a tracker has already been registered. |
@@ -5,9 +5,8 @@ describe('cgBusy', function() { | ||
var scope,compile,q,_promiseTracker,httpBackend; | ||
var scope,compile,q,httpBackend; | ||
beforeEach(inject(function($rootScope,$compile,$q,promiseTracker,$httpBackend,$templateCache) { | ||
beforeEach(inject(function($rootScope,$compile,$q,$httpBackend,$templateCache) { | ||
scope = $rootScope.$new(); | ||
compile = $compile; | ||
q = $q; | ||
_promiseTracker = promiseTracker; | ||
httpBackend = $httpBackend; | ||
@@ -22,16 +21,16 @@ httpBackend.whenGET('test-custom-template.html').respond(function(method, url, data, headers){ | ||
this.element = compile('<div cg-busy="\'my_tracker\'"></div>')(scope); | ||
this.element = compile('<div cg-busy="my_promise"></div>')(scope); | ||
angular.element('body').append(this.element); | ||
this.testPromise = q.defer(); | ||
_promiseTracker('my_tracker').addPromise(this.testPromise.promise); | ||
scope.my_promise = this.testPromise.promise; | ||
//httpBackend.flush(); | ||
//httpBackend.flush(); | ||
scope.$apply(); | ||
scope.$apply(); | ||
expect(this.element.children().length).toBe(1); //ensure element is added | ||
expect(this.element.children().length).toBe(1); //ensure element is added | ||
expect(this.element.children().css('display')).toBe('block');//ensure its visible (promise is ongoing) | ||
this.testPromise.resolve(); | ||
@@ -45,10 +44,10 @@ scope.$apply(); | ||
this.element = compile('<div cg-busy="[\'my_tracker\',\'my_tracker2\']"></div>')(scope); | ||
this.element = compile('<div cg-busy="[my_promise,my_promise2]"></div>')(scope); | ||
angular.element('body').append(this.element); | ||
this.testPromise = q.defer(); | ||
_promiseTracker('my_tracker').addPromise(this.testPromise.promise); | ||
scope.my_promise = this.testPromise.promise; | ||
this.testPromise2 = q.defer(); | ||
_promiseTracker('my_tracker2').addPromise(this.testPromise2.promise); | ||
scope.my_promise2 = this.testPromise2.promise; | ||
@@ -75,8 +74,8 @@ //httpBackend.flush(); | ||
this.element = compile('<div cg-busy="{tracker:\'my_tracker\',template:\'test-custom-template.html\'}"></div>')(scope); | ||
this.element = compile('<div cg-busy="{promise:my_promise,templateUrl:\'test-custom-template.html\'}"></div>')(scope); | ||
angular.element('body').append(this.element); | ||
httpBackend.flush(); | ||
httpBackend.flush(); | ||
scope.$apply(); | ||
scope.$apply(); | ||
@@ -83,0 +82,0 @@ expect(angular.element('#custom').html()).toBe('test-custom-template-contents'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108
38257
18
704
1