Commit c764e380ea6f43962ea643aab33bb1f94d6c43da

Authored by Fabio Teixeira
Committed by Luciano Prestes
1 parent 6ee955f9
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Put catalog component behavior into a lib file

lib/software_communities_plugin.rb
... ... @@ -119,6 +119,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin
119 119 lib/select-element.js
120 120 lib/select-field-choices
121 121 lib/auto-complete.js
  122 + lib/software-catalog-component.js
122 123 views/control-panel.js
123 124 views/edit-software.js
124 125 views/new-software.js
... ...
public/initializer.js
... ... @@ -10,7 +10,7 @@
10 10 'CompleteRegistration',
11 11 'SearchSoftwareCatalog',
12 12 'SoftwareDownload',
13   - "ProfileTabsSoftware"
  13 + 'ProfileTabsSoftware'
14 14 ];
15 15  
16 16  
... ...
public/lib/software-catalog-component.js 0 → 100644
... ... @@ -0,0 +1,83 @@
  1 +modulejs.define('SoftwareCatalogComponent', ['jquery'], function($) {
  2 + 'use strict';
  3 +
  4 + var dispatch_ajax_function;
  5 +
  6 +
  7 + function show_head_message() {
  8 + if ($("#filter-categories-select-catalog").text().length === 0){
  9 + $("#filter-categories-select-catalog").hide();
  10 + $("#filter-option-catalog-software").show();
  11 + }else{
  12 + $("#filter-categories-select-catalog").show();
  13 + $("#filter-option-catalog-software").hide();
  14 + }
  15 + }
  16 +
  17 +
  18 + function slideDowsCategoriesOptionAndHideOptionCatalog() {
  19 + $("#filter-categories-option").slideDown();
  20 + $("#filter-option-catalog-software").hide();
  21 + }
  22 +
  23 +
  24 + function slideDownCategoriesOptionAndHideCategoriesSelect() {
  25 + $("#filter-categories-option").slideDown();
  26 + $("#filter-categories-select-catalog").hide();
  27 + }
  28 +
  29 +
  30 + function slideUpCategoriesAndShowHeadMessage() {
  31 + $("#filter-categories-option").slideUp();
  32 + show_head_message();
  33 + }
  34 +
  35 +
  36 + function clearCatalogCheckbox() {
  37 + $("#filter-categories-option").slideUp();
  38 + $("#filter-option-catalog-software").show();
  39 + $("#group-categories input:checked").each(function() {
  40 + $(this).prop('checked', false);
  41 + });
  42 +
  43 + dispatch_ajax_function(true);
  44 + }
  45 +
  46 +
  47 + function selectCheckboxCategory(dispatch_ajax) {
  48 + $("#filter-categories-option").slideUp();
  49 + $("#filter-categories-select-catalog").show();
  50 + $("#filter-option-catalog-software").hide();
  51 +
  52 + dispatch_ajax_function(true);
  53 + }
  54 +
  55 +
  56 + function selectProjectSoftwareCheckbox() {
  57 + $("#filter-categories-option").slideUp();
  58 + $("#filter-categories-select-catalog").show();
  59 + $("#filter-option-catalog-software").hide();
  60 +
  61 + dispatch_ajax_function(true);
  62 + show_head_message();
  63 + }
  64 +
  65 +
  66 + function set_events() {
  67 + $("#filter-option-catalog-software").click(slideDowsCategoriesOptionAndHideOptionCatalog);
  68 + $("#filter-categories-select-catalog").click(slideDownCategoriesOptionAndHideCategoriesSelect);
  69 + $("#close-filter-catalog").click(slideUpCategoriesAndShowHeadMessage);
  70 + $("#cleanup-filter-catalg").click(clearCatalogCheckbox);
  71 + $(".categories-catalog").click(selectCheckboxCategory);
  72 + $(".project-software").click(selectProjectSoftwareCheckbox);
  73 + }
  74 +
  75 +
  76 + return {
  77 + init: function(dispatch_ajax) {
  78 + dispatch_ajax_function = dispatch_ajax;
  79 + set_events();
  80 + show_head_message();
  81 + },
  82 + }
  83 +});
... ...
public/views/search-software-catalog.js
1   -modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot'], function($, NoosferoRoot) {
  1 +modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot', 'SoftwareCatalogComponent'], function($, NoosferoRoot, SoftwareCatalogComponent) {
