Commit 15e383f64a455150474630fbdb48cb2809d2b63b

Authored by Fabio Teixeira
Committed by Gabriela Navarro
1 parent 466559b5

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