Sha256: d294cb95060b4f76d04e99e1652dd7f0ec765bc4c50cfa0267c47bac35c94cd4

Contents?: true

Size: 1.84 KB

Versions: 24

Compression:

Stored size: 1.84 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.install_public_api();

      $(function() {
        var dom_config = scrivito_ui.dom_config.read($('body'));
        if (scrivito_ui.is_inited()) {
          if (!dom_config) {
            // UI is already running, but editing is not allowed: reload UI to make it disappear.
            window.parent.location = window.location;
          }
        } else {
          if (!dom_config) {
            // UI is not yet running and config is missing.
            $.error('Missing Scrivito config. Did you forget to include scrivito_body_tags in layout?');
          }
          scrivito_ui.init(dom_config);
          scrivito_ui.gui.start();
          if (window.parent.location.hash.length) {
            location.hash = window.parent.location.hash;
          }
        }
        cms_document.connect();
      });
    }
  } else  {
    $(function() {
      // Not in UI mode, but editing is allowed: redirect to the UI mode.
      if ($('[data-scrivito-private-config]').length) {
        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') {
          $(function() {
            callback(window.document);
          });
        }
      },

      in_editable_view: function() { return false; }
    };
  }
}());

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
scrivito_sdk-0.66.0 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.66.0.rc2 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.65.2 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.66.0.rc1 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.65.1 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.65.0 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.65.0.rc2 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.65.0.rc1 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.60.0 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.60.0.rc2 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.50.1 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.60.0.rc1 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.50.0 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.50.0.rc2 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.50.0.rc1 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.42.1 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.42.1.rc3 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.42.1.rc2 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.42.1.rc1 lib/assets/javascripts/scrivito_sdk.js
scrivito_sdk-0.42.0 lib/assets/javascripts/scrivito_sdk.js