/
Nickel.js
142 lines (96 loc) · 2.69 KB
/
Nickel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
Nickel.js
~ Nickel configuration file
Part of Nickel.js
@authors
John Chavarria <m@psi.sh>
@version 1.0
@license LGPL v3.0 (http://www.gnu.org/licenses/lgpl.html)
@copyright (c) 2010-2013, Authors.
*/
// Edit this configuration to import or configure Nickel assets.
this.Nickelconfig = {
// Debug level: 3 all | 2 errors and warnings | 1 errors | 0 no debug.
debug: 3,
// Nickel Framework directory.
directory: '../',
// List of the assets that will be used.
implement: [
'template' // NickelTemplate will be imported.
],
// Assets specific configuration.
assets: {
// NickelTemplate configuration.
template: {
directory: './tpl/', // Templates directory location.
extension: 'tpl.html' // Templates extension format.
}
}
};
// Do not modify anything after this.
/*
NickelBase
~ Main file of Nickel Framework for Pokki
Part of Nickel.js
@authors
John Chavarria <m@psi.sh>
@version 1.0
@license LGPL v3.0 (http://www.gnu.org/licenses/lgpl.html)
@copyright (c) 2010-2013, Authors.
*/
(function() {
window.addEventListener('load', function() {
// Loading Nickel Framework.
Nickel.load(Nickelconfig);
delete this.Nickelconfig;
}, true);
this.Nickel = {
// Basic Nickel Framework Configuration.
configuration: {
implement: new Array()
},
load: function load(config)
{
for (var key in config) {
this.configuration[key] = config[key];
}
this.configuration.implement.push('extend');
this.implement(this.configuration.implement);
},
implement: function implement(files)
{
if (typeof files == 'object') {
for (var i = 0; i < files.length; i++) {
this.implement(files[i])
}
} else {
files = files.charAt(0).toUpperCase() +
files.substring(1, files.length).toLowerCase();
var src = this.configuration.directory + 'Nickel' + files +
'/Nickel' + files + '.js';
var script = document.createElement('script');
script.setAttribute('src', src);
document.head.appendChild(script);
}
},
error: function error(asset, type, specific)
{
if (this.configuration.debug > 0) {
specific = specific || false;
if (specific) {
switch(type) {
case 'configuration':
var code = '000';
var error =
'Missing asset configuration in Nickel.js';
break;
}
var err = asset + ': Error ' + code + ' - ' + error;
} else {
var err = asset + ': Error - ' + type;
}
console.error(err);
}
},
};
})();