/*
< miscellaneous validate >
Copyright (C) <2014> < themeshock http://www.themeshock.com/ >
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
jQuery(function(){
// creamos nuestra regla con expresiones regulares.
var filterEmail = /([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})/;
var filterUrl = /^(sip|ftp[s]|http[s]?:\/\/){0,1}(www\.){0,1}localhost|[a-zA-Z0-9\.\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2,5}\/[\.]{0,1})/;
var filterSize = /[0-9]{2}|[0-9]{3}/;
var filterColor = /(blue|red|orange|aqua|green|white|black|lime|purple|yellow|maroon|fuschia|navy|silver|gray|olive|teal|inherit|Inherit|^(hsl|rgb|#)[a-fA-F0-9\,\(\)%]+)/;
// utilizamos test para comprobar si el parametro valor cumple la regla
function validate_field(filter,valor)
{
if(filter.test(valor))
return true;
else
return false;
}
// verificamos el match en el momento de levantar la tecla
jQuery(".fontSizeTagHeadings").keyup(function()
{
if(jQuery(this).val() == '' || jQuery(this).val() == 'inherit' || jQuery(this).val() == 'Inherit')
{
jQuery(this).css("border","1px solid #dddddd");
//jQuery(this).val('#');
jQuery(this).removeAttr("maxlength");
jQuery('#button-primary-btn').val("Save Changes");
}else if(validate_field(filterSize,jQuery(this).val()) && jQuery(this).val() != 'inherit')
{
jQuery(this).attr("maxlength",3);
jQuery('#button-primary-btn').val("Save Changes");
}else
{
jQuery(this).css("border","1px solid #aa0000 !important");
jQuery('#button-primary-btn').val('Save Pls Chk Size format :(');
}
});
// verificamos el match en el momento de levantar la tecla
jQuery("#themeshock_favicon").keyup(function()
{
if(jQuery(this).val() == '')
{
//jQuery(this).val('#');
jQuery('#button-primary-btn').val("Save Changes");
jQuery(this).css("border","1px solid #dddddd");
}else if(validate_field(filterUrl,jQuery(this).val()))
{
jQuery(this).css("border","1px solid #dddddd");
jQuery('#button-primary-btn').val("Save Changes");
}else
{
jQuery(this).css("border","1px solid #aa0000 !important");
jQuery('#button-primary-btn').val('Save Pls Chk Url format :(');
}
});
// jQuery(".themeshock-mailer").keyup(function()
// {
// if(jQuery(this).val() == '' || jQuery(this).val() == '#')
// {
// jQuery(this).css("border","1px solid #dddddd");
// jQuery('#button-primary-btn').val("Save Changes");
// }else if(validate_field(filterUrl,jQuery(this).val())){
// jQuery(this).css("border","1px solid #dddddd");
// jQuery('#button-primary-btn').val("Save Changes");
// }else
// {
// jQuery(this).css("border","1px solid #aa0000 !important");
// //jQuery(".update_text").show().html("Pls chk The correct format: http://domain.com").css("color","#ea4444");
// jQuery('#button-primary-btn').val('Save Pls Chk Url format :(');
// }
// });
jQuery("#themeshock_contact_mail").keyup(function()
{
if(jQuery(this).val() == '')
{
//jQuery(this).val('#');
jQuery(this).css("border","1px solid #dddddd");
jQuery('#button-primary-btn').val("Save Changes");
}else if(validate_field(filterEmail,jQuery(this).val()))
{
jQuery('#button-primary-btn').val("Save Changes");
jQuery(this).css("border","1px solid #dddddd");
}else
{
jQuery(this).css("border","1px solid #aa0000 !important");
jQuery('#button-primary-btn').val('Save Pls Chk Email format :(');
}
});
jQuery('.controls-new-sidebar-show').click(function(e){
e.preventDefault();
jQuery(this).hide();
jQuery('input[name="add_sidebar"], .setup-new-sidebar').show();
})
})