Files
interblue.pl/modules/dpdpoland/js/dpdpoland-pudo-cod-iframe.js
2026-03-31 22:07:39 +02:00

66 lines
2.6 KiB
JavaScript

/*
* Copyright 2024 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* Licensed under the EUPL-1.2 or later.
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* It is also bundled with this package in the file LICENSE.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an AS IS basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions
* and limitations under the Licence.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2024 DPD Polska Sp. z o.o.
* @license https://joinup.ec.europa.eu/software/page/eupl
*/
// noinspection JSUnresolvedReference
if (typeof dpdPolandCodEventCreated == 'undefined') {
var dpdPolandCodEventCreated = false;
}
var dpdPolandCod_iframe = document.createElement("iframe");
dpdPolandCod_iframe.setAttribute("id", "dpdpoland-widget-pudo-cod-iframe");
dpdPolandCod_iframe.setAttribute("allow", "geolocation");
dpdPolandCod_iframe.src = dpdpoland_iframe_cod_url;
dpdPolandCod_iframe.style.width = "100%";
dpdPolandCod_iframe.style.border = "none";
dpdPolandCod_iframe.style.minHeight = "400px";
dpdPolandCod_iframe.style.height = "768px";
var dpdPolandCod_script = document.getElementById("dpdpoland-widget-pudo-cod");
if (dpdPolandCod_script)
dpdPolandCod_script.parentNode.insertBefore(dpdPolandCod_iframe, dpdPolandCod_script);
if (!dpdPolandCodEventCreated) {
var dpdPolandCod_eventListener = window[window.addEventListener ? "addEventListener" : "attachEvent"];
var dpdPolandCod_messageEvent = ("attachEvent" === dpdPolandCod_eventListener) ? "onmessage" : "message";
dpdPolandCod_eventListener(dpdPolandCod_messageEvent, function (a) {
if (getDpdPolandIdPudoCodCarrier() === getDpdPolandSelectedCarrier()) {
if (a.data.height && !isNaN(a.data.height)) {
dpdPolandCod_iframe.style.height = a.data.height + "px"
} else if (a.data.point_id)
dpdPolandCodPointSelected(a.data.point_id);
}
}, !1);
dpdPolandCodEventCreated = true
}
function dpdPolandCodPointSelected(pudoCode) {
$('.container_dpdpoland_pudo_cod_error').css("display", "none");
$('.dpdpoland-pudo-cod-new-point').css("display", "none");
$('.dpdpoland-pudo-cod-selected-point').css("display", "block");
dpdPolandSavePudoCode(pudoCode, $('#dpdpolandPudoCodModal'));
dpdPolandGetPudoAddress(pudoCode, $('.dpdpoland-cod-selected-point'))
}