Skip to content

Commit

Permalink
v4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cgross committed Apr 18, 2014
1 parent 2edf5ac commit 56c0dad
Show file tree
Hide file tree
Showing 131 changed files with 44,090 additions and 911 deletions.
Empty file modified .bowerrc
100644 → 100755
Empty file.
4 changes: 1 addition & 3 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ npm-debug.log
node_modules
.DS_Store

temp
components
bower_components
temp
28 changes: 28 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"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,
"_": true,
"moment": true,
"describe": true,
"beforeEach": true,
"module": true,
"inject": true,
"it": true,
"expect": true
}
}
Empty file modified .travis.yml
100644 → 100755
Empty file.
100 changes: 37 additions & 63 deletions Gruntfile.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,68 +1,45 @@
'use strict';
var path = require('path');

var folderMount = function folderMount(connect, point) {
return connect.static(path.resolve(point));
};

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: {
specs: 'test/*.js'
}
}
},
copy: {
main: {
files: [
{src:'angular-busy.css',dest:'dist/'}
]
}
},
ngtemplates: {
ngtemplates: {
main: {
options: {
module:'cgBusy',
Expand All @@ -71,17 +48,24 @@ module.exports = function (grunt) {
src:'angular-busy.html',
dest: 'temp/templates.js'
}
},
concat: {
},
concat: {
main: {
src: ['angular-busy.js', 'temp/templates.js'],
dest: 'dist/angular-busy.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'}
]
}
},
Expand All @@ -91,21 +75,11 @@ module.exports = function (grunt) {
'dist/angular-busy.min.css': 'dist/angular-busy.css'
}
}
}
}
});

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('server', ['livereload-start','jshint','connect', 'regarde']);
grunt.registerTask('build',['copy','ngtemplates','concat','uglify','cssmin']);
grunt.registerTask('serve', ['jshint','connect', 'watch']);
grunt.registerTask('build',['ngtemplates','concat','uglify','copy','cssmin']);
grunt.registerTask('test',['build','jasmine']);

};
Empty file modified LICENSE
100644 → 100755
Empty file.
84 changes: 52 additions & 32 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,81 +1,101 @@
# 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).
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.
> Show busy/loading indicators on any $http or $resource request, or on any promise.
## Demo

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

## Getting Started

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.

```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 (in addition to `ajoslin.promise-tracker` and the Angular 1.2 `ngAnimate` module):
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
<div cg-busy="'pizza'"></div>
<!-- Use the simple syntax -->
<div cg-busy="myPromise"></div>

<!-- Use the advanced syntax -->
<div cg-busy="{promise:myPromise,message:'Loading Your Data',templateUrl:'mycustomtemplate.html'}"></div>
```

## Options

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.

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>
```

or this:

```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.

## Overriding Defaults

```js
angular.module('yourapp').value('cgBusyTemplateName','your_custom_template_here.html');
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.
* v3.0.1 - Fix for using cg-busy when a tracker has already been registered.
* v3.0.0 - Support for new promise-tracker api. Fix for multiple cg-busy's on the same scope.
Expand Down
19 changes: 10 additions & 9 deletions angular-busy.css
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@

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

.cg-busy-default-wrapper {
text-align:center;
}

.cg-busy-default-sign{
position:absolute;
top:0;
left:50%;
margin-left:-100px;
width:170px;
height:50px;
display: inline-block;
position:relative;
padding-bottom: 6px;
color:#333333;
text-shadow:0 1px 1px rgba(255, 255, 255, 0.75);
background-color:#e9eeee;
Expand All @@ -76,11 +77,11 @@
box-shadow:inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
}
.cg-busy-default-text{
position:absolute;
left:49px;
top:15px;
margin:13px 12px 6px 49px;
font-size:16px;
color:#555;
text-align: left;
max-width: 400px;
}
.cg-busy-default-spinner{
position:absolute;
Expand Down
2 changes: 1 addition & 1 deletion angular-busy.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="bar12"></div>
</div>

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

</div>

Expand Down
Loading

0 comments on commit 56c0dad

Please sign in to comment.