PageSourceSearch

https://www.ami.ca/profiles/ami/themes/custom/corp2026/static/infu…/framework/preferences/js/Builder.js?v=1.x

js ami.ca collected 2026-09-24 17:55:18 UTC 10,038 bytes, 253 lines download raw bytes

1/*
2Copyright The Infusion copyright holders
3See the AUTHORS.md file at the top-level directory of this distribution and at
4https://github.com/fluid-project/infusion/raw/master/AUTHORS.md.
5
6Licensed under the Educational Community License (ECL), Version 2.0 or the New
7BSD license. You may not use this file except in compliance with one these
8Licenses.
9
10You may obtain a copy of the ECL 2.0 License and BSD License at
11https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
12*/
13
14var fluid_3_0_0 = fluid_3_0_0 || {};
15
16
17(function ($, fluid) {
18    "use strict";
19
20    fluid.registerNamespace("fluid.prefs");
21
22    fluid.defaults("fluid.prefs.builder", {
23        gradeNames: ["fluid.component", "fluid.prefs.auxBuilder"],
24        mergePolicy: {
25            auxSchema: "expandedAuxSchema"
26        },
27        assembledPrefsEditorGrade: {
28            expander: {
29                func: "fluid.prefs.builder.generateGrade",
30                args: ["prefsEditor", "{that}.options.auxSchema.namespace", {
31                    gradeNames: ["fluid.prefs.assembler.prefsEd", "fluid.viewComponent"],
32                    componentGrades: "{that}.options.constructedGrades",
33                    loaderGrades: "{that}.options.auxSchema.loaderGrades",
34                    defaultLocale: "{that}.options.auxSchema.defaultLocale",
35                    enhancer: {
36                        defaultLocale: "{that}.options.auxSchema.defaultLocale"
37                    }
38                }]
39            }
40        },
41        assembledUIEGrade: {
42            expander: {
43                func: "fluid.prefs.builder.generateGrade",
44                args: ["uie", "{that}.options.auxSchema.namespace", {
45                    gradeNames: ["fluid.viewComponent", "fluid.prefs.assembler.uie"],
46                    componentGrades: "{that}.options.constructedGrades"
47                }]
48            }
49        },
50        constructedGrades: {
51            expander: {
52                func: "fluid.prefs.builder.constructGrades",
53                args: [
54                    "{that}.options.auxSchema",
55                    [
56                        "enactors",
57                        "messages",
58                        "panels",
59                        "initialModel",
60                        "templateLoader",
61                        "messageLoader",
62                        "terms",
63                        "aliases_prefsEditor",
64                        "aliases_enhancer"
65                    ]
66                ]
67            }
68        },
69        mappedDefaults: "{primaryBuilder}.options.schema.properties",
70        components: {
71            primaryBuilder: {
72                type: "fluid.prefs.primaryBuilder",
73                options: {
74                    typeFilter: {
75                        expander: {
76                            func: "fluid.prefs.builder.parseAuxSchema",
77                            args: "{builder}.options.auxiliarySchema"
78                        }
79                    }
80                }
81            }
82        },
83        distributeOptions: {
84            "builder.primaryBuilder.primarySchema": {
85                source: "{that}.options.primarySchema",
86                removeSource: true,
87                target: "{that > primaryBuilder}.options.primarySchema"
88            }
89        }
90    });
91
92    fluid.defaults("fluid.prefs.assembler.uie", {
93        gradeNames: ["fluid.viewComponent"],
94        components: {
95            // These two components become global
96            store: {
97                type: "fluid.prefs.globalSettingsStore",
98                options: {
99                    distributeOptions: {
100                        "uie.store.context.checkUser": {
101                            target: "{that fluid.prefs.store}.options.contextAwareness.strategy.checks.user",
102                            record: {
103                                contextValue: "{fluid.prefs.assembler.uie}.options.storeType",
104                                gradeNames: "{fluid.prefs.assembler.uie}.options.storeType"
105                            }
106                        }
107                    }
108                }
109            },
110            enhancer: {
111                type: "fluid.component",
112                options: {
113                    gradeNames: "{that}.options.enhancerType",
114                    enhancerType: "fluid.pageEnhancer",
115                    components: {
116                        uiEnhancer: {
117                            options: {
118                                gradeNames: [
119                                    "{fluid.prefs.assembler.uie}.options.componentGrades.enactors",
120                                    "{fluid.prefs.assembler.prefsEd}
120.options.componentGrades.aliases_enhancer"
121                                ]
122                            }
123                        }
124                    }
125                }
126            }
127        },
128        distributeOptions: {
129            "uie.enhancer": {
130                source: "{that}.options.enhancer",
131                target: "{that uiEnhancer}.options",
132                removeSource: true
133            },
134            "uie.enhancer.enhancerType": {
135                source: "{that}.options.enhancerType",
136                target: "{that > enhancer}.options.enhancerType"
137            },
138            "uie.store": { // TODO: not clear that this hits anything since settings store is not a subcomponent
139                source: "{that}.options.store",
140                target: "{that fluid.prefs.store}.options"
141            }
142        }
143    });
144
145    fluid.defaults("fluid.prefs.assembler.prefsEd", {
146        gradeNames: ["fluid.viewComponent", "fluid.prefs.assembler.uie"],
147        components: {
148            prefsEditorLoader: {
149                type: "fluid.viewComponent",
150                container: "{fluid.prefs.assembler.prefsEd}.container",
151                priority: "last",
152                options: {
153                    gradeNames: [
154                        "{fluid.prefs.assembler.prefsEd}.options.componentGrades.terms",
155                        "{fluid.prefs.assembler.prefsEd}.options.componentGrades.messages",
156                        "{fluid.prefs.assembler.prefsEd}.options.componentGrades.initialModel",
157                        "{that}.options.loaderGrades"
158                    ],
159                    templateLoader: {
160                        gradeNames: ["{fluid.prefs.assembler.prefsEd}.options.componentGrades.templateLoader"]
161                    },
162                    messageLoader: {
163                        gradeNames: ["{fluid.prefs.assembler.prefsEd}.options.componentGrades.messageLoader"]
164                    },
165                    prefsEditor: {
166                        gradeNames: [
167                            "{fluid.prefs.assembler.prefsEd}.options.componentGrades.panels",
168                            "{fluid.prefs.assembler.prefsEd}.options.componentGrades.aliases_prefsEditor",
169                            "fluid.prefs.uiEnhancerRelay"
170                        ]
171                    },
172                    events: {
173                        onReady: "{fluid.prefs.assembler.prefsEd}.events.onPrefsEditorReady"
174                    }
175                }
176            }
177        },
178        events: {
179            onPrefsEditorReady: null,
180            onReady: {
181                events: {
182                    onPrefsEditorReady: "onPrefsEditorReady",
183                    onCreate: "onCreate"
184                },
185                args: ["{that}"]
186            }
187        },
188        distributeOptions: {
189            "prefsEdAssembler.prefsEditorLoader.loaderGrades": {
190                source: "{that}.options.loaderGrades",
191                removeSource: true,
192                target: "{that > prefsEditorLoader}.options.loaderGrades"
193            },
194            "prefsEdAssembler.prefsEditorLoader.terms": {
195                source: "{that}.options.terms",
196                removeSource: true,
197                target: "{that prefsEditorLoader}.options.terms"
198            },
199            "prefsEdAssembler.prefsEditorLoader.defaultLocale": {
200                source: "{that}.options.defaultLocale",
201                target: "{that prefsEditorLoader}.options.defaultLocale"
202            },
203            "prefsEdAssembler.uiEnhancer.defaultLocale": {
204                source: "{that}.options.defaultLocale",
205                target: "{that uiEnhancer}.options.defaultLocale"
206            },
207            "prefsEdAssembler.prefsEditor": {
208                source: "{that}.options.prefsEditor",
209                removeSource: true,
210                target: "{that prefsEditor}.options"
211            }
212        }
213    });
214
215    fluid.prefs.builder.generateGrade = function (name, namespace, options) {
216        var gradeNameTemplate = "%namespace.%name";
217        var gradeName = fluid.stringTemplate(gradeNameTemplate, {name: name, namespace: namespace});
218        fluid.defaults(gradeName, options);
219        return gradeName;
220    };
221
222    fluid.prefs.builder.constructGrades = function (auxSchema, gradeCategories) {
223        var constructedGrades = {};
224        fluid.each(gradeCategories, function (category) {
225            var gradeOpts = auxSchema[category];
226            if (fluid.get(gradeOpts, "gradeNames")) {
227                constructedGrades[category] = fluid.prefs.builder.generateGrade(category, auxSchema.namespace, gradeOpts);
228            }
229        });
230        return constructedGrades;
231    };
232
233    fluid.prefs.builder.parseAuxSchema = function (auxSchema) {
234        var auxTypes = [];
235        fluid.each(auxSchema, function parse(field) {
236            var type = field.type;
237            if (type) {
238                auxTypes.push(type);
239            }
240        });
241        return auxTypes;
242    };
243
244    /*
245     * A one-stop-shop function to build and instantiate a prefsEditor from a schema.
246     */
247    fluid.prefs.create = function (container, options) {
248        options = options || {};
249        var builder = fluid.prefs.builder(options.build);
250        return fluid.invokeGlobalFunction(builder.options.assembledPrefsEditorGrade, [container, options.prefsEditor]);
251    };
252
253})(jQuery, fluid_3_0_0);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.