(function() { if (window.parent !== window) { var scrivito_ui = window.parent.scrivito; if (scrivito_ui) { // In an iframe and parent window contains the UI: in UI mode. var cms_document = scrivito_ui.cms_element.from_dom_element(document); cms_document.installPublicApi(); cms_document.add_app_extensions(); // wait for app to be fully loaded document.addEventListener("DOMContentLoaded", function() { // wait for UI to be fully loaded scrivito_ui.on("load", function() { cms_document.assert_user_logged_in(); cms_document.connect(); }); }); } } else { document.addEventListener("DOMContentLoaded", function() { // Not in UI mode, but editing is allowed: redirect to the UI mode. if (document.querySelector('[data-scrivito-private-page-config]')) { console.log('Scrivito config found: redirecting to the UI...'); window.location = '/scrivito' + window.location.pathname + window.location.search + window.location.hash; } }); } // If the SDK is completely missing, the custom callbacks should nevertheless run. if (!window.scrivito) { window.scrivito = { on: function(event_name, callback) { if (event_name === 'content') { document.addEventListener("DOMContentLoaded", function() { callback(window.document); }); } }, in_editable_view: function() { return false; } }; } }());