581 lines
20 KiB
JavaScript
Executable File
581 lines
20 KiB
JavaScript
Executable File
/*
|
|
* 2007-2014 PrestaShop
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
* that is bundled with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* http://opensource.org/licenses/afl-3.0.php
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to license@prestashop.com so we can send you a copy immediately.
|
|
*
|
|
* DISCLAIMER
|
|
*
|
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
* versions in the future. If you wish to customize PrestaShop for your
|
|
* needs please refer to http://www.prestashop.com for more information.
|
|
*
|
|
* @author PrestaShop SA <contact@prestashop.com>
|
|
* @copyright 2007-2014 PrestaShop SA
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
* International Registered Trademark & Property of PrestaShop SA
|
|
*/
|
|
//global variables
|
|
var responsiveflag = false;
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
|
highdpiInit();
|
|
responsiveResize();
|
|
$(window).resize(responsiveResize);
|
|
if (navigator.userAgent.match(/Android/i))
|
|
{
|
|
var viewport = document.querySelector('meta[name="viewport"]');
|
|
viewport.setAttribute('content', 'initial-scale=1.0,maximum-scale=1.0,user-scalable=0,width=device-width,height=device-height');
|
|
window.scrollTo(0, 1);
|
|
}
|
|
blockHover();
|
|
if (typeof quickView !== 'undefined' && quickView)
|
|
quick_view();
|
|
dropDown();
|
|
|
|
if (typeof page_name != 'undefined' && !in_array(page_name, ['index', 'product']))
|
|
{
|
|
bindGrid();
|
|
|
|
$(document).on('change', '.selectProductSort', function(e){
|
|
if (typeof request != 'undefined' && request)
|
|
var requestSortProducts = request;
|
|
var splitData = $(this).val().split(':');
|
|
if (typeof requestSortProducts != 'undefined' && requestSortProducts)
|
|
document.location.href = requestSortProducts + ((requestSortProducts.indexOf('?') < 0) ? '?' : '&') + 'orderby=' + splitData[0] + '&orderway=' + splitData[1];
|
|
});
|
|
|
|
$(document).on('change', 'select[name="n"]', function(){
|
|
$(this.form).submit();
|
|
});
|
|
|
|
$(document).on('change', 'select[name="manufacturer_list"], select[name="supplier_list"]', function() {
|
|
if (this.value != '')
|
|
location.href = this.value;
|
|
});
|
|
|
|
$(document).on('change', 'select[name="currency_payement"]', function(){
|
|
setCurrency($(this).val());
|
|
});
|
|
}
|
|
|
|
$(document).on('click', '.back', function(e){
|
|
e.preventDefault();
|
|
history.back();
|
|
});
|
|
|
|
// Module ant_nw_frequence
|
|
if ($('#newsletter').is(':checked') == false) {
|
|
$('#uniform-frequence_q span').removeClass('checked');
|
|
$('#frequence_q').removeAttr('checked');
|
|
$('#uniform-frequence_3 span').removeClass('checked');
|
|
$('#frequence_3').removeAttr('checked');
|
|
$('#uniform-frequence_h span').removeClass('checked');
|
|
$('#frequence_h').removeAttr('checked');
|
|
}
|
|
|
|
$('input.frequence_nw').on('change', function(e){
|
|
if ($('#newsletter').is(':checked') == false) {
|
|
$('#uniform-newsletter').trigger('click');
|
|
$('#uniform-newsletter span').addClass('checked');
|
|
}
|
|
});
|
|
|
|
$('input#newsletter').on('change', function(e){
|
|
if ($('#newsletter').is(':checked') == false) {
|
|
$('#uniform-frequence_q span').removeClass('checked');
|
|
$('#frequence_q').removeAttr('checked');
|
|
$('#uniform-frequence_3 span').removeClass('checked');
|
|
$('#frequence_3').removeAttr('checked');
|
|
$('#uniform-frequence_h span').removeClass('checked');
|
|
$('#frequence_h').removeAttr('checked');
|
|
} else {
|
|
if ($('#frequence_h').is(':checked') == false && $('#frequence_3').is(':checked') == false) {
|
|
if ($('#frequence_q').is(':checked') == false) {
|
|
$('#frequence_q').trigger('click');
|
|
$('#uniform-frequence_q span').addClass('checked');
|
|
}
|
|
$('#uniform-frequence_3 span').removeClass('checked');
|
|
$('#frequence_3').removeAttr('checked');
|
|
$('#uniform-frequence_h span').removeClass('checked');
|
|
$('#frequence_h').removeAttr('checked');
|
|
}
|
|
}
|
|
});
|
|
|
|
jQuery.curCSS = jQuery.css;
|
|
if (!!$.prototype.cluetip)
|
|
$('a.cluetip').cluetip({
|
|
local:true,
|
|
cursor: 'pointer',
|
|
dropShadow: false,
|
|
dropShadowSteps: 0,
|
|
showTitle: false,
|
|
tracking: true,
|
|
sticky: false,
|
|
mouseOutClose: true,
|
|
fx: {
|
|
open: 'fadeIn',
|
|
openSpeed: 'fast'
|
|
}
|
|
}).css('opacity', 0.8);
|
|
|
|
if (!!$.prototype.fancybox)
|
|
$.extend($.fancybox.defaults.tpl, {
|
|
closeBtn : '<a title="' + FancyboxI18nClose + '" class="fancybox-item fancybox-close" href="javascript:;"></a>',
|
|
next : '<a title="' + FancyboxI18nNext + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
|
|
prev : '<a title="' + FancyboxI18nPrev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
|
|
});
|
|
});
|
|
|
|
function highdpiInit()
|
|
{
|
|
if($('.replace-2x').css('font-size') == "1px")
|
|
{
|
|
var els = $("img.replace-2x").get();
|
|
for(var i = 0; i < els.length; i++)
|
|
{
|
|
src = els[i].src;
|
|
extension = src.substr( (src.lastIndexOf('.') +1) );
|
|
src = src.replace("." + extension, "2x." + extension);
|
|
|
|
var img = new Image();
|
|
img.src = src;
|
|
img.height != 0 ? els[i].src = src : els[i].src = els[i].src;
|
|
}
|
|
}
|
|
}
|
|
|
|
function responsiveResize()
|
|
{
|
|
if ($(document).width() <= 767 && responsiveflag == false)
|
|
{
|
|
accordion('enable');
|
|
accordionFooter('enable');
|
|
responsiveflag = true;
|
|
}
|
|
else if ($(document).width() >= 768)
|
|
{
|
|
accordion('disable');
|
|
accordionFooter('disable');
|
|
responsiveflag = false;
|
|
}
|
|
if (typeof page_name != 'undefined' && in_array(page_name, ['category']))
|
|
resizeCatimg();
|
|
}
|
|
|
|
function blockHover(status)
|
|
{
|
|
$(document).off('mouseenter').on('mouseenter', '.product_list.grid li.ajax_block_product .product-container', function(e){
|
|
|
|
if ($('body').find('.container').width() == 1170)
|
|
{
|
|
var pcHeight = $(this).parent().outerHeight();
|
|
var pcPHeight = $(this).parent().find('.button-container').outerHeight() + $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight();
|
|
$(this).parent().addClass('hovered').css({'height':pcHeight + pcPHeight, 'margin-bottom':pcPHeight * (-1)});
|
|
}
|
|
});
|
|
|
|
$(document).off('mouseleave').on('mouseleave', '.product_list.grid li.ajax_block_product .product-container', function(e){
|
|
if ($('body').find('.container').width() == 1170)
|
|
$(this).parent().removeClass('hovered').css({'height':'auto', 'margin-bottom':'0'});
|
|
});
|
|
}
|
|
|
|
function quick_view()
|
|
{
|
|
$(document).on('click', '.quick-view:visible, .quick-view-mobile:visible', function(e)
|
|
{
|
|
e.preventDefault();
|
|
var url = this.rel;
|
|
if (url.indexOf('?') != -1)
|
|
url += '&';
|
|
else
|
|
url += '?';
|
|
|
|
if (!!$.prototype.fancybox)
|
|
$.fancybox({
|
|
'padding': 0,
|
|
'width': 1087,
|
|
'height': 610,
|
|
'type': 'iframe',
|
|
'href': url + 'content_only=1'
|
|
});
|
|
});
|
|
}
|
|
|
|
function bindGrid()
|
|
{
|
|
var view = $.totalStorage('display');
|
|
|
|
if (!view && (typeof displayList != 'undefined') && displayList)
|
|
view = 'list';
|
|
|
|
if (view && view != 'grid')
|
|
display(view);
|
|
else
|
|
$('.display').find('li#grid').addClass('selected');
|
|
|
|
$(document).on('click', '#grid', function(e){
|
|
e.preventDefault();
|
|
display('grid');
|
|
});
|
|
|
|
$(document).on('click', '#list', function(e){
|
|
e.preventDefault();
|
|
display('list');
|
|
});
|
|
}
|
|
|
|
function display(view)
|
|
{
|
|
if (view == 'list')
|
|
{
|
|
$('ul.product_list').removeClass('grid').addClass('list row');
|
|
$('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-4').addClass('col-xs-12');
|
|
$('.product_list > li').each(function(index, element) {
|
|
html = '';
|
|
html = '<div class="product-container"><div class="row">';
|
|
html += '<div class="left-block col-xs-4 col-xs-5 col-md-4">' + $(element).find('.left-block').html() + '</div>';
|
|
html += '<div class="center-block col-xs-4 col-xs-7 col-md-4">';
|
|
html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>';
|
|
html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>';
|
|
var rating = $(element).find('.comments_note').html(); // check : rating
|
|
if (rating != null) {
|
|
html += '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="comments_note">'+ rating + '</div>';
|
|
}
|
|
html += '<p class="product-desc">'+ $(element).find('.product-desc').html() + '</p>';
|
|
var colorList = $(element).find('.color-list-container').html();
|
|
if (colorList != null) {
|
|
html += '<div class="color-list-container">'+ colorList +'</div>';
|
|
}
|
|
var availability = $(element).find('.availability').html(); // check : catalog mode is enabled
|
|
if (availability != null) {
|
|
html += '<span class="availability">'+ availability +'</span>';
|
|
}
|
|
html += '</div>';
|
|
html += '<div class="right-block col-xs-4 col-xs-12 col-md-4"><div class="right-block-content row">';
|
|
var price = $(element).find('.content_price').html(); // check : catalog mode is enabled
|
|
if (price != null) {
|
|
html += '<div class="content_price col-xs-5 col-md-12">'+ price + '</div>';
|
|
}
|
|
html += '<div class="button-container col-xs-7 col-md-12">'+ $(element).find('.button-container').html() +'</div>';
|
|
html += '<div class="functional-buttons clearfix col-sm-12">' + $(element).find('.functional-buttons').html() + '</div>';
|
|
html += '</div>';
|
|
html += '</div></div>';
|
|
$(element).html(html);
|
|
});
|
|
$('.display').find('li#list').addClass('selected');
|
|
$('.display').find('li#grid').removeAttr('class');
|
|
$.totalStorage('display', 'list');
|
|
}
|
|
else
|
|
{
|
|
$('ul.product_list').removeClass('list').addClass('grid row');
|
|
$('.product_list > li').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-4');
|
|
$('.product_list > li').each(function(index, element) {
|
|
html = '';
|
|
html += '<div class="product-container">';
|
|
html += '<div class="left-block">' + $(element).find('.left-block').html() + '</div>';
|
|
html += '<div class="right-block">';
|
|
html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>';
|
|
html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>';
|
|
var rating = $(element).find('.comments_note').html(); // check : rating
|
|
if (rating != null) {
|
|
html += '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="comments_note">'+ rating + '</div>';
|
|
}
|
|
html += '<p itemprop="description" class="product-desc">'+ $(element).find('.product-desc').html() + '</p>';
|
|
var price = $(element).find('.content_price').html(); // check : catalog mode is enabled
|
|
if (price != null) {
|
|
html += '<div class="content_price">'+ price + '</div>';
|
|
}
|
|
html += '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="button-container">'+ $(element).find('.button-container').html() +'</div>';
|
|
var colorList = $(element).find('.color-list-container').html();
|
|
if (colorList != null) {
|
|
html += '<div class="color-list-container">'+ colorList +'</div>';
|
|
}
|
|
var availability = $(element).find('.availability').html(); // check : catalog mode is enabled
|
|
if (availability != null) {
|
|
html += '<span class="availability">'+ availability +'</span>';
|
|
}
|
|
html += '</div>';
|
|
html += '<div class="functional-buttons clearfix">' + $(element).find('.functional-buttons').html() + '</div>';
|
|
html += '</div>';
|
|
$(element).html(html);
|
|
});
|
|
$('.display').find('li#grid').addClass('selected');
|
|
$('.display').find('li#list').removeAttr('class');
|
|
$.totalStorage('display', 'grid');
|
|
}
|
|
}
|
|
|
|
function dropDown()
|
|
{
|
|
elementClick = '#header .current';
|
|
elementSlide = 'ul.toogle_content';
|
|
activeClass = 'active';
|
|
|
|
$(elementClick).on('click', function(e){
|
|
e.stopPropagation();
|
|
var subUl = $(this).next(elementSlide);
|
|
if(subUl.is(':hidden'))
|
|
{
|
|
subUl.slideDown();
|
|
$(this).addClass(activeClass);
|
|
}
|
|
else
|
|
{
|
|
subUl.slideUp();
|
|
$(this).removeClass(activeClass);
|
|
}
|
|
$(elementClick).not(this).next(elementSlide).slideUp();
|
|
$(elementClick).not(this).removeClass(activeClass);
|
|
e.preventDefault();
|
|
});
|
|
|
|
$(elementSlide).on('click', function(e){
|
|
e.stopPropagation();
|
|
});
|
|
|
|
$(document).on('click', function(e){
|
|
e.stopPropagation();
|
|
var elementHide = $(elementClick).next(elementSlide);
|
|
$(elementHide).slideUp();
|
|
$(elementClick).removeClass('active');
|
|
});
|
|
}
|
|
|
|
function accordionFooter(status)
|
|
{
|
|
if(status == 'enable')
|
|
{
|
|
$('#footer .footer-block h4').on('click', function(){
|
|
$(this).toggleClass('active').parent().find('.toggle-footer').stop().slideToggle('medium');
|
|
})
|
|
$('#footer').addClass('accordion').find('.toggle-footer').slideUp('fast');
|
|
}
|
|
else
|
|
{
|
|
$('.footer-block h4').removeClass('active').off().parent().find('.toggle-footer').removeAttr('style').slideDown('fast');
|
|
$('#footer').removeClass('accordion');
|
|
}
|
|
}
|
|
|
|
function accordion(status)
|
|
{
|
|
leftColumnBlocks = $('#left_column');
|
|
if(status == 'enable')
|
|
{
|
|
$('#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4').on('click', function(){
|
|
$(this).toggleClass('active').parent().find('.block_content').stop().slideToggle('medium');
|
|
})
|
|
$('#right_column, #left_column').addClass('accordion').find('.block .block_content').slideUp('fast');
|
|
}
|
|
else
|
|
{
|
|
$('#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4').removeClass('active').off().parent().find('.block_content').removeAttr('style').slideDown('fast');
|
|
$('#left_column, #right_column').removeClass('accordion');
|
|
}
|
|
}
|
|
|
|
function resizeCatimg()
|
|
{
|
|
var div = $('.cat_desc').parent('div');
|
|
var image = new Image;
|
|
$(image).load(function(){
|
|
var width = image.width;
|
|
var height = image.height;
|
|
var ratio = parseFloat(height / width);
|
|
var calc = Math.round(ratio * parseInt(div.outerWidth(false)));
|
|
div.css('min-height', calc);
|
|
});
|
|
if (div.length)
|
|
image.src = div.css('background-image').replace(/url\("?|"?\)$/ig, '');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** ==============
|
|
* Email validation
|
|
=============== */
|
|
|
|
var i18n = {
|
|
form_email_suggestion: 'Vouliez-vous dire {0} ?'
|
|
};
|
|
|
|
var emailValidator = {
|
|
domains : ['gmail.com', 'hotmail.fr', 'hotmail.com', 'yahoo.fr', 'orange.fr', 'free.fr', 'wanadoo.fr', 'live.fr', 'laposte.net', 'yahoo.com', 'sfr.fr', 'msn.com', 'neuf.fr', 'aol.com', 'voila.fr', 'facebook.com', 'me.com', 'orange.com', 'club-internet.fr', 'bbox.fr', 'noos.fr', 'outlook.fr', 'microsoft.com', 'bnpparibas.com', 'numericable.fr', 'aliceadsl.fr', 'outlook.com', 'ymail.com', 'googlemail.com', 'gmx.de', 'icloud.com', 'capgemini.com', 'web.de', 'cegetel.net', 'edhec.com', 'loreal.com', 'mac.com', 'essec.edu', 'gmail.fr', 'deloitte.fr', 'sfr.com', 'hec.edu', 'renault.com', 'google.com', 'gmx.fr', 'gadz.org', 'sncf.fr', 'leetchi.com', 'dbmail.com', 'live.com', 'libertysurf.fr', 'sgcib.com', 'skynet.be', 'aol.net', '9online.fr', 'bouyguestelecom.fr', 'gmx.net', 'mail.com'],
|
|
secondLevelDomains : ['gmail', 'hotmail', 'hotmail', 'yahoo', 'orange', 'free', 'wanadoo', 'live', 'laposte', 'yahoo', 'sfr', 'msn', 'neuf', 'aol', 'voila', 'facebook', 'orange', 'club-internet', 'bbox', 'noos', 'outlook', 'microsoft', 'bnpparibas', 'numericable', 'aliceadsl', 'outlook', 'ymail', 'googlemail', 'gmx', 'icloud', 'capgemini', 'cegetel', 'edhec', 'loreal', 'mac', 'essec', 'gmail', 'deloitte', 'sfr', 'hec', 'renault', 'google', 'gmx', 'gadz', 'sncf', 'leetchi', 'dbmail', 'libertysurf', 'skynet', 'aol', '9online', 'bouyguestelecom'],
|
|
topLevelDomains : ['fr', 'be', 'de', 'es', 'it', 'eu', 'co.uk', 'uk', 'nl', 'at', 'ca', 'com', 'info', 'net', 'org', 'bzh', 'name', 'cat', 'fi', 'se', 'gf', 'gy', 'pl', 'ie', 'il', 'lu', 'ma', 're', 'ro'],
|
|
emailInit : function(element) {
|
|
element.after($('<span></span>').addClass('form-email-helper'));
|
|
return element.on('blur', function() {
|
|
return element.mailcheck({
|
|
domains: emailValidator.domains,
|
|
secondLevelDomains: emailValidator.secondLevelDomains,
|
|
topLevelDomains: emailValidator.topLevelDomains,
|
|
suggested: function(element, suggestion) {
|
|
return emailValidator.emailSuggest(element, suggestion);
|
|
},
|
|
empty: function(element) {
|
|
return emailValidator.emailEmpty(element);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
emailSuggest : function(element, suggestion) {
|
|
var helper;
|
|
helper = element.closest('.form-group').find('.form-email-helper');
|
|
if (!helper.hasClass('active')) {
|
|
helper.addClass('active');
|
|
}
|
|
helper.html(i18n.form_email_suggestion.replace('{0}', '<button class="btn-link form-email-helper-link" type="button">' + suggestion.full + '</button>'));
|
|
return helper.find('.form-email-helper-link').one('click', function() {
|
|
element.val($(this).text());
|
|
element.closest('.form-group').removeClass('form-error').addClass('form-ok');
|
|
return helper.removeClass('active').html('');
|
|
});
|
|
},
|
|
emailEmpty : function(element) {
|
|
var helper;
|
|
helper = element.closest('.form-email-container').find('.form-email-helper');
|
|
if (helper.hasClass('active')) {
|
|
return helper.removeClass('active').html('');
|
|
}
|
|
}
|
|
};
|
|
|
|
/*! mailcheck v1.1.0 @licence MIT */
|
|
var Mailcheck = {
|
|
domainThreshold: 4,
|
|
topLevelThreshold: 3,
|
|
defaultDomains: ["yahoo.com", "google.com", "hotmail.com", "gmail.com", "me.com", "aol.com", "mac.com", "live.com", "comcast.net", "googlemail.com", "msn.com", "hotmail.co.uk", "yahoo.co.uk", "facebook.com", "verizon.net", "sbcglobal.net", "att.net", "gmx.com", "mail.com", "outlook.com", "icloud.com"],
|
|
defaultTopLevelDomains: ["co.jp", "co.uk", "com", "net", "org", "info", "edu", "gov", "mil", "ca"],
|
|
run: function(a) {
|
|
a.domains = a.domains || Mailcheck.defaultDomains, a.topLevelDomains = a.topLevelDomains || Mailcheck.defaultTopLevelDomains, a.distanceFunction = a.distanceFunction || Mailcheck.sift3Distance;
|
|
var b = function(a) {
|
|
return a
|
|
},
|
|
c = a.suggested || b,
|
|
d = a.empty || b,
|
|
e = Mailcheck.suggest(Mailcheck.encodeEmail(a.email), a.domains, a.topLevelDomains, a.distanceFunction);
|
|
return e ? c(e) : d()
|
|
},
|
|
suggest: function(a, b, c, d) {
|
|
a = a.toLowerCase();
|
|
var e = this.splitEmail(a),
|
|
f = this.findClosestDomain(e.domain, b, d, this.domainThreshold);
|
|
if (f) {
|
|
if (f != e.domain) return {
|
|
address: e.address,
|
|
domain: f,
|
|
full: e.address + "@" + f
|
|
}
|
|
} else {
|
|
var g = this.findClosestDomain(e.topLevelDomain, c, d, this.topLevelThreshold);
|
|
if (e.domain && g && g != e.topLevelDomain) {
|
|
var h = e.domain;
|
|
return f = h.substring(0, h.lastIndexOf(e.topLevelDomain)) + g, {
|
|
address: e.address,
|
|
domain: f,
|
|
full: e.address + "@" + f
|
|
}
|
|
}
|
|
}
|
|
return !1
|
|
},
|
|
findClosestDomain: function(a, b, c, d) {
|
|
d = d || this.topLevelThreshold;
|
|
var e, f = 99,
|
|
g = null;
|
|
if (!a || !b) return !1;
|
|
c || (c = this.sift3Distance);
|
|
for (var h = 0; h < b.length; h++) {
|
|
if (a === b[h]) return a;
|
|
e = c(a, b[h]), f > e && (f = e, g = b[h])
|
|
}
|
|
return d >= f && null !== g ? g : !1
|
|
},
|
|
sift3Distance: function(a, b) {
|
|
if (null == a || 0 === a.length) return null == b || 0 === b.length ? 0 : b.length;
|
|
if (null == b || 0 === b.length) return a.length;
|
|
for (var c = 0, d = 0, e = 0, f = 0, g = 5; c + d < a.length && c + e < b.length;) {
|
|
if (a.charAt(c + d) == b.charAt(c + e)) f++;
|
|
else {
|
|
d = 0, e = 0;
|
|
for (var h = 0; g > h; h++) {
|
|
if (c + h < a.length && a.charAt(c + h) == b.charAt(c)) {
|
|
d = h;
|
|
break
|
|
}
|
|
if (c + h < b.length && a.charAt(c) == b.charAt(c + h)) {
|
|
e = h;
|
|
break
|
|
}
|
|
}
|
|
}
|
|
c++
|
|
}
|
|
return (a.length + b.length) / 2 - f
|
|
},
|
|
splitEmail: function(a) {
|
|
var b = a.trim().split("@");
|
|
if (b.length < 2) return !1;
|
|
for (var c = 0; c < b.length; c++)
|
|
if ("" === b[c]) return !1;
|
|
var d = b.pop(),
|
|
e = d.split("."),
|
|
f = "";
|
|
if (0 == e.length) return !1;
|
|
if (1 == e.length) f = e[0];
|
|
else {
|
|
for (var c = 1; c < e.length; c++) f += e[c] + ".";
|
|
e.length >= 2 && (f = f.substring(0, f.length - 1))
|
|
}
|
|
return {
|
|
topLevelDomain: f,
|
|
domain: d,
|
|
address: b.join("@")
|
|
}
|
|
},
|
|
encodeEmail: function(a) {
|
|
var b = encodeURI(a);
|
|
return b = b.replace("%20", " ").replace("%25", "%").replace("%5E", "^").replace("%60", "`").replace("%7B", "{").replace("%7C", "|").replace("%7D", "}")
|
|
}
|
|
};
|
|
"undefined" != typeof module && module.exports && (module.exports = Mailcheck), "function" == typeof define && define.amd && define("mailcheck", [], function() {
|
|
return Mailcheck
|
|
}), "undefined" != typeof window && window.jQuery && ! function(a) {
|
|
a.fn.mailcheck = function(a) {
|
|
var b = this;
|
|
if (a.suggested) {
|
|
var c = a.suggested;
|
|
a.suggested = function(a) {
|
|
c(b, a)
|
|
}
|
|
}
|
|
if (a.empty) {
|
|
var d = a.empty;
|
|
a.empty = function() {
|
|
d.call(null, b)
|
|
}
|
|
}
|
|
a.email = this.val(), Mailcheck.run(a)
|
|
}
|
|
}(jQuery);
|
|
|
|
|
|
/** ==================
|
|
* END Email validation
|
|
==================== */ |