-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathitsa.build.js
216 lines (190 loc) · 6.24 KB
/
itsa.build.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/**
* The ITSA module is an aggregator for all the individual modules that the library uses.
* The developer is free to use it as it is or tailor it to contain whatever modules
* he/she might need in the global namespace.
*
* The modules themselves work quite well independent of this module and can be used
* separately without the need of them being integrated under one globa namespace.
*
*
* <i>Copyright (c) 2014 ITSA - https://github.com/itsa</i>
* New BSD License - http://choosealicense.com/licenses/bsd-3-clause/
*
* @module itsa.build
*
*/
(function (window) {
"use strict";
/**
* The ITSA class provides the core functionality for the ITSA library
* and is the root namespace for all the additional modules.
*
* The ITSA class cannot be instantiated.
* Instead, the ITSA function takes a configuration object to allow for tailoring of the library.
* The ITSA function returns itself to allow for further chaining.
*
* Calling the ITSA function is optional. If the default configuration is acceptable,
* the ITSA class can be used directly.
*
* The ITSA name is usually used only once in an application, when configuring it
* and when calling the [`ready`](#method_ready) or [`require`](#method_require) methods.
* The callback to these two methods provide a reference to ITSA itself as their argument.
* These methods allow the developer to rename ITSA to a shorter name, usually `P`,
* for use within the local scope.
*
* ITSA( config )
* .require('dialog', 'event', ...)
* .then(function (P) {
* // P is an alias of ITSA
* });
*
* // If the default configuration is acceptable, you can simply do:
* ITSA.require('dialog', 'event', ...)
* .then(function (P) {
* // P is an alias of ITSA
* });
*
* // If extra modules are to be loaded later, you can simply do:
* ITSA( config ).ready
* .then(function (P) {
* // P is an alias of ITSA
* });
*
* // And if no configuration is needed:
* ITSA.ready
* .then(function (P) {
* // P is an alias of ITSA
* });
*
*
*
* @class ITSA
* @static
* @param config {Object} Configuration options for the ITSA Library
* @return self {Object}
*/
require('css');
require('polyfill/polyfill.js'); // want the full version
var jsExt = require('js-ext/js-ext.js'), // want the full version: include it at the top, so that object.merge is available
createHashMap = require('js-ext/extra/hashmap.js').createMap;
window._ITSAmodules || Object.protectedProp(window, '_ITSAmodules', createHashMap());
/*jshint boss:true */
if (window._ITSAmodules.ITSA) {
/*jshint boss:false */
return window._ITSAmodules.ITSA; // ITSA was already created
}
var ITSA = function (config) {
ITSA._config.merge(config, {force: true});
return ITSA;
};
/**
* Global configuration properties for the ITSA object.
* It can only be set on initialization via the [`ITSA`](#docs-main) function.
*
* The config is set at a default-configutation
*
* @property _config
* @type Object
* @private
*/
ITSA._config = {
debug: true,
base: '/components'
};
/**
* Reference to `Classes` in [js-ext/extra/classes.js](../modules/js-ext.html)
*
* @property Classes
* @type Object
* @static
*/
/**
* Reference to the `LightMap`-Class in [js-ext/extra/lightmap.js](../modules/js-ext.html)
*
* @property LightMap
* @type Class
* @static
*/
/**
* Reference to the `createHashMap` function in [js-ext/extra/hashmap.js](../modules/js-ext.html)
*
* @property createHashMap
* @type function
* @static
*/
// Note: we can only merge them after je-ext is required --> ITSA.merge is only then available
ITSA.merge(jsExt);
require('window-ext')(window);
var fakedom = window.navigator.userAgent==='fake',
Event = fakedom ? require('itsa-event') : require('event-mobile')(window),
io_config = {
// timeout: 3000,
debug: true,
base: '/build'
},
dragdrop;
require('vdom')(window);
require('icons')(window);
ITSA.ClientStorage = require('client-storage');
ITSA.DB = require('client-db');
ITSA.localStorage = new ITSA.ClientStorage();
/**
* Reference to the `idGenerator` function in [utils](../modules/utils.html)
*
* @property idGenerator
* @type function
* @static
*/
require('node-plugin')(window);
require('constrain')(window);
require('panel')(window);
ITSA.merge(require('utils'));
ITSA.RESERVED_WORDS = require('js-ext/extra/reserved-words.js');
if (!fakedom) {
require('event-dom/extra/hover.js')(window);
require('event-dom/extra/valuechange.js')(window);
require('event-dom/extra/blurnode.js')(window);
require('event-dom/extra/focusnode.js')(window);
// setup dragdrop:
dragdrop = require('drag-drop')(window);
ITSA.DD = dragdrop;
ITSA.DD.init();
require('focusmanager')(window);
}
ITSA.merge(require('messages'));
require('dialog')(window);
require('scrollable')(window);
/**
* Reference to the [IO](io.html) object
* @property IO
* @type Object
* @static
*/
ITSA.IO = require('itsa-io');
ITSA.IO.config.merge(io_config);
require('itsa-io/extra/io-cors-ie9.js')(window);
require('itsa-io/extra/io-xml.js')(window);
/**
* Reference to the [Uploader](uploader.html) object
* @property Uploader
* @type Object
* @static
*/
ITSA.Uploader = require('uploader')(window);
/**
* Reference to the [UserAgent](useragent.html) object
* @property UA
* @type Object
* @static
*/
ITSA.UA = require('useragent')(window);
/**
* [Event](Event.html)-instance
* @property Event
* @type Event
* @static
*/
ITSA.Event = Event;
window._ITSAmodules.ITSA = ITSA;
module.exports = ITSA;
})(global.window || require('node-win'));