angular-countdown-date-time
Version:
angular countdown by end time
196 lines (187 loc) • 8.81 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
typeof define === 'function' && define.amd ? define('angular-countdown-date-time', ['exports', '@angular/core'], factory) :
(factory((global['angular-countdown-date-time'] = {}),global.ng.core));
}(this, (function (exports,i0) { 'use strict';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var AngularCountdownDateTimeService = /** @class */ (function () {
function AngularCountdownDateTimeService() {
}
AngularCountdownDateTimeService.decorators = [
{ type: i0.Injectable, args: [{
providedIn: 'root'
},] }
];
/** @nocollapse */
AngularCountdownDateTimeService.ctorParameters = function () { return []; };
/** @nocollapse */ AngularCountdownDateTimeService.ngInjectableDef = i0.defineInjectable({ factory: function AngularCountdownDateTimeService_Factory() { return new AngularCountdownDateTimeService(); }, token: AngularCountdownDateTimeService, providedIn: "root" });
return AngularCountdownDateTimeService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var AngularCountdownDateTimeComponent = /** @class */ (function () {
function AngularCountdownDateTimeComponent() {
debugger;
}
/**
* @return {?}
*/
AngularCountdownDateTimeComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
debugger;
this.endDate = new Date(this.endDateBind);
setInterval(( /**
* @return {?}
*/function () {
/** @type {?} */
var end = _this.endDate.toDateString();
/** @type {?} */
var start = new Date().toDateString();
_this.diff = Math.floor((_this.endDate.getTime() - new Date().getTime()) / 1000);
_this.dayTextBind = _this.dayText;
_this.hourTextBind = _this.hourText;
_this.minutesTextBind = _this.minutesText;
_this.secondsTextBind = _this.secondsText;
_this.days = _this.getDays(_this.diff);
_this.hours = _this.getHours(_this.diff);
_this.minutes = _this.getMinutes(_this.diff);
_this.seconds = _this.getSeconds(_this.diff);
}), 1000);
};
/**
* @param {?} t
* @return {?}
*/
AngularCountdownDateTimeComponent.prototype.getDays = /**
* @param {?} t
* @return {?}
*/
function (t) {
/** @type {?} */
var days;
days = Math.floor(t / 86400);
return ('0' + days).slice(-2);
};
/**
* @param {?} t
* @return {?}
*/
AngularCountdownDateTimeComponent.prototype.getHours = /**
* @param {?} t
* @return {?}
*/
function (t) {
/** @type {?} */
var days;
/** @type {?} */
var hours;
days = Math.floor(t / 86400);
t -= days * 86400;
hours = Math.floor(t / 3600) % 24;
return ('0' + hours).slice(-2);
};
/**
* @param {?} t
* @return {?}
*/
AngularCountdownDateTimeComponent.prototype.getMinutes = /**
* @param {?} t
* @return {?}
*/
function (t) {
/** @type {?} */
var days;
/** @type {?} */
var hours;
/** @type {?} */
var minutes;
days = Math.floor(t / 86400);
t -= days * 86400;
hours = Math.floor(t / 3600) % 24;
t -= hours * 3600;
minutes = Math.floor(t / 60) % 60;
return ('0' + minutes).slice(-2);
};
/**
* @param {?} t
* @return {?}
*/
AngularCountdownDateTimeComponent.prototype.getSeconds = /**
* @param {?} t
* @return {?}
*/
function (t) {
/** @type {?} */
var days;
/** @type {?} */
var hours;
/** @type {?} */
var minutes;
/** @type {?} */
var seconds;
days = Math.floor(t / 86400);
t -= days * 86400;
hours = Math.floor(t / 3600) % 24;
t -= hours * 3600;
minutes = Math.floor(t / 60) % 60;
t -= minutes * 60;
seconds = t % 60;
return ('0' + seconds).slice(-2);
};
AngularCountdownDateTimeComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'lib-angular-countdown-dateTime',
template: "<div class=\"count-down\">\r\n <div class=\"count-down-row\">\r\n <div>\r\n <span>\r\n {{days}}\r\n </span>\r\n </div>\r\n <div>\r\n <span>\r\n {{hours}}\r\n </span>\r\n </div>\r\n <div>\r\n <span>\r\n {{minutes}}\r\n </span>\r\n </div>\r\n <div>\r\n <span>\r\n {{seconds}}\r\n </span>\r\n </div>\r\n </div>\r\n <div class=\"count-down-row\">\r\n <div>\r\n {{dayTextBind}}\r\n </div>\r\n <div>\r\n {{hourTextBind}}\r\n </div>\r\n <div>\r\n {{minutesTextBind}}\r\n </div>\r\n <div>\r\n {{secondsTextBind}}\r\n </div>\r\n </div>\r\n</div>\r\n\r\n",
encapsulation: i0.ViewEncapsulation.None,
styles: [".count-down{background:#fff;border:0 solid #dadada;border-radius:4.48px;position:relative;width:100%;padding:20px 0 10px}.count-down .count-down-row{display:flex;flex-direction:row;justify-content:center;align-items:center;text-align:center}.count-down .count-down-row>div{flex-grow:1;padding-bottom:10px;width:25%}.count-down span{letter-spacing:0;font-size:1.5em;color:#616161;text-align:center;font-weight:500}"]
}] }
];
/** @nocollapse */
AngularCountdownDateTimeComponent.ctorParameters = function () { return []; };
AngularCountdownDateTimeComponent.propDecorators = {
endDateBind: [{ type: i0.Input }],
dayText: [{ type: i0.Input }],
hourText: [{ type: i0.Input }],
minutesText: [{ type: i0.Input }],
secondsText: [{ type: i0.Input }]
};
return AngularCountdownDateTimeComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var AngularCountdownDateTimeModule = /** @class */ (function () {
function AngularCountdownDateTimeModule() {
}
AngularCountdownDateTimeModule.decorators = [
{ type: i0.NgModule, args: [{
declarations: [AngularCountdownDateTimeComponent],
imports: [],
exports: [AngularCountdownDateTimeComponent]
},] }
];
return AngularCountdownDateTimeModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
exports.AngularCountdownDateTimeService = AngularCountdownDateTimeService;
exports.AngularCountdownDateTimeComponent = AngularCountdownDateTimeComponent;
exports.AngularCountdownDateTimeModule = AngularCountdownDateTimeModule;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=angular-countdown-date-time.umd.js.map