-
Notifications
You must be signed in to change notification settings - Fork 7
/
jotform-wp-embed.js
executable file
·60 lines (58 loc) · 2.34 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
/**
* Plugin Name: Jotform Online Forms
* Description: Securely embed online forms in your WordPress website.
* Requires at least: 3.3
* Requires PHP: 5.6
* Version: 1.3.2
* Author: Jotform
* Author URI: https://www.jotform.com
* License: GNU General Public License v3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
(function() {
tinymce.create('tinymce.plugins.JotFormWPEmbed', {
init : function(ed, url) {
ed.addButton('JotFormWPEmbed', {
title : 'Jotform',
image : url+'/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);
}
});
}
event.preventDefault();
if (window.jotformFormPicker) {
openWizard();
} else if (JotFormFormPicker) {
window.jotformFormPicker = new JotFormFormPicker();
openWizard();
}
}
});
},
createControl : function(n, cm) {
return null;
},
getInfo : function() {
return {
longname : "Jotform Online Forms",
author : 'Jotform',
authorurl : 'https://www.jotform.com',
version : "1.3.2"
};
}
});
tinymce.PluginManager.add('JotFormWPEmbed', tinymce.plugins.JotFormWPEmbed);
})();