chore: sync module from working instance and add install guide
This commit is contained in:
@@ -15,7 +15,7 @@ $payload = [
|
||||
$jsonPayload = json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
?>
|
||||
|
||||
<div class="panel panel-success" style="margin:10px;">
|
||||
<div class="panel panel-success" data-animal-inline-result="saved" data-animal-inline-collapse-id="<?= Html::encode((string)$collapseId) ?>" style="margin:10px;">
|
||||
<div class="panel-body" style="padding:12px;">
|
||||
<?= Html::encode(Yii::t('AnimalManagementModule.base', 'Saved. Updating section...')) ?>
|
||||
</div>
|
||||
@@ -25,8 +25,59 @@ $jsonPayload = json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNI
|
||||
$this->registerJs(<<<JS
|
||||
(function() {
|
||||
var payload = {$jsonPayload};
|
||||
|
||||
function triggerChange(element) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
|
||||
var event;
|
||||
if (typeof Event === 'function') {
|
||||
event = new Event('change', { bubbles: true });
|
||||
} else {
|
||||
event = document.createEvent('Event');
|
||||
event.initEvent('change', true, true);
|
||||
}
|
||||
element.dispatchEvent(event);
|
||||
}
|
||||
|
||||
function closeByFrameContext() {
|
||||
if (!window.parent || window.parent === window) {
|
||||
return;
|
||||
}
|
||||
|
||||
var frameElement = window.frameElement;
|
||||
if (!frameElement || !frameElement.parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
var closeControl = frameElement.parentElement.querySelector('.animal-tile-inline-iframe-close[for]');
|
||||
if (!closeControl) {
|
||||
return;
|
||||
}
|
||||
|
||||
var targetId = String(closeControl.getAttribute('for') || '');
|
||||
if (!targetId) {
|
||||
return;
|
||||
}
|
||||
|
||||
var targetElement = window.parent.document.getElementById(targetId);
|
||||
if (!targetElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((targetElement.type || '').toLowerCase() === 'radio') {
|
||||
targetElement.checked = true;
|
||||
} else {
|
||||
targetElement.checked = false;
|
||||
}
|
||||
|
||||
triggerChange(targetElement);
|
||||
}
|
||||
|
||||
if (window.parent && window.parent !== window) {
|
||||
window.parent.postMessage(payload, '*');
|
||||
closeByFrameContext();
|
||||
}
|
||||
})();
|
||||
JS
|
||||
|
||||
Reference in New Issue
Block a user