1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 | 1×
1×
1×
1×
31×
1×
425×
1×
29×
29×
29×
29×
29×
29×
29×
29×
29×
29×
29×
29×
29×
29×
29×
29×
29×
10×
29×
29×
29×
29×
1×
13×
6×
6×
6×
6×
6×
7×
7×
7×
13×
13×
11×
1×
101×
101×
17×
17×
84×
84×
101×
1×
39×
30×
30×
1×
11×
11×
40×
11×
1×
169×
169×
30×
139×
1×
70×
68×
68×
68×
68×
1×
29×
1×
28×
1×
32×
28×
28×
28×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-dropdowns"], function (require, exports, ej2_base_1, ej2_dropdowns_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PagerDropDown = (function () {
function PagerDropDown(pagerModule) {
this.pagerModule = pagerModule;
}
PagerDropDown.prototype.getModuleName = function () {
return 'pagerdropdown';
};
PagerDropDown.prototype.render = function () {
var pagerObj = this.pagerModule;
this.pagerDropDownDiv = ej2_base_1.createElement('div', { className: 'e-pagesizes' });
var dropDownDiv = ej2_base_1.createElement('div', { className: 'e-pagerdropdown' });
var defaultTextDiv = ej2_base_1.createElement('div', { className: 'e-pagerconstant' });
var input = ej2_base_1.createElement('input', { attrs: { type: 'text', tabindex: '-1' } });
this.pagerCons = ej2_base_1.createElement('span', {
className: 'e-constant', innerHTML: this.pagerModule.getLocalizedLabel('pagerDropDown')
});
dropDownDiv.appendChild(input);
defaultTextDiv.appendChild(this.pagerCons);
this.pagerDropDownDiv.appendChild(dropDownDiv);
this.pagerDropDownDiv.appendChild(defaultTextDiv);
this.pagerModule.element.appendChild(this.pagerDropDownDiv);
var pageSizesModule = this.pagerModule.pageSizes;
var pageSizesArray = (pageSizesModule.length ? this.convertValue(pageSizesModule) :
[this.pagerModule.getLocalizedLabel('All'), '5', '10', '12', '20']);
var defaultValue = this.pagerModule.pageSize;
this.dropDownListObject = new ej2_dropdowns_1.DropDownList({
dataSource: pageSizesArray,
value: defaultValue.toString(),
change: this.onChange.bind(this),
placeholder: this.pagerModule.getLocalizedLabel('pagerDropDown'),
cssClass: this.pagerModule.cssClass ? 'e-alldrop' + ' ' + this.pagerModule.cssClass : 'e-alldrop'
});
this.dropDownListObject.appendTo(input);
if (pageSizesModule.length) {
this.dropDownListObject.element.value = this.pagerModule.pageSize.toString();
}
pagerObj.pageSize = defaultValue;
pagerObj.dataBind();
pagerObj.trigger('dropDownChanged', { pageSize: defaultValue });
this.addEventListener();
};
PagerDropDown.prototype.onChange = function (e) {
if (this.dropDownListObject.value === this.pagerModule.getLocalizedLabel('All')) {
this.pagerModule.pageSize = this.pagerModule.totalRecordsCount;
this.pagerModule.isAllPage = true;
this.refresh();
e.value = this.pagerModule.pageSize;
Iif (document.getElementsByClassName('e-popup-open e-alldrop').length) {
document.getElementsByClassName('e-popup-open e-alldrop')[0].style.display = 'none';
}
}
else {
this.pagerModule.pageSize = parseInt(this.dropDownListObject.value, 10);
this.pagerModule.isAllPage = false;
Iif (this.pagerCons.innerHTML !== this.pagerModule.getLocalizedLabel('pagerDropDown')) {
this.refresh();
}
}
this.pagerModule.dataBind();
if (!this.pagerModule.isCancel) {
this.pagerModule.trigger('dropDownChanged', {
pageSize: this.pagerModule.isAllPage ||
(this.pagerModule.isAllPage === undefined && this.dropDownListObject.value === this.pagerModule.getLocalizedLabel('All')) ?
this.pagerModule.totalRecordsCount : parseInt(this.dropDownListObject.value, 10)
});
}
};
PagerDropDown.prototype.refresh = function () {
Eif (this.pagerCons) {
if (this.isPageSizeAll(this.pagerModule.pageSize)) {
this.pagerCons.innerHTML = this.pagerModule.getLocalizedLabel('pagerAllDropDown');
this.pagerCons.parentElement.classList.add('e-page-all');
}
else {
this.pagerCons.innerHTML = this.pagerModule.getLocalizedLabel('pagerDropDown');
this.pagerCons.parentElement.classList.remove('e-page-all');
}
this.pagerDropDownDiv.classList.remove('e-hide');
}
};
PagerDropDown.prototype.beforeValueChange = function (prop) {
if (typeof prop.newProp.value === 'number') {
var val = prop.newProp.value.toString();
prop.newProp.value = val;
}
};
PagerDropDown.prototype.convertValue = function (pageSizeValue) {
var item = pageSizeValue;
for (var i = 0; i < item.length; i++) {
item[parseInt(i.toString(), 10)] = parseInt(item[parseInt(i.toString(), 10)], 10) ?
item[parseInt(i.toString(), 10)].toString() : (this.pagerModule.getLocalizedLabel(item[parseInt(i.toString(), 10)]) !== '')
? this.pagerModule.getLocalizedLabel(item[parseInt(i.toString(), 10)]) : item[parseInt(i.toString(), 10)];
}
return item;
};
PagerDropDown.prototype.isPageSizeAll = function (value) {
var pageSizeNum = typeof (value) === 'string' && value !== this.pagerModule.getLocalizedLabel('All') ?
parseInt(value, 10) : value;
if (pageSizeNum === this.pagerModule.totalRecordsCount || value === this.pagerModule.getLocalizedLabel('All')) {
return true;
}
else {
return false;
}
};
PagerDropDown.prototype.setDropDownValue = function (prop, value) {
if (this.dropDownListObject) {
var isbeforeAll = this.pagerModule.isAllPage;
this.pagerModule.isAllPage = this.isPageSizeAll(value);
this.pagerModule.checkAll = (isbeforeAll && this.pagerModule.isAllPage) ? true : false;
this.dropDownListObject["" + prop] = this.pagerModule.isAllPage ? this.pagerModule.getLocalizedLabel('All') : value;
}
};
PagerDropDown.prototype.addEventListener = function () {
this.dropDownListObject.on('beforeValueChange', this.beforeValueChange, this);
};
PagerDropDown.prototype.removeEventListener = function () {
this.dropDownListObject.off('beforeValueChange', this.beforeValueChange);
};
PagerDropDown.prototype.destroy = function (args) {
if (this.dropDownListObject && !this.dropDownListObject.isDestroyed) {
this.removeEventListener();
this.dropDownListObject.destroy();
ej2_base_1.remove(this.pagerDropDownDiv);
}
};
return PagerDropDown;
}());
exports.PagerDropDown = PagerDropDown;
});
|