New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular2-promise-buttons

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-promise-buttons - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

dist/angular2-promise-buttons.module.metadata.json

5

CHANGELOG.md

@@ -0,1 +1,6 @@

<a name="1.0.4"></a>
## [1.0.4](https://github.com/johannesjo/angular2-promise-buttons/compare/v1.0.3...v1.0.4) (2017-05-10)
<a name="1.0.3"></a>

@@ -2,0 +7,0 @@ ## [1.0.3](https://github.com/johannesjo/angular2-promise-buttons/compare/v1.0.2...v1.0.3) (2017-05-10)

60

dist/angular2-promise-buttons.module.js

@@ -1,37 +0,31 @@

var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { NgModule } from '@angular/core';
import { PromiseBtnDirective } from './promise-btn.directive';
import { userCfg } from './user-cfg';
var Angular2PromiseButtonModule = Angular2PromiseButtonModule_1 = (function () {
function Angular2PromiseButtonModule() {
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@angular/core");
const promise_btn_directive_1 = require("./promise-btn.directive");
const user_cfg_1 = require("./user-cfg");
class Angular2PromiseButtonModule {
// add forRoot to make it configurable
Angular2PromiseButtonModule.forRoot = function (userCfgPassedByUser) {
static forRoot(userCfgPassedByUser) {
// NOTE: this is never allowed to contain any conditional logic
return {
ngModule: Angular2PromiseButtonModule_1,
providers: [{ provide: userCfg, useValue: userCfgPassedByUser }]
ngModule: Angular2PromiseButtonModule,
providers: [{ provide: user_cfg_1.userCfg, useValue: userCfgPassedByUser }]
};
};
return Angular2PromiseButtonModule;
}());
Angular2PromiseButtonModule = Angular2PromiseButtonModule_1 = __decorate([
NgModule({
declarations: [
PromiseBtnDirective,
],
imports: [],
exports: [
PromiseBtnDirective,
],
providers: []
})
], Angular2PromiseButtonModule);
export { Angular2PromiseButtonModule };
var Angular2PromiseButtonModule_1;
//# sourceMappingURL=/home/johannes/www/angular2-promise-buttons/angular2-promise-buttons.module.js.map
}
}
Angular2PromiseButtonModule.decorators = [
{ type: core_1.NgModule, args: [{
declarations: [
promise_btn_directive_1.PromiseBtnDirective,
],
imports: [],
exports: [
promise_btn_directive_1.PromiseBtnDirective,
],
providers: []
},] },
];
/** @nocollapse */
Angular2PromiseButtonModule.ctorParameters = () => [];
exports.Angular2PromiseButtonModule = Angular2PromiseButtonModule;
//# sourceMappingURL=angular2-promise-buttons.module.js.map

@@ -1,2 +0,4 @@

export var DEFAULT_CFG = {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_CFG = {
spinnerTpl: '<span class="btn-spinner"></span>',

@@ -9,2 +11,2 @@ disableBtn: true,

};
//# sourceMappingURL=/home/johannes/www/angular2-promise-buttons/default-promise-btn-config.js.map
//# sourceMappingURL=default-promise-btn-config.js.map

@@ -1,3 +0,7 @@

export { PromiseBtnDirective } from './promise-btn.directive';
export { Angular2PromiseButtonModule } from './angular2-promise-buttons.module';
//# sourceMappingURL=/home/johannes/www/angular2-promise-buttons/index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var promise_btn_directive_1 = require("./promise-btn.directive");
exports.PromiseBtnDirective = promise_btn_directive_1.PromiseBtnDirective;
var angular2_promise_buttons_module_1 = require("./angular2-promise-buttons.module");
exports.Angular2PromiseButtonModule = angular2_promise_buttons_module_1.Angular2PromiseButtonModule;
//# sourceMappingURL=index.js.map

@@ -1,1 +0,3 @@

//# sourceMappingURL=/home/johannes/www/angular2-promise-buttons/promise-btn-config.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=promise-btn-config.js.map

@@ -1,38 +0,24 @@

var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
import { Directive, ElementRef, Inject, Input, Renderer2 } from '@angular/core';
import { DEFAULT_CFG } from './default-promise-btn-config';
import { userCfg } from './user-cfg';
var PromiseBtnDirective = (function () {
function PromiseBtnDirective(el, userCfg, renderer) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@angular/core");
const default_promise_btn_config_1 = require("./default-promise-btn-config");
const user_cfg_1 = require("./user-cfg");
class PromiseBtnDirective {
constructor(el, userCfg, renderer) {
this.renderer = renderer;
// provide configuration
this.cfg = Object.assign({}, DEFAULT_CFG, userCfg);
this.cfg = Object.assign({}, default_promise_btn_config_1.DEFAULT_CFG, userCfg);
// save element
this.btnEl = el.nativeElement;
}
Object.defineProperty(PromiseBtnDirective.prototype, "promiseBtn", {
set: function (promise) {
this.promise = promise;
this.checkAndInitPromiseHandler(this.btnEl);
},
enumerable: true,
configurable: true
});
PromiseBtnDirective.prototype.ngAfterContentInit = function () {
set promiseBtn(promise) {
this.promise = promise;
this.checkAndInitPromiseHandler(this.btnEl);
}
ngAfterContentInit() {
this.prepareBtnEl(this.btnEl);
// trigger changes once to handle initial promises
this.checkAndInitPromiseHandler(this.btnEl);
};
PromiseBtnDirective.prototype.ngOnDestroy = function () {
}
ngOnDestroy() {
// cleanup

@@ -42,3 +28,3 @@ if (this.minDurationTimeout) {

}
};
}
/**

@@ -48,7 +34,7 @@ * Initializes all html and event handlers

*/
PromiseBtnDirective.prototype.prepareBtnEl = function (btnEl) {
prepareBtnEl(btnEl) {
// handle promises passed via promiseBtn attribute
this.appendSpinnerTpl(btnEl);
this.addHandlersForCurrentBtnOnlyIfSet(btnEl);
};
}
/**

@@ -58,3 +44,3 @@ * Checks if all required parameters are there and inits the promise handler

*/
PromiseBtnDirective.prototype.checkAndInitPromiseHandler = function (btnEl) {
checkAndInitPromiseHandler(btnEl) {
if (btnEl && this.promise) {

@@ -65,3 +51,3 @@ if (!this.promiseWatcher) {

}
};
}
/**

@@ -71,7 +57,7 @@ * Helper FN to add class

*/
PromiseBtnDirective.prototype.addLoadingClass = function (el) {
addLoadingClass(el) {
if (typeof this.cfg.btnLoadingClass === 'string') {
this.renderer.addClass(el, this.cfg.btnLoadingClass);
}
};
}
/**

@@ -81,7 +67,7 @@ * Helper FN to remove classes

*/
PromiseBtnDirective.prototype.removeLoadingClass = function (el) {
removeLoadingClass(el) {
if (typeof this.cfg.btnLoadingClass === 'string') {
this.renderer.removeClass(el, this.cfg.btnLoadingClass);
}
};
}
/**

@@ -92,3 +78,3 @@ * Handles everything to be triggered when the button is set

*/
PromiseBtnDirective.prototype.initLoadingState = function (btnEl) {
initLoadingState(btnEl) {
if (this.cfg.btnLoadingClass) {

@@ -100,3 +86,3 @@ this.addLoadingClass(btnEl);

}
};
}
/**

@@ -106,3 +92,3 @@ * Handles everything to be triggered when loading is finished

*/
PromiseBtnDirective.prototype.cancelLoadingStateIfPromiseAndMinDurationDone = function (btnEl) {
cancelLoadingStateIfPromiseAndMinDurationDone(btnEl) {
if ((!this.cfg.minDuration || this.isMinDurationTimeoutDone) && this.isPromiseDone) {

@@ -116,15 +102,15 @@ if (this.cfg.btnLoadingClass) {

}
};
}
/**
* @param {Object}btnEl
*/
PromiseBtnDirective.prototype.disableBtn = function (btnEl) {
disableBtn(btnEl) {
this.renderer.setAttribute(btnEl, 'disabled', 'disabled');
};
}
/**
* @param {Object}btnEl
*/
PromiseBtnDirective.prototype.enableBtn = function (btnEl) {
enableBtn(btnEl) {
this.renderer.removeAttribute(btnEl, 'disabled');
};
}
/**

@@ -136,4 +122,3 @@ * Initializes a watcher for the promise. Also takes

*/
PromiseBtnDirective.prototype.initPromiseHandler = function (promise, btnEl) {
var _this = this;
initPromiseHandler(promise, btnEl) {
// watch promise to resolve or fail

@@ -144,10 +129,10 @@ this.isMinDurationTimeoutDone = false;

if (this.cfg.minDuration) {
this.minDurationTimeout = setTimeout(function () {
_this.isMinDurationTimeoutDone = true;
_this.cancelLoadingStateIfPromiseAndMinDurationDone(btnEl);
this.minDurationTimeout = setTimeout(() => {
this.isMinDurationTimeoutDone = true;
this.cancelLoadingStateIfPromiseAndMinDurationDone(btnEl);
}, this.cfg.minDuration);
}
var resolveLoadingState = function () {
_this.isPromiseDone = true;
_this.cancelLoadingStateIfPromiseAndMinDurationDone(btnEl);
const resolveLoadingState = () => {
this.isPromiseDone = true;
this.cancelLoadingStateIfPromiseAndMinDurationDone(btnEl);
};

@@ -168,3 +153,3 @@ // for regular promises

}
};
}
/**

@@ -174,6 +159,6 @@ * $compile and append the spinner template to the button.

*/
PromiseBtnDirective.prototype.appendSpinnerTpl = function (btnEl) {
appendSpinnerTpl(btnEl) {
// TODO add some kind of compilation later on
btnEl.insertAdjacentHTML('beforeend', this.cfg.spinnerTpl);
};
}
/**

@@ -184,26 +169,26 @@ * Used to limit loading state to show only for the currently

*/
PromiseBtnDirective.prototype.addHandlersForCurrentBtnOnlyIfSet = function (btnEl) {
var _this = this;
addHandlersForCurrentBtnOnlyIfSet(btnEl) {
// handle current button only options via click
if (this.cfg.handleCurrentBtnOnly) {
btnEl.addEventListener(this.cfg.CLICK_EVENT, function () {
_this.initLoadingState(btnEl);
btnEl.addEventListener(this.cfg.CLICK_EVENT, () => {
this.initLoadingState(btnEl);
});
}
};
return PromiseBtnDirective;
}());
__decorate([
Input(),
__metadata("design:type", Object),
__metadata("design:paramtypes", [Object])
], PromiseBtnDirective.prototype, "promiseBtn", null);
PromiseBtnDirective = __decorate([
Directive({
selector: '[promiseBtn]'
}),
__param(1, Inject(userCfg)),
__metadata("design:paramtypes", [ElementRef, Object, Renderer2])
], PromiseBtnDirective);
export { PromiseBtnDirective };
//# sourceMappingURL=/home/johannes/www/angular2-promise-buttons/promise-btn.directive.js.map
}
}
PromiseBtnDirective.decorators = [
{ type: core_1.Directive, args: [{
selector: '[promiseBtn]'
},] },
];
/** @nocollapse */
PromiseBtnDirective.ctorParameters = () => [
{ type: core_1.ElementRef, },
{ type: undefined, decorators: [{ type: core_1.Inject, args: [user_cfg_1.userCfg,] },] },
{ type: core_1.Renderer2, },
];
PromiseBtnDirective.propDecorators = {
'promiseBtn': [{ type: core_1.Input },],
};
exports.PromiseBtnDirective = PromiseBtnDirective;
//# sourceMappingURL=promise-btn.directive.js.map

@@ -1,3 +0,5 @@

import { InjectionToken } from '@angular/core';
export var userCfg = new InjectionToken('cfg');
//# sourceMappingURL=/home/johannes/www/angular2-promise-buttons/user-cfg.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@angular/core");
exports.userCfg = new core_1.InjectionToken('cfg');
//# sourceMappingURL=user-cfg.js.map
{
"name": "angular2-promise-buttons",
"version": "1.0.3",
"version": "1.0.4",
"license": "MIT",

@@ -21,3 +21,3 @@ "repository": {

"build.clean": "rm -Rf ./dist",
"build.compile": "./node_modules/typescript/bin/tsc -p src",
"build.compile": "ngc -p ./tsconfig.build-lib.json",
"dev": "ng serve",

@@ -55,2 +55,3 @@ "start": "run-s dev",

"@angular/router": "^4.0.0",
"@types/core-js": "^0.9.41",
"@types/jasmine": "2.5.38",

@@ -57,0 +58,0 @@ "@types/node": "~6.0.60",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc