| @@ -4,14 +4,10 @@ | ||
| 4 | 4 | init : function(ed, url) { |
| 5 | 5 | javascriptUrl=url.substring(0,url.length-13); |
| 6 | 6 | // Register command for when button is clicked |
| 7 | 7 | ed.addCommand('rednao_smart_forms_short_code_clicked', function(a,donationId) { |
| 8 | + tinymce.execCommand('mceInsertContent', false, '[sform]'+donationId+'[/sform]'); | |
| 8 | 9 | |
| 9 | - var shortCode=rnJQuery('#smartFormShortCodeSelect').val(); | |
| 10 | - if(shortCode==null) | |
| 11 | - return; | |
| 12 | - tinymce.execCommand('mceInsertContent', false,shortCode); | |
| 13 | - | |
| 14 | 10 | rnJQuery("#smartformsShortCodeDialog").dialog('close'); |
| 15 | 11 | rnJQuery("#smartformsShortCodeDialog").remove(); |
| 16 | 12 | }), |
| 17 | 13 | |
| @@ -19,10 +15,9 @@ | ||
| 19 | 15 | ed.addButton('rednao_smart_forms_button', {title : 'Smart Forms', image: javascriptUrl + '/images/smartFormsIcon.png', |
| 20 | 16 | onclick:function() |
| 21 | 17 | { |
| 22 | 18 | var data={ |
| 23 | - action:"rednao_smart_form_short_code_setup", | |
| 24 | - nonce:smartformsvars.nonce | |
| 19 | + action:"rednao_smart_form_list" | |
| 25 | 20 | }; |
| 26 | 21 | |
| 27 | 22 | rnJQuery.post(ajaxurl,data,smartFormsAjaxCompleted); |
| 28 | 23 | |
| @@ -35,22 +30,15 @@ | ||
| 35 | 30 | })(); |
| 36 | 31 | var smartFormsShortCodeDialog; |
| 37 | 32 | function smartFormsAjaxCompleted(result,status) |
| 38 | 33 | { |
| 39 | - var shortCodeOptions=rnJQuery.parseJSON(result); | |
| 40 | 34 | |
| 41 | - | |
| 42 | 35 | if(smartFormsShortCodeDialog==null) |
| 43 | 36 | { |
| 44 | - var $optionsSelect=rnJQuery('<select style="display: block;width:100%;margin-bottom: 10px;" ></select>'); | |
| 45 | - var $elementsSelect=rnJQuery('<select id="smartFormShortCodeSelect" style="display: block;width:100%;"></select>'); | |
| 46 | - var smartFormsPopUpForm='<div style=""><div id="smartformsShortCodeDialog" title="Basic modal dialog">'; | |
| 47 | - smartFormsPopUpForm+='</div></div>'; | |
| 37 | + var smartFormsPopUpForm='<div style=""><div id="smartformsShortCodeDialog" title="Basic modal dialog"><select id="smartFormList">'; | |
| 38 | + smartFormsPopUpForm+='</select></div></div>' | |
| 48 | 39 | var dialog=rnJQuery(smartFormsPopUpForm); |
| 49 | - dialog.find('#smartformsShortCodeDialog').append($optionsSelect).append($elementsSelect); | |
| 50 | 40 | |
| 51 | - ConfigureDialogs(shortCodeOptions,$optionsSelect,$elementsSelect); | |
| 52 | - | |
| 53 | 41 | smartFormsShortCodeDialog=dialog.dialog({ |
| 54 | 42 | modal:true, |
| 55 | 43 | draggable:false, |
| 56 | 44 | title:'Select a Form ', |
| @@ -71,35 +59,22 @@ | ||
| 71 | 59 | smartFormsShortCodeDialog.dialog('open'); |
| 72 | 60 | rnJQuery('#redNaoSelection').val('button'); |
| 73 | 61 | } |
| 74 | 62 | |
| 75 | - function ConfigureDialogs(shortCodeOptions,$optionsSelect,$elementsSelect) | |
| 76 | - { | |
| 77 | - var isFirst=true; | |
| 78 | - for(var i=0;i<shortCodeOptions.length;i++) | |
| 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++) | |
| 79 | 69 | { |
| 80 | - $optionsSelect.append('<option '+(isFirst?'selected="selected"':'')+'>'+RedNaoEscapeHtml(shortCodeOptions[i].Name)+'</option>'); | |
| 81 | - isFirst=false; | |
| 70 | + options+=' <option value="'+formArray[i].Id+'">'+formArray[i].Name+'</option>'; | |
| 82 | 71 | } |
| 83 | 72 | |
| 84 | - $optionsSelect.change(function () | |
| 85 | - { | |
| 86 | - $elementsSelect.empty(); | |
| 87 | - var index=rnJQuery(this).find('option:selected').index(); | |
| 88 | - if(index<0) | |
| 89 | - return; | |
| 73 | + rnJQuery('#smartFormList').empty().append(options); | |
| 74 | + } | |
| 90 | 75 | |
| 91 | 76 | |
| 92 | - var selectedOption=shortCodeOptions[index]; | |
| 93 | - var isFirst=true; | |
| 94 | - for(var i=0;i<selectedOption.Elements.length;i++) | |
| 95 | - { | |
| 96 | - $elementsSelect.append('<option value="['+selectedOption.ShortCode+']'+selectedOption.Elements[i].Id+'[/'+selectedOption.ShortCode+']" '+(isFirst?'selected="selected"':'')+'>'+RedNaoEscapeHtml(selectedOption.Elements[i].Name)+'</option>'); | |
| 97 | - isFirst=false; | |
| 98 | - } | |
| 99 | - }).change(); | |
| 100 | - | |
| 101 | - } | |
| 102 | 77 | |
| 103 | 78 | |
| 104 | 79 | |
| 105 | 80 | } |