Commit 15e383f64a455150474630fbdb48cb2809d2b63b
Committed by
Gabriela Navarro
1 parent
466559b5
Exists in
master
and in
5 other branches
Set a better way to call dependencies on Initializer.js
Showing
7 changed files
with
20 additions
and
36 deletions
Show diff stats
public/initializer.js
... | ... | @@ -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 | 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('CompleteRegistration', ['jquery', 'NoosferoRoot'], function($, |
44 | 44 | |
45 | 45 | |
46 | 46 | return { |
47 | - isCompleteRegistration: function() { | |
47 | + isCurrentPage: function() { | |
48 | 48 | return $("#complete_registration").length === 1; |
49 | 49 | }, |
50 | 50 | ... | ... |
public/views/control-panel.js
public/views/create-institution.js
... | ... | @@ -299,7 +299,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] |
299 | 299 | |
300 | 300 | |
301 | 301 | return { |
302 | - isCreateInstitution: function() { | |
302 | + isCurrentPage: function() { | |
303 | 303 | return $("#institution_form").length === 1; |
304 | 304 | }, |
305 | 305 | ... | ... |
public/views/edit-software.js
... | ... | @@ -65,7 +65,7 @@ modulejs.define('EditSoftware', ['jquery', 'NoosferoRoot', 'AutoComplete', 'NewS |
65 | 65 | |
66 | 66 | |
67 | 67 | return { |
68 | - isEditSoftware: function() { | |
68 | + isCurrentPage: function() { | |
69 | 69 | return $("#especific-info").length === 1; |
70 | 70 | }, |
71 | 71 | ... | ... |
public/views/new-software.js
... | ... | @@ -40,13 +40,13 @@ modulejs.define('NewSoftware', ['jquery', 'NoosferoRoot', 'AutoComplete'], funct |
40 | 40 | |
41 | 41 | |
42 | 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('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoic |
196 | 196 | |
197 | 197 | |
198 | 198 | return { |
199 | - isUserEditProfile: function() { | |
199 | + isCurrentPage: function() { | |
200 | 200 | return $('#profile_data_email').length === 1; |
201 | 201 | }, |
202 | 202 | ... | ... |