Skip to content

Commit 0784491

Browse files
committed
Get rid of global functions
1 parent 27cfbdb commit 0784491

7 files changed

Lines changed: 148 additions & 149 deletions

File tree

src/_common/animations/animations.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/***********************************************
22
* Animation Settings
33
***********************************************/
4-
54
function animate(options) {
65
var animationName = "animated " + options.name;
76
var animationEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend";
@@ -12,4 +11,4 @@ function animate(options) {
1211
$(this).removeClass(animationName);
1312
}
1413
);
15-
}
14+
}

src/_common/form/form.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/app/dashboard/history/history.js

Lines changed: 117 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -22,122 +22,124 @@ $(function() {
2222
switchHistoryCharts(item);
2323
});
2424

25-
});
26-
27-
function switchHistoryCharts(item){
28-
var chartSelector = "#dashboard-" + item + "-chart";
25+
function switchHistoryCharts(item){
26+
var chartSelector = "#dashboard-" + item + "-chart";
27+
28+
if ($(chartSelector).has('svg').length) {
29+
$(chartSelector).empty();
30+
}
31+
32+
switch(item){
33+
case 'visits':
34+
drawVisitsChart();
35+
break;
36+
case 'downloads':
37+
drawDownloadsChart();
38+
break;
39+
}
40+
}
2941

30-
if ($(chartSelector).has('svg').length) {
31-
$(chartSelector).empty();
42+
function drawVisitsChart(){
43+
var dataVisits = [
44+
{ x: '2015-09-01', y: 70},
45+
{ x: '2015-09-02', y: 75 },
46+
{ x: '2015-09-03', y: 50},
47+
{ x: '2015-09-04', y: 75 },
48+
{ x: '2015-09-05', y: 50 },
49+
{ x: '2015-09-06', y: 75 },
50+
{ x: '2015-09-07', y: 86 }
51+
];
52+
53+
54+
Morris.Line({
55+
element: 'dashboard-visits-chart',
56+
data: dataVisits,
57+
xkey: 'x',
58+
ykeys: ['y'],
59+
ymin: 'auto 40',
60+
labels: ['Visits'],
61+
xLabels: "day",
62+
hideHover: 'auto',
63+
yLabelFormat: function (y) {
64+
// Only integers
65+
if (y === parseInt(y, 10)) {
66+
return y;
67+
}
68+
else {
69+
return '';
70+
}
71+
},
72+
resize: true,
73+
lineColors: [
74+
config.chart.colorSecondary.toString(),
75+
],
76+
pointFillColors: [
77+
config.chart.colorPrimary.toString(),
78+
]
79+
});
3280
}
3381

34-
switch(item){
35-
case 'visits':
36-
drawVisitsChart();
37-
break;
38-
case 'downloads':
39-
drawDownloadsChart();
40-
break;
82+
function drawDownloadsChart(){
83+
84+
var dataDownloads = [
85+
{
86+
year: '2006',
87+
downloads: 1300
88+
},
89+
{
90+
year: '2007',
91+
downloads: 1526
92+
},
93+
{
94+
year: '2008',
95+
downloads: 2000
96+
},
97+
{
98+
year: '2009',
99+
downloads: 1800
100+
},
101+
{
102+
year: '2010',
103+
downloads: 1650
104+
},
105+
{
106+
year: '2011',
107+
downloads: 620
108+
},
109+
{
110+
year: '2012',
111+
downloads: 1000
112+
},
113+
{
114+
year: '2013',
115+
downloads: 1896
116+
},
117+
{
118+
year: '2014',
119+
downloads: 850
120+
},
121+
{
122+
year: '2015',
123+
downloads: 1500
124+
}
125+
];
126+
127+
128+
Morris.Bar({
129+
element: 'dashboard-downloads-chart',
130+
data: dataDownloads,
131+
xkey: 'year',
132+
ykeys: ['downloads'],
133+
labels: ['Downloads'],
134+
hideHover: 'auto',
135+
resize: true,
136+
barColors: [
137+
config.chart.colorPrimary.toString(),
138+
tinycolor(config.chart.colorPrimary.toString()).darken(10).toString()
139+
],
140+
});
41141
}
42-
}
43-
44-
function drawVisitsChart(){
45-
var dataVisits = [
46-
{ x: '2015-09-01', y: 70},
47-
{ x: '2015-09-02', y: 75 },
48-
{ x: '2015-09-03', y: 50},
49-
{ x: '2015-09-04', y: 75 },
50-
{ x: '2015-09-05', y: 50 },
51-
{ x: '2015-09-06', y: 75 },
52-
{ x: '2015-09-07', y: 86 }
53-
];
54-
55-
56-
Morris.Line({
57-
element: 'dashboard-visits-chart',
58-
data: dataVisits,
59-
xkey: 'x',
60-
ykeys: ['y'],
61-
ymin: 'auto 40',
62-
labels: ['Visits'],
63-
xLabels: "day",
64-
hideHover: 'auto',
65-
yLabelFormat: function (y) {
66-
// Only integers
67-
if (y === parseInt(y, 10)) {
68-
return y;
69-
}
70-
else {
71-
return '';
72-
}
73-
},
74-
resize: true,
75-
lineColors: [
76-
config.chart.colorSecondary.toString(),
77-
],
78-
pointFillColors: [
79-
config.chart.colorPrimary.toString(),
80-
]
81-
});
82-
}
83-
84-
function drawDownloadsChart(){
85-
86-
var dataDownloads = [
87-
{
88-
year: '2006',
89-
downloads: 1300
90-
},
91-
{
92-
year: '2007',
93-
downloads: 1526
94-
},
95-
{
96-
year: '2008',
97-
downloads: 2000
98-
},
99-
{
100-
year: '2009',
101-
downloads: 1800
102-
},
103-
{
104-
year: '2010',
105-
downloads: 1650
106-
},
107-
{
108-
year: '2011',
109-
downloads: 620
110-
},
111-
{
112-
year: '2012',
113-
downloads: 1000
114-
},
115-
{
116-
year: '2013',
117-
downloads: 1896
118-
},
119-
{
120-
year: '2014',
121-
downloads: 850
122-
},
123-
{
124-
year: '2015',
125-
downloads: 1500
126-
}
127-
];
128-
129-
130-
Morris.Bar({
131-
element: 'dashboard-downloads-chart',
132-
data: dataDownloads,
133-
xkey: 'year',
134-
ykeys: ['downloads'],
135-
labels: ['Downloads'],
136-
hideHover: 'auto',
137-
resize: true,
138-
barColors: [
139-
config.chart.colorPrimary.toString(),
140-
tinycolor(config.chart.colorPrimary.toString()).darken(10).toString()
141-
],
142-
});
143-
}
142+
});
143+
144+
145+

