Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions partials/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ <h1 class="text-center grey-text"><strong>EXAMPLES</strong></h1>
</jsonforms>
</div>
</div>
<div layout="column" layout-align="center center">
<md-button style="background-color: #d9534f"
class="md-raised md-primary"
ng-click="vm.openEditorInNewTab()">Try in the Editor</md-button>
</div>
</div>
</article>
11 changes: 8 additions & 3 deletions partials/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ <h3 class="text-center editor-label" style="font-size: 20px; font-weight:bold">U
</div>
</div>
<div layout="column" layout-align="center center">
<md-button style="background-color: #d9534f"
class="md-raised md-primary"
ui-sref="examples">More examples</md-button>
<div layout="row">
<md-button style="background-color: #d9534f"
class="md-raised md-primary"
ui-sref="examples">More examples</md-button>
<md-button style="background-color: #d9534f"
class="md-raised md-primary"
ng-click="vm.openEditorInNewTab()">Try in the Editor</md-button>
</div>
</div>
</div>
</article>