diff --git a/README.md b/README.md index 9aaa510..dbec7e1 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ Activate Plugin As a Noosfero administrator user, go to administrator panel: +- Execute the command to allow city and states to show up: + psql -U USERNAME -d NOOSFERO_DATABASE -a -f db/brazil_national_regions.sql - Click on "Enable/disable plugins" option - Click on "MPOG Software Plugin" check-box diff --git a/public/mpog-user-validations.js b/public/mpog-user-validations.js index 0c596a3..3907771 100644 --- a/public/mpog-user-validations.js +++ b/public/mpog-user-validations.js @@ -126,10 +126,12 @@ if( (typeof jQuery("#profile_data_cell_phone").data("rawMaskFn") === 'undefined') ) { jQuery("#profile_data_cell_phone").mask("(99) 9999?9-9999"); jQuery("#profile_data_comercial_phone").mask("(99) 9999?9-9999"); + jQuery("#profile_data_contact_phone").mask("(99) 9999?9-9999"); } } else { jQuery("#profile_data_cell_phone").unmask(); jQuery("#profile_data_comercial_phone").unmask(); + jQuery("#profile_data_contact_phone").unmask(); } } @@ -147,75 +149,103 @@ }); } - function set_full_name_validation() { - // Sorry, I know its ugly. But I cant get ([^\w\*\s*])|(^|\s)([a-z]|[0-9]) - // to ignore Brazilian not so much special chars in names - function replace_some_special_chars(text) { - return text.replace(/([áàâãéèêíïóôõöú])/g, function(value){ - if( ["á","à","â","ã"].indexOf(value) != -1 ) - return "a"; - else if( ["é","è","ê"].indexOf(value) != -1 ) - return "e"; - else if( ["í","ï"].indexOf(value) != -1 ) - return "i"; - else if ( ["ó","ô","õ","ö"].indexOf(value) != -1 ) - return "o"; - else if( ["ú"].indexOf(value) != -1 ) - return "u"; - else - return value; - }); - } + // Sorry, I know its ugly. But I cant get ([^\w\*\s*])|(^|\s)([a-z]|[0-9]) + // to ignore Brazilian not so much special chars in names + function replace_some_special_chars(text) { + return text.replace(/([áàâãéèêíïóôõöú])/g, function(value){ + if( ["á","à","â","ã"].indexOf(value) != -1 ) + return "a"; + else if( ["é","è","ê"].indexOf(value) != -1 ) + return "e"; + else if( ["í","ï"].indexOf(value) != -1 ) + return "i"; + else if ( ["ó","ô","õ","ö"].indexOf(value) != -1 ) + return "o"; + else if( ["ú"].indexOf(value) != -1 ) + return "u"; + else + return value; + }); + } - function is_invalid_formated(text) { - var full_validation = /([^\w\*\s*])|(^|\s)([a-z]|[0-9])/; // no special chars and do not initialize with no capital latter - var partial_validation = /[^\w\*\s*]/; // no special chars - text = replace_some_special_chars(text); - var slices = text.split(" "); - var invalid = false; - - for(var i = 0; i < slices.length; i++) { - if( slices[i].length > 3 ) { - invalid = full_validation.test(slices[i]); - } else { - invalid = partial_validation.test(slices[i]); - } + function is_invalid_formated(text) { + var full_validation = /([^\w\*\s*])|(^|\s)([a-z]|[0-9])/; // no special chars and do not initialize with no capital latter + var partial_validation = /[^\w\*\s*]/; // no special chars + text = replace_some_special_chars(text); + var slices = text.split(" "); + var invalid = false; - if(invalid) break; + for(var i = 0; i < slices.length; i++) { + if( slices[i].length > 3 ) { + invalid = full_validation.test(slices[i]); + } else { + invalid = partial_validation.test(slices[i]); } - return invalid; + if(invalid) break; } - function show_full_name_error_message() { - var field = jQuery("#profile_data_name"); + return invalid; + } - field.removeClass("validated").addClass("invalid"); + jQuery("#profile_data_name").blur(function(){ + jQuery(this).attr("class", ""); - if(!jQuery(".full_name_error")[0]) { - var message = jQuery("#full_name_error").val(); - field.parent().append(""+message+""); - } else { - jQuery(".full_name_error").show(); - } + if( this.value.length > 0 && is_invalid_formated(this.value) ) { + show_full_name_error_message(); + } else { + hide_full_name_error_message(); } + }); + - function hide_full_name_error_message() { - jQuery("#profile_data_name").removeClass("invalid").addClass("validated"); - jQuery(".full_name_error").hide(); + // Generic + function show_plugin_error_message(field_id, hidden_message_id ) { + var field = jQuery("#"+field_id); + + field.removeClass("validated").addClass("invalid"); + + if(!jQuery("." + hidden_message_id)[0]) { + var message = jQuery("#" + hidden_message_id).val(); + field.parent().append("
-<%= hidden_field_tag("full_name_error", _("Should begin with a capital letter and no special characters")) %> \ No newline at end of file +<%= hidden_field_tag("full_name_error", _("Should begin with a capital letter and no special characters")) %> +<%= hidden_field_tag("email_error", _("Email should have the following format: name@host.br")) %> +<%= hidden_field_tag("site_error", _("Site should have a valid format: http://name.hosts")) %> \ No newline at end of file -- libgit2 0.21.2