META-INF.resources.butterfaces-dist-js.butterfaces-ajax.js Maven / Gradle / Ivy
///
///
var ButterFaces;
(function (ButterFaces) {
var Ajax = /** @class */ (function () {
function Ajax() {
}
Ajax.sendRequest = function (clientId, event, renderIds, /*optional string */ params, disableRenderIds) {
jsf.ajax.request(clientId, event, {
"javax.faces.behavior.event": event,
render: renderIds.join(", "),
params: params,
onevent: (function (data) {
// console.log(data);
if (disableRenderIds) {
ButterFaces.Ajax.disableElementsOnRequest(data, renderIds);
}
})
});
};
Ajax.disableElementsOnRequest = function (data, ids) {
var status = data.status;
// console.log(data);
// console.log(ids);
switch (status) {
case "begin":// Before the ajax request is sent.
// console.log('ajax request begin');
for (var i = 0; i < ids.length; i++) {
var $elementToDisable = $(document.getElementById(ids[i]));
if ($elementToDisable.length !== 0) {
// console.log('disable ' + ids[i]);
new ButterFaces.Overlay(0, false, document.getElementById(ids[i])).show();
// console.log('disablee ' + ids[i]);
}
}
break;
case "complete":// After the ajax response is arrived.
// console.log('ajax request complete');
break;
case "success":// After update of HTML DOM based on ajax response..
// console.log('ajax request success');
for (var i = 0; i < ids.length; i++) {
var $elementToEmable = $(document.getElementById(ids[i]));
if ($elementToEmable.length !== 0) {
// console.log('enable ' + ids[i]);
new ButterFaces.Overlay(0, false, document.getElementById(ids[i])).hide();
// console.log('enabled ' + ids[i]);
}
}
break;
}
};
return Ajax;
}());
ButterFaces.Ajax = Ajax;
})(ButterFaces || (ButterFaces = {}));
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJ1dHRlcmZhY2VzLWFqYXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsbUVBQW1FO0FBQ25FLDZDQUE2QztBQUU3QyxJQUFVLFdBQVcsQ0EyRHBCO0FBM0RELFdBQVUsV0FBVztJQUNqQjtRQUFBO1FBeURBLENBQUM7UUF4RFUsZ0JBQVcsR0FBbEIsVUFBbUIsUUFBZ0IsRUFBRS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ICAgICAgICAgICAgICAgICAgICAgICBCdXR0ZXJGYWNlcy5BamF4LmRpc2FibGVFbGVtZW50c09uUmVxdWVzdChkYXRhLCByZW5kZXJJZHMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG5cbiAgICAgICAgc3RhdGljIGRpc2FibGVFbGVtZW50c09uUmVxdWVzdChkYXRhOiBhbnksIGlkczogc3RyaW5nW10pIHtcbiAgICAgICAgICAgIGxldCBzdGF0dXM6IHN0cmluZyA9IGRhdGEuc3RhdHVzO1xuXG4gICAgICAgICAgICAvLyBjb25zb2xlLmxvZyhkYXRhKTtcbiAgICAgICAgICAgIC8vIGNvbnNvbGUubG9nKGlkcyk7XG5cbiAgICAgICAgICAgIHN3aXRjaCAoc3RhdHVzKSB7XG4gICAgICAgICAgICAgICAgY2FzZSBcImJlZ2luXCI6IC8vIEJlZm9yZSB0aGUgYWpheCByZXF1ZXN0IGlzIHNlbnQuXG4gICAgICAgICAgICAgICAgICAgIC8vIGNvbnNvbGUubG9nKCdhamF4IHJlcXVlc3QgYmVnaW4nKTtcblxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGlkcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0ICRlbGVtZW50VG9EaXNhYmxlID0gJChkb2N1bWVudC5nZXRFbGVtZW50QnlJZChpZHNbaV0pKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCRlbGVtZW50VG9EaXNhYmxlLmxlbmd0aCAhPT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvbnNvbGUubG9nKCdkaXNhYmxlICcgKyBpZHNbaV0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBCdXR0ZXJGYWNlcy5PdmVybGF5KDAsIGZhbHNlLCBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChpZHNbaV0pKS5zaG93KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJ2Rpc2FibGVlICcgKyBpZHNbaV0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgICBjYXNlIFwiY29tcGxldGVcIjogLy8gQWZ0ZXIgdGhlIGFqYXggcmVzcG9uc2UgaXMgYXJyaXZlZC5cbiAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJ2FqYXggcmVxdWVzdCBjb21wbGV0ZScpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgICAgIGNhc2UgXCJzdWNjZXNzXCI6IC8vIEFmdGVyIHVwZGF0ZSBvZiBIVE1MIERPTSBiYXNlZCBvbiBhamF4IHJlc3BvbnNlLi5cbiAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJ2FqYXggcmVxdWVzdCBzdWNjZXNzJyk7XG5cbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBpZHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCAkZWxlbWVudFRvRW1hYmxlID0gJChkb2N1bWVudC5nZXRFbGVtZW50QnlJZChpZHNbaV0pKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCRlbGVtZW50VG9FbWFibGUubGVuZ3RoICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJ2VuYWJsZSAnICsgaWRzW2ldKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXcgQnV0dGVyRmFjZXMuT3ZlcmxheSgwLCBmYWxzZSwgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoaWRzW2ldKSkuaGlkZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvbnNvbGUubG9nKCdlbmFibGVkICcgKyBpZHNbaV0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59Il19