[ Index ]

MailPress 7.2

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

title

Body

[close]

/mp-includes/js/ -> mp_form.js (source)

   1  var mp_form = {
   2  
   3      selectors : {
   4          submit  : 'div.MailPress input.mp_submit', 
   5          form    : 'form.mp-form', 
   6          formdiv : 'div.mp-formdiv', 
   7          loading : 'div.mp-loading', 
   8          message : 'div.mp-message'
   9      }, 
  10  
  11      init : function() {
  12          jQuery(mp_form.selectors.submit).click( function() { mp_form.ajax(jQuery(this).parents('.MailPress')); return false;} );
  13      }, 
  14  
  15      ajax : function(div) {
  16          var data = {};
  17          jQuery(mp_form.selectors.form+' [type!=submit]',  div).each(function(){
  18              data[ jQuery(this).attr('name') ] = jQuery(this).val();
  19          });
  20          jQuery(mp_form.selectors.formdiv, div).fadeTo(500,0);
  21           jQuery(mp_form.selectors.loading, div).fadeTo(500,1);
  22  
  23          //# ajax
  24          jQuery.ajax({
  25              data: data,
  26              beforeSend: null,
  27              type: "POST", 
  28              url: MP_Widget.url,
  29              success: mp_form.callback
  30              });
  31      }, 
  32  
  33      callback : function(r) {
  34           var mess  = jQuery('message',r).text();
  35           var email = jQuery('email',r).text();
  36           var name  = jQuery('name',r).text();
  37           var id    = jQuery('id',r).text();
  38          var div   = jQuery('#' + id);
  39  
  40          jQuery(mp_form.selectors.form+' [name=email]',  div).val(email);
  41          jQuery(mp_form.selectors.form+' [name=name]',  div).val(name);
  42  
  43           jQuery(mp_form.selectors.loading, div).fadeTo(500,0);
  44          jQuery(mp_form.selectors.message, div).html(mess).fadeTo(1000,1);
  45  
  46           setTimeout('mp_form.show("' + id + '")',2000);
  47      }, 
  48  
  49      show : function(id) {
  50          var div   = jQuery('#' + id);
  51           jQuery(mp_form.selectors.message, div).fadeTo(1000,0);
  52          jQuery(mp_form.selectors.formdiv, div).fadeTo(500,1);
  53      }
  54  }
  55  jQuery(document).ready( function() { mp_form.init(); } );


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