Commit afe6caef144aa5f85ee15363700904a4a1c55f2e

Authored by Marcos Pereira
1 parent 3fff11dc

creating triggers to hide add button

Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
src/noosfero-spb/gov_user/public/views/create-institution.js
@@ -16,11 +16,16 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;] @@ -16,11 +16,16 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;]
16 NoosferoRoot.urlWithSubDirectory("/account/search_cities") 16 NoosferoRoot.urlWithSubDirectory("/account/search_cities")
17 }; 17 };
18 18
  19 + function set_institution_field_name(name) {
  20 + $("#input_institution").attr("value", "");
  21 + $("#input_institution").attr("value", name);
  22 + }
19 23
20 function open_create_institution_modal(evt) { 24 function open_create_institution_modal(evt) {
21 evt.preventDefault(); 25 evt.preventDefault();
  26 + var institution_name = $("#input_institution").val();
22 27
23 - $.get(AJAX_URL.create_institution_modal, function(response){ 28 + $.get(AJAX_URL.create_institution_modal, {"community[name]" : institution_name}).done(function(response){
24 $("#institution_dialog").html(response); 29 $("#institution_dialog").html(response);
25 30
26 set_form_count_custom_data(); 31 set_form_count_custom_data();
@@ -32,6 +37,7 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;] @@ -32,6 +37,7 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;]
32 height: 530, 37 height: 530,
33 position: 'center', 38 position: 'center',
34 close: function() { 39 close: function() {
  40 + set_institution_field_name($("#community_name").val());
35 $("#institution_dialog").html(""); 41 $("#institution_dialog").html("");
36 $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); 42 $('#institution_empty_ajax_message').switchClass("show-field", "hide-field");
37 toggle_extra_fields_style_status(false); 43 toggle_extra_fields_style_status(false);
@@ -228,9 +234,22 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;] @@ -228,9 +234,22 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;]
228 toggle_extra_fields_style_status(true); 234 toggle_extra_fields_style_status(true);
229 $("#create_institution_link").click(open_create_institution_modal); 235 $("#create_institution_link").click(open_create_institution_modal);
230 } else { 236 } else {
231 - $('#institution_empty_ajax_message').switchClass("show-field", "hide-field");  
232 - $("#create_institution_link").remove();  
233 - toggle_extra_fields_style_status(false); 237 + $("li.ui-menu-item a.ui-corner-all").click(function() {
  238 + $('#institution_empty_ajax_message').switchClass("show-field", "hide-field");
  239 + $("#create_institution_link").remove();
  240 + toggle_extra_fields_style_status(false);
  241 + });
  242 + $("li.ui-menu-item a.ui-corner-all").keypress(function(e) {
  243 + alert(e);
  244 + var key = e.keyCode;
  245 + alert(key);
  246 + if(key == 13) {
  247 + $("li.ui-menu-item a.ui-corner-all").click();
  248 + }
  249 + });
  250 + //$('#institution_empty_ajax_message').switchClass("show-field", "hide-field");
  251 + //$("#create_institution_link").remove();
  252 + //toggle_extra_fields_style_status(false);
234 } 253 }
235 }, 254 },
236 error: function(ajax, stat, errorThrown) { 255 error: function(ajax, stat, errorThrown) {
@@ -425,5 +444,6 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;] @@ -425,5 +444,6 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;]
425 institution_autocomplete: function(){ 444 institution_autocomplete: function(){
426 institution_autocomplete(); 445 institution_autocomplete();
427 } 446 }
  447 +
428 }; 448 };
429 }); 449 });