This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstatus-bar.js
More file actions
169 lines (169 loc) · 7.11 KB
/
status-bar.js
File metadata and controls
169 lines (169 loc) · 7.11 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ej2_base_1 = require("@syncfusion/ej2-base");
var ej2_splitbuttons_1 = require("@syncfusion/ej2-splitbuttons");
/**
* Represents document editor status bar.
*/
var StatusBar = (function () {
function StatusBar(parentElement, docEditor) {
var _this = this;
this.startPage = 1;
this.initializeStatusBar = function () {
var label = ej2_base_1.createElement('label', { styles: 'margin-top: 6px;margin-right: 2px' });
label.textContent = 'Page ';
_this.statusBarDiv.appendChild(label);
// tslint:disable-next-line:max-line-length
_this.pageNumberLabel = ej2_base_1.createElement('label', { id: 'documenteditor_page_no', styles: 'text-transform:capitalize;white-space:pre;overflow:hidden;user-select:none;cursor:text;height:17px;max-width:150px' });
_this.editablePageNumber = ej2_base_1.createElement('div', { id: 'editablePageNumber', styles: 'border: 1px solid #F1F1F1;display: inline-flex;height: 17px;padding: 0px 4px;', className: 'single-line e-de-pagenumber-text' });
_this.editablePageNumber.appendChild(_this.pageNumberLabel);
_this.updatePageNumber();
_this.statusBarDiv.appendChild(_this.editablePageNumber);
_this.editablePageNumber.setAttribute('title', 'The current page number in the document. Click or tap to navigate specific page.');
// tslint:disable-next-line:max-line-length
var label1 = ej2_base_1.createElement('label', { styles: 'margin-left:2px;letter-spacing: 1.05px;' });
label1.textContent = 'of';
_this.statusBarDiv.appendChild(label1);
// tslint:disable-next-line:max-line-length
_this.pageCount = ej2_base_1.createElement('label', { id: 'documenteditor_pagecount', styles: 'margin-left:6px;letter-spacing: 1.05px;' });
_this.statusBarDiv.appendChild(_this.pageCount);
_this.updatePageCount();
var zoomBtn = ej2_base_1.createElement('button', {
id: 'documenteditor-zoom',
// tslint:disable-next-line:max-line-length
className: 'e-de-statusbar-zoom'
});
_this.statusBarDiv.appendChild(zoomBtn);
zoomBtn.setAttribute('title', 'Zoom level. Click or tap to open the Zoom options.');
var items = [
{
text: '200%',
},
{
text: '175%',
},
{
text: '150%',
},
{
text: '125%',
},
{
text: '100%',
},
{
text: '75%',
},
{
text: '50%',
},
{
text: '25%',
},
{
separator: true
},
{
text: 'Fit one page'
},
{
text: 'Fit page width',
},
];
_this.zoom = new ej2_splitbuttons_1.DropDownButton({ content: '100%', items: items, select: _this.onZoom }, zoomBtn);
};
this.onZoom = function (args) {
_this.setZoomValue(args.item.text);
_this.updateZoomContent();
};
this.updateZoomContent = function () {
_this.zoom.content = Math.round(_this.documentEditor.zoomFactor * 100) + '%';
};
this.setZoomValue = function (text) {
if (text.match('Fit one page')) {
_this.documentEditor.fitPage('FitOnePage');
}
else if (text.match('Fit page width')) {
_this.documentEditor.fitPage('FitPageWidth');
}
else {
_this.documentEditor.zoomFactor = parseInt(text, 0) / 100;
}
};
/**
* Updates page count.
*/
this.updatePageCount = function () {
_this.pageCount.textContent = _this.editorPageCount.toString();
};
/**
* Updates page number.
*/
this.updatePageNumber = function () {
_this.pageNumberLabel.textContent = _this.startPage.toString();
};
this.updatePageNumberOnViewChange = function (args) {
if (_this.documentEditor.selection
&& _this.documentEditor.selection.startPage >= args.startPage && _this.documentEditor.selection.startPage <= args.endPage) {
_this.startPage = _this.documentEditor.selection.startPage;
}
else {
_this.startPage = args.startPage;
}
_this.updatePageNumber();
};
this.wireEvents = function () {
_this.editablePageNumber.addEventListener('keydown', function (e) {
if (e.which === 13) {
e.preventDefault();
var pageNumber = parseInt(_this.editablePageNumber.textContent, 0);
if (pageNumber > _this.editorPageCount) {
_this.updatePageNumber();
}
else {
if (_this.documentEditor.selection) {
_this.documentEditor.selection.goToPage(pageNumber);
}
else {
_this.documentEditor.scrollToPage(pageNumber);
}
}
_this.editablePageNumber.contentEditable = 'false';
if (_this.editablePageNumber.textContent === '') {
_this.updatePageNumber();
}
}
if (e.which > 64) {
e.preventDefault();
}
});
_this.editablePageNumber.addEventListener('blur', function () {
if (_this.editablePageNumber.textContent === '' || parseInt(_this.editablePageNumber.textContent, 0) > _this.editorPageCount) {
_this.updatePageNumber();
}
_this.editablePageNumber.contentEditable = 'false';
});
_this.editablePageNumber.addEventListener('click', function () {
_this.updateDocumentEditorPageNumber();
});
};
this.updateDocumentEditorPageNumber = function () {
_this.editablePageNumber.contentEditable = 'true';
_this.editablePageNumber.focus();
window.getSelection().selectAllChildren(_this.editablePageNumber);
};
this.statusBarDiv = parentElement;
this.documentEditor = docEditor;
this.initializeStatusBar();
this.wireEvents();
}
Object.defineProperty(StatusBar.prototype, "editorPageCount", {
get: function () {
return this.documentEditor.pageCount;
},
enumerable: true,
configurable: true
});
return StatusBar;
}());
exports.StatusBar = StatusBar;