lib/assets/javascripts/scrivito.js in scrivito_sdk-1.6.1 vs lib/assets/javascripts/scrivito.js in scrivito_sdk-1.7.0.rc1

- old
+ new

@@ -1,35 +1,53 @@ -(function() { +"use strict"; + +(function () { + var scrivitoUi = undefined; + if (window.parent !== window) { - var scrivito_ui = window.parent.scrivito; - if (scrivito_ui) { + scrivitoUi = window.parent.scrivito; + if (scrivitoUi) { // 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(); + var cmsDocument = scrivitoUi.cms_element.from_dom_element(document); + cmsDocument.installPublicApi(); + cmsDocument.add_app_extensions(); // wait for app to be fully loaded - document.addEventListener("DOMContentLoaded", function() { + 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(); + scrivitoUi.on("load", function () { + cmsDocument.assert_user_logged_in(); + cmsDocument.connect(); }); }); } } + if (window.scrivito && window.scrivito.client) { + scrivito.client.initialize({ scrivitoUi: scrivitoUi, realmContext: window.scrivito }); + } + // 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); - }); - } - }, + window.scrivito = {}; + } - in_editable_view: function() { return false; } + if (!window.scrivito.on) { + window.scrivito.on = function (eventName, callback) { + if (eventName === 'content') { + document.addEventListener("DOMContentLoaded", function () { + return callback(window.document); + }); + } }; } -}()); + + if (!window.scrivito.in_editable_view) { + window.scrivito.in_editable_view = function () { + return false; + }; + } +})(); +// this is an asset pipeline manifest file that the rails developer includes +// in order to use Scrivito. this manifest does _not_ include the JS SDK. +// +