2021-06-15 09:41:50 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Cognito Forms WordPress Plugin.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2022-01-22 22:17:27 -05:00
|
|
|
?>
|
2021-06-15 09:41:50 -04:00
|
|
|
|
2022-01-22 22:17:27 -05:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Cognito Forms</title>
|
|
|
|
<style>
|
|
|
|
html, body {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
#cognito-frame {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
border: none;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<iframe id="cognito-frame" src="https://forms.cognito.test/integrations/cms"></iframe>
|
2021-12-23 15:50:33 -05:00
|
|
|
|
2022-01-22 22:17:27 -05:00
|
|
|
<script type="text/javascript">
|
|
|
|
window.addEventListener('message', handleMessage);
|
2021-12-23 15:50:33 -05:00
|
|
|
|
2022-01-22 22:17:27 -05:00
|
|
|
function handleMessage(event) {
|
|
|
|
var frame = document.getElementById('cognito-frame');
|
|
|
|
var baseUrl = new URL(frame.getAttribute('src')).origin;
|
2021-12-23 15:50:33 -05:00
|
|
|
|
2022-01-22 22:17:27 -05:00
|
|
|
if (event.origin === baseUrl) {
|
|
|
|
console.log('Message received!');
|
|
|
|
sendData(event.data);
|
2021-06-15 09:41:50 -04:00
|
|
|
}
|
2022-01-22 22:17:27 -05:00
|
|
|
}
|
2021-12-23 15:50:33 -05:00
|
|
|
|
2022-01-22 22:17:27 -05:00
|
|
|
function sendData(data) {
|
|
|
|
embedCode = data.embedCodes.Seamless;
|
|
|
|
console.log(embedCode);
|
2021-12-23 15:50:33 -05:00
|
|
|
|
2022-01-22 22:17:27 -05:00
|
|
|
if (top.tinyMCE && top.tinyMCE.activeEditor) {
|
|
|
|
top.tinyMCE.activeEditor.insertContent(embedCode);
|
|
|
|
}
|
2021-12-23 15:50:33 -05:00
|
|
|
|
2022-01-22 22:17:27 -05:00
|
|
|
top.tinymce.activeEditor.windowManager.close();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
2021-12-23 15:50:33 -05:00
|
|
|
</html>
|