Skip to content
This repository was archived by the owner on Jul 1, 2021. It is now read-only.

Commit a549452

Browse files
committed
Ajout du plugin mailcheck.js
1 parent 0541b28 commit a549452

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module.exports = function(grunt) {
3636
'public/js/dest/scripts.min.js':[
3737
'public/bower/jquery/dist/jquery.min.js',
3838
'public/bower/pace/pace.min.js',
39+
'public/bower/mailcheck/src/mailcheck.min.js',
3940
'public/bower/bootstrap/dist/js/bootstrap.min.js',
4041
'public/js/*.js'
4142
]

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"html5shiv": "3.7.2",
2121
"respond": "1.4.2",
2222
"font-awesome": "4.2.0",
23-
"pace": "~1.0.2"
23+
"pace": "~1.0.2",
24+
"mailcheck": "~1.1.0"
2425
}
2526
}

public/js/mailcheck.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var domains = [
2+
'gmail.com','hotmail.fr','aliceadsl.fr','free.fr','hotmail.com','sfr.fr','wanadoo.fr','yahoo.com','laposte.net',
3+
'voila.fr','orange.fr','ovh.net','outlook.com','live.fr','yahoo.fr','ymail.com','gmx.fr','gmx.com','gmx.net',
4+
'msn.com','online.fr','hushmail.com','openmailbox.org','opmbx.org'
5+
];
6+
7+
var secondLevelDomains = [
8+
'gmail','hotmail','aliceadsl','free','hotmail','sfr','wanadoo','yahoo','laposte',
9+
'voila','orange','ovh','outlook','live','yahoo','ymail','gmx','gmx','msn','online',
10+
'hushmail','openmailbox','opmbx'
11+
];
12+
13+
var topLevelDomains = ['com','fr','com','net','org'];
14+
var mailInput = $('input[name="mail"]');
15+
16+
mailInput.on('blur', function() {
17+
18+
$( this ).mailcheck({
19+
20+
domains:domains,
21+
secondLevelDomains:secondLevelDomains,
22+
topLevelDomains:topLevelDomains,
23+
24+
suggested: function( element, suggestion ) {
25+
mailInput.after('<span class="help-block">Vous voulez dire <a id="suggestion" href="javascript:{}">' + suggestion.full + '</a> ?</span>');
26+
},
27+
28+
empty: function( element ) {
29+
mailInput.next().remove();
30+
}
31+
32+
});
33+
34+
});
35+
36+
$( document ).on( 'click', '#suggestion', function() {
37+
38+
mailInput.val( $('a#suggestion').text() );
39+
mailInput.next().remove();
40+
41+
});

0 commit comments

Comments
 (0)