-
Notifications
You must be signed in to change notification settings - Fork 146
/
admin-shortcode.js
38 lines (30 loc) · 1.06 KB
/
admin-shortcode.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
/*jshint devel:true */
/*global send_to_editor */
/*global tb_remove */
jQuery(function($) {
$('#wpuf-form-insert').on('click', function(e) {
e.preventDefault();
var shortcode = '',
type = $('#wpuf-form-type').val();
if ( type === 'post' ) {
var post = $('#wpuf-form-post').val();
shortcode += '[wpuf_form id="' + post + '"]';
} else {
var registration = $('#wpuf-form-registration').val();
shortcode += '[wpuf_profile type="registration" id="' + registration + '"] [wpuf_profile type="profile" id="' + registration + '"]';
}
send_to_editor(shortcode);
tb_remove();
});
$('#wpuf-form-type').on('change', function() {
var val = $(this).val();
if ( val === 'post' ) {
$('.show-if-post').show();
$('.show-if-registration').hide();
} else {
$('.show-if-post').hide();
$('.show-if-registration').show();
}
});
$('#wpuf-form-type').trigger('change');
});