define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PagerMessage = (function () {
function PagerMessage(pagerModule) {
this.pagerModule = pagerModule;
}
PagerMessage.prototype.render = function () {
var div = ej2_base_1.createElement('div', { className: 'e-parentmsgbar' });
this.pageNoMsgElem = ej2_base_1.createElement('span', { className: 'e-pagenomsg', styles: 'textalign:right' });
this.pageCountMsgElem = ej2_base_1.createElement('span', { className: 'e-pagecountmsg', styles: 'textalign:right' });
ej2_base_1.append([this.pageNoMsgElem, this.pageCountMsgElem], div);
this.pagerModule.element.appendChild(div);
this.refresh();
};
PagerMessage.prototype.refresh = function () {
var pagerObj = this.pagerModule;
this.pageNoMsgElem.textContent = this.format(pagerObj.getLocalizedLabel('currentPageInfo'), [pagerObj.totalRecordsCount === 0 ? 0 :
pagerObj.currentPage, pagerObj.totalPages || 0, pagerObj.totalRecordsCount || 0]) + ' ';
this.pageCountMsgElem.textContent = this.format(pagerObj.getLocalizedLabel(pagerObj.totalRecordsCount <= 1 ? 'totalItemInfo' : 'totalItemsInfo'), [pagerObj.totalRecordsCount || 0, pagerObj.totalRecordsCount ? (pagerObj.pageSize * (pagerObj.currentPage - 1)) + 1 : 0,
pagerObj.pageSize * pagerObj.currentPage > pagerObj.totalRecordsCount ? pagerObj.totalRecordsCount :
pagerObj.pageSize * pagerObj.currentPage]);
this.pageNoMsgElem.parentElement.classList.remove('e-hide');
};
PagerMessage.prototype.hideMessage = function () {
if (this.pageNoMsgElem) {
this.pageNoMsgElem.style.display = 'none';
}
if (this.pageCountMsgElem) {
this.pageCountMsgElem.style.display = 'none';
}
};
PagerMessage.prototype.showMessage = function () {
if (!this.pageNoMsgElem) {
this.render();
}
this.pageNoMsgElem.style.display = '';
this.pageCountMsgElem.style.display = '';
};
PagerMessage.prototype.destroy = function () {
};
PagerMessage.prototype.format = function (str, args) {
var regx;
var regExp = RegExp;
for (var i = 0; i < args.length; i++) {
regx = new regExp('\\{' + (i) + '\\}', 'gm');
if (this.isValidLocale(this.pagerModule.locale)) {
str = str.replace(regx, args[parseInt(i.toString(), 10)].toLocaleString(this.pagerModule.locale));
}
else {
str = str.replace(regx, args[parseInt(i.toString(), 10)].toString());
}
}
return str;
};
PagerMessage.prototype.isValidLocale = function (locale) {
try {
new Intl.NumberFormat(locale);
return true;
}
catch (e) {
return false;
}
};
return PagerMessage;
}());
exports.PagerMessage = PagerMessage;
});
|