[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-admin/js/ -> forms.js (source)

   1  // forms
   2  
   3  var mp_forms = {
   4  
   5      control : function() {
   6          var err = jQuery('div#div_form_toemail').hasClass('form-invalid');
   7  
   8          if (!mp_forms.is_email(jQuery('#form_toemail').val()))
   9          {
  10              jQuery('div#div_form_toemail').addClass('form-invalid');
  11              jQuery("#form_settings").tabs( 'select' , 4 );
  12          }
  13          else jQuery('div#div_form_toemail').removeClass('form-invalid');
  14      },
  15  
  16      is_empty : function(t) { return (t.length == 0); },
  17  //    is_email : function(m) { var pattern = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/; return pattern.test(m); },
  18      is_email : function(m) {
  19          var _r;
  20          var data = { action: "mp_ajax", mp_action: "email", email: m }; 
  21          jQuery.ajax({ 
  22              data: data, type: "POST", 
  23              async: false, 
  24              url: ajaxurl, 
  25              success: function(r) { _r = r;} 
  26          }); 
  27          return (_r==1); 
  28      },
  29  
  30      init : function() {
  31          //
  32          jQuery("#mp_help").tabs();
  33          jQuery("#form_settings").tabs({
  34              activate : function( event, ui){
  35                  jQuery("[href='#mp_help_tab_" + ui.newPanel.attr('data-tab') + "']").click();
  36              }
  37          });
  38          // 
  39          jQuery('#recipient_theme').change( function() {
  40              var a = jQuery(this); 
  41              jQuery('.recipient_template').hide(); 
  42              jQuery( '#recipient_' + a.val()).show();
  43           });
  44          // 
  45          jQuery('#visitor_theme').change( function() {
  46              var a = jQuery(this); 
  47              jQuery('.visitor_template').hide(); 
  48              jQuery( '#visitor_' + a.val()).show();
  49           });
  50          // conf
  51          jQuery('#visitor_subscription').change( function() {
  52              var a = jQuery(this);
  53              if ('0' == a.val()) jQuery( '.visitor_subscription_selected').hide();
  54              else jQuery( '.visitor_subscription_selected').show();
  55           });
  56          jQuery('#visitor_mail').change( function() {
  57              var a = jQuery(this);
  58              if ('0' == a.val()) jQuery( '.visitor_mail_selected').hide();
  59              else jQuery( '.visitor_mail_selected').show();
  60           });
  61          // control form
  62          jQuery('form#add').submit( function() {
  63              mp_forms.control();
  64          });
  65      }
  66  }
  67  jQuery(document).ready(function(){ mp_forms.init(); });


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1