Commit e682f9c198fec014bbdfbc9278722fbe620a39e3
Committed by
Gabriela Navarro
1 parent
d24e09be
Exists in
master
and in
79 other branches
Add Brazil as first country in the institution's select
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
4 changed files
with
58 additions
and
42 deletions
Show diff stats
lib/mpog_software_plugin.rb
@@ -248,7 +248,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -248,7 +248,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
248 | end | 248 | end |
249 | 249 | ||
250 | def js_files | 250 | def js_files |
251 | - ["mpog-software.js", "mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js", "mpog-incomplete-registration.js", "mpog-search.js", "jquery.maskedinput.min.js"] | 251 | + ["mpog-custom-libraries.js", "mpog-software.js", "mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js", "mpog-incomplete-registration.js", "mpog-search.js", "jquery.maskedinput.min.js"] |
252 | end | 252 | end |
253 | 253 | ||
254 | def add_new_organization_buttons | 254 | def add_new_organization_buttons |
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +/* | ||
2 | +* "Class" for select and option html generation | ||
3 | +*/ | ||
4 | +var SelectElement = (function() { | ||
5 | + function SelectElement(name, id) { | ||
6 | + this.select = document.createElement("select"); | ||
7 | + } | ||
8 | + | ||
9 | + SelectElement.prototype.setAttr = function(attr, value) { | ||
10 | + return this.select.setAttribute(attr, value); | ||
11 | + }; | ||
12 | + | ||
13 | + SelectElement.prototype.addOption = function(option) { | ||
14 | + return this.select.add(option); | ||
15 | + }; | ||
16 | + | ||
17 | + SelectElement.prototype.getSelect = function() { | ||
18 | + return this.select; | ||
19 | + }; | ||
20 | + | ||
21 | + SelectElement.generateOption = function(value, text) { | ||
22 | + var option; | ||
23 | + option = document.createElement("option"); | ||
24 | + option.setAttribute("value", value); | ||
25 | + option.text = text; | ||
26 | + return option; | ||
27 | + }; | ||
28 | + | ||
29 | + return SelectElement; | ||
30 | +})(); | ||
0 | \ No newline at end of file | 31 | \ No newline at end of file |
public/mpog-institution-validations.js
@@ -181,11 +181,13 @@ | @@ -181,11 +181,13 @@ | ||
181 | jQuery(".intitution_cnpj_field").mask("99.999.999/9999-99"); | 181 | jQuery(".intitution_cnpj_field").mask("99.999.999/9999-99"); |
182 | } | 182 | } |
183 | 183 | ||
184 | - function show_hide_cnpj_city() { | 184 | + function show_hide_cnpj_city(e) { |
185 | var cnpj = jQuery("#institutions_cnpj").parent().parent(); | 185 | var cnpj = jQuery("#institutions_cnpj").parent().parent(); |
186 | var city = jQuery("#community_city").parent().parent(); | 186 | var city = jQuery("#community_city").parent().parent(); |
187 | var state = jQuery("#community_state").parent().parent(); | 187 | var state = jQuery("#community_state").parent().parent(); |
188 | 188 | ||
189 | + if( this.value == "-1" ) jQuery(this).val("BR"); | ||
190 | + | ||
189 | if( this.value != "BR" ) { | 191 | if( this.value != "BR" ) { |
190 | cnpj.hide(); | 192 | cnpj.hide(); |
191 | city.hide(); | 193 | city.hide(); |
@@ -195,21 +197,33 @@ | @@ -195,21 +197,33 @@ | ||
195 | city.show(); | 197 | city.show(); |
196 | state.show(); | 198 | state.show(); |
197 | } | 199 | } |
200 | + | ||
201 | + e.preventDefault(); | ||
198 | } | 202 | } |
199 | 203 | ||
200 | - function set_events() { | ||
201 | - show_private_institutions_fields(); | 204 | + function institution_type_actions() { |
205 | + if( this.value == "PublicInstitution" ) | ||
206 | + show_public_institutions_fields(); | ||
207 | + else | ||
208 | + show_private_institutions_fields(); | ||
209 | + } | ||
210 | + | ||
211 | + function set_form_count_custom_data() { | ||
212 | + var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); | ||
213 | + var default_option = SelectElement.generateOption("BR", "Brazil"); | ||
202 | 214 | ||
215 | + jQuery('#community_country').find("option[value='']").remove(); | ||
216 | + jQuery('#community_country').prepend(divisor_option); | ||
217 | + jQuery('#community_country').prepend(default_option); | ||
203 | jQuery('#community_country').val("BR"); | 218 | jQuery('#community_country').val("BR"); |
219 | + } | ||
220 | + | ||
221 | + function set_events() { | ||
222 | + show_private_institutions_fields(); | ||
204 | 223 | ||
205 | jQuery("#create_institution_link").click(open_create_institution_modal); | 224 | jQuery("#create_institution_link").click(open_create_institution_modal); |
206 | 225 | ||
207 | - jQuery("input[type='radio']").click(function(){ | ||
208 | - if( this.value == "PublicInstitution" ) | ||
209 | - show_public_institutions_fields(); | ||
210 | - else | ||
211 | - show_private_institutions_fields(); | ||
212 | - }); | 226 | + jQuery("input[type='radio']").click(institution_type_actions); |
213 | 227 | ||
214 | jQuery('#save_institution_button').click(save_institution); | 228 | jQuery('#save_institution_button').click(save_institution); |
215 | 229 | ||
@@ -226,5 +240,8 @@ | @@ -226,5 +240,8 @@ | ||
226 | institution_autocomplete(); | 240 | institution_autocomplete(); |
227 | } | 241 | } |
228 | 242 | ||
229 | - jQuery(document).ready(set_events); | 243 | + jQuery(document).ready(function(){ |
244 | + set_form_count_custom_data(); | ||
245 | + set_events(); | ||
246 | + }); | ||
230 | })(); | 247 | })(); |
public/mpog-user-validations.js
1 | (function(){ | 1 | (function(){ |
2 | /* | 2 | /* |
3 | - * "Class" for select and option html generation | ||
4 | - */ | ||
5 | - var SelectElement = (function() { | ||
6 | - function SelectElement(name, id) { | ||
7 | - this.select = document.createElement("select"); | ||
8 | - } | ||
9 | - | ||
10 | - SelectElement.prototype.setAttr = function(attr, value) { | ||
11 | - return this.select.setAttribute(attr, value); | ||
12 | - }; | ||
13 | - | ||
14 | - SelectElement.prototype.addOption = function(option) { | ||
15 | - return this.select.add(option); | ||
16 | - }; | ||
17 | - | ||
18 | - SelectElement.prototype.getSelect = function() { | ||
19 | - return this.select; | ||
20 | - }; | ||
21 | - | ||
22 | - SelectElement.generateOption = function(value, text) { | ||
23 | - var option; | ||
24 | - option = document.createElement("option"); | ||
25 | - option.setAttribute("value", value); | ||
26 | - option.text = text; | ||
27 | - return option; | ||
28 | - }; | ||
29 | - | ||
30 | - return SelectElement; | ||
31 | - })(); | ||
32 | - | ||
33 | - /* | ||
34 | * "Class" that switch state field between input and select | 3 | * "Class" that switch state field between input and select |
35 | * If the Country if Brazil, set state to select field | 4 | * If the Country if Brazil, set state to select field |
36 | * else set it as a input field | 5 | * else set it as a input field |