Improvements for embedded Cognito Forms editor

This commit is contained in:
Michael Thomas 2022-01-26 13:59:34 -05:00
parent b2b3fca468
commit 9e800d1bbb
1 changed files with 53 additions and 61 deletions

View File

@ -1,61 +1,53 @@
<?php <?php
/** /**
* Cognito Forms WordPress Plugin. * Cognito Forms WordPress Plugin.
* *
* The Cognito Forms WordPress Plugin is free software; you can redistribute it and/or modify * The Cognito Forms WordPress Plugin is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as * it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* The Cognito Forms WordPress Plugin is distributed in the hope that it will be useful, * The Cognito Forms WordPress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
require_once dirname(__FILE__) . '/../api.php'; $url = 'https://www.cognitoforms.com/';
$url = CognitoAPI::$formsBase; if ($_GET['page'] == 'CognitoCreateForm') {
$url = $url . 'forms/new';
if ($_GET['page'] == 'CognitoCreateForm') { } elseif ($_GET['page'] == "CognitoTemplates") {
$url = $url . 'forms/new'; $url = $url . 'templates';
} elseif ($_GET['page'] == "CognitoTemplates") { } else {
$url = $url . 'templates'; $url = $url . 'forms';
} else { }
$url = $url . 'forms'; ?>
}
?> <iframe id="cognito-frame" src="<?= $url ?>"></iframe>
<iframe id="cognito-frame" src="<?php print $url; ?>" style="width:100%; overflow-x: hidden;"></iframe> <style>
body {
<style> overflow: hidden;
body { }
overflow: hidden; #wpcontent {
} padding-left: 0!important;
#wpcontent { }
padding-left: 0!important; #wpfooter {
} display: none;
</style> }
#wpwrap, #wpcontent, #wpbody, #wpbody-content {
<script language="javascript"> height: 100%;
// Remove all content injected prior to the iframe (ex. wordpress update banners) }
var element = document.getElementById('cognito-frame'); #wpbody-content *:not(#cognito-frame) {
for (; element; element = element.previousSibling) { display: none!important;
if (element.nodeType === 1 && element.id !== 'cognito-frame') { }
element.style.display = 'none'; #cognito-frame {
} width: 100%;
} height: 100%;
overflow-x: hidden;
window.addEventListener('resize', resizeListener); }
</style>
// Handler to watch for window resize to correctly update iframe height
function resizeListener(event) {
var adminheight = document.getElementById('wpadminbar').clientHeight;
document.getElementById('cognito-frame').height = (document.body.clientHeight) + "px";
}
resizeListener();
</script>