-
Notifications
You must be signed in to change notification settings - Fork 97
/
UploaderCompatibility-Infusion1.3.js
87 lines (69 loc) · 3.1 KB
/
UploaderCompatibility-Infusion1.3.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
/*
Copyright 2011 OCAD University
Licensed under the Educational Community License (ECL), Version 2.0 or the New
BSD license. You may not use this file except in compliance with one these
Licenses.
You may obtain a copy of the ECL 2.0 License and BSD License at
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
*/
// Declare dependencies
/*global fluid_1_5:true*/
// JSLint options
/*jslint white: true, funcinvoke: true, undef: true, newcap: true, nomen: true, regexp: true, bitwise: true, browser: true, forin: true, maxerr: 100, indent: 4 */
var fluid_1_5 = fluid_1_5 || {};
/**************************************************************************************
* Note: this file should not be included in the InfusionAll build. *
* Instead, users should add this file manually if backwards compatibility is needed. *
**************************************************************************************/
(function (fluid) {
fluid.registerNamespace("fluid.compat.fluid_1_3.uploader");
fluid.enhance.check({"fluid.uploader.fluid_1_3" : true});
fluid.compat.fluid_1_3.uploader.fileTypeTransformer = function (val) {
var mimeTypeMap = fluid.uploader.mimeTypeRegistry;
if (fluid.isArrayable(val) || typeof (val) !== "string") {
return val;
}
var exts = val.split(";");
if (exts.length === 0) {
return undefined;
}
var mimeTypes = [];
fluid.each(exts, function (ext) {
ext = ext.substring(2);
var mimeType = mimeTypeMap[ext];
if (mimeType) {
mimeTypes.push(mimeType);
}
});
return mimeTypes;
};
fluid.compat.fluid_1_3.uploader.optionsRules = {
// TODO: Remove these when model transformation can handle additive transformations.
"gradeNames": "gradeNames",
"components": "components",
"invokers": "invokers",
"queueSettings": "queueSettings",
"demo": "demo",
"selectors": "selectors",
"focusWithEvent": "focusWithEvent",
"styles": "styles",
"events": "events",
"listeners": "listeners",
"strings": "strings",
"mergePolicy": "mergePolicy",
"queueSettings.fileTypes": {
transform: {
type: "fluid.compat.fluid_1_3.uploader.fileTypeTransformer",
inputPath: "queueSettings.fileTypes"
}
}
};
fluid.demands("fluid.uploader", "fluid.uploader.fluid_1_3", {
options: fluid.transformOne(fluid.compat.fluid_1_3.uploader.optionsRules)
});
// TODO: In theory, this could be done with a mergePolicy on "transformOptions", if only we could ensure a scheme
// for ordering fluid_1_2.uploader before fluid_1_3.uploader in the sequence
fluid.demands("fluid.uploader", ["fluid.uploader.fluid_1_2", "fluid.uploader.fluid_1_3"], {
options: fluid.transformMany([fluid.compat.fluid_1_2.uploader.optionsRules, fluid.compat.fluid_1_3.uploader.optionsRules])
});
})(fluid_1_5);