PluginProbe
Smart Forms – when you need more than just a contact form / 0.5
Smart Forms – when you need more than just a contact form v0.5
trunk 0.5 0.5.5 0.6 0.7 0.8 0.8.5 0.9.1
smart-forms / js / shortcode / smartFormsShortCodeButton.js

smartFormsShortCodeButton.js in Smart Forms – when you need more than just a contact form 0.5, at js/shortcode/smartFormsShortCodeButton.js

83 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function() {
2 javascriptUrl='';
3 tinymce.create('tinymce.plugins.rednao_smart_forms', {
4 init : function(ed, url) {
5 javascriptUrl=url.substring(0,url.length-13);
6 // Register command for when button is clicked
7 ed.addCommand('rednao_smart_forms_short_code_clicked', function(a,donationId) {
8 tinymce.execCommand('mceInsertContent', false, '[sform]'+donationId+'[/sform]');
9
10 rnJQuery("#smartformsShortCodeDialog").dialog('close');
11 rnJQuery("#smartformsShortCodeDialog").remove();
12 }),
13
14 // Register buttons - trigger above command when clicked
15 ed.addButton('rednao_smart_forms_button', {title : 'Smart Forms', image: javascriptUrl + '/images/smartFormsIcon.png',
16 onclick:function()
17 {
18 var data={
19 action:"rednao_smart_form_list"
20 };
21
22 rnJQuery.post(ajaxurl,data,smartFormsAjaxCompleted);
23
24 }});
25 }
26 });
27
28
29 tinymce.PluginManager.add('rednao_smart_forms_button', tinymce.plugins.rednao_smart_forms);
30 })();
31 var smartFormsShortCodeDialog;
32 function smartFormsAjaxCompleted(result,status)
33 {
34
35 if(smartFormsShortCodeDialog==null)
36 {
37 var smartFormsPopUpForm='<div style=""><div id="smartformsShortCodeDialog" title="Basic modal dialog"><select id="smartFormList">';
38 smartFormsPopUpForm+='</select></div></div>'
39 var dialog=rnJQuery(smartFormsPopUpForm);
40
41 smartFormsShortCodeDialog=dialog.dialog({
42 modal:true,
43 draggable:false,
44 title:'Select a Form ',
45 resizable:false,
46 buttons:[
47 {text: "Apply", click: function() {tinymce.execCommand('rednao_smart_forms_short_code_clicked', false, rnJQuery('#smartFormList').val())}},
48 {text: "Cancel", click: function() {rnJQuery(this).dialog("close")}}
49 ],
50 create: function(event, ui){
51 rnJQuery('.ui-dialog').wrap('<div class="smartFormsSlider" />');
52 },
53 open: function(event, ui){
54 rnJQuery('.ui-widget-overlay').wrap('<div class="smartFormsSlider" />');
55 rnJQuery(".smartFormsConfigurationFields").val('');
56 }
57 });
58 }else{
59 smartFormsShortCodeDialog.dialog('open');
60 rnJQuery('#redNaoSelection').val('button');
61 }
62
63 ajaxFormCompleted(result);
64
65 function ajaxFormCompleted(result) {
66 var formArray=rnJQuery.parseJSON(result);
67 var options="";
68 for(var i=0;i<formArray.length;i++)
69 {
70 options+=' <option value="'+formArray[i].Id+'">'+formArray[i].Name+'</option>';
71 }
72
73 rnJQuery('#smartFormList').empty().append(options);
74 }
75
76
77
78
79
80 }
81
82
83