src/auth/login/login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $(function() {
2929
}
3030
}
3131

32-
$.extend(loginValidationSettings, validationDefaultSettings);
32+
$.extend(loginValidationSettings, config.validations);
3333

3434
$('#login-form').validate(loginValidationSettings);
3535
})

src/auth/reset/reset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $(function() {
2525
}
2626
}
2727

28-
$.extend(resetValidationSettings, validationDefaultSettings);
28+
$.extend(resetValidationSettings, config.validations);
2929

3030
$('#reset-form').validate(resetValidationSettings);
3131
})

src/auth/signup/signup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ $(function() {
8282
}
8383
}
8484

85-
$.extend(signupValidationSettings, validationDefaultSettings);
85+
$.extend(signupValidationSettings, config.validations);
8686

8787
$('#signup-form').validate(signupValidationSettings);
8888
});

src/config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@ config.ResponsiveBootstrapToolkitVisibilityDivs = {
1414

1515
ResponsiveBootstrapToolkit.use('Custom', config.ResponsiveBootstrapToolkitVisibilityDivs);
1616

17+
//validation configuration
18+
config.validations = {
19+
debug: true,
20+
errorClass:'has-error',
21+
validClass:'success',
22+
errorElement:"span",
23+
24+
// add error class
25+
highlight: function(element, errorClass, validClass) {
26+
$(element).parents("div.form-group")
27+
.addClass(errorClass)
28+
.removeClass(validClass);
29+
},
30+
31+
// add error class
32+
unhighlight: function(element, errorClass, validClass) {
33+
$(element).parents(".has-error")
34+
.removeClass(errorClass)
35+
.addClass(validClass);
36+
},
37+
38+
// submit handler
39+
submitHandler: function(form) {
40+
form.submit();
41+
}
42+
}
43+
1744
//delay time configuration
1845
config.delayTime = 50;
1946

0 commit comments

Comments
 (0)