Skip to content

Commit 7e1afec

Browse files
committed
IFFE Pattern and no var app
Reference for IFFE Pattern: http://angularjs.learnwebtutorials.com/javascript-iffe-angularjs.html No var app = angular.module, this is not necessary
1 parent 6f99520 commit 7e1afec

82 files changed

Lines changed: 5362 additions & 4938 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/app/js/app.js

Lines changed: 166 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,179 @@
1-
'use strict';
2-
/**
3-
* @ngdoc overview
4-
* @name loopbackApp
5-
* @description
6-
* # loopbackApp
7-
*
8-
* Main module of the application.
9-
*/
10-
var app = angular.module('loopbackApp', [
11-
'angular-loading-bar',
12-
'angular.filter',
13-
'angularBootstrapNavTree',
14-
'angularFileUpload',
15-
'btford.markdown',
16-
'oitozero.ngSweetAlert',
17-
'config',
18-
'formly',
19-
'formlyBootstrap',
20-
'lbServices',
21-
'monospaced.elastic',
22-
'ngAnimate',
23-
'ngCookies',
24-
'ngResource',
25-
'ngRoute',
26-
'ngSanitize',
27-
'ngTouch',
28-
'ui.bootstrap',
29-
'ui.codemirror',
30-
'ui.gravatar',
31-
'ui.grid',
32-
'ui.router',
33-
'toasty',
34-
'autofields',
35-
'gettext',
36-
'angular-underscore/filters',
37-
'schemaForm',
38-
'ui.select',
39-
'com.module.core',
40-
'com.module.about',
41-
'com.module.browser',
42-
'com.module.events',
43-
'com.module.files',
44-
'com.module.notes',
45-
'com.module.pages',
46-
'com.module.posts',
47-
'com.module.products',
48-
'com.module.sandbox',
49-
'com.module.settings',
50-
'com.module.users'
51-
]);
1+
(function () {
2+
'use strict';
3+
/**
4+
* @ngdoc overview
5+
* @name loopbackApp
6+
* @description
7+
* # loopbackApp
8+
*
9+
* Main module of the application.
10+
*/
11+
angular
12+
.module('loopbackApp', [
13+
'angular-loading-bar',
14+
'angular.filter',
15+
'angularBootstrapNavTree',
16+
'angularFileUpload',
17+
'btford.markdown',
18+
'oitozero.ngSweetAlert',
19+
'config',
20+
'formly',
21+
'formlyBootstrap',
22+
'lbServices',
23+
'monospaced.elastic',
24+
'ngAnimate',
25+
'ngCookies',
26+
'ngResource',
27+
'ngRoute',
28+
'ngSanitize',
29+
'ngTouch',
30+
'ui.bootstrap',
31+
'ui.codemirror',
32+
'ui.gravatar',
33+
'ui.grid',
34+
'ui.router',
35+
'toasty',
36+
'autofields',
37+
'gettext',
38+
'angular-underscore/filters',
39+
'schemaForm',
40+
'ui.select',
41+
'com.module.core',
42+
'com.module.about',
43+
'com.module.browser',
44+
'com.module.events',
45+
'com.module.files',
46+
'com.module.notes',
47+
'com.module.pages',
48+
'com.module.posts',
49+
'com.module.products',
50+
'com.module.sandbox',
51+
'com.module.settings',
52+
'com.module.users'
53+
])
54+
.run(function ($rootScope, $cookies, gettextCatalog) {
5255

53-
app.run(function ($rootScope, $cookies, gettextCatalog) {
56+
$rootScope.locales = {
57+
'de' : {
58+
lang : 'de',
59+
country: 'DE',
60+
name : gettextCatalog.getString('German')
61+
},
62+
'en' : {
63+
lang : 'en',
64+
country: 'US',
65+
name : gettextCatalog.getString('English')
66+
},
67+
'es_MX': {
68+
lang : 'es_MX',
69+
country: 'MX',
70+
name : gettextCatalog.getString('Spanish')
71+
},
72+
'fr' : {
73+
lang : 'fr',
74+
country: 'FR',
75+
name : gettextCatalog.getString('Français')
76+
},
77+
'nl' : {
78+
lang : 'nl',
79+
country: 'NL',
80+
name : gettextCatalog.getString('Dutch')
81+
},
82+
'pt-BR': {
83+
lang : 'pt_BR',
84+
country: 'BR',
85+
name : gettextCatalog.getString('Portuguese Brazil')
86+
},
87+
'ru_RU': {
88+
lang : 'ru_RU',
89+
country: 'RU',
90+
name : gettextCatalog.getString('Russian')
91+
}
92+
};
5493

55-
$rootScope.locales = {
56-
'de': {
57-
lang: 'de',
58-
country: 'DE',
59-
name: gettextCatalog.getString('German')
60-
},
61-
'en': {
62-
lang: 'en',
63-
country: 'US',
64-
name: gettextCatalog.getString('English')
65-
},
66-
'es_MX': {
67-
lang: 'es_MX',
68-
country: 'MX',
69-
name: gettextCatalog.getString('Spanish')
70-
},
71-
'fr': {
72-
lang: 'fr',
73-
country: 'FR',
74-
name: gettextCatalog.getString('Français')
75-
},
76-
'nl': {
77-
lang: 'nl',
78-
country: 'NL',
79-
name: gettextCatalog.getString('Dutch')
80-
},
81-
'pt-BR': {
82-
lang: 'pt_BR',
83-
country: 'BR',
84-
name: gettextCatalog.getString('Portuguese Brazil')
85-
},
86-
'ru_RU': {
87-
lang: 'ru_RU',
88-
country: 'RU',
89-
name: gettextCatalog.getString('Russian')
90-
}
91-
};
94+
var lang = $cookies.lang || navigator.language || navigator.userLanguage;
9295

93-
var lang = $cookies.lang || navigator.language || navigator.userLanguage;
96+
$rootScope.locale = $rootScope.locales[lang];
9497

95-
$rootScope.locale = $rootScope.locales[lang];
98+
if ($rootScope.locale === undefined) {
99+
$rootScope.locale = $rootScope.locales[lang];
100+
if ($rootScope.locale === undefined) {
101+
$rootScope.locale = $rootScope.locales['en'];
102+
}
103+
}
96104

97-
if ($rootScope.locale === undefined) {
98-
$rootScope.locale = $rootScope.locales[lang];
99-
if ($rootScope.locale === undefined) {
100-
$rootScope.locale = $rootScope.locales['en'];
101-
}
102-
}
105+
gettextCatalog.setCurrentLanguage($rootScope.locale.lang);
103106

104-
gettextCatalog.setCurrentLanguage($rootScope.locale.lang);
107+
})
108+
.run(function (formlyConfig) {
109+
/*
110+
ngModelAttrs stuff
111+
*/
112+
var ngModelAttrs = {};
105113

106-
});
114+
function camelize(string) {
115+
string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
116+
return chr ? chr.toUpperCase() : '';
117+
});
118+
// Ensure 1st char is always lowercase
119+
return string.replace(/^([A-Z])/, function (match, chr) {
120+
return chr ? chr.toLowerCase() : '';
121+
});
122+
}
107123

108-
app.run(function (formlyConfig) {
109-
/*
110-
ngModelAttrs stuff
111-
*/
112-
var ngModelAttrs = {};
124+
/*
125+
timepicker
126+
*/
127+
ngModelAttrs = {};
113128

114-
function camelize (string) {
115-
string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
116-
return chr ? chr.toUpperCase() : '';
117-
});
118-
// Ensure 1st char is always lowercase
119-
return string.replace(/^([A-Z])/, function (match, chr) {
120-
return chr ? chr.toLowerCase() : '';
121-
});
122-
}
129+
// attributes
130+
angular.forEach([
131+
'meridians',
132+
'readonly-input',
133+
'mousewheel',
134+
'arrowkeys'
135+
], function (attr) {
136+
ngModelAttrs[camelize(attr)] = {attribute: attr};
137+
});
123138

124-
/*
125-
timepicker
126-
*/
127-
ngModelAttrs = {};
128-
129-
// attributes
130-
angular.forEach([
131-
'meridians',
132-
'readonly-input',
133-
'mousewheel',
134-
'arrowkeys'
135-
], function (attr) {
136-
ngModelAttrs[camelize(attr)] = {attribute: attr};
137-
});
139+
// bindings
140+
angular.forEach([
141+
'hour-step',
142+
'minute-step',
143+
'show-meridian'
144+
], function (binding) {
145+
ngModelAttrs[camelize(binding)] = {bound: binding};
146+
});
138147

139-
// bindings
140-
angular.forEach([
141-
'hour-step',
142-
'minute-step',
143-
'show-meridian'
144-
], function (binding) {
145-
ngModelAttrs[camelize(binding)] = {bound: binding};
146-
});
148+
formlyConfig.setType({
149+
name : 'timepicker',
150+
template : '<timepicker ng-model="model[options.key]"></timepicker>',
151+
wrapper : [
152+
'bootstrapLabel',
153+
'bootstrapHasError'
154+
],
155+
defaultOptions: {
156+
ngModelAttrs : ngModelAttrs,
157+
templateOptions: {
158+
timepickerOptions: {}
159+
}
160+
}
161+
});
147162

148-
formlyConfig.setType({
149-
name: 'timepicker',
150-
template: '<timepicker ng-model="model[options.key]"></timepicker>',
151-
wrapper: ['bootstrapLabel', 'bootstrapHasError'],
152-
defaultOptions: {
153-
ngModelAttrs: ngModelAttrs,
154-
templateOptions: {
155-
timepickerOptions: {}
156-
}
157-
}
158-
});
163+
formlyConfig.setType({
164+
name : 'datepicker',
165+
template : '<datepicker ng-model="model[options.key]" ></datepicker>',
166+
wrapper : [
167+
'bootstrapLabel',
168+
'bootstrapHasError'
169+
],
170+
defaultOptions: {
171+
ngModelAttrs : ngModelAttrs,
172+
templateOptions: {
173+
datepickerOptions: {}
174+
}
175+
}
176+
});
177+
});
159178

