Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Bump to version 1.3
Browse files Browse the repository at this point in the history
1. Use the Mailgun Email Validation API instead of Mailcheck for
validating email addresses
  • Loading branch information
Aaron Huisinga committed Mar 7, 2016
1 parent 3013302 commit d56f417
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 41 deletions.
1 change: 0 additions & 1 deletion assets/js/mailcheck.min.js

This file was deleted.

1 change: 1 addition & 0 deletions assets/js/mailgun-validator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 64 additions & 34 deletions assets/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,56 @@ jQuery('document').ready(function ($) {
$('.btn-primary').removeAttr('disabled');
});

var delay = (function () {
var timer = 0;
return function (callback, ms) {
clearTimeout(timer);
timer = setTimeout(callback, ms);
};
})();

// Mailcheck
$('#email').on('keyup', function () {
var input = $(this);
if (input.val().length < 10) {
return false;
// Email Validation
if (HomesReport.mailgun !== undefined && HomesReport.mailgun !== '') {
$('#email').mailgun_validator({
api_key: HomesReport.mailgun,
in_progress: function () {
$('#email').parent().removeClass('has-warning has-error');
$(".mailcheck-suggestion").remove();
$("[type=submit]").addClass("disabled").attr("disabled", "disabled");
},
success: function (data) {
$('#email').after(get_suggestion_str(data['is_valid'], data['did_you_mean']));
},
error: function () {
$("[type=submit]").removeClass("disabled").removeAttr("disabled");
}
});
}
// Parse Mailgun Responses
function get_suggestion_str(is_valid, alternate) {
if (is_valid) {
if (alternate) {
$('#email').parent().addClass('has-warning');
return '<div class="mailcheck-suggestion help-block">Did you mean <a href="#">' + alternate + '</a>?</div>';
}
if ($('#form-clicked').length) {
$('form').unbind().submit();
$("[type=submit]").addClass("disabled").attr("disabled", "disabled");
} else {
$("[type=submit]").removeClass("disabled").removeAttr("disabled");
}

return;
}
$('#email').parent().addClass('has-error');
if (alternate) {
return '<div class="mailcheck-suggestion help-block">This email is invalid. Did you mean <a href="#">' + alternate + '</a>?</div>';
}
return '<div class="mailcheck-suggestion help-block">This email is invalid.</div>';
}

delay(function () {
input.mailcheck({
suggested: function (element, suggestion) {
$('.mailcheck-suggestion').remove();
$(element).after('<div class="mailcheck-suggestion" style="margin-top:5px;">Did you mean <a href="#">' + suggestion.full + '</a>?</div>');
},
empty: function () {
$('.mailcheck-suggestion').remove();
}
});
}, 500);
$(".form-group").on("click", ".mailcheck-suggestion a", function (e) {
e.preventDefault();
$("#email").val($(this).text());
$("[type=submit]").removeClass("disabled").removeAttr("disabled");
$(".mailcheck-suggestion").remove();
});

$('.form-group').on('click', '.mailcheck-suggestion a', function (e) {
$('form').submit(function (e) {
e.preventDefault();

$('#email').val($(this).text());
$('.mailcheck-suggestion').remove();
$(this).after('<input type="hidden" id="form-clicked" value="true">');
$('#email').trigger('focusout');
});

// Show results modal
Expand Down Expand Up @@ -99,11 +116,24 @@ jQuery('document').ready(function ($) {
conversion = $('#conversion').val();
if (conversion != '') {
if (conversion !== retargeting) {
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
!function (f, b, e, v, n, t, s) {
if (f.fbq)return;
n = f.fbq = function () {
n.callMethod ?
n.callMethod.apply(n, arguments) : n.queue.push(arguments)
};
if (!f._fbq)f._fbq = n;
n.push = n;
n.loaded = !0;
n.version = '2.0';
n.queue = [];
t = b.createElement(e);
t.async = !0;
t.src = v;
s = b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t, s)
}(window,
document, 'script', '//connect.facebook.net/en_US/fbevents.js');

fbq('init', conversion);
}
Expand Down
7 changes: 4 additions & 3 deletions classes/class-homes-report.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,14 @@ public function enqueue_scripts()
'jquery'
], HOMES_REPORT_PLUGIN_VERSION);
wp_enqueue_script($this->token . '-js');
wp_register_script('mailcheck', esc_url($this->assets_url . 'js/mailcheck.min.js'), [
wp_register_script('mailgun-validator', esc_url($this->assets_url . 'js/mailgun-validator.js'), [
'jquery'
], HOMES_REPORT_PLUGIN_VERSION);
wp_enqueue_script('mailcheck');
wp_enqueue_script('mailgun-validator');

$localize = [
'ajaxurl' => admin_url('admin-ajax.php')
'ajaxurl' => admin_url('admin-ajax.php'),
'mailgun' => defined('MAILGUN_PUBLIC') ? MAILGUN_PUBLIC : ''
];
wp_localize_script($this->token . '-js', 'HomesReport', $localize);
}
Expand Down
4 changes: 2 additions & 2 deletions homes-report.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace ColdTurkey\HomesReport;
/*
* Plugin Name: Homes Report
* Version: 1.2.2
* Version: 1.3
* Plugin URI: http://www.coldturkeygroup.com/
* Description: WordPress funnel that collects visitor contact information in exchange for a customized report from a Real Estate agent.
* Author: Cold Turkey Group
Expand All @@ -20,7 +20,7 @@
define('HOMES_REPORT_PLUGIN_PATH', trailingslashit(plugin_dir_path(__FILE__)));

if (!defined('HOMES_REPORT_PLUGIN_VERSION'))
define('HOMES_REPORT_PLUGIN_VERSION', '1.2.2');
define('HOMES_REPORT_PLUGIN_VERSION', '1.3');

require_once('classes/class-homes-report.php');

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: Aaron Huisinga
Tags: real estate, platform, homes report
Requires at least: 3.5
Tested up to: 4.3
Stable tag: 1.2.2
Stable tag: 1.3

WordPress funnel that collects visitor contact information in exchange for a customized report from a Real Estate agent.

Expand Down

0 comments on commit d56f417

Please sign in to comment.