Commit da4e538596a42dc0c6d9682eff37cd1060e28029

Authored by Luciano Prestes
Committed by Gabriela Navarro
1 parent 897eb62e
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

Refactor javascript of catalog

Signed-off-by: Hebert Douglas <hebertdougl@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
lib/mpog_software_plugin.rb
... ... @@ -130,7 +130,6 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
130 130 mpog-search.js
131 131 software-catalog.js
132 132 mpog-software-block.js
133   - catalog-filter.js
134 133 )
135 134 end
136 135  
... ...
public/catalog-filter.js
... ... @@ -1,59 +0,0 @@
1   -jQuery(function(){
2   - function show_head_message() {
3   - if (jQuery("#filter-categories-select-catalog").text().blank()){
4   - jQuery("#filter-categories-select-catalog").hide();
5   - jQuery("#filter-option-catalog-software").show();
6   - }else{
7   - jQuery("#filter-categories-select-catalog").show();
8   - jQuery("#filter-option-catalog-software").hide();
9   - }
10   - }
11   -
12   - show_head_message();
13   -
14   - jQuery("#filter-categories-option").hide();
15   - jQuery("#filter-option-catalog-software").click(function(){
16   - jQuery("#filter-categories-option").slideDown();
17   - jQuery("#filter-option-catalog-software").hide();
18   - });
19   -
20   - jQuery("#filter-categories-option").hide();
21   - jQuery("#filter-categories-select-catalog").click(function(){
22   - jQuery("#filter-categories-option").slideDown();
23   - jQuery("#filter-categories-select-catalog").hide();
24   - });
25   -
26   - jQuery("#close-filter-catalog").click(function(){
27   - jQuery("#filter-categories-option").slideUp();
28   - show_head_message();
29   - });
30   -
31   - jQuery("#cleanup-filter-catalg").click(function(){
32   - jQuery("#filter-categories-option").slideUp();
33   - jQuery("#filter-option-catalog-software").show();
34   - jQuery("#group-categories input:checked").each(function() {
35   - jQuery(this).prop('checked', false);
36   - });
37   - });
38   -
39   - jQuery(".categories-catalog").click(function(){
40   - jQuery("#filter-categories-option").slideUp();
41   - jQuery("#filter-categories-select-catalog").show();
42   - jQuery("#filter-option-catalog-software").hide();
43   - });
44   -
45   - jQuery(".project-software").click(function(){
46   - jQuery("#filter-categories-option").slideUp();
47   - jQuery("#filter-categories-select-catalog").show();
48   - jQuery("#filter-option-catalog-software").hide();
49   - });
50   -
51   - function clear_categories_filter(e) {
52   - e.preventDefault();
53   - jQuery("#categories-filter input:checked").each(function() {
54   - jQuery(this).prop('checked', false);
55   - });
56   - }
57   -});
58   -
59   -
public/software-catalog.js
... ... @@ -55,6 +55,51 @@
55 55 jQuery(this).parent().remove();
56 56 }
57 57  
  58 + function show_head_message() {
  59 + if (jQuery("#filter-categories-select-catalog").text().blank()){
  60 + jQuery("#filter-categories-select-catalog").hide();
  61 + jQuery("#filter-option-catalog-software").show();
  62 + }else{
  63 + jQuery("#filter-categories-select-catalog").show();
  64 + jQuery("#filter-option-catalog-software").hide();
  65 + }
  66 + }
  67 +
  68 + function slideDowsCategoriesOptionAndHideOptionCatalog() {
  69 + jQuery("#filter-categories-option").slideDown();
  70 + jQuery("#filter-option-catalog-software").hide();
  71 + }
  72 +
  73 + function slideDownCategoriesOptionAndHideCategoriesSelect() {
  74 + jQuery("#filter-categories-option").slideDown();
  75 + jQuery("#filter-categories-select-catalog").hide();
  76 + }
  77 +
  78 + function slideUpCategoriesAndShowHeadMessage() {
  79 + jQuery("#filter-categories-option").slideUp();
  80 + show_head_message();
  81 + }
  82 +
  83 + function clearCatalogCheckbox(){
  84 + jQuery("#filter-categories-option").slideUp();
  85 + jQuery("#filter-option-catalog-software").show();
  86 + jQuery("#group-categories input:checked").each(function() {
  87 + jQuery(this).prop('checked', false);
  88 + });
  89 + }
  90 +
  91 + function selectCheckboxCategory() {
  92 + jQuery("#filter-categories-option").slideUp();
  93 + jQuery("#filter-categories-select-catalog").show();
  94 + jQuery("#filter-option-catalog-software").hide();
  95 + }
  96 +
  97 + function selectProjectSoftwareCheckbox() {
  98 + jQuery("#filter-categories-option").slideUp();
  99 + jQuery("#filter-categories-select-catalog").show();
  100 + jQuery("#filter-option-catalog-software").hide();
  101 + }
  102 +
58 103 function set_autocomplate() {
59 104 jQuery("#software-catalog").autocomplete({
60 105 source : function(request, response){
... ... @@ -84,10 +129,20 @@
84 129  
85 130 function set_events() {
86 131 jQuery(".catalog-remove-item").click(remote_catalog_item);
  132 + jQuery("#filter-option-catalog-software").click(slideDowsCategoriesOptionAndHideOptionCatalog);
  133 + jQuery("#filter-categories-select-catalog").click(slideDownCategoriesOptionAndHideCategoriesSelect);
  134 + jQuery("#close-filter-catalog").click(slideUpCategoriesAndShowHeadMessage);
  135 + jQuery("#cleanup-filter-catalg").click(clearCatalogCheckbox);
  136 + jQuery(".categories-catalog").click(selectCheckboxCategory);
  137 + jQuery(".project-software").click(selectProjectSoftwareCheckbox);
87 138 }
88 139  
  140 +
89 141 jQuery(document).ready(function(){
90 142 set_autocomplate();
91 143 set_events();
  144 + show_head_message();
  145 + jQuery("#filter-categories-option").hide();
92 146 });
  147 +
93 148 })();
... ...