Skip to content

Commit c3bd47e

Browse files
committed
v4.0.0
1 parent 2edf5ac commit c3bd47e

24 files changed

+570
-2583
lines changed

.bowerrc

100644100755
File mode changed.

.gitignore

100644100755
File mode changed.

.jshintrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"curly": true,
3+
"eqeqeq": true,
4+
"immed": true,
5+
"latedef": true,
6+
"newcap": true,
7+
"noarg": true,
8+
"sub": true,
9+
"undef": true,
10+
"boss": true,
11+
"eqnull": true,
12+
"browser": true,
13+
"smarttabs": true,
14+
"globals": {
15+
"jQuery": true,
16+
"angular": true,
17+
"console": true,
18+
"$": true,
19+
"_": true,
20+
"moment": true,
21+
"describe": true,
22+
"beforeEach": true,
23+
"module": true,
24+
"inject": true,
25+
"it": true,
26+
"expect": true
27+
}
28+
}

.travis.yml

100644100755
File mode changed.

Gruntfile.js

100644100755
Lines changed: 37 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,45 @@
11
'use strict';
2-
var path = require('path');
3-
4-
var folderMount = function folderMount(connect, point) {
5-
return connect.static(path.resolve(point));
6-
};
72

83
module.exports = function (grunt) {
9-
// Project configuration.
4+
5+
require('load-grunt-tasks')(grunt);
6+
107
grunt.initConfig({
118
connect: {
12-
livereload: {
9+
main: {
1310
options: {
14-
port: 8001,
15-
middleware: function(connect, options) {
16-
return [folderMount(connect, options.base)]
17-
}
11+
port: 9001
1812
}
1913
}
2014
},
21-
regarde: {
22-
all: {
23-
files: ['**/*','!node_modules/**/*'],
24-
tasks: ['livereload']
15+
watch: {
16+
main: {
17+
options: {
18+
livereload: true,
19+
livereloadOnError: false,
20+
spawn: false
21+
},
22+
files: ['angular-busy.html','angular-busy.js','angular-busy.css','dist/**/*','demo/**/*'],
23+
tasks: ['jshint','build']
2524
}
2625
},
2726
jshint: {
28-
options: {
29-
curly: true,
30-
eqeqeq: true,
31-
immed: true,
32-
latedef: true,
33-
newcap: true,
34-
noarg: true,
35-
sub: true,
36-
undef: true,
37-
boss: true,
38-
eqnull: true,
39-
browser: true,
40-
smarttabs: true,
41-
globals: {
42-
jQuery: true,
43-
angular: true,
44-
console: true,
45-
$: true
46-
}
47-
},
48-
files: ['angular-busy.js']
27+
main: {
28+
options: {
29+
jshintrc: '.jshintrc'
30+
},
31+
src: 'angular-busy.js'
32+
}
4933
},
5034
jasmine: {
5135
unit: {
52-
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'],
36+
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'],
5337
options: {
5438
specs: 'test/*.js'
5539
}
5640
}
5741
},
58-
copy: {
59-
main: {
60-
files: [
61-
{src:'angular-busy.css',dest:'dist/'}
62-
]
63-
}
64-
},
65-
ngtemplates: {
42+
ngtemplates: {
6643
main: {
6744
options: {
6845
module:'cgBusy',
@@ -71,17 +48,24 @@ module.exports = function (grunt) {
7148
src:'angular-busy.html',
7249
dest: 'temp/templates.js'
7350
}
74-
},
75-
concat: {
51+
},
52+
concat: {
7653
main: {
7754
src: ['angular-busy.js', 'temp/templates.js'],
7855
dest: 'dist/angular-busy.js'
7956
}
80-
},
57+
},
58+
copy: {
59+
main: {
60+
files: [
61+
{src:'angular-busy.css',dest:'dist/'}
62+
]
63+
}
64+
},
8165
uglify: {
8266
main: {
8367
files: [
84-
{src:'dist/angular-busy.js',dest:'dist/angular-busy.min.js'}
68+
{src:'dist/angular-busy.js',dest:'dist/angular-busy.min.js'}
8569
]
8670
}
8771
},
@@ -91,21 +75,11 @@ module.exports = function (grunt) {
9175
'dist/angular-busy.min.css': 'dist/angular-busy.css'
9276
}
9377
}
94-
}
78+
}
9579
});
9680

97-
grunt.loadNpmTasks('grunt-regarde');
98-
grunt.loadNpmTasks('grunt-contrib-connect');
99-
grunt.loadNpmTasks('grunt-contrib-livereload');
100-
grunt.loadNpmTasks('grunt-contrib-copy');
101-
grunt.loadNpmTasks('grunt-contrib-uglify');
102-
grunt.loadNpmTasks('grunt-contrib-jshint');
103-
grunt.loadNpmTasks('grunt-contrib-jasmine');
104-
grunt.loadNpmTasks('grunt-contrib-cssmin');
105-
grunt.loadNpmTasks('grunt-contrib-concat');
106-
grunt.loadNpmTasks('grunt-angular-templates');
107-
108-
grunt.registerTask('server', ['livereload-start','jshint','connect', 'regarde']);
109-
grunt.registerTask('build',['copy','ngtemplates','concat','uglify','cssmin']);
81+
grunt.registerTask('serve', ['jshint','connect', 'watch']);
82+
grunt.registerTask('build',['ngtemplates','concat','uglify','copy','cssmin']);
11083
grunt.registerTask('test',['build','jasmine']);
84+
11185
};

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,101 @@
11
# angular-busy [![Build Status](https://travis-ci.org/cgross/angular-busy.png?branch=master)](https://travis-ci.org/cgross/angular-busy)
22

3-
> Show busy/loading indicators on any element during $http requests (or any promise).
4-
5-
This library depends on v1.5 of [Andy Joslin's angular-promise-tracker](https://github.com/ajoslin/angular-promise-tracker).
6-
7-
Annotate an `$http` request using `angular-promise-tracker` and add `cg-busy` on an element to display a busy
8-
indication on a specific element during the `$http` request.
9-
10-
This library builds on Angular 1.2 and the new Angular animate module in `animate.js`.
11-
12-
Supports IE 10, and recent versions of FF and Chrome.
3+
> Show busy/loading indicators on any $http or $resource request, or on any promise.
134
145
## Demo
156

167
[Live Demo](http://cgross.github.io/angular-busy/demo)
178

189
## Getting Started
1910

20-
Add `dist/angular-busy.js` and `dist/angular-busy.css` to your index.html. Also add the `angular-promise-tracker` files as necessary.
11+
Install with Bower or download the the files directly from the dist folder in the repo.
12+
13+
```bash
14+
bower install angular-busy --save
15+
```
16+
17+
Add `dist/angular-busy.js` and `dist/angular-busy.css` to your index.html.
2118

22-
Add `cgBusy` as a module dependency for your module (in addition to `ajoslin.promise-tracker` and the Angular 1.2 `ngAnimate` module):
19+
Add `cgBusy` as a module dependency for your module.
2320

2421
```js
25-
angular.module('your_app', ['ngAnimate','ajoslin.promise-tracker','cgBusy']);
22+
angular.module('your_app', ['cgBusy']);
2623
```
2724

28-
Add the promise trackers as you normally would using `angular-promise-tracker`:
25+
Add your promise to $scope and reference that in the `cg-busy` directive:
2926

3027
```js
31-
function MyCtrl($scope) {
28+
function MyCtrl($scope,$http,User) {
3229

33-
$scope.pizzaFlavor = $http.get('/pizzaFlavor', { tracker: 'pizza' });
30+
//using $http
31+
$scope.myPromise = $http.get('...');
32+
33+
//if you have a User class based on $resource
34+
$scope.myPromise = User.$save();
3435

3536
}
3637
```
3738

38-
Add `cg-busy` to the elements you wish to be _busy_ during those requests:
39-
4039
```html
41-
<div cg-busy="'pizza'"></div>
40+
<!-- Use the simple syntax -->
41+
<div cg-busy="myPromise"></div>
42+
43+
<!-- Use the advanced syntax -->
44+
<div cg-busy="{promise:myPromise,message:'Loading Your Data',templateUrl:'mycustomtemplate.html'}"></div>
4245
```
4346

4447
## Options
4548

46-
The `cg-busy` directive expects a value that is interpreted as an expression. The value may be specified as an object literal
47-
or simply as a string if only the `tracker` value is provided.
49+
The `cg-busy` directive expects either a promise or a configuration object.
4850

4951
In other words. You may do this:
5052

5153
```html
52-
<div cg-busy="'my_tracker'"></div> <!-- Notice the extra single quotes because its an expression -->
54+
<div cg-busy="myPromise"></div>
5355
```
5456

5557
or this:
5658

5759
```html
58-
<div cg-busy="{tracker:'my_tracker',backdrop:false,template:'myAwesomeTemplate.html'}"></div>
60+
<div cg-busy="{promise:myPromise,message:'Loading',backdrop:false,templateUrl:'myAwesomeTemplate.html',delay:300,minDuration:700}"></div>
5961
```
6062

61-
* `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.
63+
* `promise` - Required. The promise (or array of promises) that will cause the busy indicator to show.
64+
* `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.
6265
* `backdrop` - Optional. Boolean, default is true. If true a faded backdrop will be shown behind the progress indicator.
63-
* `template` - Optional. If provided, the given template will be shown in place of the default progress
64-
indicatory template. Use this to override the default UI and provide your own.
66+
* `templateUrl` - Optional. If provided, the given template will be shown in place of the default progress indicatory template.
67+
* `delay` - Optional. The amount of time to wait until showing the indicator. Defaults to 0. Specified in milliseconds.
68+
* `minDuration` - Optional. The amount of time to keep the indicator showing even if the promise was resolved quicker. Defaults to 0. Specified in milliseconds.
6569

6670
## Providing Custom Templates
6771

68-
The default progress template shows a spinner and a 'Please Wait...' message. But you can define custom templates per instance
69-
(as shown above) or change the global default template. To change the global default template just provide a new
70-
`$injector` value for `cgBusyTemplateName`. Ex:
72+
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.
73+
74+
## Overriding Defaults
7175

72-
```js
73-
angular.module('yourapp').value('cgBusyTemplateName','your_custom_template_here.html');
76+
The defaut values for `message`, `backdrop`, `templateUrl`, `delay`, and `minDuration` may all be overriden by overriding the `$injector` value for `cgBusyDefaults`, like so:
77+
78+
```js
79+
angular.module('your_app').value('cgBusyDefaults',{
80+
message:'Loading Stuff',
81+
backdrop: false,
82+
templateUrl: 'my_custom_template.html',
83+
delay: 300,
84+
minDuration: 700
85+
});
7486
```
7587

76-
Templates are full, normal Angular partials with access to the scope of where the `cg-busy` was used.
88+
Only the values you'd like overriden need to be specified.
89+
7790

7891
## Release History
92+
* v4.0.0 - Big update
93+
* Dependency on angular-promise-tracker has been removed. We now track promises directly.
94+
* Message is now configurable.
95+
* The template options is now templateUrl.
96+
* The delay option has been added.
97+
* The minDuration option has been added.
98+
* Changing default template has been modified to be part of the new `cgBusyDefaults` value.
7999
* v3.0.2 - Reverting back to promise-tracker v1.5 due to changes in the api.
80100
* v3.0.1 - Fix for using cg-busy when a tracker has already been registered.
81101
* v3.0.0 - Support for new promise-tracker api. Fix for multiple cg-busy's on the same scope.

angular-busy.css

100644100755
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@
5454

5555
/* All styles below are for the default template. */
5656

57+
.cg-busy-default-wrapper {
58+
text-align:center;
59+
}
60+
5761
.cg-busy-default-sign{
58-
position:absolute;
59-
top:0;
60-
left:50%;
61-
margin-left:-100px;
62-
width:170px;
63-
height:50px;
62+
display: inline-block;
63+
position:relative;
64+
padding-bottom: 6px;
6465
color:#333333;
6566
text-shadow:0 1px 1px rgba(255, 255, 255, 0.75);
6667
background-color:#e9eeee;
@@ -76,11 +77,11 @@
7677
box-shadow:inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
7778
}
7879
.cg-busy-default-text{
79-
position:absolute;
80-
left:49px;
81-
top:15px;
80+
margin:13px 12px 6px 49px;
8281
font-size:16px;
8382
color:#555;
83+
text-align: left;
84+
max-width: 400px;
8485
}
8586
.cg-busy-default-spinner{
8687
position:absolute;

angular-busy.html

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="bar12"></div>
1818
</div>
1919

20-
<div class="cg-busy-default-text">Please Wait...</div>
20+
<div class="cg-busy-default-text">{{$message}}</div>
2121

2222
</div>
2323

0 commit comments

Comments
 (0)