META-INF.resources.butterfaces-dist-js.butterfaces-waitingpanel.jquery.js Maven / Gradle / Ivy
///
///
var ButterFaces;
(function (ButterFaces) {
var WaitingPanel = /** @class */ (function () {
function WaitingPanel(overlay) {
this.overlay = overlay;
}
WaitingPanel.prototype.processAjaxUpdate = function () {
var _this = this;
var ajaxRequestsRunning = 0;
return function (_a) {
var status = _a.status;
console.log("ButterFaces.WaitingPanel.onEvent - processEvent: " + status);
if (status === "begin") {
ajaxRequestsRunning++;
}
else if (status === "success") {
ajaxRequestsRunning--;
}
if (ajaxRequestsRunning > 0) {
console.log("ButterFaces.WaitingPanel.onEvent - show " + ajaxRequestsRunning);
_this.overlay.show();
}
else {
console.log("ButterFaces.WaitingPanel.onEvent - hide " + ajaxRequestsRunning);
_this.overlay.hide();
}
};
};
WaitingPanel.prototype.processOnError = function (data) {
if (data) {
console.error("ButterFaces.WaitingPanel.onError - An error occured, closing waiting panel. errorType: " + data.status + ", description: " + data.description);
ButterFaces.Overlay.hideAll();
}
};
return WaitingPanel;
}());
ButterFaces.WaitingPanel = WaitingPanel;
})(ButterFaces || (ButterFaces = {}));
(function ($) {
// extend jQuery --------------------------------------------------------------------
var eventRegistered = false;
var overlay;
$.fn.waitingPanel = function (_a) {
var waitingPanelDelay = _a.waitingPanelDelay, blockpage = _a.blockpage;
return this.each(function () {
// I found no way to remove event listener from jsf js.
// I tried to register a callback once and change it on render waiting panel but after this
// no waiting panel appears anymore.
// Actually on each rendering of this component a new callback is put on event listener collection.
if (!eventRegistered) {
// console.log("waitingPanel - register: " + _elementId);
overlay = new ButterFaces.Overlay(waitingPanelDelay, blockpage);
var waitingPanel = new ButterFaces.WaitingPanel(overlay);
jsf.ajax.addOnEvent(waitingPanel.processAjaxUpdate());
jsf.ajax.addOnError(waitingPanel.processOnError);
eventRegistered = true;
}
overlay.delay = waitingPanelDelay;
overlay.isTransparentBlockingOverlayActive = blockpage;
});
};
}(jQuery));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZX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BkYXRlKCkge1xuICAgICAgICAgICAgbGV0IGFqYXhSZXF1ZXN0c1J1bm5pbmcgPSAwO1xuXG4gICAgICAgICAgICByZXR1cm4gKHtzdGF0dXN9KSA9PiB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJCdXR0ZXJGYWNlcy5XYWl0aW5nUGFuZWwub25FdmVudCAtIHByb2Nlc3NFdmVudDogXCIgKyBzdGF0dXMpO1xuICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT09IFwiYmVnaW5cIikge1xuICAgICAgICAgICAgICAgICAgICBhamF4UmVxdWVzdHNSdW5uaW5nKys7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0dXMgPT09IFwic3VjY2Vzc1wiKSB7XG4gICAgICAgICAgICAgICAgICAgIGFqYXhSZXF1ZXN0c1J1bm5pbmctLTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGFqYXhSZXF1ZXN0c1J1bm5pbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiQnV0dGVyRmFjZXMuV2FpdGluZ1BhbmVsLm9uRXZlbnQgIC0gc2hvdyBcIiArIGFqYXhSZXF1ZXN0c1J1bm5pbmcpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLm92ZXJsYXkuc2hvdygpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiQnV0dGVyRmFjZXMuV2FpdGluZ1BhbmVsLm9uRXZlbnQgIC0gaGlkZSBcIiArIGFqYXhSZXF1ZXN0c1J1bm5pbmcpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLm92ZXJsYXkuaGlkZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICBwdWJsaWMgcHJvY2Vzc09uRXJyb3IoZGF0YToganNmLmFqYXguUmVxdWVz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