Commit 15e383f64a455150474630fbdb48cb2809d2b63b

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

Set a better way to call dependencies on Initializer.js

public/initializer.js
@@ -8,39 +8,23 @@ var dependencies = [ @@ -8,39 +8,23 @@ var dependencies = [
8 ]; 8 ];
9 9
10 10
11 -modulejs.define('Initializer', dependencies, function(cp, es, ns, uep, ci, cr) { 11 +modulejs.define('Initializer', dependencies, function() {
12 'use strict'; 12 'use strict';
13 13
  14 + var __dependencies = arguments;
14 15
15 - return {  
16 - init: function() {  
17 - if( cp.isControlPanel() ) {  
18 - cp.init();  
19 - }  
20 -  
21 -  
22 - if( es.isEditSoftware() ) {  
23 - es.init();  
24 - }  
25 -  
26 -  
27 - if( ns.isNewSoftware() ) {  
28 - ns.init();  
29 - }  
30 16
31 -  
32 - if( uep.isUserEditProfile() ) {  
33 - uep.init();  
34 - }  
35 -  
36 -  
37 - if( ci.isCreateInstitution() ) {  
38 - ci.init();  
39 - } 17 + function call_dependency(dependency) {
  18 + if( dependency.isCurrentPage() ) {
  19 + dependency.init();
  20 + }
  21 + }
40 22
41 23
42 - if( cr.isCompleteRegistration() ) {  
43 - cr.init(); 24 + return {
  25 + init: function() {
  26 + for(var i=0, len = __dependencies.length; i < len; i++) {
  27 + call_dependency(__dependencies[i]);
44 } 28 }
45 } 29 }
46 }; 30 };
public/views/complete-registration.js
@@ -44,7 +44,7 @@ modulejs.define(&#39;CompleteRegistration&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;], function($, @@ -44,7 +44,7 @@ modulejs.define(&#39;CompleteRegistration&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;], function($,
44 44
45 45
46 return { 46 return {
47 - isCompleteRegistration: function() { 47 + isCurrentPage: function() {
48 return $("#complete_registration").length === 1; 48 return $("#complete_registration").length === 1;
49 }, 49 },
50 50
public/views/control-panel.js
@@ -42,7 +42,7 @@ modulejs.define(&#39;ControlPanel&#39;, [&#39;jquery&#39;], function($) { @@ -42,7 +42,7 @@ modulejs.define(&#39;ControlPanel&#39;, [&#39;jquery&#39;], function($) {
42 42
43 43
44 return { 44 return {
45 - isControlPanel: function() { 45 + isCurrentPage: function() {
46 return $("#profile-editor-index").length === 1; 46 return $("#profile-editor-index").length === 1;
47 }, 47 },
48 48
public/views/create-institution.js
@@ -299,7 +299,7 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;] @@ -299,7 +299,7 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;]
299 299
300 300
301 return { 301 return {
302 - isCreateInstitution: function() { 302 + isCurrentPage: function() {
303 return $("#institution_form").length === 1; 303 return $("#institution_form").length === 1;
304 }, 304 },
305 305
public/views/edit-software.js
@@ -65,7 +65,7 @@ modulejs.define(&#39;EditSoftware&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;AutoComplete&#39;, &#39;NewS @@ -65,7 +65,7 @@ modulejs.define(&#39;EditSoftware&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;AutoComplete&#39;, &#39;NewS
65 65
66 66
67 return { 67 return {
68 - isEditSoftware: function() { 68 + isCurrentPage: function() {
69 return $("#especific-info").length === 1; 69 return $("#especific-info").length === 1;
70 }, 70 },
71 71
public/views/new-software.js
@@ -40,13 +40,13 @@ modulejs.define(&#39;NewSoftware&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;AutoComplete&#39;], funct @@ -40,13 +40,13 @@ modulejs.define(&#39;NewSoftware&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;AutoComplete&#39;], funct
40 40
41 41
42 return { 42 return {
43 - init: function() {  
44 - license_info_autocomplete(); 43 + isCurrentPage: function() {
  44 + return $('#new-software-page').length === 1;
45 }, 45 },
46 46
47 47
48 - isNewSoftware: function() {  
49 - return $('#new-software-page').length === 1; 48 + init: function() {
  49 + license_info_autocomplete();
50 } 50 }
51 } 51 }
52 }); 52 });
public/views/user-edit-profile.js
@@ -196,7 +196,7 @@ modulejs.define(&#39;UserEditProfile&#39;, [&#39;jquery&#39;, &#39;SelectElement&#39;, &#39;SelectFieldChoic @@ -196,7 +196,7 @@ modulejs.define(&#39;UserEditProfile&#39;, [&#39;jquery&#39;, &#39;SelectElement&#39;, &#39;SelectFieldChoic
196 196
197 197
198 return { 198 return {
199 - isUserEditProfile: function() { 199 + isCurrentPage: function() {
200 return $('#profile_data_email').length === 1; 200 return $('#profile_data_email').length === 1;
201 }, 201 },
202 202