2 2 'use strict';
3 3  
4 4 var AJAX_URL = {
... ... @@ -7,56 +7,7 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot'], function($,
7 7 };
8 8  
9 9  
10   - function show_head_message() {
11   - if ($("#filter-categories-select-catalog").text().length === 0){
12   - $("#filter-categories-select-catalog").hide();
13   - $("#filter-option-catalog-software").show();
14   - }else{
15   - $("#filter-categories-select-catalog").show();
16   - $("#filter-option-catalog-software").hide();
17   - }
18   - }
19   -
20   -
21   - function slideDowsCategoriesOptionAndHideOptionCatalog() {
22   - $("#filter-categories-option").slideDown();
23   - $("#filter-option-catalog-software").hide();
24   - }
25   -
26   -
27   - function slideDownCategoriesOptionAndHideCategoriesSelect() {
28   - $("#filter-categories-option").slideDown();
29   - $("#filter-categories-select-catalog").hide();
30   - }
31   -
32   -
33   - function slideUpCategoriesAndShowHeadMessage() {
34   - $("#filter-categories-option").slideUp();
35   - show_head_message();
36   - }
37   -
38   -
39   - function clearCatalogCheckbox(){
40   - $("#filter-categories-option").slideUp();
41   - $("#filter-option-catalog-software").show();
42   - $("#group-categories input:checked").each(function() {
43   - $(this).prop('checked', false);
44   - });
45   -
46   - dispatch_search_ajax(update_search_page_on_ajax, true);
47   - }
48   -
49   -
50   - function selectCheckboxCategory() {
51   - $("#filter-categories-option").slideUp();
52   - $("#filter-categories-select-catalog").show();
53   - $("#filter-option-catalog-software").hide();
54   -
55   - dispatch_search_ajax(update_search_page_on_ajax, true);
56   - }
57   -
58   -
59   - function dispatch_search_ajax(callback, enable_load) {
  10 + function dispatch_search_ajax(enable_load) {
60 11 var search_params = get_search_params();
61 12  
62 13 if(enable_load) {
... ... @@ -67,7 +18,7 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot'], function($,
67 18 url: AJAX_URL.software_infos,
68 19 type: "GET",
69 20 data: search_params,
70   - success: callback,
  21 + success: update_search_page_on_ajax,
71 22 error: function(){
72 23 close_loading();
73 24 }
... ... @@ -130,7 +81,6 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot'], function($,
130 81 selected_categories_field.html(result_categories);
131 82 pagination.html(result_pagination);
132 83 software_count.html(result_software_count);
133   - show_head_message();
134 84 highlight_searched_terms();
135 85 catalog_message();
136 86  
... ... @@ -141,7 +91,7 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot'], function($,
141 91 function hide_load_after_ajax() {
142 92 if ($("#overlay_loading_modal").is(":visible")) {
143 93 close_loading();
144   - setTimeout(hide_load_after_ajax, 2000);
  94 + setTimeout(hide_load_after_ajax, 1500);
145 95 }
146 96 }
147 97  
... ... @@ -168,16 +118,6 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot'], function($,
168 118 }
169 119  
170 120  
171   - function selectProjectSoftwareCheckbox() {
172   - $("#filter-categories-option").slideUp();
173   - $("#filter-categories-select-catalog").show();
174   - $("#filter-option-catalog-software").hide();
175   -
176   - dispatch_search_ajax(update_search_page_on_ajax, true);
177   - show_head_message();
178   - }
179   -
180   -
181 121 function update_page_by_ajax_on_select_change() {
182 122 dispatch_search_ajax(update_search_page_on_ajax, true);
183 123 }
... ... @@ -200,12 +140,6 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot'], function($,
200 140  
201 141  
202 142 function set_events() {
203   - $("#filter-option-catalog-software").click(slideDowsCategoriesOptionAndHideOptionCatalog);
204   - $("#filter-categories-select-catalog").click(slideDownCategoriesOptionAndHideCategoriesSelect);
205   - $("#close-filter-catalog").click(slideUpCategoriesAndShowHeadMessage);
206   - $("#cleanup-filter-catalg").click(clearCatalogCheckbox);
207   - $(".categories-catalog").click(selectCheckboxCategory);
208   - $(".project-software").click(selectProjectSoftwareCheckbox);
209 143 $("#software_display").change(update_page_by_ajax_on_select_change);
210 144 $("#sort").change(update_page_by_ajax_on_select_change);
211 145  
... ... @@ -222,9 +156,10 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot'], function($,
222 156 init: function() {
223 157 set_events();
224 158 catalog_message();
225   - show_head_message();
226 159  
227 160 $("#filter-categories-option").hide();
  161 +
  162 + SoftwareCatalogComponent.init(dispatch_search_ajax);
228 163 }
229 164 }
230 165 });
231 166 \ No newline at end of file
... ...