Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
grbsk committed Jun 19, 2014
2 parents 336d0b3 + afaa301 commit 0b9f048
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-busy",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/HackedByChinese/ng-busy",
"authors": [
"Mike Grabski <me@mikegrabski.com>"
Expand Down
14 changes: 6 additions & 8 deletions build/angular-busy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*** An AngularJS module for reacting to when your app is busy.
* @author Mike Grabski <me@mikegrabski.com>
* @version v0.1.2
* @version v0.1.3
* @link https://github.com/HackedByChinese/ng-busy.git
* @license MIT
*/
Expand All @@ -10,7 +10,7 @@
angular.module('ngBusy.interceptor', [])
.provider('busyInterceptor', function() {

this.$get = function($rootScope, $q) {
this.$get = ['$rootScope', '$q', function($rootScope, $q) {
var _total = 0, _completed = 0;

function complete() {
Expand Down Expand Up @@ -44,17 +44,15 @@
return $q.reject(rejection);
}
};
};

this.$get.$inject = ['$rootScope', '$q'];
}];
})
.config(['$httpProvider', function($httpProvider) {
.config(['$httpProvider', function($httpProvider) {
$httpProvider.interceptors.push('busyInterceptor');
}]);

// minimal: <button busy="Loading..." />
// complete: <button busy="Loading..." busy-when-url="string" busy-when-name="string" busy-add-classes="string" busy-remove-classes="string" busy-disabled="bool" not-busy-when-url="string" not-busy-when-name="string" not-busy-add-classes="string" not-busy-remove-classes="string" not-busy-disabled="bool" />

angular.module('ngBusy.busy', [])
.directive('busy', ['$parse', '$timeout', function($parse, $timeout) {
return {
Expand Down Expand Up @@ -155,4 +153,4 @@
});

angular.module('ngBusy', ['ngBusy.interceptor', 'ngBusy.busy']);
})(window, window.angular);
})(window, window.angular);
2 changes: 1 addition & 1 deletion build/angular-busy.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build/angular-busy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-busy",
"version": "0.1.2",
"version": "0.1.3",
"description": "An AngularJS module for reacting to when your app is busy.",
"main": [
"build/angular-busy.js",
Expand Down
12 changes: 5 additions & 7 deletions src/angular-busy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
angular.module('ngBusy.interceptor', [])
.provider('busyInterceptor', function() {

this.$get = function($rootScope, $q) {
this.$get = ['$rootScope', '$q', function($rootScope, $q) {
var _total = 0, _completed = 0;

function complete() {
Expand Down Expand Up @@ -39,17 +39,15 @@
return $q.reject(rejection);
}
};
};

this.$get.$inject = ['$rootScope', '$q'];
}];
})
.config(['$httpProvider', function($httpProvider) {
.config(['$httpProvider', function($httpProvider) {
$httpProvider.interceptors.push('busyInterceptor');
}]);

// minimal: <button busy="Loading..." />
// complete: <button busy="Loading..." busy-when-url="string" busy-when-name="string" busy-add-classes="string" busy-remove-classes="string" busy-disabled="bool" not-busy-when-url="string" not-busy-when-name="string" not-busy-add-classes="string" not-busy-remove-classes="string" not-busy-disabled="bool" />

angular.module('ngBusy.busy', [])
.directive('busy', ['$parse', '$timeout', function($parse, $timeout) {
return {
Expand Down Expand Up @@ -150,4 +148,4 @@
});

angular.module('ngBusy', ['ngBusy.interceptor', 'ngBusy.busy']);
})(window, window.angular);
})(window, window.angular);
24 changes: 12 additions & 12 deletions src/angular-busy.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

describe('ngBusy', function() {

beforeEach(function () {
this.addMatchers({
toEqualData: function (expected) {
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('ngBusy', function() {
});

$http.get('path', {name: 'test'});

$httpBackend.flush();
});

Expand Down Expand Up @@ -87,7 +87,7 @@ describe('ngBusy', function() {
});

$http.get('path', {notBusy:true});

$httpBackend.flush();
});

Expand All @@ -100,7 +100,7 @@ describe('ngBusy', function() {
$httpBackend.flush();

expect(interceptor.outstanding()).toBe(0);
expect($rootScope.$broadcast).not.toHaveBeenCalled();
expect($rootScope.$broadcast).not.toHaveBeenCalled();
});

it ('should ignore rejections if notBusy is true', function() {
Expand Down Expand Up @@ -179,13 +179,13 @@ describe('ngBusy', function() {

it ('should swap busy message with original content on busy.end with zero remaining', function() {
var el = create(), $scope = el.isolateScope();
$rootScope.$broadcast('busy.begin', {url: '/path', name: 'name'});

$rootScope.$broadcast('busy.begin', {url: '/path', name: 'name'});
expect($scope.busy).toBe(true);

$rootScope.$broadcast('busy.end', {url: '/path', name: 'name', remaining: 0});
expect($scope.busy).toBe(false);
expect(el.html()).toBe('<i class="icon-ok"></i> Submit');
expect(el.html()).toBe('<i class="icon-ok"></i> Submit');
});

it ('should disable buttons when busy then restore', function() {
Expand Down Expand Up @@ -287,22 +287,22 @@ describe('ngBusy', function() {
});

it ('should transclude child busy-message directive when present and use as busyMessage', function() {
var testValue = 'I\'m busy', expectedBusyMessage = '<strong class="ng-scope ng-binding">' + testValue + '</strong>', expectedNotBusyMessage = '<busy-message></busy-message><em>Submit</em>';
var testValue = 'I\'m busy', expectedNotBusyMessage = '<busy-message></busy-message><em>Submit</em>';

$rootScope.testValue = testValue;

var el = create('<button busy><busy-message><strong>{{testValue}}</strong></busy-message><em>Submit</em></button>'), $scope = el.isolateScope();

expect(el.html()).toBe(expectedNotBusyMessage);
expect($scope.busyMessageElement[0].outerHTML).toBe(expectedBusyMessage);
expect($scope.busyMessageElement[0].outerHTML).toMatch('<strong class="[a-z\\-\\s]+">I\'m busy</strong>');

$rootScope.$broadcast('busy.begin');

expect(el.html()).toBe(expectedBusyMessage);
expect(el.html()).toMatch('<strong class="[a-z\\-\\s]+">I\'m busy</strong>');

$rootScope.$broadcast('busy.end', {remaining: 0});

expect(el.html()).toBe(expectedNotBusyMessage);
});
});
});
});

0 comments on commit 0b9f048

Please sign in to comment.