Working Prototype
This commit is contained in:
@@ -40,11 +40,11 @@
|
||||
|
||||
var closeElement = tinyMCEPopup.getWin().document.querySelector('.mceClose, .mce-close');
|
||||
if (closeElement) closeElement.style.color = '#fff';
|
||||
|
||||
|
||||
function cognito_submit() {
|
||||
var formSelect = document.getElementById('formSelect');
|
||||
var shortcode = '[CognitoForms id="' + formSelect.value + '"]';
|
||||
|
||||
|
||||
if (window.tinyMCE) {
|
||||
if (window.tinyMCE.execInstanceCommand) {
|
||||
window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, shortcode);
|
||||
@@ -53,44 +53,44 @@
|
||||
else if (window.tinyMCE.focusedEditor) {
|
||||
window.tinyMCE.focusedEditor.insertContent(shortcode);
|
||||
}
|
||||
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
jQuery(function() {
|
||||
var data = {
|
||||
action: "get_forms"
|
||||
};
|
||||
jQuery.post(tinyMCEPopup.params.ajax_url, data, function(response) {
|
||||
jQuery.post(tinyMCEPopup.params.ajax_url, data, function(response) {
|
||||
if (response) {
|
||||
var forms = JSON.parse(response);
|
||||
|
||||
|
||||
var formSelect = jQuery("#formSelect");
|
||||
jQuery.each(forms, function() {
|
||||
formSelect.append(jQuery("<option></option>")
|
||||
.attr("value", this.Id)
|
||||
.text(this.Name));
|
||||
});
|
||||
|
||||
|
||||
jQuery("#form-list").show();
|
||||
} else {
|
||||
jQuery("#no-forms").show();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<div id="no-forms" style="display:none;">
|
||||
<h3>You are not logged into your Cognito Forms account.</h3>
|
||||
<p>Please click on the "Cognito Forms" link in the menu on the left and log in to register this plug-in with your account.</p>
|
||||
</div>
|
||||
|
||||
<div id="form-list" style="display:none;">
|
||||
|
||||
<div id="form-list">
|
||||
<h3>Embed a Form</h3>
|
||||
<form method="post" action="">
|
||||
<label for="formSelect">Choose a form</label>
|
||||
@@ -100,4 +100,4 @@
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user