Commit 7da23487725aa017ac605abcc309e40c1ed77d76
Committed by
Gabriela Navarro
1 parent
8c5d6d8b
Exists in
master
and in
5 other branches
Remove dead code from user profile_editor
Showing
4 changed files
with
25 additions
and
442 deletions
Show diff stats
controllers/software_communities_plugin_controller.rb
1 | require 'csv' | 1 | require 'csv' |
2 | class SoftwareCommunitiesPluginController < ApplicationController | 2 | class SoftwareCommunitiesPluginController < ApplicationController |
3 | 3 | ||
4 | - def check_reactivate_account | ||
5 | - if request.xhr? && params[:email] | ||
6 | - result = "" | ||
7 | - user = User.where(:email => params[:email]) | ||
8 | - | ||
9 | - if user.length == 1 && !user[0].person.visible | ||
10 | - result = "<span id='forgot_link'><a href='/account/forgot_password'> Reactive account</a></span>" | ||
11 | - end | ||
12 | - | ||
13 | - render :json => result.to_json | ||
14 | - end | ||
15 | - end | ||
16 | - | ||
17 | def hide_registration_incomplete_percentage | 4 | def hide_registration_incomplete_percentage |
18 | response = false | 5 | response = false |
19 | 6 |
lib/software_communities_plugin.rb
@@ -119,7 +119,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -119,7 +119,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
119 | end | 119 | end |
120 | 120 | ||
121 | def js_files | 121 | def js_files |
122 | - #mpog-user-validations.js | ||
123 | %w( | 122 | %w( |
124 | vendor/jquery.maskedinput.min.js | 123 | vendor/jquery.maskedinput.min.js |
125 | vendor/modulejs-1.5.0.min.js | 124 | vendor/modulejs-1.5.0.min.js |
@@ -134,7 +133,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -134,7 +133,6 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
134 | views/user-edit-profile.js | 133 | views/user-edit-profile.js |
135 | initializer.js | 134 | initializer.js |
136 | app.js | 135 | app.js |
137 | - | ||
138 | mpog-institution-validations.js | 136 | mpog-institution-validations.js |
139 | mpog-incomplete-registration.js | 137 | mpog-incomplete-registration.js |
140 | mpog-search.js | 138 | mpog-search.js |
public/mpog-user-validations.js
@@ -1,332 +0,0 @@ | @@ -1,332 +0,0 @@ | ||
1 | -(function(){ | ||
2 | - var AJAX_URL = { | ||
3 | - check_reactivate_account: | ||
4 | - url_with_subdirectory("/plugin/software_communities/check_reactivate_account") | ||
5 | - }; | ||
6 | - | ||
7 | - | ||
8 | - /* | ||
9 | - * "Class" that switch state field between input and select | ||
10 | - * If the Country if Brazil, set state to select field | ||
11 | - * else set it as a input field | ||
12 | - */ | ||
13 | - var SelectFieldChoices = (function() { | ||
14 | - function SelectFieldChoices(state_id, city_id, state_url) { | ||
15 | - this.state_id = state_id; | ||
16 | - this.input_html = jQuery(state_id).parent().html(); | ||
17 | - this.old_value = jQuery(state_id).val(); | ||
18 | - this.city_parent_div = jQuery(city_id).parent().parent().parent(); | ||
19 | - this.state_url = state_url; | ||
20 | - } | ||
21 | - | ||
22 | - SelectFieldChoices.prototype.getCurrentStateElement = function() { | ||
23 | - return jQuery(this.state_id); | ||
24 | - }; | ||
25 | - | ||
26 | - SelectFieldChoices.prototype.replaceWith = function(html) { | ||
27 | - var parent_div = this.getCurrentStateElement().parent(); | ||
28 | - parent_div.html(html); | ||
29 | - }; | ||
30 | - | ||
31 | - SelectFieldChoices.prototype.generateSelect = function(state_list) { | ||
32 | - var select_element, option; | ||
33 | - | ||
34 | - select_element = new SelectElement(); | ||
35 | - select_element.setAttr("name", "profile_data[state]"); | ||
36 | - select_element.setAttr("id", "state_field"); | ||
37 | - select_element.setAttr("class", "type-select valid"); | ||
38 | - | ||
39 | - state_list.forEach(function(state) { | ||
40 | - option = SelectElement.generateOption(state, state); | ||
41 | - select_element.addOption(option); | ||
42 | - }); | ||
43 | - | ||
44 | - return select_element.getSelect(); | ||
45 | - }; | ||
46 | - | ||
47 | - SelectFieldChoices.prototype.replaceStateWithSelectElement = function() { | ||
48 | - var klass = this; | ||
49 | - | ||
50 | - jQuery.get(this.state_url, function(response) { | ||
51 | - var select_html; | ||
52 | - | ||
53 | - if (response.length > 0) { | ||
54 | - select_html = klass.generateSelect(response); | ||
55 | - klass.replaceWith(select_html); | ||
56 | - | ||
57 | - if (klass.old_value.length !== 0 && response.include(klass.old_value)) { | ||
58 | - klass.getCurrentStateElement().val(klass.old_value); | ||
59 | - } | ||
60 | - } | ||
61 | - }); | ||
62 | - }; | ||
63 | - | ||
64 | - SelectFieldChoices.prototype.replaceStateWithInputElement = function() { | ||
65 | - this.replaceWith(this.input_html); | ||
66 | - }; | ||
67 | - | ||
68 | - SelectFieldChoices.prototype.hideCity = function() { | ||
69 | - this.city_parent_div.addClass("mpog_hidden_field"); | ||
70 | - }; | ||
71 | - | ||
72 | - SelectFieldChoices.prototype.showCity = function() { | ||
73 | - this.city_parent_div.removeClass("mpog_hidden_field"); | ||
74 | - }; | ||
75 | - | ||
76 | - SelectFieldChoices.prototype.actualFieldIsInput = function() { | ||
77 | - return this.getCurrentStateElement().attr("type") === "text"; | ||
78 | - }; | ||
79 | - | ||
80 | - return SelectFieldChoices; | ||
81 | - })(); | ||
82 | - | ||
83 | - function set_form_count_custom_data() { | ||
84 | - var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); | ||
85 | - var default_option = SelectElement.generateOption("BR", "Brazil"); | ||
86 | - | ||
87 | - jQuery('#profile_data_country').find("option[value='']").remove(); | ||
88 | - jQuery('#profile_data_country').prepend(divisor_option); | ||
89 | - jQuery('#profile_data_country').prepend(default_option); | ||
90 | - jQuery('#profile_data_country').val("BR"); | ||
91 | - } | ||
92 | - | ||
93 | - function set_initial_form_custom_data(selectFieldChoices) { | ||
94 | - set_form_count_custom_data(); | ||
95 | - | ||
96 | - jQuery("#password-balloon").html(jQuery("#user_password_menssage").val()); | ||
97 | - jQuery("#profile_data_email").parent().append(jQuery("#email_public_message").remove()); | ||
98 | - | ||
99 | - if( jQuery("#state_field").length !== 0 ) selectFieldChoices.replaceStateWithSelectElement(); | ||
100 | - } | ||
101 | - | ||
102 | - function check_reactivate_account(value, input_object){ | ||
103 | - jQuery.ajax({ | ||
104 | - url : AJAX_URL.check_reactivate_account, | ||
105 | - type: "GET", | ||
106 | - data: { "email": value }, | ||
107 | - success: function(response) { | ||
108 | - if( jQuery("#forgot_link").length === 0 ) | ||
109 | - jQuery(input_object).parent().append(response); | ||
110 | - else | ||
111 | - jQuery("#forgot_link").html(response); | ||
112 | - }, | ||
113 | - error: function(type, err, message) { | ||
114 | - console.log(type+" -- "+err+" -- "+message); | ||
115 | - } | ||
116 | - }); | ||
117 | - } | ||
118 | - | ||
119 | - function put_brazil_based_on_email(){ | ||
120 | - var suffixes = ['gov.br', 'jus.br', 'leg.br', 'mp.br']; | ||
121 | - var value = this.value; | ||
122 | - var input_object = this; | ||
123 | - var gov_suffix = false; | ||
124 | - | ||
125 | - suffixes.each(function(suffix){ | ||
126 | - var has_suffix = new RegExp("(.*)"+suffix+"$", "i"); | ||
127 | - | ||
128 | - if( has_suffix.test(value) ) { | ||
129 | - gov_suffix = true; | ||
130 | - jQuery("#profile_data_country").val("BR"); | ||
131 | - } | ||
132 | - }); | ||
133 | - | ||
134 | - jQuery("#profile_data_country").find(':not(:selected)').css('display', (gov_suffix?'none':'block')); | ||
135 | - | ||
136 | - check_reactivate_account(value, input_object); | ||
137 | - } | ||
138 | - | ||
139 | - function validate_email_format(){ | ||
140 | - var correct_format_regex = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; | ||
141 | - | ||
142 | - if( this.value.length > 0 ) { | ||
143 | - if(correct_format_regex.test(this.value)) | ||
144 | - this.className = "validated"; | ||
145 | - else | ||
146 | - this.className = "invalid"; | ||
147 | - } else | ||
148 | - this.className = ""; | ||
149 | - } | ||
150 | - | ||
151 | - function verify_user_password_size() { | ||
152 | - if( this.value.length < 6 ) { | ||
153 | - jQuery(this).switchClass("validated", "invalid"); | ||
154 | - } else { | ||
155 | - jQuery(this).switchClass("invalid", "validated"); | ||
156 | - } | ||
157 | - } | ||
158 | - | ||
159 | - function show_or_hide_phone_mask() { | ||
160 | - if(jQuery("#profile_data_country").val() == "BR") { | ||
161 | - if( (typeof jQuery("#profile_data_cell_phone").data("rawMaskFn") === 'undefined') ) { | ||
162 | - jQuery("#profile_data_cell_phone").mask("(99) 9999?9-9999"); | ||
163 | - jQuery("#profile_data_comercial_phone").mask("(99) 9999?9-9999"); | ||
164 | - jQuery("#profile_data_contact_phone").mask("(99) 9999?9-9999"); | ||
165 | - } | ||
166 | - } else { | ||
167 | - jQuery("#profile_data_cell_phone").unmask(); | ||
168 | - jQuery("#profile_data_comercial_phone").unmask(); | ||
169 | - jQuery("#profile_data_contact_phone").unmask(); | ||
170 | - } | ||
171 | - } | ||
172 | - | ||
173 | - function fix_phone_mask_format(id) { | ||
174 | - jQuery(id).blur(function() { | ||
175 | - var last = jQuery(this).val().substr( jQuery(this).val().indexOf("-") + 1 ); | ||
176 | - | ||
177 | - if( last.length == 3 ) { | ||
178 | - var move = jQuery(this).val().substr( jQuery(this).val().indexOf("-") - 1, 1 ); | ||
179 | - var lastfour = move + last; | ||
180 | - var first = jQuery(this).val().substr( 0, 9 ); | ||
181 | - | ||
182 | - jQuery(this).val( first + '-' + lastfour ); | ||
183 | - } | ||
184 | - }); | ||
185 | - } | ||
186 | - | ||
187 | - // Generic | ||
188 | - function show_plugin_error_message(field_selector, hidden_message_id ) { | ||
189 | - var field = jQuery(field_selector); | ||
190 | - | ||
191 | - field.removeClass("validated").addClass("invalid"); | ||
192 | - | ||
193 | - if(!jQuery("." + hidden_message_id)[0]) { | ||
194 | - var message = jQuery("#" + hidden_message_id).val(); | ||
195 | - field.parent().append("<div class='" + hidden_message_id + " errorExplanation'>"+message+"</span>"); | ||
196 | - } else { | ||
197 | - jQuery("." + hidden_message_id).show(); | ||
198 | - } | ||
199 | - } | ||
200 | - | ||
201 | - function hide_plugin_error_message(field_selector, hidden_message_id) { | ||
202 | - jQuery(field_selector).removeClass("invalid").addClass("validated"); | ||
203 | - jQuery("." + hidden_message_id).hide(); | ||
204 | - } | ||
205 | - | ||
206 | - function addBlurFields(field_selector, hidden_message_id, validation_function, allow_blank) { | ||
207 | - jQuery(field_selector).blur(function(){ | ||
208 | - jQuery(this).attr("class", ""); | ||
209 | - | ||
210 | - if( validation_function(this.value, !!allow_blank) ) { | ||
211 | - show_plugin_error_message(field_selector, hidden_message_id); | ||
212 | - } else { | ||
213 | - hide_plugin_error_message(field_selector, hidden_message_id); | ||
214 | - } | ||
215 | - }); | ||
216 | - } | ||
217 | - | ||
218 | - function invalid_email_validation(value, allow_blank) { | ||
219 | - if( allow_blank && value.trim().length === 0 ) { | ||
220 | - return false; | ||
221 | - } | ||
222 | - | ||
223 | - var correct_format_regex = new RegExp(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/); | ||
224 | - | ||
225 | - return !correct_format_regex.test(value); | ||
226 | - } | ||
227 | - | ||
228 | - function invalid_site_validation(value) { | ||
229 | - var correct_format_regex = new RegExp(/(^|)(http[s]{0,1})\:\/\/(\w+[.])\w+/g); | ||
230 | - | ||
231 | - return !correct_format_regex.test(value); | ||
232 | - } | ||
233 | - //End generic | ||
234 | - | ||
235 | - function get_privacy_selector_parent_div(field_id, actual) { | ||
236 | - if( actual === undefined ) actual = jQuery(field_id); | ||
237 | - | ||
238 | - if( actual.is("form") || actual.length === 0 ) return null; // Not allow recursion over form | ||
239 | - | ||
240 | - if( actual.hasClass("field-with-privacy-selector") ) { | ||
241 | - return actual; | ||
242 | - } else { | ||
243 | - return get_privacy_selector_parent_div(field_id, actual.parent()); | ||
244 | - } | ||
245 | - } | ||
246 | - | ||
247 | - function try_to_remove(list, field) { | ||
248 | - try { | ||
249 | - list.push(field.remove()); | ||
250 | - } catch(e) { | ||
251 | - console.log("Cound not remove field"); | ||
252 | - } | ||
253 | - } | ||
254 | - | ||
255 | - function get_edit_fields_in_insertion_order() { | ||
256 | - var containers = []; | ||
257 | - | ||
258 | - try_to_remove(containers, jQuery("h2")[0]); | ||
259 | - try_to_remove(containers, jQuery(".pseudoformlabel").parent().parent()); | ||
260 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_name")); | ||
261 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_email")); | ||
262 | - try_to_remove(containers, jQuery("#user_secondary_email").parent().parent()); | ||
263 | - try_to_remove(containers, jQuery("#select_institution")); | ||
264 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_cell_phone")); | ||
265 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_contact_phone")); | ||
266 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_comercial_phone")); | ||
267 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_personal_website")); | ||
268 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_organization_website")); | ||
269 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_birth_date")); | ||
270 | - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_country")); | ||
271 | - try_to_remove(containers, get_privacy_selector_parent_div("#state_field")); | ||
272 | - try_to_remove(containers, get_privacy_selector_parent_div("#city_field")); | ||
273 | - | ||
274 | - return containers; | ||
275 | - } | ||
276 | - | ||
277 | - function change_edit_fields_order() { | ||
278 | - var form = jQuery("#profile-data"); | ||
279 | - if( form.length !== 0 ) { | ||
280 | - var containers = get_edit_fields_in_insertion_order(); | ||
281 | - | ||
282 | - containers.reverse(); | ||
283 | - | ||
284 | - containers.forEach(function(container){ | ||
285 | - form.prepend(container); | ||
286 | - }); | ||
287 | - } | ||
288 | - } | ||
289 | - | ||
290 | - jQuery(document).ready(function(){ | ||
291 | - change_edit_fields_order(); // To change the fields order, it MUST be the first function executed | ||
292 | - | ||
293 | - var selectFieldChoices = new SelectFieldChoices("#state_field", "#city_field", "/plugin/software_communities/get_brazil_states"); | ||
294 | - set_initial_form_custom_data(selectFieldChoices); | ||
295 | - | ||
296 | - jQuery('#secondary_email_field').blur(validate_email_format); | ||
297 | - | ||
298 | - jQuery("#user_email").blur(put_brazil_based_on_email); | ||
299 | - | ||
300 | - jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); }); | ||
301 | - jQuery('#secondary_email_field').blur(function() { jQuery('#secondary-email-balloon').fadeOut('slow'); }); | ||
302 | - | ||
303 | - jQuery("#user_pw").blur(verify_user_password_size); | ||
304 | - | ||
305 | - jQuery("#profile_data_country").blur(show_or_hide_phone_mask); | ||
306 | - | ||
307 | - // Event that calls the "Class" to siwtch state field types | ||
308 | - jQuery("#profile_data_country").change(function(){ | ||
309 | - if( this.value == "-1" ) jQuery(this).val("BR"); | ||
310 | - | ||
311 | - if( this.value == "BR" && selectFieldChoices.actualFieldIsInput() ) { | ||
312 | - selectFieldChoices.replaceStateWithSelectElement(); | ||
313 | - selectFieldChoices.showCity(); | ||
314 | - } else if( this.value != "BR" && !selectFieldChoices.actualFieldIsInput() ) { | ||
315 | - selectFieldChoices.replaceStateWithInputElement(); | ||
316 | - selectFieldChoices.hideCity(); | ||
317 | - } | ||
318 | - }); | ||
319 | - | ||
320 | - show_or_hide_phone_mask(); | ||
321 | - jQuery("#profile_data_birth_date").mask("99/99/9999"); | ||
322 | - | ||
323 | - fix_phone_mask_format("#profile_data_cell_phone"); | ||
324 | - fix_phone_mask_format("#profile_data_comercial_phone"); | ||
325 | - fix_phone_mask_format("#profile_data_contact_phone"); | ||
326 | - | ||
327 | - addBlurFields("#profile_data_email", "email_error", invalid_email_validation); | ||
328 | - addBlurFields("#user_secondary_email", "email_error", invalid_email_validation, true); | ||
329 | - addBlurFields("#profile_data_personal_website", "site_error", invalid_site_validation); | ||
330 | - addBlurFields("#profile_data_organization_website", "site_error", invalid_site_validation); | ||
331 | - }); | ||
332 | -})(); |
public/views/user-edit-profile.js
1 | -modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', 'SelectFieldChoices'], function($, NoosferoRoot, SelectElement, SelectFieldChoices) { | 1 | +modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoices'], function($, SelectElement, SelectFieldChoices) { |
2 | 'use strict'; | 2 | 'use strict'; |
3 | 3 | ||
4 | - var AJAX_URL = { | ||
5 | - check_reactivate_account: | ||
6 | - NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/check_reactivate_account") | ||
7 | - }; | ||
8 | - | ||
9 | - | ||
10 | function set_form_count_custom_data() { | 4 | function set_form_count_custom_data() { |
11 | var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); | 5 | var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); |
12 | var default_option = SelectElement.generateOption("BR", "Brazil"); | 6 | var default_option = SelectElement.generateOption("BR", "Brazil"); |
@@ -28,71 +22,26 @@ modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', ' | @@ -28,71 +22,26 @@ modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', ' | ||
28 | } | 22 | } |
29 | 23 | ||
30 | 24 | ||
31 | - function check_reactivate_account(value, input_object){ | ||
32 | - $.ajax({ | ||
33 | - url : AJAX_URL.check_reactivate_account, | ||
34 | - type: "GET", | ||
35 | - data: { "email": value }, | ||
36 | - success: function(response) { | ||
37 | - if( $("#forgot_link").length === 0 ) | ||
38 | - $(input_object).parent().append(response); | ||
39 | - else | ||
40 | - $("#forgot_link").html(response); | ||
41 | - }, | ||
42 | - error: function(type, err, message) { | ||
43 | - console.log(type+" -- "+err+" -- "+message); | ||
44 | - } | ||
45 | - }); | ||
46 | - } | ||
47 | - | ||
48 | - | ||
49 | - function put_brazil_based_on_email(){ | ||
50 | - var suffixes = ['gov.br', 'jus.br', 'leg.br', 'mp.br']; | ||
51 | - var value = this.value; | ||
52 | - var input_object = this; | ||
53 | - var gov_suffix = false; | 25 | + function show_state_if_country_is_brazil() { |
26 | + var selectFieldChoices = new SelectFieldChoices("#state_field", "#city_field", "/plugin/software_communities/get_brazil_states"); | ||
27 | + set_initial_form_custom_data(selectFieldChoices); | ||
54 | 28 | ||
55 | - suffixes.each(function(suffix){ | ||
56 | - var has_suffix = new RegExp("(.*)"+suffix+"$", "i"); | 29 | + $("#profile_data_country").change(function(){ |
30 | + if( this.value === "-1" ) $(this).val("BR"); | ||
57 | 31 | ||
58 | - if( has_suffix.test(value) ) { | ||
59 | - gov_suffix = true; | ||
60 | - $("#profile_data_country").val("BR"); | 32 | + if( this.value === "BR" && selectFieldChoices.actualFieldIsInput() ) { |
33 | + selectFieldChoices.replaceStateWithSelectElement(); | ||
34 | + selectFieldChoices.showCity(); | ||
35 | + } else if( this.value !== "BR" && !selectFieldChoices.actualFieldIsInput() ) { | ||
36 | + selectFieldChoices.replaceStateWithInputElement(); | ||
37 | + selectFieldChoices.hideCity(); | ||
61 | } | 38 | } |
62 | }); | 39 | }); |
63 | - | ||
64 | - $("#profile_data_country").find(':not(:selected)').css('display', (gov_suffix?'none':'block')); | ||
65 | - | ||
66 | - check_reactivate_account(value, input_object); | ||
67 | - } | ||
68 | - | ||
69 | - | ||
70 | - function validate_email_format(){ | ||
71 | - var correct_format_regex = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; | ||
72 | - | ||
73 | - if( this.value.length > 0 ) { | ||
74 | - if(correct_format_regex.test(this.value)) { | ||
75 | - this.className = "validated"; | ||
76 | - } else { | ||
77 | - this.className = "invalid"; | ||
78 | - } | ||
79 | - } else { | ||
80 | - this.className = ""; | ||
81 | - } | ||
82 | - } | ||
83 | - | ||
84 | - | ||
85 | - function verify_user_password_size() { | ||
86 | - if( this.value.length < 6 ) { | ||
87 | - $(this).switchClass("validated", "invalid"); | ||
88 | - } else { | ||
89 | - $(this).switchClass("invalid", "validated"); | ||
90 | - } | ||
91 | } | 40 | } |
92 | 41 | ||
93 | 42 | ||
94 | function show_or_hide_phone_mask() { | 43 | function show_or_hide_phone_mask() { |
95 | - if($("#profile_data_country").val() == "BR") { | 44 | + if($("#profile_data_country").val() === "BR") { |
96 | if( (typeof $("#profile_data_cell_phone").data("rawMaskFn") === 'undefined') ) { | 45 | if( (typeof $("#profile_data_cell_phone").data("rawMaskFn") === 'undefined') ) { |
97 | $("#profile_data_cell_phone").mask("(99) 9999?9-9999"); | 46 | $("#profile_data_cell_phone").mask("(99) 9999?9-9999"); |
98 | $("#profile_data_comercial_phone").mask("(99) 9999?9-9999"); | 47 | $("#profile_data_comercial_phone").mask("(99) 9999?9-9999"); |
@@ -110,7 +59,7 @@ modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', ' | @@ -110,7 +59,7 @@ modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', ' | ||
110 | $(id).blur(function() { | 59 | $(id).blur(function() { |
111 | var last = $(this).val().substr( $(this).val().indexOf("-") + 1 ); | 60 | var last = $(this).val().substr( $(this).val().indexOf("-") + 1 ); |
112 | 61 | ||
113 | - if( last.length == 3 ) { | 62 | + if( last.length === 3 ) { |
114 | var move = $(this).val().substr( $(this).val().indexOf("-") - 1, 1 ); | 63 | var move = $(this).val().substr( $(this).val().indexOf("-") - 1, 1 ); |
115 | var lastfour = move + last; | 64 | var lastfour = move + last; |
116 | var first = $(this).val().substr( 0, 9 ); | 65 | var first = $(this).val().substr( 0, 9 ); |
@@ -231,13 +180,18 @@ modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', ' | @@ -231,13 +180,18 @@ modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', ' | ||
231 | 180 | ||
232 | 181 | ||
233 | function set_fields_validations() { | 182 | function set_fields_validations() { |
234 | - $('#secondary_email_field').blur(validate_email_format); | 183 | + $("#profile_data_country").blur(show_or_hide_phone_mask); |
235 | 184 | ||
236 | - $("#user_email").blur(put_brazil_based_on_email); | 185 | + $("#profile_data_birth_date").mask("99/99/9999"); |
237 | 186 | ||
238 | - $("#user_pw").blur(verify_user_password_size); | 187 | + fix_phone_mask_format("#profile_data_cell_phone"); |
188 | + fix_phone_mask_format("#profile_data_comercial_phone"); | ||
189 | + fix_phone_mask_format("#profile_data_contact_phone"); | ||
239 | 190 | ||
240 | - $("#profile_data_country").blur(show_or_hide_phone_mask); | 191 | + add_blur_fields("#profile_data_email", "email_error", invalid_email_validation); |
192 | + add_blur_fields("#user_secondary_email", "email_error", invalid_email_validation, true); | ||
193 | + add_blur_fields("#profile_data_personal_website", "site_error", invalid_site_validation); | ||
194 | + add_blur_fields("#profile_data_organization_website", "site_error", invalid_site_validation); | ||
241 | } | 195 | } |
242 | 196 | ||
243 | 197 | ||
@@ -250,35 +204,11 @@ modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', ' | @@ -250,35 +204,11 @@ modulejs.define('UserEditProfile', ['jquery', 'NoosferoRoot', 'SelectElement', ' | ||
250 | init: function() { | 204 | init: function() { |
251 | change_edit_fields_order(); // To change the fields order, it MUST be the first function executed | 205 | change_edit_fields_order(); // To change the fields order, it MUST be the first function executed |
252 | 206 | ||
253 | - var selectFieldChoices = new SelectFieldChoices("#state_field", "#city_field", "/plugin/software_communities/get_brazil_states"); | ||
254 | - set_initial_form_custom_data(selectFieldChoices); | ||
255 | - | ||
256 | - | ||
257 | - | ||
258 | - // Event that calls the "Class" to siwtch state field types | ||
259 | - $("#profile_data_country").change(function(){ | ||
260 | - if( this.value == "-1" ) $(this).val("BR"); | ||
261 | - | ||
262 | - if( this.value == "BR" && selectFieldChoices.actualFieldIsInput() ) { | ||
263 | - selectFieldChoices.replaceStateWithSelectElement(); | ||
264 | - selectFieldChoices.showCity(); | ||
265 | - } else if( this.value != "BR" && !selectFieldChoices.actualFieldIsInput() ) { | ||
266 | - selectFieldChoices.replaceStateWithInputElement(); | ||
267 | - selectFieldChoices.hideCity(); | ||
268 | - } | ||
269 | - }); | 207 | + show_state_if_country_is_brazil(); |
270 | 208 | ||
271 | show_or_hide_phone_mask(); | 209 | show_or_hide_phone_mask(); |
272 | - $("#profile_data_birth_date").mask("99/99/9999"); | ||
273 | - | ||
274 | - fix_phone_mask_format("#profile_data_cell_phone"); | ||
275 | - fix_phone_mask_format("#profile_data_comercial_phone"); | ||
276 | - fix_phone_mask_format("#profile_data_contact_phone"); | ||
277 | 210 | ||
278 | - add_blur_fields("#profile_data_email", "email_error", invalid_email_validation); | ||
279 | - add_blur_fields("#user_secondary_email", "email_error", invalid_email_validation, true); | ||
280 | - add_blur_fields("#profile_data_personal_website", "site_error", invalid_site_validation); | ||
281 | - add_blur_fields("#profile_data_organization_website", "site_error", invalid_site_validation); | 211 | + set_fields_validations(); |
282 | } | 212 | } |
283 | } | 213 | } |
284 | }); | 214 | }); |