tinymce-rails 4.4.1 → 4.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/source/tinymce/tinymce.js +406 -197
- data/lib/tinymce/rails/version.rb +2 -2
- data/vendor/assets/javascripts/tinymce/plugins/codesample/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/contextmenu/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/importcss/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/lists/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/spellchecker/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/table/plugin.js +2 -2
- data/vendor/assets/javascripts/tinymce/plugins/template/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/themes/inlite/theme.js +1 -1
- data/vendor/assets/javascripts/tinymce/tinymce.js +14 -13
- metadata +2 -55
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/atomic.js +0 -5
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-atomic.js +0 -1491
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-browser.js +0 -1491
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-demo.js +0 -1491
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-prod.js +0 -1491
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/browser.js +0 -10
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/demo.js +0 -8
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/prod.js +0 -5
- data/vendor/assets/javascripts/tinymce/themes/inlite/config/dent/depend.js +0 -21
- data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/compile/bootstrap.js +0 -1526
- data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/compile/theme.js +0 -1594
- data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/inline/theme.js +0 -1679
- data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/inline/theme.raw.js +0 -1679
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/css/demo.css +0 -25
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/html/demo.html +0 -69
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/js/tinymce/inlite/Demo.js +0 -28
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/Theme.js +0 -150
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Arr.js +0 -22
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Bookmark.js +0 -130
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Unlink.js +0 -84
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Uuid.js +0 -34
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Actions.js +0 -106
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Convert.js +0 -37
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/ElementMatcher.js +0 -47
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Layout.js +0 -95
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Matcher.js +0 -39
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js +0 -61
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/PredicateId.js +0 -32
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/SelectionMatcher.js +0 -55
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/SkinLoader.js +0 -45
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/UrlType.js +0 -27
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/file/Conversions.js +0 -31
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/file/Picker.js +0 -40
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js +0 -80
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Forms.js +0 -102
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Panel.js +0 -218
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Toolbar.js +0 -126
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/alien/ArrTest.js +0 -9
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/alien/UuidTest.js +0 -10
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/ConvertTest.js +0 -12
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/MatcherTest.js +0 -51
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/UrlTypeTest.js +0 -33
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/ThemeTest.js +0 -202
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/alien/BookmarkTest.js +0 -65
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/alien/UnlinkTest.js +0 -38
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/ActionsTest.js +0 -177
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/ElementMatcher.js +0 -69
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/LayoutTest.js +0 -118
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/MeasureTest.js +0 -62
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/PredicateIdTest.js +0 -26
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/SelectionMatcherTest.js +0 -76
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/file/ConversionsTest.js +0 -41
- data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/file/SelectionMatcher.js +0 -55
@@ -1,1491 +0,0 @@
|
|
1
|
-
(function (scope) {
|
2
|
-
var ephox = scope.ephox = scope.ephox || {};
|
3
|
-
var bolt = ephox.bolt = ephox.bolt || {};
|
4
|
-
|
5
|
-
var def = function (deps, factory) {
|
6
|
-
return factory.apply(null, deps);
|
7
|
-
};
|
8
|
-
var kernel = bolt.kernel = bolt.kernel || {};
|
9
|
-
kernel.api = kernel.api || {};
|
10
|
-
kernel.async = kernel.api || {};
|
11
|
-
kernel.fp = kernel.fp || {};
|
12
|
-
kernel.modulator = kernel.modulator || {};
|
13
|
-
kernel.module = kernel.module || {};
|
14
|
-
kernel.fp.array = def(
|
15
|
-
[
|
16
|
-
],
|
17
|
-
|
18
|
-
function () {
|
19
|
-
var equals = function (a1, a2) {
|
20
|
-
if (a1.length !== a2.length)
|
21
|
-
return false;
|
22
|
-
for (var i = 0; i < a1.length; ++i)
|
23
|
-
if (a1[i] !== a2[i])
|
24
|
-
return false;
|
25
|
-
return true;
|
26
|
-
};
|
27
|
-
|
28
|
-
var forall = function (a, f) {
|
29
|
-
var fn = f || function (x) {
|
30
|
-
return x === true;
|
31
|
-
};
|
32
|
-
for (var i = 0; i < a.length; ++i)
|
33
|
-
if (fn(a[i]) !== true)
|
34
|
-
return false;
|
35
|
-
return true;
|
36
|
-
};
|
37
|
-
|
38
|
-
var map = function (a, f) {
|
39
|
-
var r = [];
|
40
|
-
for (var i = 0; i < a.length; ++i)
|
41
|
-
r.push(f(a[i], i));
|
42
|
-
return r;
|
43
|
-
};
|
44
|
-
|
45
|
-
var flatten = function (a) {
|
46
|
-
var r = [];
|
47
|
-
for (var i = 0; i < a.length; ++i)
|
48
|
-
r = r.concat(a[i]);
|
49
|
-
return r;
|
50
|
-
};
|
51
|
-
|
52
|
-
var flatmap = function (a, f) {
|
53
|
-
return flatten(map(a, f));
|
54
|
-
};
|
55
|
-
|
56
|
-
var filter = function (a, f) {
|
57
|
-
var r = [];
|
58
|
-
for (var i = 0; i < a.length; ++i)
|
59
|
-
if (f(a[i]))
|
60
|
-
r.push(a[i]);
|
61
|
-
return r;
|
62
|
-
};
|
63
|
-
|
64
|
-
var each = map;
|
65
|
-
|
66
|
-
var contains = function (a, x) {
|
67
|
-
return !forall(a, function (v) {
|
68
|
-
return v !== x;
|
69
|
-
});
|
70
|
-
};
|
71
|
-
|
72
|
-
var indexof = function (a, x) {
|
73
|
-
for (var i = 0; i < a.length; ++i)
|
74
|
-
if (a[i] === x)
|
75
|
-
return i;
|
76
|
-
return -1;
|
77
|
-
};
|
78
|
-
|
79
|
-
return {
|
80
|
-
equals: equals,
|
81
|
-
forall: forall,
|
82
|
-
map: map,
|
83
|
-
flatten: flatten,
|
84
|
-
flatmap: flatmap,
|
85
|
-
filter: filter,
|
86
|
-
each: each,
|
87
|
-
contains: contains,
|
88
|
-
indexof: indexof
|
89
|
-
};
|
90
|
-
}
|
91
|
-
);
|
92
|
-
kernel.fp.object = def(
|
93
|
-
[
|
94
|
-
],
|
95
|
-
|
96
|
-
function () {
|
97
|
-
var map = function (o, f) {
|
98
|
-
var r = {};
|
99
|
-
for (var i in o)
|
100
|
-
if (o.hasOwnProperty(i))
|
101
|
-
r[i] = f(i, o[i]);
|
102
|
-
return r;
|
103
|
-
};
|
104
|
-
|
105
|
-
var each = map;
|
106
|
-
|
107
|
-
var merge = function (d, s) {
|
108
|
-
each(s, function (k, v) {
|
109
|
-
d[k] = v;
|
110
|
-
});
|
111
|
-
};
|
112
|
-
|
113
|
-
var keys = function (o) {
|
114
|
-
var r = [];
|
115
|
-
each(o, function (k) {
|
116
|
-
r.push(k);
|
117
|
-
});
|
118
|
-
return r;
|
119
|
-
};
|
120
|
-
|
121
|
-
return {
|
122
|
-
each: each,
|
123
|
-
keys: keys,
|
124
|
-
map: map,
|
125
|
-
merge: merge
|
126
|
-
};
|
127
|
-
}
|
128
|
-
);
|
129
|
-
kernel.fp.functions = def(
|
130
|
-
[
|
131
|
-
],
|
132
|
-
|
133
|
-
function () {
|
134
|
-
var curry = function (f) {
|
135
|
-
var slice = Array.prototype.slice;
|
136
|
-
var args = slice.call(arguments, 1);
|
137
|
-
return function () {
|
138
|
-
var all = args.concat(slice.call(arguments, 0));
|
139
|
-
return f.apply(null, all);
|
140
|
-
};
|
141
|
-
};
|
142
|
-
|
143
|
-
var not = function (z) {
|
144
|
-
return function () {
|
145
|
-
var slice = Array.prototype.slice;
|
146
|
-
return !z.apply(null, slice.call(arguments, 0));
|
147
|
-
};
|
148
|
-
};
|
149
|
-
|
150
|
-
var apply = function (f) {
|
151
|
-
var slice = Array.prototype.slice;
|
152
|
-
return f.apply(null, slice.call(arguments, 0));
|
153
|
-
};
|
154
|
-
|
155
|
-
return {
|
156
|
-
curry: curry,
|
157
|
-
not: not,
|
158
|
-
apply: apply
|
159
|
-
};
|
160
|
-
}
|
161
|
-
);kernel.async.map = def(
|
162
|
-
[
|
163
|
-
kernel.fp.array
|
164
|
-
],
|
165
|
-
|
166
|
-
function (ar) {
|
167
|
-
var amap = function (data, f, oncomplete) {
|
168
|
-
var total = data.length;
|
169
|
-
var count = 0;
|
170
|
-
var results = [];
|
171
|
-
|
172
|
-
ar.each(data, function (datum, i) {
|
173
|
-
f(datum, function (result) {
|
174
|
-
++count;
|
175
|
-
results[i] = result;
|
176
|
-
if (count === total)
|
177
|
-
oncomplete(results);
|
178
|
-
});
|
179
|
-
});
|
180
|
-
};
|
181
|
-
|
182
|
-
return {
|
183
|
-
amap: amap
|
184
|
-
};
|
185
|
-
}
|
186
|
-
);
|
187
|
-
/**
|
188
|
-
* This module has a dual responsibility:
|
189
|
-
* 1. Ensures that asynchronous function calls, 'f', that share the same
|
190
|
-
* 'key' are not executed in parallel.
|
191
|
-
* 2. In the case where an attempt to call in parallel is prevented,
|
192
|
-
* the 'action' callbacks are executed when the asynchronous call is
|
193
|
-
* completed.
|
194
|
-
*
|
195
|
-
* Example:
|
196
|
-
* When we async-map to remotely fetch module definition, it is
|
197
|
-
* important that only a single define is evaluated, but the
|
198
|
-
* notification that the definition has completed is propagated
|
199
|
-
* to all interested parties.
|
200
|
-
*
|
201
|
-
* 1. we require dependencies 'x' and 'y'
|
202
|
-
*
|
203
|
-
* 2. both x and y are defined in the same file (i.e. compiled together), 'a.js'.
|
204
|
-
*
|
205
|
-
* 3. we resolve x and y, to their load spec using a modulator
|
206
|
-
* x_spec = {load: function () { -- load a.js -- }, url: a.js, serial: false};
|
207
|
-
* y_spec = {load: function () { -- load a.js -- }, url: a.js, serial: false};
|
208
|
-
*
|
209
|
-
* 4. we make the piggyback call for x:
|
210
|
-
* piggybacker.piggyback(x_spec.url, x_spec.load, xdone);
|
211
|
-
*
|
212
|
-
* this will register the 'xdone' action, and actually
|
213
|
-
* trigger the load call, with a synthetic callback
|
214
|
-
* responsible for triggering all registered actions.
|
215
|
-
*
|
216
|
-
* 5. we make the piggyback call for y:
|
217
|
-
* piggybacker.piggyback(y_spec.url, y_spec.load, ydone);
|
218
|
-
*
|
219
|
-
* this will register the 'ydone' action, but NOT trigger
|
220
|
-
* the load call.
|
221
|
-
*
|
222
|
-
* 6. the load call completes, and calls the synthetic callback,
|
223
|
-
* which is responsible for triggering both 'xdone' and 'ydone'.
|
224
|
-
*
|
225
|
-
* 7. something else happens that means we have to load 'a.js' again,
|
226
|
-
* the piggybacker DOES NOT prevent this call, and will follow
|
227
|
-
* the above process.
|
228
|
-
*/
|
229
|
-
kernel.async.piggybacker = def(
|
230
|
-
[
|
231
|
-
kernel.fp.array,
|
232
|
-
kernel.fp.functions
|
233
|
-
],
|
234
|
-
|
235
|
-
function (ar, fn) {
|
236
|
-
var create = function () {
|
237
|
-
var queue = {}; // key -> [actions]
|
238
|
-
|
239
|
-
var process = function (key) {
|
240
|
-
var actions = queue[key];
|
241
|
-
delete queue[key];
|
242
|
-
ar.each(actions, fn.apply);
|
243
|
-
};
|
244
|
-
|
245
|
-
var piggyback = function (key, f, action) {
|
246
|
-
if (queue[key] === undefined) {
|
247
|
-
queue[key] = [ action ];
|
248
|
-
f(fn.curry(process, key));
|
249
|
-
} else {
|
250
|
-
queue[key].push(action);
|
251
|
-
}
|
252
|
-
};
|
253
|
-
|
254
|
-
return {
|
255
|
-
piggyback: piggyback
|
256
|
-
};
|
257
|
-
};
|
258
|
-
|
259
|
-
return {
|
260
|
-
create: create
|
261
|
-
};
|
262
|
-
}
|
263
|
-
);
|
264
|
-
kernel.modulator.globalator = def(
|
265
|
-
[
|
266
|
-
],
|
267
|
-
|
268
|
-
function () {
|
269
|
-
var create = function () {
|
270
|
-
// FIX pull out
|
271
|
-
var resolve = function (name, scope) {
|
272
|
-
var parts = name.split('.');
|
273
|
-
var r = scope;
|
274
|
-
for (var i = 0; i < parts.length && r !== undefined; ++i)
|
275
|
-
r = r[parts[i]];
|
276
|
-
return r;
|
277
|
-
};
|
278
|
-
|
279
|
-
var global = Function('return this')();
|
280
|
-
|
281
|
-
var can = function (id) {
|
282
|
-
return id.indexOf('global!') === 0;
|
283
|
-
};
|
284
|
-
|
285
|
-
var get = function (id, define, require) {
|
286
|
-
var name = id.substring('global!'.length);
|
287
|
-
|
288
|
-
var load = function (onsuccess, onfailure) {
|
289
|
-
var instance = resolve(name, global);
|
290
|
-
if (instance !== undefined) {
|
291
|
-
define(id, [], function () { return instance; });
|
292
|
-
onsuccess();
|
293
|
-
} else {
|
294
|
-
onfailure('Modulator error: could not resolve global [' + name + ']');
|
295
|
-
}
|
296
|
-
};
|
297
|
-
|
298
|
-
return {
|
299
|
-
url: id, // this just needs to be unique, no download required.
|
300
|
-
load: load,
|
301
|
-
serial: true
|
302
|
-
};
|
303
|
-
};
|
304
|
-
|
305
|
-
return {
|
306
|
-
can: can,
|
307
|
-
get: get
|
308
|
-
}
|
309
|
-
};
|
310
|
-
return {
|
311
|
-
create: create
|
312
|
-
};
|
313
|
-
}
|
314
|
-
);
|
315
|
-
kernel.modulator.bolt = def(
|
316
|
-
[
|
317
|
-
kernel.fp.functions
|
318
|
-
],
|
319
|
-
|
320
|
-
function (fn) {
|
321
|
-
var create = function (loader, pather, namespace, path, idTransformer, options) {
|
322
|
-
var can = function (id) {
|
323
|
-
return id === namespace || id.indexOf(namespace + '.') === 0 || id.indexOf(namespace + '/') === 0;
|
324
|
-
};
|
325
|
-
|
326
|
-
var get = function (id) {
|
327
|
-
var before = options !== undefined && options.absolute === true ? path : pather(path);
|
328
|
-
var after = options !== undefined && options.fresh === true ? '?cachebuster=' + new Date().getTime() : '';
|
329
|
-
var url = before + "/" + idTransformer(id) + '.js' + after;
|
330
|
-
var load = fn.curry(loader.load, url);
|
331
|
-
|
332
|
-
return {
|
333
|
-
url: url,
|
334
|
-
load: load,
|
335
|
-
serial: false
|
336
|
-
};
|
337
|
-
};
|
338
|
-
|
339
|
-
return {
|
340
|
-
can: can,
|
341
|
-
get: get
|
342
|
-
};
|
343
|
-
};
|
344
|
-
|
345
|
-
return {
|
346
|
-
create: create
|
347
|
-
};
|
348
|
-
}
|
349
|
-
);kernel.module.stratifier = def(
|
350
|
-
[
|
351
|
-
kernel.fp.array
|
352
|
-
],
|
353
|
-
|
354
|
-
function (ar) {
|
355
|
-
var stratify = function (specs) {
|
356
|
-
var parallels = ar.filter(specs, function (spec) {
|
357
|
-
return !spec.serial;
|
358
|
-
});
|
359
|
-
return parallels.length > 0 ? parallels : specs.slice(0, 1);
|
360
|
-
};
|
361
|
-
|
362
|
-
return {
|
363
|
-
stratify: stratify
|
364
|
-
};
|
365
|
-
}
|
366
|
-
);
|
367
|
-
/**
|
368
|
-
* This module performs dependency analysis of strings that depend on sets of
|
369
|
-
* strings.
|
370
|
-
*
|
371
|
-
* The input is an array of root strings to start analysis from, and an object
|
372
|
-
* that contains a mapping of each string to the strings it depends on.
|
373
|
-
*
|
374
|
-
* Performing an analysis results in either:
|
375
|
-
* 1. an empty array, indicating that all dependencies are satisfied,
|
376
|
-
* 2. an array of strings that are, at the minimum, still needed in order to
|
377
|
-
* satisfy the given dependency trees, or
|
378
|
-
* 3. an array of strings that form a dependency cycle.
|
379
|
-
*/
|
380
|
-
kernel.module.analyser = def(
|
381
|
-
[
|
382
|
-
kernel.fp.array
|
383
|
-
],
|
384
|
-
|
385
|
-
function (array) {
|
386
|
-
var collect = function (path, name) {
|
387
|
-
var i = array.indexof(path, name);
|
388
|
-
var p = path.slice(i);
|
389
|
-
return p.concat([name]);
|
390
|
-
};
|
391
|
-
|
392
|
-
/**
|
393
|
-
* @param {array} roots Contains a list of root ids
|
394
|
-
* @param {object} modules Contains dependency information in format: { id: [ 'id1', 'id2' ] }
|
395
|
-
*/
|
396
|
-
var analyse = function (roots, modules) {
|
397
|
-
var done = {};
|
398
|
-
var path = [];
|
399
|
-
var missing = [];
|
400
|
-
var cycle;
|
401
|
-
|
402
|
-
var children = function (name) {
|
403
|
-
array.each(modules[name], attempt);
|
404
|
-
};
|
405
|
-
|
406
|
-
var examine = function (name) {
|
407
|
-
if (modules[name])
|
408
|
-
children(name);
|
409
|
-
else
|
410
|
-
missing.push(name);
|
411
|
-
};
|
412
|
-
|
413
|
-
var descend = function (name) {
|
414
|
-
path.push(name);
|
415
|
-
examine(name);
|
416
|
-
path.pop();
|
417
|
-
};
|
418
|
-
|
419
|
-
var decycle = function (name) {
|
420
|
-
if (array.contains(path, name))
|
421
|
-
cycle = collect(path, name);
|
422
|
-
else
|
423
|
-
descend(name);
|
424
|
-
};
|
425
|
-
|
426
|
-
var attempt = function (name) {
|
427
|
-
if (!done[name]) {
|
428
|
-
decycle(name);
|
429
|
-
done[name] = true;
|
430
|
-
}
|
431
|
-
};
|
432
|
-
|
433
|
-
array.each(roots, attempt);
|
434
|
-
|
435
|
-
return cycle ? { cycle: cycle } : { load: missing };
|
436
|
-
};
|
437
|
-
|
438
|
-
return {
|
439
|
-
analyse: analyse
|
440
|
-
};
|
441
|
-
}
|
442
|
-
);
|
443
|
-
kernel.module.fetcher = def(
|
444
|
-
[
|
445
|
-
kernel.fp.array,
|
446
|
-
kernel.fp.functions,
|
447
|
-
kernel.async.map,
|
448
|
-
kernel.async.piggybacker,
|
449
|
-
kernel.module.stratifier
|
450
|
-
],
|
451
|
-
|
452
|
-
function (ar, fn, map, piggybacker, stratifier) {
|
453
|
-
var create = function (regulator, validator, onerror, define, require, demand) {
|
454
|
-
var piggyback = piggybacker.create();
|
455
|
-
|
456
|
-
var validate = function (onsuccess, results) {
|
457
|
-
var failed = ar.filter(results, fn.not(validator));
|
458
|
-
if (failed.length > 0)
|
459
|
-
onerror('Fetcher error: modules were not defined: ' + failed.join(', '));
|
460
|
-
else
|
461
|
-
onsuccess();
|
462
|
-
};
|
463
|
-
|
464
|
-
var mapper = function (spec, onresult) {
|
465
|
-
var action = fn.curry(onresult, spec.id);
|
466
|
-
var load = function (callback) {
|
467
|
-
spec.load(callback, onerror);
|
468
|
-
};
|
469
|
-
piggyback.piggyback(spec.url, load, action);
|
470
|
-
};
|
471
|
-
|
472
|
-
var asyncfetch = function (specs, onsuccess) {
|
473
|
-
var oncomplete = fn.curry(validate, onsuccess);
|
474
|
-
var strata = stratifier.stratify(specs);
|
475
|
-
map.amap(strata, mapper, oncomplete);
|
476
|
-
};
|
477
|
-
|
478
|
-
var fetch = function (ids, onsuccess) {
|
479
|
-
regulator.regulate(ids, define, require, demand, function (specs) {
|
480
|
-
asyncfetch(specs, onsuccess);
|
481
|
-
}, onerror);
|
482
|
-
};
|
483
|
-
|
484
|
-
return {
|
485
|
-
fetch: fetch
|
486
|
-
};
|
487
|
-
};
|
488
|
-
|
489
|
-
return {
|
490
|
-
create: create
|
491
|
-
};
|
492
|
-
}
|
493
|
-
);
|
494
|
-
kernel.module.loader = def(
|
495
|
-
[
|
496
|
-
kernel.module.analyser
|
497
|
-
],
|
498
|
-
|
499
|
-
function (analyser) {
|
500
|
-
var load = function (roots, deps, fetcher, oncontinue, onsuccess, onerror) {
|
501
|
-
var result = analyser.analyse(roots, deps);
|
502
|
-
|
503
|
-
if (result.cycle)
|
504
|
-
onerror('Dependency error: a circular module dependency exists from ' + result.cycle.join(' ~> '));
|
505
|
-
else if (result.load.length === 0)
|
506
|
-
onsuccess();
|
507
|
-
else
|
508
|
-
fetcher.fetch(result.load, oncontinue);
|
509
|
-
};
|
510
|
-
|
511
|
-
return {
|
512
|
-
load: load
|
513
|
-
};
|
514
|
-
}
|
515
|
-
);
|
516
|
-
kernel.module.manager = def(
|
517
|
-
[
|
518
|
-
kernel.fp.array,
|
519
|
-
kernel.fp.object,
|
520
|
-
kernel.module.loader,
|
521
|
-
kernel.module.fetcher
|
522
|
-
],
|
523
|
-
|
524
|
-
function (ar, obj, loader, fetcher) {
|
525
|
-
var create = function (regulator, onerror) {
|
526
|
-
var blueprints = {}; // id -> { id: string, dependencies: [ string ], definition: function }
|
527
|
-
var modules = {}; // id -> module
|
528
|
-
|
529
|
-
// Adds a module to the system.
|
530
|
-
var define = function (id, dependencies, definition) {
|
531
|
-
if (id === undefined)
|
532
|
-
onerror("Define error: module id can not be undefined");
|
533
|
-
else if (blueprints[id] !== undefined)
|
534
|
-
onerror("Define error: module '" + id + "' is already defined");
|
535
|
-
else
|
536
|
-
blueprints[id] = { id: id, dependencies: dependencies, definition: definition };
|
537
|
-
};
|
538
|
-
|
539
|
-
// Loads a set of modules asynchronously.
|
540
|
-
var require = function (ids, callback) {
|
541
|
-
var onsuccess = function () {
|
542
|
-
var instances = ar.map(ids, demand);
|
543
|
-
callback.apply(null, instances);
|
544
|
-
};
|
545
|
-
|
546
|
-
var oncontinue = function () {
|
547
|
-
var deps = obj.map(blueprints, function (k, v) {
|
548
|
-
return v.dependencies;
|
549
|
-
});
|
550
|
-
loader.load(ids, deps, fetch, oncontinue, onsuccess, onerror);
|
551
|
-
};
|
552
|
-
|
553
|
-
oncontinue();
|
554
|
-
};
|
555
|
-
|
556
|
-
// Instantiates a module and all of its dependencies.
|
557
|
-
var demand = function (id) {
|
558
|
-
if (modules[id] !== undefined)
|
559
|
-
return modules[id];
|
560
|
-
if (blueprints[id] === undefined)
|
561
|
-
throw "module '" + id + "' is not defined";
|
562
|
-
var result = instantiate(id);
|
563
|
-
if (result === undefined)
|
564
|
-
throw "module '" + id + "' returned undefined from definition function";
|
565
|
-
modules[id] = result;
|
566
|
-
return result;
|
567
|
-
};
|
568
|
-
|
569
|
-
var instantiate = function (id) {
|
570
|
-
var blueprint = blueprints[id];
|
571
|
-
var args = ar.map(blueprint.dependencies, demand); // Instantiate dependencies
|
572
|
-
return blueprint.definition.apply(null, args); // Instantiate self
|
573
|
-
};
|
574
|
-
|
575
|
-
var validator = function (id) { return blueprints[id] !== undefined; };
|
576
|
-
var fetch = fetcher.create(regulator, validator, onerror, define, require, demand);
|
577
|
-
|
578
|
-
return {
|
579
|
-
define: define,
|
580
|
-
require: require,
|
581
|
-
demand: demand
|
582
|
-
};
|
583
|
-
};
|
584
|
-
|
585
|
-
return {
|
586
|
-
create: create
|
587
|
-
};
|
588
|
-
}
|
589
|
-
);
|
590
|
-
kernel.api.sources = def(
|
591
|
-
[
|
592
|
-
kernel.fp.array,
|
593
|
-
kernel.fp.object,
|
594
|
-
kernel.modulator.globalator
|
595
|
-
],
|
596
|
-
|
597
|
-
function (ar, obj, globalator) {
|
598
|
-
var create = function (builtins, configuration) {
|
599
|
-
var data = {
|
600
|
-
'global': { instance: globalator }
|
601
|
-
};
|
602
|
-
obj.each(builtins, function (key, value) {
|
603
|
-
data[key] = { instance: value };
|
604
|
-
});
|
605
|
-
ar.each(configuration.types, function (spec) {
|
606
|
-
data[spec.type] = { id: spec.modulator };
|
607
|
-
});
|
608
|
-
var sourcespecs = configuration.sources.slice(0);
|
609
|
-
var sources = [ globalator.create() ];
|
610
|
-
|
611
|
-
var guard = function (type) {
|
612
|
-
if (data[type] === undefined)
|
613
|
-
throw 'Unknown modulator type [' + type + '].';
|
614
|
-
};
|
615
|
-
|
616
|
-
var isResolved = function (type) {
|
617
|
-
guard(type);
|
618
|
-
return data[type].instance !== undefined;
|
619
|
-
};
|
620
|
-
|
621
|
-
var idOf = function (type) {
|
622
|
-
guard(type);
|
623
|
-
return data[type].id;
|
624
|
-
};
|
625
|
-
|
626
|
-
var instanceOf = function (type) {
|
627
|
-
guard(type);
|
628
|
-
return data[type].instance;
|
629
|
-
};
|
630
|
-
|
631
|
-
var register = function (type, instance) {
|
632
|
-
guard(type);
|
633
|
-
data[type].instance = instance;
|
634
|
-
};
|
635
|
-
|
636
|
-
var find = function (id) {
|
637
|
-
for (var i = 0; i < sources.length; ++i)
|
638
|
-
if (sources[i].can(id))
|
639
|
-
return { found: sources[i] };
|
640
|
-
return { notfound: true };
|
641
|
-
};
|
642
|
-
|
643
|
-
var crank = function () {
|
644
|
-
var left = [];
|
645
|
-
ar.each(sourcespecs, function (spec) {
|
646
|
-
if (isResolved(spec.type)) {
|
647
|
-
var instance = instanceOf(spec.type);
|
648
|
-
var source = instance.create.apply(null, spec.args);
|
649
|
-
sources.push(source);
|
650
|
-
} else
|
651
|
-
left.push(spec);
|
652
|
-
});
|
653
|
-
sourcespecs = left;
|
654
|
-
};
|
655
|
-
|
656
|
-
return {
|
657
|
-
isResolved: isResolved,
|
658
|
-
idOf: idOf,
|
659
|
-
instanceOf: instanceOf,
|
660
|
-
register: register,
|
661
|
-
find: find,
|
662
|
-
crank: crank
|
663
|
-
};
|
664
|
-
};
|
665
|
-
|
666
|
-
return {
|
667
|
-
create: create
|
668
|
-
};
|
669
|
-
}
|
670
|
-
);
|
671
|
-
kernel.api.regulator = def(
|
672
|
-
[
|
673
|
-
kernel.fp.array,
|
674
|
-
kernel.fp.functions
|
675
|
-
],
|
676
|
-
|
677
|
-
function (ar, fn) {
|
678
|
-
var create = function (sources) {
|
679
|
-
/*
|
680
|
-
* 1. Resolve configuration as much as possible
|
681
|
-
* 2. Check for unresolved modulator types that are required to continue.
|
682
|
-
* a) Go ahead and resolve, if we have everything we need.
|
683
|
-
* b) Delay, requiring the modulators, then retry.
|
684
|
-
*/
|
685
|
-
var regulate = function (ids, define, require, demand, onsuccess, onerror) {
|
686
|
-
sources.crank();
|
687
|
-
var required = ar.map(ids, determinetype);
|
688
|
-
var unresolved = ar.filter(required, fn.not(sources.isResolved));
|
689
|
-
if (unresolved.length === 0)
|
690
|
-
resolve(ids, define, require, demand, onsuccess, onerror);
|
691
|
-
else
|
692
|
-
delay(unresolved, ids, define, require, demand, onsuccess, onerror);
|
693
|
-
};
|
694
|
-
|
695
|
-
var resolve = function (ids, define, require, demand, onsuccess, onerror) {
|
696
|
-
var r = [];
|
697
|
-
for (var i = 0; i < ids.length; ++i) {
|
698
|
-
var id = ids[i];
|
699
|
-
var source = sources.find(id);
|
700
|
-
if (source.notfound) {
|
701
|
-
onerror('Could not find source for module [' + id + ']');
|
702
|
-
return;
|
703
|
-
}
|
704
|
-
var spec = source.found.get(id, define, require, demand);
|
705
|
-
r[i] = build(id, spec);
|
706
|
-
}
|
707
|
-
onsuccess(r);
|
708
|
-
};
|
709
|
-
|
710
|
-
var build = function (id, spec) {
|
711
|
-
return {
|
712
|
-
id: id,
|
713
|
-
url: spec.url,
|
714
|
-
load: spec.load,
|
715
|
-
serial: spec.serial
|
716
|
-
};
|
717
|
-
};
|
718
|
-
|
719
|
-
var delay = function (types, ids, define, require, demand, onsuccess, onerror) {
|
720
|
-
var modulatorids = ar.map(types, sources.idOf);
|
721
|
-
require(modulatorids, function (/* modulators */) {
|
722
|
-
var modulators = arguments;
|
723
|
-
ar.each(types, function (type, i) {
|
724
|
-
sources.register(type, modulators[i]);
|
725
|
-
});
|
726
|
-
regulate(ids, define, require, demand, onsuccess, onerror);
|
727
|
-
});
|
728
|
-
};
|
729
|
-
|
730
|
-
var determinetype = function (id) {
|
731
|
-
var index = id.indexOf('!');
|
732
|
-
return index === -1 ? 'bolt' : id.substring(0, index);
|
733
|
-
};
|
734
|
-
|
735
|
-
return {
|
736
|
-
regulate: regulate
|
737
|
-
};
|
738
|
-
};
|
739
|
-
|
740
|
-
return {
|
741
|
-
create: create
|
742
|
-
};
|
743
|
-
}
|
744
|
-
);
|
745
|
-
kernel.api.config = def(
|
746
|
-
[
|
747
|
-
kernel.module.manager,
|
748
|
-
kernel.api.regulator,
|
749
|
-
kernel.api.sources
|
750
|
-
],
|
751
|
-
|
752
|
-
function (manager, regulator, sources) {
|
753
|
-
var configure = function (configuration, builtins, onerror) {
|
754
|
-
var s = sources.create(builtins, configuration);
|
755
|
-
var r = regulator.create(s);
|
756
|
-
var engine = manager.create(r, onerror);
|
757
|
-
|
758
|
-
return {
|
759
|
-
define: engine.define,
|
760
|
-
require: engine.require,
|
761
|
-
demand: engine.demand
|
762
|
-
};
|
763
|
-
};
|
764
|
-
|
765
|
-
return {
|
766
|
-
configure: configure
|
767
|
-
};
|
768
|
-
}
|
769
|
-
);
|
770
|
-
})(Function('return this')());
|
771
|
-
|
772
|
-
(function (scope) {
|
773
|
-
var ephox = scope.ephox = scope.ephox || {};
|
774
|
-
var bolt = ephox.bolt = ephox.bolt || {};
|
775
|
-
|
776
|
-
var def = function (deps, factory) {
|
777
|
-
return factory.apply(null, deps);
|
778
|
-
};
|
779
|
-
var loader = bolt.loader = bolt.loader || {};
|
780
|
-
loader.executor = loader.executor || {};
|
781
|
-
loader.api = loader.api || {};
|
782
|
-
loader.transporter = loader.transporter || {};
|
783
|
-
loader.tag = loader.tag || {};
|
784
|
-
loader.tag.script = def(
|
785
|
-
[
|
786
|
-
],
|
787
|
-
|
788
|
-
function () {
|
789
|
-
var guard = function (callback) {
|
790
|
-
return function (evt) {
|
791
|
-
if (evt.srcElement.readyState === "loaded" || evt.srcElement.readyState === "complete")
|
792
|
-
callback();
|
793
|
-
};
|
794
|
-
};
|
795
|
-
|
796
|
-
var ie = function (el) {
|
797
|
-
return el.attachEvent && !window.opera;
|
798
|
-
};
|
799
|
-
|
800
|
-
var onload = function (el, callback) {
|
801
|
-
if (ie(el))
|
802
|
-
el.attachEvent("onreadystatechange", guard(callback));
|
803
|
-
else
|
804
|
-
el.addEventListener("load", callback, false);
|
805
|
-
};
|
806
|
-
|
807
|
-
var createtag = function (callback) {
|
808
|
-
var el = document.createElement("script");
|
809
|
-
el.type = "text/javascript";
|
810
|
-
onload(el, callback);
|
811
|
-
return el;
|
812
|
-
};
|
813
|
-
|
814
|
-
var insert = function (decorator, callback) {
|
815
|
-
var el = createtag(callback);
|
816
|
-
decorator(el);
|
817
|
-
var head = document.getElementsByTagName("head")[0];
|
818
|
-
head.appendChild(el);
|
819
|
-
};
|
820
|
-
|
821
|
-
return {
|
822
|
-
insert: insert
|
823
|
-
};
|
824
|
-
}
|
825
|
-
);
|
826
|
-
loader.transporter.commonjs = def(
|
827
|
-
[
|
828
|
-
],
|
829
|
-
|
830
|
-
function () {
|
831
|
-
var read = function (url, success, error) {
|
832
|
-
var fs = require('fs');
|
833
|
-
fs.exists(url, function (exists) {
|
834
|
-
if (exists)
|
835
|
-
fs.readFile(url, 'UTF-8', function (err, data) {
|
836
|
-
if (err)
|
837
|
-
error('Error reading file [' + url + '], error [' + err + ']');
|
838
|
-
else
|
839
|
-
success(data);
|
840
|
-
});
|
841
|
-
else
|
842
|
-
error('File does not exist [' + url + ']');
|
843
|
-
});
|
844
|
-
};
|
845
|
-
|
846
|
-
return {
|
847
|
-
read: read
|
848
|
-
};
|
849
|
-
}
|
850
|
-
);
|
851
|
-
loader.transporter.xhr = def(
|
852
|
-
[
|
853
|
-
],
|
854
|
-
|
855
|
-
function () {
|
856
|
-
var requestObject = function () {
|
857
|
-
// Correct way to use XMLHttpRequest in IE:
|
858
|
-
// http://blogs.msdn.com/b/ie/archive/2006/01/23/516393.aspx
|
859
|
-
var factories = [
|
860
|
-
function () { return new XMLHttpRequest() },
|
861
|
-
function () { return new ActiveXObject("Microsoft.XMLHTTP") }
|
862
|
-
];
|
863
|
-
|
864
|
-
return fallback(factories);
|
865
|
-
};
|
866
|
-
|
867
|
-
var fallback = function (items) {
|
868
|
-
for (var i = 0; i < items.length; ++i) {
|
869
|
-
try {
|
870
|
-
return items[i]();
|
871
|
-
} catch (e) {
|
872
|
-
}
|
873
|
-
}
|
874
|
-
};
|
875
|
-
|
876
|
-
var handler = function (req, url, success, error) {
|
877
|
-
return function () {
|
878
|
-
if (req.readyState === 4)
|
879
|
-
done(req, url, success, error);
|
880
|
-
};
|
881
|
-
};
|
882
|
-
|
883
|
-
var done = function (req, url, success, error) {
|
884
|
-
if (req.status === 200 || req.status === 304)
|
885
|
-
success(req.responseText);
|
886
|
-
else
|
887
|
-
error('Transport error: ' + req.status + ' ' + req.statusText + ' for resource: "' + url + '"');
|
888
|
-
};
|
889
|
-
|
890
|
-
var getUrl = function (req, url, success, error) {
|
891
|
-
req.open('GET', url, true);
|
892
|
-
req.onreadystatechange = handler(req, url, success, error);
|
893
|
-
req.send();
|
894
|
-
};
|
895
|
-
|
896
|
-
var request = function (url, success, error) {
|
897
|
-
var req = requestObject();
|
898
|
-
if (req)
|
899
|
-
getUrl(req, url, success, error);
|
900
|
-
else
|
901
|
-
error('Transport error: browser does not support XMLHttpRequest.');
|
902
|
-
};
|
903
|
-
|
904
|
-
return {
|
905
|
-
request: request
|
906
|
-
};
|
907
|
-
}
|
908
|
-
);
|
909
|
-
loader.executor.evaller = def(
|
910
|
-
[
|
911
|
-
],
|
912
|
-
|
913
|
-
function () {
|
914
|
-
var execute = function (data, onsuccess, onfailure) {
|
915
|
-
try {
|
916
|
-
eval(data);
|
917
|
-
} catch(e) {
|
918
|
-
onfailure(e);
|
919
|
-
return;
|
920
|
-
}
|
921
|
-
|
922
|
-
onsuccess();
|
923
|
-
};
|
924
|
-
|
925
|
-
return {
|
926
|
-
execute: execute
|
927
|
-
};
|
928
|
-
}
|
929
|
-
);
|
930
|
-
loader.executor.injector = def(
|
931
|
-
[
|
932
|
-
loader.tag.script
|
933
|
-
],
|
934
|
-
|
935
|
-
function (script) {
|
936
|
-
var execute = function (data, onsuccess, onfailure) {
|
937
|
-
var inject = function (tag) {
|
938
|
-
tag.text = data;
|
939
|
-
};
|
940
|
-
|
941
|
-
var noop = function () {};
|
942
|
-
|
943
|
-
// Injection does not fire events, but execution happens synchronously,
|
944
|
-
// so we just make an explicit callback
|
945
|
-
script.insert(inject, noop);
|
946
|
-
onsuccess();
|
947
|
-
};
|
948
|
-
|
949
|
-
return {
|
950
|
-
execute: execute
|
951
|
-
};
|
952
|
-
}
|
953
|
-
);
|
954
|
-
loader.api.commonjsevaller = def(
|
955
|
-
[
|
956
|
-
loader.transporter.commonjs,
|
957
|
-
loader.executor.evaller
|
958
|
-
],
|
959
|
-
|
960
|
-
function (commonjs, evaller) {
|
961
|
-
var load = function (url, onsuccess, onfailure) {
|
962
|
-
var inject = function (data) {
|
963
|
-
evaller.execute(data, onsuccess, onfailure);
|
964
|
-
};
|
965
|
-
|
966
|
-
commonjs.read(url, inject, onfailure);
|
967
|
-
};
|
968
|
-
|
969
|
-
return {
|
970
|
-
load: load
|
971
|
-
};
|
972
|
-
}
|
973
|
-
);
|
974
|
-
loader.api.scripttag = def(
|
975
|
-
[
|
976
|
-
loader.tag.script
|
977
|
-
],
|
978
|
-
|
979
|
-
function (script) {
|
980
|
-
var load = function (url, onsuccess, onfailure) {
|
981
|
-
var sourcer = function (tag) {
|
982
|
-
tag.src = url;
|
983
|
-
};
|
984
|
-
|
985
|
-
script.insert(sourcer, onsuccess);
|
986
|
-
};
|
987
|
-
|
988
|
-
return {
|
989
|
-
load: load
|
990
|
-
};
|
991
|
-
}
|
992
|
-
);
|
993
|
-
loader.api.xhrevaller = def(
|
994
|
-
[
|
995
|
-
loader.transporter.xhr,
|
996
|
-
loader.executor.evaller
|
997
|
-
],
|
998
|
-
|
999
|
-
function (xhr, evaller) {
|
1000
|
-
var load = function (url, onsuccess, onfailure) {
|
1001
|
-
var inject = function (data) {
|
1002
|
-
evaller.execute(data, onsuccess, onfailure);
|
1003
|
-
};
|
1004
|
-
|
1005
|
-
xhr.request(url, inject, onfailure);
|
1006
|
-
};
|
1007
|
-
|
1008
|
-
return {
|
1009
|
-
load: load
|
1010
|
-
};
|
1011
|
-
}
|
1012
|
-
);
|
1013
|
-
loader.api.xhrinjector = def(
|
1014
|
-
[
|
1015
|
-
loader.transporter.xhr,
|
1016
|
-
loader.executor.injector
|
1017
|
-
],
|
1018
|
-
|
1019
|
-
function (xhr, injector) {
|
1020
|
-
var load = function (url, onsuccess, onfailure) {
|
1021
|
-
var inject = function (data) {
|
1022
|
-
injector.execute(data, onsuccess);
|
1023
|
-
};
|
1024
|
-
|
1025
|
-
xhr.request(url, inject, onfailure);
|
1026
|
-
};
|
1027
|
-
|
1028
|
-
return {
|
1029
|
-
load: load
|
1030
|
-
};
|
1031
|
-
}
|
1032
|
-
);
|
1033
|
-
})(Function('return this')());
|
1034
|
-
|
1035
|
-
(function (scope) {
|
1036
|
-
var ephox = scope.ephox = scope.ephox || {};
|
1037
|
-
var bolt = ephox.bolt = ephox.bolt || {};
|
1038
|
-
|
1039
|
-
var def = function (deps, factory) {
|
1040
|
-
return factory.apply(null, deps);
|
1041
|
-
};
|
1042
|
-
var module = bolt.module = bolt.module || {};
|
1043
|
-
module.bootstrap = module.bootstrap || {};
|
1044
|
-
module.config = module.config || {};
|
1045
|
-
module.error = module.error || {};
|
1046
|
-
module.modulator = module.modulator || {};
|
1047
|
-
module.reader = module.reader || {};
|
1048
|
-
module.runtime = module.runtime || {};
|
1049
|
-
module.util = module.util || {};
|
1050
|
-
module.error.error = def(
|
1051
|
-
[
|
1052
|
-
],
|
1053
|
-
|
1054
|
-
function () {
|
1055
|
-
var die = function (msg) {
|
1056
|
-
throw msg || new Error('unknown error');
|
1057
|
-
};
|
1058
|
-
|
1059
|
-
return {
|
1060
|
-
die: die
|
1061
|
-
};
|
1062
|
-
}
|
1063
|
-
);
|
1064
|
-
module.config.mapper = def(
|
1065
|
-
[
|
1066
|
-
],
|
1067
|
-
|
1068
|
-
function () {
|
1069
|
-
var flat = function (id) {
|
1070
|
-
return id;
|
1071
|
-
};
|
1072
|
-
|
1073
|
-
var hierarchical = function (id) {
|
1074
|
-
return id.replace(/\./g, '/');
|
1075
|
-
};
|
1076
|
-
|
1077
|
-
var constant = function (name) {
|
1078
|
-
return function () {
|
1079
|
-
return name;
|
1080
|
-
};
|
1081
|
-
};
|
1082
|
-
|
1083
|
-
return {
|
1084
|
-
flat: flat,
|
1085
|
-
hierarchical: hierarchical,
|
1086
|
-
constant: constant
|
1087
|
-
};
|
1088
|
-
}
|
1089
|
-
);
|
1090
|
-
module.api = def(
|
1091
|
-
[
|
1092
|
-
module.runtime
|
1093
|
-
],
|
1094
|
-
|
1095
|
-
function (runtime) {
|
1096
|
-
var delegate = function (method) {
|
1097
|
-
return function () {
|
1098
|
-
return runtime[method].apply(null, arguments);
|
1099
|
-
};
|
1100
|
-
};
|
1101
|
-
|
1102
|
-
return {
|
1103
|
-
define: delegate('define'),
|
1104
|
-
require: delegate('require'),
|
1105
|
-
demand: delegate('demand'),
|
1106
|
-
main: delegate('main'),
|
1107
|
-
load: delegate('load'),
|
1108
|
-
loadscript: delegate('loadscript')
|
1109
|
-
};
|
1110
|
-
}
|
1111
|
-
);
|
1112
|
-
module.util.path = def(
|
1113
|
-
[
|
1114
|
-
],
|
1115
|
-
|
1116
|
-
function () {
|
1117
|
-
var dirname = function (file) {
|
1118
|
-
var normalized = file.replace(/\\/g, '/');
|
1119
|
-
var end = normalized.lastIndexOf('/');
|
1120
|
-
return normalized.substring(0, end);
|
1121
|
-
};
|
1122
|
-
|
1123
|
-
var basename = function (file) {
|
1124
|
-
var normalized = file.replace(/\\/g, '/');
|
1125
|
-
var end = normalized.lastIndexOf('/');
|
1126
|
-
return normalized.substring(end + 1);
|
1127
|
-
};
|
1128
|
-
|
1129
|
-
return {
|
1130
|
-
basename: basename,
|
1131
|
-
dirname: dirname
|
1132
|
-
};
|
1133
|
-
}
|
1134
|
-
);
|
1135
|
-
module.util.locator = def(
|
1136
|
-
[
|
1137
|
-
],
|
1138
|
-
|
1139
|
-
function () {
|
1140
|
-
var browser = function () {
|
1141
|
-
var scripts = document.getElementsByTagName("script");
|
1142
|
-
return scripts[scripts.length - 1].src;
|
1143
|
-
};
|
1144
|
-
|
1145
|
-
var runtime = module.runtime.locate;
|
1146
|
-
|
1147
|
-
var locate = function () {
|
1148
|
-
var f = runtime || browser;
|
1149
|
-
return f();
|
1150
|
-
};
|
1151
|
-
|
1152
|
-
return {
|
1153
|
-
locate: locate
|
1154
|
-
};
|
1155
|
-
}
|
1156
|
-
);
|
1157
|
-
module.util.pather = def(
|
1158
|
-
[
|
1159
|
-
module.util.path
|
1160
|
-
],
|
1161
|
-
|
1162
|
-
function (path) {
|
1163
|
-
var create = function (relativeto) {
|
1164
|
-
var base = path.dirname(relativeto);
|
1165
|
-
return function (path) {
|
1166
|
-
return base + '/' + path;
|
1167
|
-
};
|
1168
|
-
};
|
1169
|
-
|
1170
|
-
return {
|
1171
|
-
create: create
|
1172
|
-
};
|
1173
|
-
}
|
1174
|
-
);module.modulator.modulators = def(
|
1175
|
-
[
|
1176
|
-
ephox.bolt.kernel.fp.functions,
|
1177
|
-
ephox.bolt.kernel.modulator.bolt,
|
1178
|
-
ephox.bolt.loader.api.commonjsevaller,
|
1179
|
-
ephox.bolt.loader.api.scripttag,
|
1180
|
-
ephox.bolt.loader.api.xhrevaller,
|
1181
|
-
ephox.bolt.loader.api.xhrinjector
|
1182
|
-
],
|
1183
|
-
|
1184
|
-
function (fn, bolt, commonjsevaller, scripttag, xhrevaller, xhrinjector) {
|
1185
|
-
var wrap = function (modulator, loader) {
|
1186
|
-
var create = fn.curry(modulator.create, loader);
|
1187
|
-
|
1188
|
-
return {
|
1189
|
-
create: create
|
1190
|
-
}
|
1191
|
-
};
|
1192
|
-
|
1193
|
-
return {
|
1194
|
-
boltcommonjs: wrap(bolt, commonjsevaller),
|
1195
|
-
boltscripttag: wrap(bolt, scripttag),
|
1196
|
-
boltxhreval: wrap(bolt, xhrevaller),
|
1197
|
-
boltxhrinjector: wrap(bolt, xhrinjector)
|
1198
|
-
};
|
1199
|
-
}
|
1200
|
-
);
|
1201
|
-
module.config.builtins = def(
|
1202
|
-
[
|
1203
|
-
ephox.bolt.module.modulator.modulators.boltscripttag,
|
1204
|
-
ephox.bolt.module.modulator.modulators.boltcommonjs
|
1205
|
-
],
|
1206
|
-
|
1207
|
-
function (boltscripttag, boltcommonjs) {
|
1208
|
-
return {
|
1209
|
-
// TODO: 'amd' is maintained for backwards compatibility, will be removed
|
1210
|
-
// at some point.
|
1211
|
-
browser: { bolt: boltscripttag, amd: boltscripttag },
|
1212
|
-
commonjs: { bolt: boltcommonjs, amd: boltcommonjs }
|
1213
|
-
};
|
1214
|
-
}
|
1215
|
-
);
|
1216
|
-
module.config.specs = def(
|
1217
|
-
[
|
1218
|
-
module.util.pather
|
1219
|
-
],
|
1220
|
-
|
1221
|
-
function (pather) {
|
1222
|
-
var type = function (type, implementation) {
|
1223
|
-
return {
|
1224
|
-
type: type,
|
1225
|
-
implementation: implementation,
|
1226
|
-
modulator: implementation + '.Modulator',
|
1227
|
-
compiler: implementation + '.Compiler'
|
1228
|
-
};
|
1229
|
-
};
|
1230
|
-
|
1231
|
-
var source = function (relativeto) {
|
1232
|
-
return function (type /*, args */) {
|
1233
|
-
return {
|
1234
|
-
type: type,
|
1235
|
-
relativeto: relativeto,
|
1236
|
-
args: [ pather.create(relativeto) ].concat(Array.prototype.slice.call(arguments, 1))
|
1237
|
-
};
|
1238
|
-
}
|
1239
|
-
};
|
1240
|
-
|
1241
|
-
return {
|
1242
|
-
type: type,
|
1243
|
-
source: source
|
1244
|
-
};
|
1245
|
-
}
|
1246
|
-
);
|
1247
|
-
module.reader.bouncing = def(
|
1248
|
-
[
|
1249
|
-
ephox.bolt.kernel.fp.array,
|
1250
|
-
module.error.error,
|
1251
|
-
module.config.specs
|
1252
|
-
],
|
1253
|
-
|
1254
|
-
function (ar, error, specs) {
|
1255
|
-
var bounce = function (done, read, acc) {
|
1256
|
-
var next = acc.configs.shift();
|
1257
|
-
read(next.relativeto, next.config, done, acc);
|
1258
|
-
};
|
1259
|
-
|
1260
|
-
var tick = function (file, cfg, done, read, acc) {
|
1261
|
-
var munged = ar.map(cfg.configs || [], function (config) {
|
1262
|
-
return { relativeto: file, config: config };
|
1263
|
-
});
|
1264
|
-
var accumulated = {
|
1265
|
-
sources: acc.sources.concat(cfg.sources || []),
|
1266
|
-
types: acc.types.concat(cfg.types || []),
|
1267
|
-
configs: munged.concat(acc.configs)
|
1268
|
-
};
|
1269
|
-
if (accumulated.configs.length > 0)
|
1270
|
-
bounce(done, read, accumulated);
|
1271
|
-
else
|
1272
|
-
done({ sources: accumulated.sources, types: accumulated.types });
|
1273
|
-
};
|
1274
|
-
|
1275
|
-
/*
|
1276
|
-
* All precedence is depth-first, pre-order. Example:
|
1277
|
-
*
|
1278
|
-
* A
|
1279
|
-
* /-\
|
1280
|
-
* B C
|
1281
|
-
* /| |\
|
1282
|
-
* D E F G
|
1283
|
-
*
|
1284
|
-
* Configs are read in A, B, D, E, C, F, G.
|
1285
|
-
*
|
1286
|
-
* If configs mixed delegation and sources, the
|
1287
|
-
* sources would be ordered the same: A, B, D, E, C, F, G.
|
1288
|
-
*/
|
1289
|
-
|
1290
|
-
var evaluate = function (file, payload, done, read, acc) {
|
1291
|
-
var result = {};
|
1292
|
-
/* eval scope */
|
1293
|
-
var mapper = module.config.mapper;
|
1294
|
-
var type = specs.type;
|
1295
|
-
var source = specs.source(file);
|
1296
|
-
var configure = function (configuration) {
|
1297
|
-
result = configuration;
|
1298
|
-
};
|
1299
|
-
try {
|
1300
|
-
eval(payload);
|
1301
|
-
} catch (e) {
|
1302
|
-
throw 'Could not load configuration [' + file + '], with: ' + e;
|
1303
|
-
}
|
1304
|
-
tick(file, result, done, read, acc);
|
1305
|
-
};
|
1306
|
-
|
1307
|
-
return {
|
1308
|
-
evaluate: evaluate
|
1309
|
-
};
|
1310
|
-
}
|
1311
|
-
);
|
1312
|
-
module.reader.browser = def(
|
1313
|
-
[
|
1314
|
-
module.error.error,
|
1315
|
-
module.reader.bouncing,
|
1316
|
-
module.util.path,
|
1317
|
-
ephox.bolt.loader.transporter.xhr
|
1318
|
-
],
|
1319
|
-
|
1320
|
-
function (error, bouncing, path, xhr) {
|
1321
|
-
var read = function (relativeto, file, done, acc) {
|
1322
|
-
var accumulated = acc || { sources: [], types: [], configs: [] };
|
1323
|
-
var base = path.dirname(relativeto);
|
1324
|
-
var absolute = base + '/' + file;
|
1325
|
-
xhr.request(absolute, function (payload) {
|
1326
|
-
bouncing.evaluate(absolute, payload, done, read, accumulated);
|
1327
|
-
}, error.die);
|
1328
|
-
};
|
1329
|
-
|
1330
|
-
return {
|
1331
|
-
read: read
|
1332
|
-
};
|
1333
|
-
}
|
1334
|
-
);
|
1335
|
-
module.reader.node = def(
|
1336
|
-
[
|
1337
|
-
module.reader.bouncing
|
1338
|
-
],
|
1339
|
-
|
1340
|
-
function (bouncing, path, fs) {
|
1341
|
-
var read = function (relativeto, file, done, acc) {
|
1342
|
-
var fs = require('fs');
|
1343
|
-
var path = require('path');
|
1344
|
-
var accumulated = acc || { sources: [], types: [], configs: [] };
|
1345
|
-
var base = path.dirname(relativeto);
|
1346
|
-
var absolute = path.resolve(base, file);
|
1347
|
-
var payload = fs.readFileSync(absolute, 'UTF-8');
|
1348
|
-
bouncing.evaluate(absolute, payload, done, read, accumulated);
|
1349
|
-
};
|
1350
|
-
|
1351
|
-
return {
|
1352
|
-
read: read
|
1353
|
-
};
|
1354
|
-
}
|
1355
|
-
);
|
1356
|
-
module.reader.direct = def(
|
1357
|
-
[
|
1358
|
-
],
|
1359
|
-
|
1360
|
-
function () {
|
1361
|
-
var create = function (configuration) {
|
1362
|
-
return function (done) {
|
1363
|
-
done({
|
1364
|
-
sources: configuration.sources || [],
|
1365
|
-
types: configuration.types || [],
|
1366
|
-
configs: configuration.configs || []
|
1367
|
-
});
|
1368
|
-
};
|
1369
|
-
};
|
1370
|
-
|
1371
|
-
return {
|
1372
|
-
create: create
|
1373
|
-
};
|
1374
|
-
}
|
1375
|
-
);
|
1376
|
-
module.bootstrap.configloader = def(
|
1377
|
-
[
|
1378
|
-
module.util.locator,
|
1379
|
-
module.reader.browser
|
1380
|
-
],
|
1381
|
-
|
1382
|
-
function (locator, browser) {
|
1383
|
-
var create = function (file) {
|
1384
|
-
var script = locator.locate();
|
1385
|
-
return function (done) {
|
1386
|
-
browser.read(script, file, done);
|
1387
|
-
};
|
1388
|
-
};
|
1389
|
-
|
1390
|
-
return {
|
1391
|
-
create: create
|
1392
|
-
};
|
1393
|
-
}
|
1394
|
-
);module.bootstrap.deferred = def(
|
1395
|
-
[
|
1396
|
-
ephox.bolt.kernel.fp.array
|
1397
|
-
],
|
1398
|
-
|
1399
|
-
function (ar) {
|
1400
|
-
var deferred = [];
|
1401
|
-
|
1402
|
-
var require = function (ids, fn) {
|
1403
|
-
var r = function (real) {
|
1404
|
-
real(ids, fn);
|
1405
|
-
};
|
1406
|
-
deferred.push(r);
|
1407
|
-
};
|
1408
|
-
|
1409
|
-
var configured = function (require) {
|
1410
|
-
ar.each(deferred, function (action) {
|
1411
|
-
action(require);
|
1412
|
-
});
|
1413
|
-
deferred = [];
|
1414
|
-
};
|
1415
|
-
|
1416
|
-
return {
|
1417
|
-
require: require,
|
1418
|
-
configured: configured
|
1419
|
-
};
|
1420
|
-
}
|
1421
|
-
);
|
1422
|
-
module.bootstrap.main = def(
|
1423
|
-
[
|
1424
|
-
ephox.bolt.kernel.api.config,
|
1425
|
-
module.bootstrap.deferred,
|
1426
|
-
module.runtime
|
1427
|
-
],
|
1428
|
-
|
1429
|
-
function (config, deferred, runtime) {
|
1430
|
-
var main = function (id, args, configids, callback) {
|
1431
|
-
runtime.require(configids || [], function () {
|
1432
|
-
callback && callback.apply(null, arguments);
|
1433
|
-
runtime.require([ id ], function (module) {
|
1434
|
-
module.apply(null, args || []);
|
1435
|
-
});
|
1436
|
-
});
|
1437
|
-
};
|
1438
|
-
|
1439
|
-
return {
|
1440
|
-
main: main
|
1441
|
-
};
|
1442
|
-
}
|
1443
|
-
);
|
1444
|
-
module.bootstrap.install = def(
|
1445
|
-
[
|
1446
|
-
ephox.bolt.kernel.api.config,
|
1447
|
-
module.bootstrap.deferred,
|
1448
|
-
module.bootstrap.main,
|
1449
|
-
module.runtime,
|
1450
|
-
module.error.error
|
1451
|
-
],
|
1452
|
-
|
1453
|
-
function (config, deferred, main, runtime, error) {
|
1454
|
-
var notready = function () { throw 'bolt not initialised, can not call define or demand, did you mean to use require or main?'; };
|
1455
|
-
|
1456
|
-
var install = function (reader, builtins, load, loadscript) {
|
1457
|
-
runtime.define = notready;
|
1458
|
-
runtime.demand = notready;
|
1459
|
-
runtime.require = deferred.require;
|
1460
|
-
runtime.main = main.main;
|
1461
|
-
runtime.load = load;
|
1462
|
-
runtime.loadscript = loadscript;
|
1463
|
-
|
1464
|
-
reader(function (configuration) {
|
1465
|
-
var bolt = config.configure(configuration, builtins, error.die);
|
1466
|
-
runtime.define = bolt.define;
|
1467
|
-
runtime.require = bolt.require;
|
1468
|
-
runtime.demand = bolt.demand;
|
1469
|
-
|
1470
|
-
deferred.configured(runtime.require);
|
1471
|
-
});
|
1472
|
-
};
|
1473
|
-
|
1474
|
-
return {
|
1475
|
-
install: install
|
1476
|
-
};
|
1477
|
-
}
|
1478
|
-
);
|
1479
|
-
|
1480
|
-
})(Function('return this')());
|
1481
|
-
(function (global) {
|
1482
|
-
var obj = ephox.bolt.kernel.fp.object;
|
1483
|
-
var api = ephox.bolt.module.api;
|
1484
|
-
var builtins = ephox.bolt.module.config.builtins.browser;
|
1485
|
-
var install = ephox.bolt.module.bootstrap.install;
|
1486
|
-
var reader = ephox.bolt.module.bootstrap.configloader.create("prod.js");
|
1487
|
-
var transport = ephox.bolt.loader.transporter.xhr.request;
|
1488
|
-
var script = ephox.bolt.loader.api.scripttag.load;
|
1489
|
-
install.install(reader, builtins, transport, script);
|
1490
|
-
obj.merge(global, api);
|
1491
|
-
})(Function("return this;")());
|