forked from jotform/wordpress-embed-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjotform-wp-embed.js
executable file
·62 lines (61 loc) · 2.44 KB
/
jotform-wp-embed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Plugin Name: JotForm Embed Forms
Plugin URI: https://www.jotform.com/labs/
Description:
Version: 1.2.6
Author: JotForm.com
Author URI: https://www.jotform.com
License: GNU General Public License v3
*/
(function() {
tinymce.create('tinymce.plugins.JotFormWPEmbed', {
init : function(ed, url) {
ed.addButton('JotFormWPEmbed', {
title : 'JotForm',
image : url+'/images/jotform.png',
onclick : function(event) {
function openWizard() {
window.jotformFormPicker.openWizard(function(data){
var value;
var isValid;
if(typeof data !== 'string'){
isValid = data && data.title && data.id && data.id !== "Please enter your form id";
value = '[jotform id="' + data.id + '" title="'+data.title+'"]';
} else{
isValid = data.length > 0 && data !== "Please enter your form id";
value = '[jotform id="' + data + '"]';
}
if (isValid) {
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, value);
}
});
}
if(window.jotformFormPicker) {
event.preventDefault();
openWizard();
}
else {
jQuery.getScript("//js.jotform.com/JotFormFormPicker.js", function(data, textStatus, jqxhr) {
event.preventDefault();
window.jotformFormPicker = new JotFormFormPicker();
openWizard();
});
}
}
});
},
createControl : function(n, cm) {
return null;
},
getInfo : function() {
return {
longname : "JotForm Embed Forms",
author : 'JotForm.com',
authorurl : 'https://www.jotform.com',
infourl : 'https://www.jotform.com/labs/',
version : "1.2.5"
};
}
});
tinymce.PluginManager.add('JotFormWPEmbed', tinymce.plugins.JotFormWPEmbed);
})();