az-promise-show
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -0,1 +1,7 @@ | ||
# 1.1.0 | ||
## New Features | ||
- Adding the `constant` `azPromiseShowOptions` which has a `className` property which you can set to customize the class applied to the element when it should be hidden. | ||
# 1.0.1 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "az-promise-show", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "angular directives to show or hide an element based on the state of a promise", | ||
@@ -16,3 +16,3 @@ "main": "dist/az-promise-show.js", | ||
"babel-loader": "5.1.4", | ||
"better-npm-run": "benoror/better-npm-run", | ||
"better-npm-run": "benoror/better-npm-run#0.0.1", | ||
"chai": "3.0.0", | ||
@@ -43,2 +43,3 @@ "codecov.io": "0.1.2", | ||
"build": "npm run build:dist & npm run build:prod", | ||
"start": "npm run test", | ||
"test": "better-npm-run test", | ||
@@ -45,0 +46,0 @@ "test:ci": "npm run test:single && npm run check-coverage", |
@@ -13,2 +13,3 @@ // some versions of angular don't export the angular module properly, | ||
.module('azPromiseShow', []) | ||
.constant('azPromiseShowOptions', {className: 'ng-hide'}) | ||
.directive('azPromiseShow', azPromise(true)) | ||
@@ -22,8 +23,8 @@ .directive('azPromiseHide', azPromise(false)) | ||
var changeFrom = show ? 'addClass' : 'removeClass'; | ||
return /* @ngInject */ function azPromiseShowDefinition($log) { | ||
return /* @ngInject */ function azPromiseShowDefinition($log, azPromiseShowOptions) { | ||
return { | ||
restrict: 'A', | ||
link: function(scope, el, attrs) { | ||
var displayNone = attrs.azPromiseShowHideClass || 'ng-hide'; | ||
scope.$watch(attrs[attr], function(newVal) { | ||
var displayNone = attrs.azPromiseShowHideClass || azPromiseShowOptions.className; | ||
if (newVal) { | ||
@@ -30,0 +31,0 @@ if (!newVal.finally) { |
@@ -10,8 +10,9 @@ import 'angular'; | ||
const basicTemplate = '<div az-promise-show="aPromise"></div>'; | ||
let scope, el, $timeout, $compile; | ||
let scope, el, $timeout, $compile, options; | ||
beforeEach(inject((_$compile_, $rootScope, _$timeout_) => { | ||
beforeEach(inject((_$compile_, $rootScope, _$timeout_, azPromiseShowOptions) => { | ||
$timeout = _$timeout_; | ||
$compile = _$compile_; | ||
scope = $rootScope.$new(); | ||
options = azPromiseShowOptions; | ||
})); | ||
@@ -53,2 +54,13 @@ | ||
it(`should allow you to configure a custom class using 'azPromiseShowOptions'`, () => { | ||
options.className = 'custom-class'; | ||
compileAndDigest(); | ||
scope.aPromise = $timeout(() => {}); | ||
scope.$digest(); | ||
expectShowing(options.className); | ||
$timeout.flush(); | ||
scope.$digest(); | ||
expectHidden(options.className); | ||
}); | ||
function compileAndDigest(template = basicTemplate) { | ||
@@ -55,0 +67,0 @@ el = $compile(template)(scope); |
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
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
24334
210