Skip to content
Snippets Groups Projects
Commit 64f11197 authored by berliner's avatar berliner Committed by christian.wiedemann
Browse files

Issue #3353020 by berliner: Prevent JS errors when Layout Builder is not...

Issue #3353020 by berliner: Prevent JS errors when Layout Builder is not initially displayed but loaded later via ajax
parent 8d0ea509
No related branches found
No related tags found
No related merge requests found
!function(e){function t(o){if(a[o])return a[o].exports;var n=a[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var a={};t.m=e,t.c=a,t.d=function(e,a,o){t.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,a){if(1&a&&(e=t(e)),8&a)return e;if(4&a&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&a&&"string"!=typeof e)for(var n in e)t.d(o,n,function(t){return e[t]}.bind(null,n));return o},t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,"a",a),a},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="../",t(t.s=2)}([,,function(e,t,a){e.exports=a(3)},function(e,t,a){"use strict";a.r(t);var o=a(4),n=(a.n(o),a(5)),s=(a.n(n),a(6)),r=(a.n(s),a(7)),i=(a.n(r),a(8));a.n(i)},function(){"use strict";var e,t;e=jQuery,t=Drupal,drupalSettings,t.behaviors.gin_lb_lb={attach:t=>{once("gin-lb-lb",".layout-builder-block",t).forEach(t=>{var a=e(t);const o="gin-lb--disable-section-focus";new MutationObserver((function(t){t.forEach((function(t){"class"===t.attributeName&&(e(t.target).hasClass("focus")?e(t.target).parents(".layout-builder__section").addClass(o):e(t.target).parents(".layout-builder__section").removeClass(o))}))})).observe(a[0],{attributes:!0})})}}},function(){"use strict";var e,t,a;e=jQuery,t=Drupal,a=drupalSettings,t.behaviors.offCanvas={width:null==localStorage.getItem("gin_lb_offcanvas_width")?null==(a.gin_lb||{}).offcanvas_width?450:a.gin_lb.offcanvas_width:localStorage.getItem("gin_lb_offcanvas_width"),links:[],attach:()=>{function a(a){const o=e(a).data("dialog-options"),n=null==o?{}:o;n.width=t.behaviors.offCanvas.width,e(a).attr("data-dialog-options",JSON.stringify(n)),t.ajax.instances.forEach(e=>{null!=e&&"off_canvas"===e.dialogRenderer&&(null==e.options.data.dialogOptions&&(e.options.data.dialogOptions={}),n.width&&(e.options.data.dialogOptions.width=n.width))})}once("gin-canvas-event","body").forEach(()=>{e("body").on("dialogresizestop",()=>{const o=e(".ui-dialog-off-canvas");t.behaviors.offCanvas.width=o.width(),localStorage.setItem("gin_lb_offcanvas_width",t.behaviors.offCanvas.width),t.behaviors.offCanvas.links.forEach(e=>{a(e)})})}),window.setTimeout(()=>{once("glb-offcanvas-width","a[data-dialog-renderer]").forEach(e=>{t.behaviors.offCanvas.links.push(e),a(e)})},300)}}},function(){"use strict";var e;jQuery,e=Drupal,drupalSettings,e.behaviors.ginLbToolbar={attach:()=>{once("glb-primary-save",".glb-primary-save ").forEach(e=>{e.addEventListener("click",(function(){document.querySelector("#gin_sidebar .form-actions .glb-button--primary").click()}))})}}},function(){"use strict";var e;jQuery,e=Drupal,drupalSettings,e.behaviors.glb_preview_regions={attach:()=>{once("glb-preview-region","body").forEach(()=>{const e=document.getElementById("glb-toolbar-preview-regions"),t=document.getElementById("glb-toolbar-preview-content"),a=document.getElementById("layout-builder-content-preview"),o=document.getElementsByTagName("body")[0];t.checked=a.checked,e.checked=o.classList.contains("glb-preview-regions--enable"),e.addEventListener("change",()=>{e.checked?(document.querySelector(".layout__region-info").parentNode.classList.add("layout-builder__region"),document.querySelector("body").classList.add("glb-preview-regions--enable")):o.classList.remove("glb-preview-regions--enable")}),t.addEventListener("change",()=>{a.checked!==t.checked&&a.click()})})}}},function(){"use strict";var e,t;e=jQuery,t=Drupal,drupalSettings,t.behaviors.ginLbToastify={attach:t=>{let a=e(".ui-dialog-off-canvas").length?e(".ui-dialog-off-canvas").width():0;once("glb-messages-warning",".glb-messages--warning",t).forEach(t=>{e(t).hasClass("toastify")||(Toastify({text:e(t).html(),escapeMarkup:!1,close:!0,gravity:"bottom",duration:6e3,position:"right",offset:{x:0},className:"glb-messages glb-messages--warning",style:{background:"var(--colorGinWarningBackground)"}}).showToast(),e(t).hide())}),once("glb-messages-error",".glb-messages--error",t).forEach(t=>{e(t).hasClass("toastify")||(Toastify({text:e(t).html(),escapeMarkup:!1,gravity:"bottom",duration:6e3,position:"right",close:!0,offset:{x:a},className:"glb-messages glb-messages--error",style:{background:"var(--colorGinErrorBackground)"}}).showToast(),e(t).hide())}),once("glb-messages-status",".glb-messages--status",t).forEach(t=>{e(t).hasClass("toastify")||1<=e(t).parents(".glb-sidebar__content").length||(Toastify({text:e(t).html(),escapeMarkup:!1,close:!0,gravity:"bottom",duration:6e3,position:"right",offset:{x:a},className:"glb-messages glb-messages--status",style:{background:"var(--colorGinStatusBackground)"}}).showToast(),e(t).hide())})}}}]);
\ No newline at end of file
!function(e){function t(o){if(a[o])return a[o].exports;var n=a[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var a={};t.m=e,t.c=a,t.d=function(e,a,o){t.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,a){if(1&a&&(e=t(e)),8&a)return e;if(4&a&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&a&&"string"!=typeof e)for(var n in e)t.d(o,n,function(t){return e[t]}.bind(null,n));return o},t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,"a",a),a},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="../",t(t.s=2)}([,,function(e,t,a){e.exports=a(3)},function(e,t,a){"use strict";a.r(t);var o=a(4),n=(a.n(o),a(5)),s=(a.n(n),a(6)),r=(a.n(s),a(7)),i=(a.n(r),a(8));a.n(i)},function(){"use strict";var e,t;e=jQuery,t=Drupal,drupalSettings,t.behaviors.gin_lb_lb={attach:t=>{once("gin-lb-lb",".layout-builder-block",t).forEach(t=>{var a=e(t);const o="gin-lb--disable-section-focus";new MutationObserver((function(t){t.forEach((function(t){"class"===t.attributeName&&(e(t.target).hasClass("focus")?e(t.target).parents(".layout-builder__section").addClass(o):e(t.target).parents(".layout-builder__section").removeClass(o))}))})).observe(a[0],{attributes:!0})})}}},function(){"use strict";var e,t,a;e=jQuery,t=Drupal,a=drupalSettings,t.behaviors.offCanvas={width:null==localStorage.getItem("gin_lb_offcanvas_width")?null==(a.gin_lb||{}).offcanvas_width?450:a.gin_lb.offcanvas_width:localStorage.getItem("gin_lb_offcanvas_width"),links:[],attach:()=>{function a(a){const o=e(a).data("dialog-options"),n=null==o?{}:o;n.width=t.behaviors.offCanvas.width,e(a).attr("data-dialog-options",JSON.stringify(n)),t.ajax.instances.forEach(e=>{null!=e&&"off_canvas"===e.dialogRenderer&&(null==e.options.data.dialogOptions&&(e.options.data.dialogOptions={}),n.width&&(e.options.data.dialogOptions.width=n.width))})}once("gin-canvas-event","body").forEach(()=>{e("body").on("dialogresizestop",()=>{const o=e(".ui-dialog-off-canvas");t.behaviors.offCanvas.width=o.width(),localStorage.setItem("gin_lb_offcanvas_width",t.behaviors.offCanvas.width),t.behaviors.offCanvas.links.forEach(e=>{a(e)})})}),window.setTimeout(()=>{once("glb-offcanvas-width","a[data-dialog-renderer]").forEach(e=>{t.behaviors.offCanvas.links.push(e),a(e)})},300)}}},function(){"use strict";var e;jQuery,e=Drupal,drupalSettings,e.behaviors.ginLbToolbar={attach:()=>{once("glb-primary-save",".glb-primary-save ").forEach(e=>{e.addEventListener("click",(function(){document.querySelector("#gin_sidebar .form-actions .glb-button--primary").click()}))})}}},function(){"use strict";var e;jQuery,e=Drupal,drupalSettings,e.behaviors.glb_preview_regions={attach:()=>{null===document.getElementById("layout-builder-content-preview")||once("glb-preview-region","body").forEach(()=>{const e=document.getElementById("glb-toolbar-preview-regions"),t=document.getElementById("glb-toolbar-preview-content"),a=document.getElementById("layout-builder-content-preview"),o=document.getElementsByTagName("body")[0];t.checked=a.checked,e.checked=o.classList.contains("glb-preview-regions--enable"),e.addEventListener("change",()=>{e.checked?(document.querySelector(".layout__region-info").parentNode.classList.add("layout-builder__region"),document.querySelector("body").classList.add("glb-preview-regions--enable")):o.classList.remove("glb-preview-regions--enable")}),t.addEventListener("change",()=>{a.checked!==t.checked&&a.click()})})}}},function(){"use strict";var e,t;e=jQuery,t=Drupal,drupalSettings,t.behaviors.ginLbToastify={attach:t=>{let a=e(".ui-dialog-off-canvas").length?e(".ui-dialog-off-canvas").width():0;once("glb-messages-warning",".glb-messages--warning",t).forEach(t=>{e(t).hasClass("toastify")||(Toastify({text:e(t).html(),escapeMarkup:!1,close:!0,gravity:"bottom",duration:6e3,position:"right",offset:{x:0},className:"glb-messages glb-messages--warning",style:{background:"var(--colorGinWarningBackground)"}}).showToast(),e(t).hide())}),once("glb-messages-error",".glb-messages--error",t).forEach(t=>{e(t).hasClass("toastify")||(Toastify({text:e(t).html(),escapeMarkup:!1,gravity:"bottom",duration:6e3,position:"right",close:!0,offset:{x:a},className:"glb-messages glb-messages--error",style:{background:"var(--colorGinErrorBackground)"}}).showToast(),e(t).hide())}),once("glb-messages-status",".glb-messages--status",t).forEach(t=>{e(t).hasClass("toastify")||1<=e(t).parents(".glb-sidebar__content").length||(Toastify({text:e(t).html(),escapeMarkup:!1,close:!0,gravity:"bottom",duration:6e3,position:"right",offset:{x:a},className:"glb-messages glb-messages--status",style:{background:"var(--colorGinStatusBackground)"}}).showToast(),e(t).hide())})}}}]);
\ No newline at end of file
......@@ -6,6 +6,9 @@
Drupal.behaviors.glb_preview_regions = {
attach: (context) => {
if (document.getElementById('layout-builder-content-preview') === null) {
return;
}
once('glb-preview-region', 'body').forEach(()=>{
const toolbarPreviewRegion = document.getElementById('glb-toolbar-preview-regions');
const toolbarPreviewContent = document.getElementById('glb-toolbar-preview-content');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment