Skip to content

Dev 2.0 #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/creds.js
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ajaxChimp Changelog

### 2.0.0 - 10/June/2015

-
-

### 1.3.0 - 8/May/2014

- Transalations for success message now work
Expand Down
10 changes: 0 additions & 10 deletions MINIFY.md

This file was deleted.

99 changes: 63 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ AjaxChimp is a jQuery plugin that lets you ajaxify your mailchimp form.

Use this if you hate the jarring transition to the mailchimp website upon submitting an email address to mailchimp.

**Note**: This relies on an undocumented feature at mailchimp that uses JSONP to allow cross-domain ajax to work. You have been warned. (It has however, been around for at least 3 years that I know of, and probably more.)
**Note**: This relies on an undocumented feature at mailchimp that uses JSONP to allow cross-domain ajax to work. You have been warned. (It has however, been around for at least 4 years that I know of, and probably more.)


## Install
Expand All @@ -15,18 +15,18 @@ Just add the script to your webpage (along with jQuery ofcourse). Get it here:
curl -O https://github.com/raw/scdoshi/jquery-ajaxchimp/master/jquery.ajaxchimp.js
```

#### bower
##### or via bower

```
bower install ajaxchimp
```


## Requirements

* jQuery

**Note**: Developed with 1.9.1, but it should work with earlier versions. If it does or does not work with a particular version, please open an issue on github.
**Note**: Developed with 2.1.4, but it should work with earlier versions. If it does or does not work with a particular version, please open an issue on github.


## Use

Expand All @@ -36,7 +36,7 @@ bower install ajaxchimp
$('form-selector').ajaxChimp();
```

## Label
## Error / Success messages

If a label element is included in the form for the email input, then the success or error message will be displayed in it. A `valid` or `error` class will also be added accordingly.

Expand All @@ -59,25 +59,30 @@ $('#mc-form').ajaxChimp({

## Options

### Callback
### Callbacks

Optionally, you can specify a callback with either method to run after the ajax query to mailchimp succeeds or fails.

Optionally, you can specify a callback with either method to run after the
ajax query to mailchimp succeeds or fails.
The form element that triggered the ajax call is also passed in to the callbacks as the last argument.

```js
$('form-selector').ajaxChimp({
var formAjaxChimp = $('form-selector').ajaxChimp({
callback: callbackFunction
});
```

The JSONP response from mailchimp will be passed to the callback function
formAjaxChimp.done(function (data, textStatus, jqXHR, form) {
// success callback code here
});

formAjaxChimp.fail(function (jqXHR, textStatus, errorThrown, form) {
// failure callback code here
});

formAjaxChimp.always(function () {
var form = arguments[3];
// always callback code here
});

```js
function callbackFunction (resp) {
if (resp.result === 'success') {
// Do stuff
}
}
```

### URL
Expand All @@ -96,14 +101,26 @@ The mailchimp post url will look like this:
http://blahblah.us1.list-manage.com/subscribe/post?u=5afsdhfuhdsiufdba6f8802&id=4djhfdsh99f
```

### Language Support
### Custom messages

To display custom messages, override the default english translations.

Notice the use of `$1`, `$2` etc. These are regular expression groups from the original messages for the parts that are dynamic, such as the email address. You can omit them if you want to use a constant message.

For success and error messages in different languages:
For e.g., to change the success message:

```js
$.ajaxChimp.translations.en = {
success: 'Why not say this instead, for the email address $1',
}

```

### Multiple language support

- Specify the language as an option.
- Include `jquery.ajaxchimp.langs.js` in the html file


```js
$('form-selector').ajaxChimp({
language: 'es'
Expand All @@ -116,29 +133,39 @@ You can also add custom translations just for your website:

```js
$.ajaxChimp.translations.es = {
'submit': 'Grabación en curso...',
0: 'Te hemos enviado un email de confirmación',
1: 'Por favor, introduzca un valor',
2: 'Una dirección de correo electrónico debe contener una sola @',
3: 'La parte de dominio de la dirección de correo electrónico no es válida (la parte después de la @:)',
4: 'La parte de usuario de la dirección de correo electrónico no es válida (la parte antes de la @:)',
5: 'Esta dirección de correo electrónico se ve falso o no válido. Por favor, introduce una dirección de correo electrónico real'
submit: 'Grabación en curso...',
success: 'Te hemos enviado un email de confirmación $1',
error: {
1: 'Por favor, introduzca un valor',
2: 'Una dirección de correo electrónico debe contener una sola @',
3: 'La parte de dominio de la dirección de correo electrónico no es válida (la parte después de la @: $1)',
4: 'La parte de usuario de la dirección de correo electrónico no es válida (la parte antes de la @: $1)',
5: 'Esta dirección de correo electrónico se ve falso o no válido. Por favor, introduce una dirección de correo electrónico real',
6: 'blah blah',
7: 'blah',
}
}
```

The mapping to english for mailchimp responses and the submit message are as follows:

```js
// Submit Message
// 'submit': 'Submitting...'

// Mailchimp Responses
// 0: 'We have sent you a confirmation email'
// 1: 'Please enter a value'
// 2: 'An email address must contain a single @'
// 3: 'The domain portion of the email address is invalid (the portion after the @: )'
// 4: 'The username portion of the email address is invalid (the portion before the @: )'
// 5: 'This email address looks fake or invalid. Please enter a real email address'
// submit: 'Submitting...'

// Success Message
// success: 'Please confirm by clicking on the link we just sent to $1.'

// Error Messages
// errors: {
// 1: 'Please enter a value',
// 2: 'An email address must contain a single @',
// 3: 'The domain portion of the email address is invalid (the portion after the @: $1 )',
// 4: 'The username portion of the email address is invalid (the portion before the @: $1 )',
// 5: 'This email address looks fake or invalid. Please enter a real email address',
// 6: 'Too many subscribe attempts for this email address. Please try again in about 5 minutes.',
// 7: '$1 is already subscribed to list $2'
// }

```

4 changes: 2 additions & 2 deletions ajaxchimp.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ajaxchimp",
"title": "jQuery ajaxChimp for MailChimp",
"description": "Ajaxify your mailchimp form.",
"version": "1.3.0",
"version": "2.0.0",
"main": "./jquery.ajaxchimp.js",
"author": {
"name": "Siddharth Doshi",
Expand All @@ -16,7 +16,7 @@
"licenses": [
{
"type": "MIT",
"url": "https://raw.github.com/scdoshi/jquery-ajaxchimp/master/LICENSE"
"url": "https://raw.githubusercontent.com/scdoshi/jquery-ajaxchimp/master/LICENSE"
}
],
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "ajaxchimp",
"version": "1.3.0",
"version": "2.0.0",
"main": "./jquery.ajaxchimp.js",
"dependencies": {
"jquery": ">=1.9.0"
},
"ignore": [
"**/.*",
"./ajaxchimp.jquery.json",
"./MINIFY.md"
"./src"
]
}
1 change: 1 addition & 0 deletions dist/jquery.ajaxchimp.langs.min.js

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

1 change: 1 addition & 0 deletions dist/jquery.ajaxchimp.min.js

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

147 changes: 0 additions & 147 deletions jquery.ajaxchimp.js

This file was deleted.

Loading