Commit e682f9c198fec014bbdfbc9278722fbe620a39e3

Authored by Fabio Teixeira
Committed by Gabriela Navarro
1 parent d24e09be

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>
lib/mpog_software_plugin.rb
... ... @@ -248,7 +248,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
248 248 end
249 249  
250 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 252 end
253 253  
254 254 def add_new_organization_buttons
... ...
public/mpog-custom-libraries.js 0 → 100644
... ... @@ -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 31 \ No newline at end of file
... ...
public/mpog-institution-validations.js
... ... @@ -181,11 +181,13 @@
181 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 185 var cnpj = jQuery("#institutions_cnpj").parent().parent();
186 186 var city = jQuery("#community_city").parent().parent();
187 187 var state = jQuery("#community_state").parent().parent();
188 188  
  189 + if( this.value == "-1" ) jQuery(this).val("BR");
  190 +
189 191 if( this.value != "BR" ) {
190 192 cnpj.hide();
191 193 city.hide();
... ... @@ -195,21 +197,33 @@
195 197 city.show();
196 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 218 jQuery('#community_country').val("BR");
  219 + }
  220 +
  221 + function set_events() {
  222 + show_private_institutions_fields();
204 223  
205 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 228 jQuery('#save_institution_button').click(save_institution);
215 229  
... ... @@ -226,5 +240,8 @@
226 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 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 3 * "Class" that switch state field between input and select
35 4 * If the Country if Brazil, set state to select field
36 5 * else set it as a input field
... ...