@progress/telerik-jquery-report-viewer 21.24.305 → 22.24.709
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/cjs/accessibility.js +208 -0
- package/dist/cjs/base-component.js +26 -0
- package/dist/cjs/binder.js +79 -0
- package/dist/cjs/command.js +32 -0
- package/dist/cjs/commandSet.js +167 -0
- package/dist/cjs/controller.js +1204 -0
- package/dist/cjs/documentMapArea.js +159 -0
- package/dist/cjs/domUtils.js +50 -0
- package/dist/cjs/enums.js +52 -0
- package/dist/cjs/event-emitter.js +131 -0
- package/dist/cjs/events.js +23 -0
- package/dist/cjs/globalSettings.js +9 -0
- package/dist/cjs/history.js +131 -0
- package/dist/cjs/index.js +58 -0
- package/dist/cjs/jqueryThrottleDebounce.js +48 -0
- package/dist/cjs/kendo-jquery.js +4 -0
- package/dist/cjs/mainMenu.js +323 -0
- package/dist/cjs/mem-storage.js +44 -0
- package/dist/cjs/pagesArea.js +622 -0
- package/dist/cjs/parameterValidators.js +164 -0
- package/dist/cjs/parameters.js +921 -0
- package/dist/cjs/parametersArea.js +486 -0
- package/dist/cjs/perspectives.js +138 -0
- package/dist/cjs/print.js +165 -0
- package/dist/cjs/report-viewer/report-viewer-settings.js +138 -0
- package/dist/cjs/reportViewer.js +665 -0
- package/dist/cjs/scroll.js +535 -0
- package/dist/cjs/search.js +584 -0
- package/dist/cjs/sendEmail.js +392 -0
- package/dist/cjs/service-client-sentinel.js +52 -0
- package/dist/cjs/serviceClient.js +311 -0
- package/dist/cjs/sideMenu.js +216 -0
- package/dist/cjs/sr.js +164 -0
- package/dist/cjs/stringResources.js +11 -0
- package/dist/cjs/telerikReportViewer.kendo.js +60196 -0
- package/dist/cjs/telerikReportViewer.kendo.min.js +19776 -0
- package/dist/cjs/template-cache.js +39 -0
- package/dist/cjs/toolbar/link-button.js +42 -0
- package/dist/cjs/toolbar/page-count-label.js +18 -0
- package/dist/cjs/toolbar/page-number-input.js +64 -0
- package/dist/cjs/touch.js +86 -0
- package/dist/cjs/uiController.js +142 -0
- package/dist/cjs/uiFreezeCoordinator.js +282 -0
- package/dist/cjs/utils.js +489 -0
- package/dist/es/accessibility.js +204 -0
- package/dist/es/base-component.js +22 -0
- package/dist/es/binder.js +75 -0
- package/dist/es/command.js +28 -0
- package/dist/es/commandSet.js +163 -0
- package/dist/es/controller.js +1200 -0
- package/dist/es/documentMapArea.js +155 -0
- package/dist/es/domUtils.js +43 -0
- package/dist/es/enums.js +41 -0
- package/dist/es/event-emitter.js +127 -0
- package/dist/es/events.js +19 -0
- package/dist/es/globalSettings.js +5 -0
- package/dist/es/history.js +127 -0
- package/dist/es/index.js +24 -0
- package/dist/es/jqueryThrottleDebounce.js +46 -0
- package/dist/es/kendo-jquery.js +1 -0
- package/dist/es/mainMenu.js +319 -0
- package/dist/es/mem-storage.js +40 -0
- package/dist/es/pagesArea.js +618 -0
- package/dist/es/parameterValidators.js +160 -0
- package/dist/es/parameters.js +916 -0
- package/dist/es/parametersArea.js +482 -0
- package/dist/es/perspectives.js +134 -0
- package/dist/es/print.js +161 -0
- package/dist/es/report-viewer/report-viewer-settings.js +134 -0
- package/dist/es/reportViewer.js +661 -0
- package/dist/es/scroll.js +531 -0
- package/dist/es/search.js +580 -0
- package/dist/es/sendEmail.js +388 -0
- package/dist/es/service-client-sentinel.js +48 -0
- package/dist/es/serviceClient.js +307 -0
- package/dist/es/sideMenu.js +212 -0
- package/dist/es/sr.js +162 -0
- package/dist/es/stringResources.js +7 -0
- package/dist/es/telerikReportViewer.kendo.js +60194 -0
- package/dist/es/telerikReportViewer.kendo.min.js +19774 -0
- package/dist/es/template-cache.js +35 -0
- package/dist/es/toolbar/link-button.js +38 -0
- package/dist/es/toolbar/page-count-label.js +14 -0
- package/dist/es/toolbar/page-number-input.js +60 -0
- package/dist/es/touch.js +82 -0
- package/dist/es/uiController.js +138 -0
- package/dist/es/uiFreezeCoordinator.js +278 -0
- package/dist/es/utils.js +444 -0
- package/dist/font/font-icons.css +4 -4
- package/dist/font/font-icons.min.css +3 -3
- package/dist/js/telerikReportViewer.js +8346 -8507
- package/dist/js/telerikReportViewer.min.js +1 -17
- package/dist/js/telerikReportViewer.stringResources.js +166 -173
- package/dist/styles/telerikReportViewer.css +3 -3
- package/dist/styles/telerikReportViewer.min.css +3 -3
- package/dist/templates/telerikReportViewerTemplate-FA.html +4 -4
- package/dist/templates/telerikReportViewerTemplate.html +6 -6
- package/package.json +14 -7
- /package/dist/font/{ReportingIcons-18.0.24.305.ttf → ReportingIcons-18.1.24.709.ttf} +0 -0
@@ -0,0 +1,392 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
var stringResources = require('./stringResources.js');
|
6
|
+
var binder = require('./binder.js');
|
7
|
+
var command = require('./command.js');
|
8
|
+
|
9
|
+
var defaultOptions = {};
|
10
|
+
function replaceStringResources($sendEmailDialog) {
|
11
|
+
if (!$sendEmailDialog) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
var labels = $sendEmailDialog.find(".trv-replace-string");
|
15
|
+
var ariaLabel = $sendEmailDialog.find("[aria-label]");
|
16
|
+
var titles = $sendEmailDialog.find("[title]");
|
17
|
+
if (labels.length) {
|
18
|
+
Array.from(labels).forEach((element) => {
|
19
|
+
replaceText($(element));
|
20
|
+
});
|
21
|
+
}
|
22
|
+
if (ariaLabel.length) {
|
23
|
+
Array.from(ariaLabel).forEach((element) => {
|
24
|
+
replaceAttribute($(element), "aria-label");
|
25
|
+
});
|
26
|
+
}
|
27
|
+
if (titles.length) {
|
28
|
+
Array.from(titles).forEach((element) => {
|
29
|
+
replaceAttribute($(element), "title");
|
30
|
+
});
|
31
|
+
}
|
32
|
+
}
|
33
|
+
function replaceText($el) {
|
34
|
+
if ($el) {
|
35
|
+
$el.text(stringResources.stringResources[$el.text()]);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
function replaceAttribute($el, attribute) {
|
39
|
+
if ($el) {
|
40
|
+
$el.attr(attribute, stringResources.stringResources[$el.attr(attribute)]);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
function SendEmail(placeholder, options, viewerOptions) {
|
44
|
+
options = $.extend({}, defaultOptions, options);
|
45
|
+
var controller = options.controller;
|
46
|
+
var initialized = false;
|
47
|
+
var dialogVisible = false;
|
48
|
+
var $placeholder;
|
49
|
+
var kendoSendEmailDialog;
|
50
|
+
var selector = viewerOptions.viewerSelector;
|
51
|
+
var inputFrom;
|
52
|
+
var inputTo;
|
53
|
+
var inputCC;
|
54
|
+
var inputSubject;
|
55
|
+
var docFormat;
|
56
|
+
var docFormatEl;
|
57
|
+
var bodyEditorEl;
|
58
|
+
var bodyEditor;
|
59
|
+
var docFormatList;
|
60
|
+
var optionsCommandSet;
|
61
|
+
var windowLocation;
|
62
|
+
var reportViewerWrapper = $("[data-selector='" + selector + "']").find(".trv-report-viewer");
|
63
|
+
if (!controller) {
|
64
|
+
throw "No controller (telerikReporting.ReportViewerController) has been specified.";
|
65
|
+
}
|
66
|
+
if (!viewerOptions.sendEmail || !viewerOptions.sendEmail.enabled) {
|
67
|
+
var toolbarSendEmailItem = $("[data-selector='" + selector + "']").find("a[data-command='telerik_ReportViewer_toggleSendEmailDialog']").closest(".k-item ");
|
68
|
+
toolbarSendEmailItem.hide();
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
controller.beginLoadReport(closeAndClear).viewModeChanged(closeAndClear);
|
72
|
+
controller.getSendEmailDialogState(function(event, args) {
|
73
|
+
args.visible = dialogVisible;
|
74
|
+
}).setSendEmailDialogVisible(function(event, args) {
|
75
|
+
toggle(args.visible);
|
76
|
+
}).setSearchDialogVisible(function(event, args) {
|
77
|
+
if (args.visible && dialogVisible) {
|
78
|
+
toggle(!dialogVisible);
|
79
|
+
}
|
80
|
+
});
|
81
|
+
controller.getDocumentFormats().then(function(formats) {
|
82
|
+
docFormatList = formats;
|
83
|
+
});
|
84
|
+
function closeAndClear() {
|
85
|
+
toggle(false);
|
86
|
+
}
|
87
|
+
function toggle(show) {
|
88
|
+
dialogVisible = show;
|
89
|
+
if (show) {
|
90
|
+
ensureInitialized();
|
91
|
+
setDefaultValues(viewerOptions.sendEmail);
|
92
|
+
kendoSendEmailDialog.open();
|
93
|
+
} else {
|
94
|
+
if (kendoSendEmailDialog && kendoSendEmailDialog.options.visible) {
|
95
|
+
kendoSendEmailDialog.close();
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
function getBody() {
|
100
|
+
return bodyEditor ? bodyEditor.value() : "";
|
101
|
+
}
|
102
|
+
function ensureInitialized() {
|
103
|
+
if (!initialized) {
|
104
|
+
$placeholder = $(placeholder);
|
105
|
+
inputFrom = $placeholder.find("[name='from']");
|
106
|
+
inputTo = $placeholder.find("[name='to']");
|
107
|
+
inputCC = $placeholder.find("[name='cc']");
|
108
|
+
inputSubject = $placeholder.find("[name='subject']");
|
109
|
+
docFormatEl = $placeholder.find("[name='format']");
|
110
|
+
bodyEditorEl = $placeholder.find("textarea");
|
111
|
+
setAttrs();
|
112
|
+
initCommands();
|
113
|
+
replaceStringResources($placeholder);
|
114
|
+
try {
|
115
|
+
kendoSendEmailDialog = reportViewerWrapper.find(".trv-send-email-window").kendoWindow({
|
116
|
+
title: stringResources.stringResources.sendEmailDialogTitle,
|
117
|
+
minWidth: 350,
|
118
|
+
minHeight: 350,
|
119
|
+
maxHeight: 900,
|
120
|
+
modal: true,
|
121
|
+
close: function() {
|
122
|
+
storeDialogPosition();
|
123
|
+
clearValidation();
|
124
|
+
},
|
125
|
+
open: function() {
|
126
|
+
adjustDialogSize();
|
127
|
+
adjustDialogPosition();
|
128
|
+
},
|
129
|
+
deactivate: function() {
|
130
|
+
controller.setSendEmailDialogVisible({
|
131
|
+
visible: false
|
132
|
+
});
|
133
|
+
},
|
134
|
+
activate: function() {
|
135
|
+
kendoSendEmailDialog.wrapper.find(".trv-send-email-fields input[type='email']:visible").first().focus();
|
136
|
+
setTimeout(function() {
|
137
|
+
setValidation();
|
138
|
+
}, 250);
|
139
|
+
}
|
140
|
+
}).data("kendoWindow");
|
141
|
+
} catch (error) {
|
142
|
+
console.error("Instantiation of Kendo Window for Send Email dialog threw an exception", error);
|
143
|
+
throw error;
|
144
|
+
}
|
145
|
+
kendoSendEmailDialog.wrapper.addClass("trv-send-email");
|
146
|
+
try {
|
147
|
+
docFormat = docFormatEl.kendoComboBox({
|
148
|
+
dataTextField: "localizedName",
|
149
|
+
dataValueField: "name",
|
150
|
+
dataSource: docFormatList || [],
|
151
|
+
filter: "startswith",
|
152
|
+
dataBound: function() {
|
153
|
+
this.select(0);
|
154
|
+
this.trigger("change");
|
155
|
+
}
|
156
|
+
}).data("kendoComboBox");
|
157
|
+
} catch (error) {
|
158
|
+
console.error("Instantiation of Kendo ComboBox as document format selector threw an exception", error);
|
159
|
+
throw error;
|
160
|
+
}
|
161
|
+
$placeholder.on("keydown", '[name="format_input"]', function(event) {
|
162
|
+
var tabkey = 9;
|
163
|
+
if (event.keyCode === tabkey && bodyEditor) {
|
164
|
+
setTimeout(function() {
|
165
|
+
bodyEditor.focus();
|
166
|
+
});
|
167
|
+
}
|
168
|
+
});
|
169
|
+
try {
|
170
|
+
bodyEditor = bodyEditorEl.kendoEditor({
|
171
|
+
tools: [
|
172
|
+
"bold",
|
173
|
+
"italic",
|
174
|
+
"underline",
|
175
|
+
"strikethrough",
|
176
|
+
"justifyLeft",
|
177
|
+
"justifyCenter",
|
178
|
+
"justifyRight",
|
179
|
+
"justifyFull",
|
180
|
+
"insertUnorderedList",
|
181
|
+
"insertOrderedList",
|
182
|
+
"indent",
|
183
|
+
"outdent",
|
184
|
+
"createLink",
|
185
|
+
"unlink",
|
186
|
+
"cleanFormatting",
|
187
|
+
"formatting",
|
188
|
+
"fontName",
|
189
|
+
"fontSize",
|
190
|
+
"foreColor",
|
191
|
+
"backColor",
|
192
|
+
"subscript",
|
193
|
+
"superscript"
|
194
|
+
]
|
195
|
+
}).data("kendoEditor");
|
196
|
+
} catch (error) {
|
197
|
+
console.error("Instantiation of Kendo Editor for Email body editor threw an exception", error);
|
198
|
+
throw error;
|
199
|
+
}
|
200
|
+
setDefaultValues(viewerOptions.sendEmail);
|
201
|
+
initialized = true;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
$(window).resize(function() {
|
205
|
+
if (kendoSendEmailDialog && kendoSendEmailDialog.options.visible) {
|
206
|
+
storeDialogPosition();
|
207
|
+
adjustDialogSize();
|
208
|
+
adjustDialogPosition();
|
209
|
+
}
|
210
|
+
});
|
211
|
+
function setAttrs() {
|
212
|
+
$placeholder.find(".trv-send-email-field input").each(function() {
|
213
|
+
var el = $(this);
|
214
|
+
var attrName = el.attr("name");
|
215
|
+
el.attr("id", selector + "-" + attrName);
|
216
|
+
});
|
217
|
+
$placeholder.find(".trv-send-email-label label").each(function() {
|
218
|
+
var el = $(this);
|
219
|
+
var attrName = el.attr("for");
|
220
|
+
el.attr("for", selector + "-" + attrName);
|
221
|
+
});
|
222
|
+
}
|
223
|
+
function storeDialogPosition() {
|
224
|
+
var kendoWindow = kendoSendEmailDialog.element.parent(".k-window");
|
225
|
+
windowLocation = kendoWindow.offset();
|
226
|
+
}
|
227
|
+
function adjustDialogSize() {
|
228
|
+
var kendoWindow = kendoSendEmailDialog.element.parent(".k-window");
|
229
|
+
var windowWidth = $(window).width();
|
230
|
+
var kendoWindowWidth = 350;
|
231
|
+
if (windowWidth > 800) {
|
232
|
+
kendoWindowWidth = 720;
|
233
|
+
}
|
234
|
+
kendoWindow.css({ width: kendoWindowWidth });
|
235
|
+
kendoSendEmailDialog.refresh({
|
236
|
+
width: kendoWindowWidth
|
237
|
+
});
|
238
|
+
}
|
239
|
+
function adjustDialogPosition() {
|
240
|
+
if (!windowLocation) {
|
241
|
+
kendoSendEmailDialog.center();
|
242
|
+
} else {
|
243
|
+
var padding = 10;
|
244
|
+
var windowWidth = $(window).innerWidth();
|
245
|
+
var windowHeight = $(window).innerHeight();
|
246
|
+
var kendoWindow = kendoSendEmailDialog.wrapper;
|
247
|
+
var width = kendoWindow.outerWidth(true);
|
248
|
+
var height = kendoWindow.outerHeight(true);
|
249
|
+
var left = windowLocation.left;
|
250
|
+
var top = windowLocation.top;
|
251
|
+
var right = left + width;
|
252
|
+
var bottom = top + height;
|
253
|
+
if (right > windowWidth - padding) {
|
254
|
+
left = Math.max(padding, windowWidth - width - padding);
|
255
|
+
kendoWindow.css({ left });
|
256
|
+
kendoSendEmailDialog.setOptions({
|
257
|
+
position: {
|
258
|
+
left
|
259
|
+
}
|
260
|
+
});
|
261
|
+
}
|
262
|
+
if (bottom > windowHeight - padding) {
|
263
|
+
top = Math.max(padding, windowHeight - height - padding);
|
264
|
+
kendoWindow.css({ top });
|
265
|
+
kendoSendEmailDialog.setOptions({
|
266
|
+
position: {
|
267
|
+
top
|
268
|
+
}
|
269
|
+
});
|
270
|
+
}
|
271
|
+
}
|
272
|
+
}
|
273
|
+
function initCommands() {
|
274
|
+
optionsCommandSet = {
|
275
|
+
"sendEmail_Cancel": new command.Command(function() {
|
276
|
+
closeWindow();
|
277
|
+
}),
|
278
|
+
"sendEmail_Send": new command.Command(function() {
|
279
|
+
sendingEmail();
|
280
|
+
})
|
281
|
+
};
|
282
|
+
binder.Binder.attachCommands($placeholder.find(".trv-send-email-actions"), optionsCommandSet, viewerOptions);
|
283
|
+
}
|
284
|
+
function sendingEmail(cmd, args) {
|
285
|
+
var sendEmailArgs = {
|
286
|
+
from: inputFrom.val(),
|
287
|
+
to: inputTo.val(),
|
288
|
+
cc: inputCC.val(),
|
289
|
+
subject: inputSubject.val(),
|
290
|
+
format: docFormat.value(),
|
291
|
+
body: getBody(),
|
292
|
+
deviceInfo: {}
|
293
|
+
};
|
294
|
+
if (validateFields()) {
|
295
|
+
controller.sendReport(sendEmailArgs);
|
296
|
+
closeWindow();
|
297
|
+
}
|
298
|
+
}
|
299
|
+
function setValidation() {
|
300
|
+
inputFrom.off("blur").on("blur", function(event) {
|
301
|
+
if (!isEmpty($(this))) {
|
302
|
+
isValidEmail($(this), false);
|
303
|
+
}
|
304
|
+
});
|
305
|
+
inputTo.off("blur").on("blur", function(event) {
|
306
|
+
if (!isEmpty($(this))) {
|
307
|
+
isValidEmail($(this), true);
|
308
|
+
}
|
309
|
+
});
|
310
|
+
inputCC.off("blur").on("blur", function(event) {
|
311
|
+
if ($(this).val().length) {
|
312
|
+
isValidEmail($(this), true);
|
313
|
+
} else {
|
314
|
+
hideError($(this));
|
315
|
+
}
|
316
|
+
});
|
317
|
+
}
|
318
|
+
function validateFields() {
|
319
|
+
var fromIsValid = isEmpty(inputFrom) || !isValidEmail(inputFrom, false);
|
320
|
+
var toIsValid = isEmpty(inputTo) || !isValidEmail(inputTo, true);
|
321
|
+
var ccIsValid = inputCC.val().length && !isValidEmail(inputCC, true);
|
322
|
+
var hasFormat = docFormat.value().length;
|
323
|
+
if (!hasFormat) {
|
324
|
+
showError(docFormatEl, "data-required-msg");
|
325
|
+
}
|
326
|
+
if (fromIsValid || toIsValid || ccIsValid || !hasFormat) {
|
327
|
+
return false;
|
328
|
+
}
|
329
|
+
return true;
|
330
|
+
}
|
331
|
+
function setDefaultValues(sendEmail) {
|
332
|
+
inputFrom.val(sendEmail && sendEmail.from || "");
|
333
|
+
inputTo.val(sendEmail && sendEmail.to || "");
|
334
|
+
inputCC.val(sendEmail && sendEmail.cc || "");
|
335
|
+
inputSubject.val(sendEmail && sendEmail.subject || "");
|
336
|
+
if (sendEmail && sendEmail.format) {
|
337
|
+
docFormat.value(sendEmail.format);
|
338
|
+
} else {
|
339
|
+
docFormat.select(0);
|
340
|
+
}
|
341
|
+
docFormat.trigger("change");
|
342
|
+
bodyEditor.value(sendEmail && sendEmail.body || "");
|
343
|
+
}
|
344
|
+
function isEmpty($el) {
|
345
|
+
if (!$el.val().length) {
|
346
|
+
showError($el, "data-required-msg");
|
347
|
+
return true;
|
348
|
+
}
|
349
|
+
hideError($el);
|
350
|
+
return false;
|
351
|
+
}
|
352
|
+
function showError($el, tag) {
|
353
|
+
var validationMsg = stringResources.stringResources[$el.attr(tag)];
|
354
|
+
$('[data-for="' + $el.attr("name") + '"]').addClass("-visible").text(validationMsg);
|
355
|
+
}
|
356
|
+
function hideError($el) {
|
357
|
+
$('[data-for="' + $el.attr("name") + '"]').removeClass("-visible");
|
358
|
+
}
|
359
|
+
function isValidEmail($el, moreThenOneEmail) {
|
360
|
+
var inputValue = $el.val();
|
361
|
+
if (moreThenOneEmail) {
|
362
|
+
var listEmailsAddress = inputValue.split(/[\s,;]+/);
|
363
|
+
for (var i = 0; i < listEmailsAddress.length; i++) {
|
364
|
+
if (!_validateEmail(listEmailsAddress[i].trim(), $el)) {
|
365
|
+
return false;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
return true;
|
369
|
+
}
|
370
|
+
return _validateEmail(inputValue, $el);
|
371
|
+
}
|
372
|
+
function _validateEmail(email, $el) {
|
373
|
+
var regexEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
|
374
|
+
if (email.indexOf(",") > -1 || email.indexOf(";") > -1) {
|
375
|
+
showError($el, "data-single-email-msg");
|
376
|
+
return false;
|
377
|
+
}
|
378
|
+
if (!regexEmail.test(email)) {
|
379
|
+
showError($el, "data-email-msg");
|
380
|
+
return false;
|
381
|
+
}
|
382
|
+
return true;
|
383
|
+
}
|
384
|
+
function closeWindow() {
|
385
|
+
kendoSendEmailDialog.close();
|
386
|
+
}
|
387
|
+
function clearValidation() {
|
388
|
+
$(".k-invalid-msg").removeClass("-visible");
|
389
|
+
}
|
390
|
+
}
|
391
|
+
|
392
|
+
exports.SendEmail = SendEmail;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
var stringResources = require('./stringResources.js');
|
6
|
+
|
7
|
+
function isNumber(value) {
|
8
|
+
return typeof value === "number" && isFinite(value);
|
9
|
+
}
|
10
|
+
function secondsToMilliseconds(seconds) {
|
11
|
+
return seconds * 1e3;
|
12
|
+
}
|
13
|
+
function ServiceClientSentinel(serviceClient, clientID, sessionTimeoutSeconds) {
|
14
|
+
if (!serviceClient) {
|
15
|
+
throw stringResources.stringResources.noServiceClient;
|
16
|
+
}
|
17
|
+
if (!isNumber(sessionTimeoutSeconds)) {
|
18
|
+
throw "sessionTimeoutSeconds must a number and must be finite";
|
19
|
+
}
|
20
|
+
var interval;
|
21
|
+
var pingMilliseconds;
|
22
|
+
if (sessionTimeoutSeconds <= 120) {
|
23
|
+
pingMilliseconds = secondsToMilliseconds(sessionTimeoutSeconds) / 2;
|
24
|
+
} else {
|
25
|
+
pingMilliseconds = secondsToMilliseconds(sessionTimeoutSeconds - 60);
|
26
|
+
}
|
27
|
+
function start() {
|
28
|
+
if (pingMilliseconds <= 0) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
interval = setInterval(function() {
|
32
|
+
serviceClient.keepClientAlive(clientID);
|
33
|
+
}, pingMilliseconds);
|
34
|
+
}
|
35
|
+
function restart() {
|
36
|
+
stop();
|
37
|
+
start();
|
38
|
+
}
|
39
|
+
function stop() {
|
40
|
+
if (interval) {
|
41
|
+
clearInterval(interval);
|
42
|
+
interval = null;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
return {
|
46
|
+
start,
|
47
|
+
restart,
|
48
|
+
stop
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
52
|
+
exports.ServiceClientSentinel = ServiceClientSentinel;
|