Commit 466559b59a96f1e4c6ef54091fbcf05bc475ff2d

Authored by Fabio Teixeira
Committed by Gabriela Navarro
1 parent 2e14336d
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

Execute complete_registration javascript only when needed

lib/software_communities_plugin.rb
... ... @@ -132,9 +132,9 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin
132 132 views/new-software.js
133 133 views/user-edit-profile.js
134 134 views/create-institution.js
  135 + views/complete-registration.js
135 136 initializer.js
136 137 app.js
137   - mpog-incomplete-registration.js
138 138 mpog-search.js
139 139 software-catalog.js
140 140 mpog-software-block.js
... ...
public/initializer.js
... ... @@ -3,11 +3,12 @@ var dependencies = [
3 3 'EditSoftware',
4 4 'NewSoftware',
5 5 'UserEditProfile',
6   - 'CreateInstitution'
  6 + 'CreateInstitution',
  7 + 'CompleteRegistration'
7 8 ];
8 9  
9 10  
10   -modulejs.define('Initializer', dependencies, function(cp, es, ns, uep, ci) {
  11 +modulejs.define('Initializer', dependencies, function(cp, es, ns, uep, ci, cr) {
11 12 'use strict';
12 13  
13 14  
... ... @@ -36,6 +37,11 @@ modulejs.define('Initializer', dependencies, function(cp, es, ns, uep, ci) {
36 37 if( ci.isCreateInstitution() ) {
37 38 ci.init();
38 39 }
  40 +
  41 +
  42 + if( cr.isCompleteRegistration() ) {
  43 + cr.init();
  44 + }
39 45 }
40 46 };
41 47 });
... ...
public/mpog-incomplete-registration.js
... ... @@ -1,38 +0,0 @@
1   -(function() {
2   - var AJAX_URL = {
3   - hide_registration_incomplete_percentage:
4   - url_with_subdirectory("/plugin/software_communities/hide_registration_incomplete_percentage")
5   - };
6   -
7   -
8   - function hide_incomplete_percentage(evt) {
9   - evt.preventDefault();
10   -
11   - jQuery.get(AJAX_URL.hide_registration_incomplete_percentage, {hide:true}, function(response){
12   - if( response == true )
13   - jQuery("#complete_registration").fadeOut();
14   - });
15   - }
16   -
17   - function show_complete_progressbar() {
18   - var percentage = jQuery("#complete_registration_message span").html();
19   - var canvas_tag = document.getElementById("complete_registration_percentage");
20   -
21   - if( canvas_tag != null ) {
22   - var context = canvas_tag.getContext("2d");
23   -
24   - percentage = canvas_tag.width*(percentage/100.0);
25   -
26   - context.beginPath();
27   - context.rect(0, 0, percentage, canvas_tag.height);
28   - context.fillStyle = '#00FF00';
29   - context.fill();
30   - }
31   - }
32   -
33   - jQuery(document).ready(function(){
34   - jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage);
35   -
36   - show_complete_progressbar();
37   - });
38   -})();
39 0 \ No newline at end of file
public/views/complete-registration.js 0 → 100644
... ... @@ -0,0 +1,60 @@
  1 +modulejs.define('CompleteRegistration', ['jquery', 'NoosferoRoot'], function($, NoosferoRoot) {
  2 + 'use strict';
  3 +
  4 +
  5 + var AJAX_URL = {
  6 + hide_registration_incomplete_percentage:
  7 + NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/hide_registration_incomplete_percentage")
  8 + };
  9 +
  10 +
  11 + function hide_incomplete_percentage(evt) {
  12 + evt.preventDefault();
  13 +
  14 + jQuery.get(AJAX_URL.hide_registration_incomplete_percentage, {hide:true}, function(response){
  15 + if( response === true ) {
  16 + jQuery("#complete_registration").fadeOut();
  17 + }
  18 + });
  19 + }
  20 +
  21 +
  22 + function show_complete_progressbar() {
  23 + var percentage = jQuery("#complete_registration_message span").html();
  24 + var canvas_tag = document.getElementById("complete_registration_percentage");
  25 +
  26 + if( canvas_tag !== null ) {
  27 + var context = canvas_tag.getContext("2d");
  28 +
  29 + percentage = canvas_tag.width*(percentage/100.0);
  30 +
  31 + context.beginPath();
  32 + context.rect(0, 0, percentage, canvas_tag.height);
  33 + context.fillStyle = '#00FF00';
  34 + context.fill();
  35 + }
  36 + }
  37 +
  38 +
  39 + function repositioning_bar_percentage() {
  40 + var complete_message = $("#complete_registration").remove();
  41 +
  42 + $(".profile-info-options").before(complete_message);
  43 + }
  44 +
  45 +
  46 + return {
  47 + isCompleteRegistration: function() {
  48 + return $("#complete_registration").length === 1;
  49 + },
  50 +
  51 +
  52 + init: function() {
  53 + repositioning_bar_percentage();
  54 +
  55 + jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage);
  56 +
  57 + show_complete_progressbar();
  58 + }
  59 + }
  60 +});
0 61 \ No newline at end of file
... ...
views/incomplete_registration.html.erb
... ... @@ -9,15 +9,3 @@
9 9 </div>
10 10 </div>
11 11 </div>
12   -
13   -<script type="text/javascript">
14   - (function($){
15   - 'use strict';
16   -
17   - $(document).ready(function(){
18   - var complete_message = $("#complete_registration").remove();
19   -
20   - $(".profile-info-options").before(complete_message);
21   - });
22   - })(jQuery);
23   -</script>
24 12 \ No newline at end of file
... ...