| @@ -1,96 +1,112 @@ | ||
| 1 | -jQuery(function($){ | |
| 2 | - | |
| 3 | - function get_tinymce_content(name){ | |
| 4 | - if (jQuery("#"+name+" .wp-editor-wrap").hasClass("tmce-active")){ | |
| 5 | - return tinyMCE.get(name+'_textarea').getContent(); | |
| 6 | - } else | |
| 7 | - { | |
| 8 | - return jQuery("#" +name+ "_textarea").val(); | |
| 9 | - } | |
| 10 | - } | |
| 11 | - | |
| 12 | - var save_button = $('.accua_form_save_settings_button'); | |
| 13 | - var save_status = $(".accua_form_save_settings_status"); | |
| 14 | - $('.accua_form_save_settings_button').click(function(){ | |
| 15 | - save_button.attr('disabled', 'disabled') | |
| 16 | - save_status.empty(); | |
| 17 | - save_status.append("<span class='accua_form_api_throbbler'></span>"); | |
| 18 | - | |
| 19 | - var form_id = $('#accua_form_save_settings_id').val(); | |
| 20 | - | |
| 21 | - var data = { | |
| 22 | - 'action': 'accua-save-form-settings', | |
| 23 | - 'form-id': form_id, | |
| 24 | - 'title': $('#title').val(), | |
| 25 | - 'use_ajax': ($('#accua_form_use_ajax .accua_form_value').is(':checked') ? 1 : 0) | |
| 26 | - }; | |
| 27 | - | |
| 28 | - var layout = $('#accua_form_layout .accua_form_value').val(); | |
| 29 | - if (layout == 'toplabel' || layout == 'sidebyside') { | |
| 30 | - data.layout = layout; | |
| 31 | - } | |
| 32 | - | |
| 33 | - $.each( | |
| 34 | - ['success_message','error_message','emails_from','admin_emails_to','emails_bcc','admin_emails_subject','admin_emails_message','confirmation_emails_subject','confirmation_emails_message'], | |
| 35 | - function(i,key){ | |
| 36 | - var value = $('#accua_form_'+key+' .accua_form_check_override:checked').val(); | |
| 37 | - if(value!=undefined && value!=0) { | |
| 38 | - if(value==-1) | |
| 39 | - { | |
| 40 | - data[key] =''; | |
| 41 | - data[key+"_no_message"] = 1; | |
| 42 | - } | |
| 43 | - else { | |
| 44 | - var element = $('#accua_form_'+key+' .accua_form_value'); | |
| 45 | - if(element.is('input')){ | |
| 46 | - data[key] = $('#accua_form_'+key+' .accua_form_value').val(); | |
| 47 | - } | |
| 48 | - else if(element.is('textarea')) { | |
| 49 | - data[key] = get_tinymce_content('accua_form_'+key); | |
| 50 | - } | |
| 51 | - } | |
| 52 | - } | |
| 53 | - } | |
| 54 | - ); | |
| 55 | - | |
| 56 | - /* | |
| 57 | - $.post( | |
| 58 | - ajaxurl, | |
| 59 | - data, | |
| 60 | - function(){}, | |
| 61 | - 'json' | |
| 62 | - ) | |
| 63 | - */ | |
| 64 | - | |
| 65 | - $.ajax(ajaxurl, { | |
| 66 | - 'type': 'POST', | |
| 67 | - 'data': data, | |
| 68 | - 'success': function(){ | |
| 69 | - document.getElementById('accua_form_preview_area').src = 'admin-ajax.php?action=accua_forms_preview&fid=' + form_id; | |
| 70 | - try { | |
| 71 | - if (history.pushState && window.location.search.search('page=accua_forms_list') == -1) { | |
| 72 | - history.pushState('', document.title, 'admin.php?page=accua_forms_list&fid=' + form_id); | |
| 73 | - window.onpopstate = function(event) { | |
| 74 | - location.reload(); | |
| 75 | - } | |
| 76 | - } | |
| 77 | - } catch (e) {} | |
| 78 | - | |
| 79 | - var success_message = $("<span style='color:#0C0'>Settings saved</span>"); | |
| 80 | - save_status.empty(); | |
| 81 | - save_status.append(success_message); | |
| 82 | - var success_fadeout = function(){ | |
| 83 | - success_message.fadeOut(5000); | |
| 84 | - } | |
| 85 | - setTimeout(success_fadeout, 15000); | |
| 86 | - save_button.removeAttr('disabled'); | |
| 87 | - }, | |
| 88 | - 'error': function(){ | |
| 89 | - save_status.empty(); | |
| 90 | - save_status.append("<span style='color:#c00'>Error saving settings, please retry</span>"); | |
| 91 | - save_button.removeAttr('disabled'); | |
| 92 | - } | |
| 93 | - }); | |
| 94 | - | |
| 95 | - }); | |
| 96 | -}); | |
| 1 | +jQuery(function($){ | |
| 2 | + $('#accua_form_style_border_color .accua_form_value').colorPicker(); | |
| 3 | + $('#accua_form_style_background_color .accua_form_value').colorPicker(); | |
| 4 | + $('#accua_form_style_color .accua_form_value').colorPicker(); | |
| 5 | + $('#accua_form_style_field_border_color .accua_form_value').colorPicker(); | |
| 6 | + $('#accua_form_style_field_background_color .accua_form_value').colorPicker(); | |
| 7 | + $('#accua_form_style_field_color .accua_form_value').colorPicker(); | |
| 8 | + $('#accua_form_style_submit_border_color .accua_form_value').colorPicker(); | |
| 9 | + $('#accua_form_style_submit_background_color .accua_form_value').colorPicker(); | |
| 10 | + $('#accua_form_style_submit_color .accua_form_value').colorPicker(); | |
| 11 | + | |
| 12 | + function get_tinymce_content(name){ | |
| 13 | + if (jQuery("#"+name+" .wp-editor-wrap").hasClass("tmce-active")){ | |
| 14 | + return tinyMCE.get(name+'_textarea').getContent(); | |
| 15 | + } else | |
| 16 | + { | |
| 17 | + return jQuery("#" +name+ "_textarea").val(); | |
| 18 | + } | |
| 19 | + } | |
| 20 | + | |
| 21 | + var save_button = $('.accua_form_save_settings_button'); | |
| 22 | + var save_status = $(".accua_form_save_settings_status"); | |
| 23 | + $('.accua_form_save_settings_button').click(function(){ | |
| 24 | + save_button.attr('disabled', 'disabled') | |
| 25 | + save_status.empty(); | |
| 26 | + save_status.append("<span class='accua_form_api_throbbler'></span>"); | |
| 27 | + | |
| 28 | + var form_id = $('#accua_form_save_settings_id').val(); | |
| 29 | + | |
| 30 | + var data = { | |
| 31 | + 'action': 'accua-save-form-settings', | |
| 32 | + 'form-id': form_id, | |
| 33 | + '_nonce_edit_form': $('#_nonce_edit_form').val(), | |
| 34 | + 'title': $('#title').val(), | |
| 35 | + 'use_ajax': ($('#accua_form_use_ajax .accua_form_value').is(':checked') ? 1 : 0) | |
| 36 | + }; | |
| 37 | + | |
| 38 | + var layout = $('#accua_form_layout .accua_form_value').val(); | |
| 39 | + if (layout == 'toplabel' || layout == 'sidebyside') { | |
| 40 | + data.layout = layout; | |
| 41 | + } | |
| 42 | + | |
| 43 | + $.each( | |
| 44 | + ['success_message','error_message','emails_from_name','emails_from','admin_emails_to','emails_bcc','admin_emails_subject','admin_emails_message','confirmation_emails_subject','confirmation_emails_message','style_margin','style_border_color','style_border_width','style_border_radius','style_background_color','style_padding','style_color','style_font_size','style_field_spacing','style_field_border_color','style_field_border_width','style_field_border_radius','style_field_background_color','style_field_padding','style_field_color','style_submit_border_color','style_submit_border_width','style_submit_border_radius','style_submit_background_color','style_submit_padding','style_submit_color','style_submit_font_size'], | |
| 45 | + function(i,key){ | |
| 46 | + var value = $('#accua_form_'+key+' .accua_form_check_override:checked').val(); | |
| 47 | + if(value!=undefined && value!=0) { | |
| 48 | + if(value==-1) | |
| 49 | + { | |
| 50 | + data[key] =''; | |
| 51 | + data[key+"_no_message"] = 1; | |
| 52 | + } | |
| 53 | + else { | |
| 54 | + var element = $('#accua_form_'+key+' .accua_form_value'); | |
| 55 | + if(element.is('input')){ | |
| 56 | + data[key] = $('#accua_form_'+key+' .accua_form_value').val(); | |
| 57 | + } | |
| 58 | + else if(element.is('textarea')) { | |
| 59 | + data[key] = get_tinymce_content('accua_form_'+key); | |
| 60 | + } | |
| 61 | + } | |
| 62 | + } | |
| 63 | + } | |
| 64 | + ); | |
| 65 | + | |
| 66 | + /* | |
| 67 | + $.post( | |
| 68 | + ajaxurl, | |
| 69 | + data, | |
| 70 | + function(){}, | |
| 71 | + 'json' | |
| 72 | + ) | |
| 73 | + */ | |
| 74 | + | |
| 75 | + if (accuaWidgets) { | |
| 76 | + $('#widgets-right .button-primary.widget-control-save').click(); | |
| 77 | + accuaWidgets.saveOrder(); | |
| 78 | + } | |
| 79 | + | |
| 80 | + | |
| 81 | + setTimeout(function(){ | |
| 82 | + $.ajax(ajaxurl, { | |
| 83 | + 'type': 'POST', | |
| 84 | + 'data': data, | |
| 85 | + 'success': function(){ | |
| 86 | + document.getElementById('accua_form_preview_area').src = 'admin-ajax.php?action=accua_forms_preview&fid=' + form_id; | |
| 87 | + try { | |
| 88 | + if (history.pushState && window.location.search.search('page=accua_forms_list') == -1) { | |
| 89 | + history.pushState('', document.title, 'admin.php?page=accua_forms_list&fid=' + form_id); | |
| 90 | + window.onpopstate = function(event) { | |
| 91 | + location.reload(); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + } catch (e) {} | |
| 95 | + | |
| 96 | + var success_message = $("<span class='savedsettings'>Settings saved</span>"); | |
| 97 | + save_status.empty(); | |
| 98 | + save_status.append(success_message); | |
| 99 | + var success_fadeout = function(){ | |
| 100 | + success_message.fadeOut(5000); | |
| 101 | + } | |
| 102 | + setTimeout(success_fadeout, 15000); | |
| 103 | + save_button.removeAttr('disabled'); | |
| 104 | + }, | |
| 105 | + 'error': function(){ | |
| 106 | + save_status.empty(); | |
| 107 | + save_status.append("<span class='error_savedsettings'>Error saving settings, please retry</span>"); | |
| 108 | + save_button.removeAttr('disabled'); | |
| 109 | + } | |
| 110 | + }); }, 400); | |
| 111 | + }); | |
| 112 | +}); | |