160-
formlyConfig.setType({
161-
name: 'datepicker',
162-
template: '<datepicker ng-model="model[options.key]" ></datepicker>',
163-
wrapper: ['bootstrapLabel', 'bootstrapHasError'],
164-
defaultOptions: {
165-
ngModelAttrs: ngModelAttrs,
166-
templateOptions: {
167-
datepickerOptions: {}
168-
}
169-
}
170-
});
171-
});
179+
})();
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
'use strict';
2-
/**
3-
* @ngdoc overview
4-
* @name com.module.about
5-
* @module
6-
* @description
7-
* @requires loopbackApp
8-
*
9-
* The `com.module.core` module provides services for interacting with
10-
* the models exposed by the LoopBack server via the REST API.
11-
*
12-
*/
13-
angular.module('com.module.about', []);
1+
(function () {
2+
'use strict';
3+
/**
4+
* @ngdoc overview
5+
* @name com.module.about
6+
* @module
7+
* @description
8+
* @requires loopbackApp
9+
*
10+
* The `com.module.core` module provides services for interacting with
11+
* the models exposed by the LoopBack server via the REST API.
12+
*
13+
*/
14+
angular.module('com.module.about', []);
15+
16+
})();
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
'use strict';
2-
angular.module('com.module.about')
3-
.run(function($rootScope, gettextCatalog) {
4-
5-
$rootScope.addDashboardBox(gettextCatalog.getString('About'), 'bg-maroon',
6-
'ion-information', 0, 'app.about.index');
7-
8-
});
1+
(function () {
2+
'use strict';
3+
angular
4+
.module('com.module.about')
5+
.run(function ($rootScope, gettextCatalog) {
6+
$rootScope.addDashboardBox(gettextCatalog.getString('About'), 'bg-maroon',
7+
'ion-information', 0, 'app.about.index');
8+
});
9+
})();

0 commit comments

Comments
 (0)