238 |
238 |
239 serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); |
239 serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); |
240 return widget; |
240 return widget; |
241 }; |
241 }; |
242 |
242 |
243 /** Go through the defaults to set a reasonable value */ |
|
244 IriSP.configureDefaults = function(libdir, platform_url) { |
|
245 /* the defaults configuration is messy and complicated. There are two things to know : |
|
246 - we want to allow overwriting of defaults - that's why we have IriSP.widgetDefaults |
|
247 and IriSP.defaults.widgetDefaults. The first is filled by the embedder and then fleshed out |
|
248 with the contents of the first. We use underscore.defaults for that, but there's one problem with |
|
249 this function : it doesn't work recursively. |
|
250 - we need to compute some values at runtime instead of at compile time |
|
251 */ |
|
252 |
|
253 IriSP.lib = IriSP.underscore.defaults(IriSP.lib, IriSP.defaults.lib(libdir)); |
|
254 |
|
255 /* get the factory defaults for the widgets and merge them with the default the user |
|
256 may have defined |
|
257 */ |
|
258 var factory_defaults = IriSP.defaults.widgetsDefaults(platform_url); |
|
259 for(var widget in factory_defaults) { |
|
260 |
|
261 /* create the object if it doesn't exists */ |
|
262 if (IriSP.null_or_undefined(IriSP.widgetsDefaults[widget])) |
|
263 IriSP.widgetsDefaults[widget] = {}; |
|
264 |
|
265 IriSP.widgetsDefaults[widget] = IriSP.underscore.defaults(IriSP.widgetsDefaults[widget], factory_defaults[widget]); |
|
266 } |
|
267 |
|
268 IriSP.paths = IriSP.underscore.defaults(IriSP.paths, IriSP.defaults.paths); |
|
269 IriSP.default_templates_vars = IriSP.underscore.defaults(IriSP.default_templates_vars, |
|
270 IriSP.defaults.default_templates_vars()); |
|
271 |
|
272 if (IriSP.null_or_undefined(IriSP.user)) |
|
273 IriSP.user = {}; |
|
274 |
|
275 IriSP.user = IriSP.underscore.defaults(IriSP.user, IriSP.defaults.user()); |
|
276 }; |
|
277 |
|
278 /** single point of entry for the metadataplayer */ |
243 /** single point of entry for the metadataplayer */ |
279 IriSP.initPlayer = function(config, metadata_url, libdir, platform_url) { |
244 IriSP.initPlayer = function(config, metadata_url) { |
280 document.getElementById(config.gui.container).innerHTML = IriSP.templToHTML(IriSP.loading_template, config.gui); |
245 document.getElementById(config.gui.container).innerHTML = IriSP.templToHTML(IriSP.loading_template, config.gui); |
281 IriSP.configureDefaults(libdir, platform_url); |
246 IriSP.loadLibs(config, metadata_url, |
282 IriSP.loadLibs(IriSP.lib, config, metadata_url, |
|
283 function() { |
247 function() { |
284 |
248 |
285 var layoutManager = new IriSP.LayoutManager(config.gui); |
249 var layoutManager = new IriSP.LayoutManager(config.gui); |
286 |
250 |
287 var pop = IriSP.configurePopcorn(layoutManager, config.player); |
251 var pop = IriSP.configurePopcorn(layoutManager, config.player); |
288 |
252 |
289 var widgets = IriSP.configureWidgets(pop, layoutManager, config.gui); |
253 IriSP._widgets = IriSP.configureWidgets(pop, layoutManager, config.gui); |
290 var modules = IriSP.configureModules(pop, config.modules); |
254 IriSP._modules = IriSP.configureModules(pop, config.modules); |
291 IriSP.jQuery('#Ldt-loader').detach(); |
255 IriSP.jQuery('#Ldt-loader').detach(); |
292 }); |
256 }); |
293 }; |
257 }; |