Sha256: 533e3ba5d83ae81d9a9b6dd86677443a635d738d79c1a263cc321b2628fe21da

Contents?: true

Size: 1.51 KB

Versions: 14

Compression:

Stored size: 1.51 KB

Contents

(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; }
    };
  }
}());

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
scrivito_sdk-1.5.5 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.5.rc1 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.4 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.4.rc1 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.3 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.3.rc1 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.2 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.2.rc1 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.1 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.1.rc2 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.1.rc1 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.0 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.0.rc2 lib/assets/javascripts/scrivito.js
scrivito_sdk-1.5.0.rc1 lib/assets/javascripts/scrivito.js