Update admin templates
This commit is contained in:
parent
7abb135072
commit
1aa0423886
|
@ -23,7 +23,7 @@ $url = CognitoAPI::$formsBase;
|
||||||
if ($_GET['page'] == 'CognitoCreateForm') {
|
if ($_GET['page'] == 'CognitoCreateForm') {
|
||||||
$url = $url . 'forms/new';
|
$url = $url . 'forms/new';
|
||||||
} elseif ($_GET['page'] == "CognitoTemplates") {
|
} elseif ($_GET['page'] == "CognitoTemplates") {
|
||||||
$url = $url . 'forms/templates';
|
$url = $url . 'templates';
|
||||||
} else {
|
} else {
|
||||||
$url = $url . 'forms';
|
$url = $url . 'forms';
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,16 @@ if ($_GET['page'] == 'CognitoCreateForm') {
|
||||||
<iframe id="cognito-frame" src="<?php print $url; ?>" style="width:100%; overflow-x: hidden;"></iframe>
|
<iframe id="cognito-frame" src="<?php print $url; ?>" style="width:100%; overflow-x: hidden;"></iframe>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body { overflow: hidden; }
|
body {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
#wpcontent {
|
||||||
|
padding-left: 0!important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script language="javascript">
|
<script language="javascript">
|
||||||
|
// Remove all content injected prior to the iframe (ex. wordpress update banners)
|
||||||
var element = document.getElementById('cognito-frame');
|
var element = document.getElementById('cognito-frame');
|
||||||
for (; element; element = element.previousSibling) {
|
for (; element; element = element.previousSibling) {
|
||||||
if (element.nodeType === 1 && element.id !== 'cognito-frame') {
|
if (element.nodeType === 1 && element.id !== 'cognito-frame') {
|
||||||
|
@ -43,9 +49,6 @@ if ($_GET['page'] == 'CognitoCreateForm') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var adminheight = document.getElementById('wpadminbar').clientHeight;
|
|
||||||
document.getElementById('cognito-frame').height = (document.body.clientHeight - adminheight) + "px";
|
|
||||||
window.addEventListener("message", messageListener);
|
|
||||||
window.addEventListener('resize', resizeListener);
|
window.addEventListener('resize', resizeListener);
|
||||||
|
|
||||||
// Handler to watch for window resize to correctly update iframe height
|
// Handler to watch for window resize to correctly update iframe height
|
||||||
|
@ -54,28 +57,5 @@ if ($_GET['page'] == 'CognitoCreateForm') {
|
||||||
|
|
||||||
document.getElementById('cognito-frame').height = (document.body.clientHeight) + "px";
|
document.getElementById('cognito-frame').height = (document.body.clientHeight) + "px";
|
||||||
}
|
}
|
||||||
|
resizeListener();
|
||||||
// Handler to listen for session tokens being broadcast from the Cognito iframe
|
|
||||||
function messageListener(event) {
|
|
||||||
var data = event.data;
|
|
||||||
|
|
||||||
var found = data.indexOf("token:");
|
|
||||||
if (found == 0) {
|
|
||||||
var token = data.substring("token:".length);
|
|
||||||
|
|
||||||
// If a session token was received, and no api key is present, update
|
|
||||||
fetchApiKey(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Posts token to a hidden iframe so that a separate script can fetch necessary keys
|
|
||||||
function fetchApiKey(token) {
|
|
||||||
if (!token) return;
|
|
||||||
var data = {
|
|
||||||
action: "fetch_api_keys",
|
|
||||||
token: token
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery.post(ajaxurl, data, function(response) { });
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue