diff --git a/assets/css/src/public.styl b/assets/css/src/public.styl index b7e42f5fb4..e69de29bb2 100644 --- a/assets/css/src/public.styl +++ b/assets/css/src/public.styl @@ -1,3 +0,0 @@ -@import 'nib' - -@require 'common' diff --git a/assets/js/src/public.js b/assets/js/src/public.js index 046258086a..d48b27bffe 100644 --- a/assets/js/src/public.js +++ b/assets/js/src/public.js @@ -29,57 +29,59 @@ define('public', ['mailpoet', 'jquery', 'jquery-validation'], $(function() { // setup form validation - $('form.mailpoet_form').validate({ - submitHandler: function(form) { - var data = $(form).serializeArray() || {}; + $('form.mailpoet_form').each(function() { + $(this).validate({ + submitHandler: function(form) { + var data = $(form).serializeArray() || {}; - // clear messages - $(form).find('.mailpoet_message').html(''); + // clear messages + $(form).find('.mailpoet_message').html(''); - // check if we're on the same domain - if(isSameDomain(MailPoetForm.ajax_url) === false) { - // non ajax post request - return true; - } else { - // ajax request - MailPoet.Ajax.post({ - url: MailPoetForm.ajax_url, - token: MailPoetForm.token, - endpoint: 'subscribers', - action: 'save', - data: formatData(data), - onSuccess: function(response) { - if(response !== true) { - // errors - $.each(response, function(index, error) { - $(form) - .find('.mailpoet_message') - .append('
'+ - error+ - '
'); - }); - } else { - // successfully subscribed - if(response.page !== undefined) { - // go to page - window.location.href = response.page; - } else if(response.message !== undefined) { - // display success message - $(form) - .find('.mailpoet_message') - .html(''+ - response.message+ - '
'); + // check if we're on the same domain + if(isSameDomain(MailPoetForm.ajax_url) === false) { + // non ajax post request + return true; + } else { + // ajax request + MailPoet.Ajax.post({ + url: MailPoetForm.ajax_url, + token: MailPoetForm.token, + endpoint: 'subscribers', + action: 'save', + data: formatData(data), + onSuccess: function(response) { + if(response !== true) { + // errors + $.each(response, function(index, error) { + $(form) + .find('.mailpoet_message') + .append(''+ + error+ + '
'); + }); + } else { + // successfully subscribed + if(response.page !== undefined) { + // go to page + window.location.href = response.page; + } else if(response.message !== undefined) { + // display success message + $(form) + .find('.mailpoet_message') + .html(''+ + response.message+ + '
'); + } + + // reset form + $(form).trigger('reset'); } - - // reset form - $(form).trigger('reset'); } - } - }); + }); + } + return false; } - return false; - } + }); }); }); } diff --git a/lib/Form/Widget.php b/lib/Form/Widget.php index 395758efe2..315f7f11aa 100644 --- a/lib/Form/Widget.php +++ b/lib/Form/Widget.php @@ -65,6 +65,9 @@ class Widget extends \WP_Widget { $this->id_base ); + $form_id = $this->id_base.'_'.$this->number; + $form_type = 'widget'; + $output = ''; // before widget @@ -73,12 +76,14 @@ class Widget extends \WP_Widget { // title $output .= $before_title.$title.$after_title; - // form - $form_id = $this->id_base.'_'.$this->number; - $form_type = 'widget'; - + // container $output .= '