UNPKG

jsf.js_next_gen

Version:

A next generation typescript reimplementation of jsf.js

52 lines 2.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventData = void 0; /*! Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to you under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const mona_dish_1 = require("mona-dish"); const Const_1 = require("../core/Const"); class EventData { static createFromRequest(request, internalContext, context, /*event name*/ name) { let eventData = new EventData(); let internalSource = "_internal._source"; eventData.type = Const_1.EVENT; eventData.status = name; eventData.source = internalContext.getIf("_source", "_element").value; // this fixes the issue that the source element is not present anymore at done // at page transitions if (!eventData.source) { let sourceId = context.getIf(Const_1.SOURCE) .orElseLazy(() => context.getIf(Const_1.P_AJAX_SOURCE).value) .orElseLazy(() => context.getIf(Const_1.CTX_PARAM_REQ_PASS_THR, Const_1.P_AJAX_SOURCE).value) .value; if (sourceId) { eventData.source = mona_dish_1.DQ.byId(sourceId, true).first().value.value; } if (eventData.source) { //we store the event source for later references internalContext.assign("_source", "_element").value = eventData.source; } } if (name !== Const_1.BEGIN) { eventData.responseCode = request === null || request === void 0 ? void 0 : request.status; eventData.responseText = request === null || request === void 0 ? void 0 : request.responseText; eventData.responseXML = request === null || request === void 0 ? void 0 : request.responseXML; } return eventData; } } exports.EventData = EventData; //# sourceMappingURL=EventData.js.map