diff --git a/js/app.js b/js/app.js index 626d75bae2..048fca4df7 100644 --- a/js/app.js +++ b/js/app.js @@ -352,6 +352,35 @@ angular.module('jsonforms-website', [ return false; }; + vm.openEditorInNewTab = function () { + vm.reparseStatic(); + + var tab = window.open('http://jsonformseditor.herokuapp.com/#/demo'); + var data = { + dataSchema: vm.localStaticModelObject, + uiSchema: vm.localStaticViewObject + }; + var passedByReference = { ackReceived: false }; + + window.addEventListener('message', function(event) { + if (event.data == 'ACK') { + window.removeEventListener('message', function() {}, false); + passedByReference.ackReceived = true; + } + }, false); + + vm.postMessagetoTab(tab, data, passedByReference); + }; + + vm.postMessagetoTab = function(tab, data, passedByReference) { + setTimeout(function () { + tab.postMessage(data, '*'); + if (!passedByReference.ackReceived) { + vm.postMessagetoTab(tab, data, passedByReference); + } + }, 1000); + }; + vm.staticDataProvider = StaticData; vm.dynamicDataProvider = DynamicData; diff --git a/partials/examples.html b/partials/examples.html index b13740c1fc..9bbdbc75d2 100644 --- a/partials/examples.html +++ b/partials/examples.html @@ -22,5 +22,10 @@

EXAMPLES

+
+ Try in the Editor +
\ No newline at end of file diff --git a/partials/landing.html b/partials/landing.html index 60c6c8a6c2..8bd009f4f5 100644 --- a/partials/landing.html +++ b/partials/landing.html @@ -76,9 +76,14 @@

U
- More examples +
+ More examples + Try in the Editor +
\ No newline at end of file