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 217 218 219 220 221 | 11x 11x 11x 11x 11x 11x 11x 315x 315x 315x 315x 11x 48x 48x 321x 321x 222x 48x 11x 48x 48x 366x 366x 156x 48x 11x 6x 6x 6x | /* Copyright 2013-2015 OCAD University Copyright 2015-2016 Raising the Floor - International 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 */ var fluid_3_0_0 = fluid_3_0_0 || {}; (function ($, fluid) { "use strict"; fluid.registerNamespace("fluid.prefs"); fluid.defaults("fluid.prefs.builder", { gradeNames: ["fluid.component", "fluid.prefs.auxBuilder"], mergePolicy: { auxSchema: "expandedAuxSchema" }, assembledPrefsEditorGrade: { expander: { func: "fluid.prefs.builder.generateGrade", args: ["prefsEditor", "{that}.options.auxSchema.namespace", { gradeNames: ["fluid.prefs.assembler.prefsEd", "fluid.viewComponent"], componentGrades: "{that}.options.constructedGrades", loaderGrades: "{that}.options.auxSchema.loaderGrades" }] } }, assembledUIEGrade: { expander: { func: "fluid.prefs.builder.generateGrade", args: ["uie", "{that}.options.auxSchema.namespace", { gradeNames: ["fluid.viewComponent", "fluid.prefs.assembler.uie"], componentGrades: "{that}.options.constructedGrades" }] } }, constructedGrades: { expander: { func: "fluid.prefs.builder.constructGrades", args: ["{that}.options.auxSchema", ["enactors", "messages", "panels", "initialModel", "templateLoader", "messageLoader", "terms"]] } }, mappedDefaults: "{primaryBuilder}.options.schema.properties", components: { primaryBuilder: { type: "fluid.prefs.primaryBuilder", options: { typeFilter: { expander: { func: "fluid.prefs.builder.parseAuxSchema", args: "{builder}.options.auxiliarySchema" } } } } }, distributeOptions: { "builder.primaryBuilder.primarySchema": { source: "{that}.options.primarySchema", removeSource: true, target: "{that > primaryBuilder}.options.primarySchema" } } }); fluid.defaults("fluid.prefs.assembler.uie", { gradeNames: ["fluid.viewComponent"], components: { // These two components become global store: { type: "fluid.prefs.globalSettingsStore", options: { distributeOptions: { "uie.store.context.checkUser": { target: "{that fluid.prefs.store}.options.contextAwareness.strategy.checks.user", record: { contextValue: "{fluid.prefs.assembler.uie}.options.storeType", gradeNames: "{fluid.prefs.assembler.uie}.options.storeType" } } } } }, enhancer: { type: "fluid.component", options: { gradeNames: "{that}.options.enhancerType", enhancerType: "fluid.pageEnhancer", components: { uiEnhancer: { options: { gradeNames: ["{fluid.prefs.assembler.uie}.options.componentGrades.enactors"] } } } } } }, distributeOptions: { "uie.enhancer": { source: "{that}.options.enhancer", target: "{that uiEnhancer}.options", removeSource: true }, "uie.enhancer.enhancerType": { source: "{that}.options.enhancerType", target: "{that > enhancer}.options.enhancerType" }, "uie.store": { // TODO: not clear that this hits anything since settings store is not a subcomponent source: "{that}.options.store", target: "{that fluid.prefs.store}.options" } } }); fluid.defaults("fluid.prefs.assembler.prefsEd", { gradeNames: ["fluid.viewComponent", "fluid.prefs.assembler.uie"], components: { prefsEditorLoader: { type: "fluid.viewComponent", container: "{fluid.prefs.assembler.prefsEd}.container", priority: "last", options: { gradeNames: [ "{fluid.prefs.assembler.prefsEd}.options.componentGrades.terms", "{fluid.prefs.assembler.prefsEd}.options.componentGrades.messages", "{fluid.prefs.assembler.prefsEd}.options.componentGrades.initialModel", "{that}.options.loaderGrades" ], templateLoader: { gradeNames: ["{fluid.prefs.assembler.prefsEd}.options.componentGrades.templateLoader"] }, messageLoader: { gradeNames: ["{fluid.prefs.assembler.prefsEd}.options.componentGrades.messageLoader"] }, prefsEditor: { gradeNames: ["{fluid.prefs.assembler.prefsEd}.options.componentGrades.panels", "fluid.prefs.uiEnhancerRelay"] }, events: { onReady: "{fluid.prefs.assembler.prefsEd}.events.onPrefsEditorReady" } } } }, events: { onPrefsEditorReady: null, onReady: { events: { onPrefsEditorReady: "onPrefsEditorReady", onCreate: "onCreate" }, args: ["{that}"] } }, distributeOptions: { "prefsEdAssembler.prefsEditorLoader.loaderGrades": { source: "{that}.options.loaderGrades", removeSource: true, target: "{that > prefsEditorLoader}.options.loaderGrades" }, "prefsEdAssembler.prefsEditorLoader.terms": { source: "{that}.options.terms", removeSource: true, target: "{that prefsEditorLoader}.options.terms" }, "prefsEdAssembler.prefsEditor": { source: "{that}.options.prefsEditor", removeSource: true, target: "{that prefsEditor}.options" } } }); fluid.prefs.builder.generateGrade = function (name, namespace, options) { var gradeNameTemplate = "%namespace.%name"; var gradeName = fluid.stringTemplate(gradeNameTemplate, {name: name, namespace: namespace}); fluid.defaults(gradeName, options); return gradeName; }; fluid.prefs.builder.constructGrades = function (auxSchema, gradeCategories) { var constructedGrades = {}; fluid.each(gradeCategories, function (category) { var gradeOpts = auxSchema[category]; if (fluid.get(gradeOpts, "gradeNames")) { constructedGrades[category] = fluid.prefs.builder.generateGrade(category, auxSchema.namespace, gradeOpts); } }); return constructedGrades; }; fluid.prefs.builder.parseAuxSchema = function (auxSchema) { var auxTypes = []; fluid.each(auxSchema, function parse(field) { var type = field.type; if (type) { auxTypes.push(type); } }); return auxTypes; }; /* * A one-stop-shop function to build and instantiate a prefsEditor from a schema. */ fluid.prefs.create = function (container, options) { options = options || {}; var builder = fluid.prefs.builder(options.build); return fluid.invokeGlobalFunction(builder.options.assembledPrefsEditorGrade, [container, options.prefsEditor]); }; })(jQuery, fluid_3_0_0); |