--- a/src/js/init.js Fri Jan 27 17:27:48 2012 +0100
+++ b/src/js/init.js Mon Jan 30 16:23:55 2012 +0100
@@ -207,3 +207,48 @@
serializer.sync(IriSP.wrap(widget, function() { this.draw(); }));
return widget;
};
+
+/** Go through the defaults to set a reasonable value */
+IriSP.configureDefaults = function(libdir, platform_url) {
+ /* the defaults configuration is messy and complicated. There are two things to know :
+ - we want to allow overwriting of defaults - that's why we have IriSP.widgetDefaults
+ and IriSP.defaults.widgetDefaults. The first is filled by the embedder and then fleshed out
+ with the contents of the first. We use underscore.defaults for that, but there's one problem with
+ this function : it doesn't work recursively.
+ - we need to compute some values at runtime instead of at compile time
+ */
+
+ IriSP.lib = IriSP.underscore.defaults(IriSP.lib, IriSP.defaults.lib(libdir));
+
+ /* get the factory defaults for the widgets and merge them with the default the user
+ may have defined
+ */
+ var factory_defaults = IriSP.defaults.widgetsDefaults(platform_url);
+ for(var widget in factory_defaults) {
+
+ /* create the object if it doesn't exists */
+ if (IriSP.null_or_undefined(IriSP.widgetsDefaults[widget]))
+ IriSP.widgetsDefaults[widget] = {};
+
+ IriSP.widgetsDefaults[widget] = IriSP.underscore.defaults(IriSP.widgetsDefaults[widget], factory_defaults[widget]);
+ }
+
+ IriSP.paths = IriSP.underscore.defaults(IriSP.paths, IriSP.defaults.paths);
+ IriSP.default_templates_vars = IriSP.underscore.defaults(IriSP.default_templates_vars,
+ IriSP.defaults.default_templates_vars());
+};
+
+/** single point of entry for the metadataplayer */
+IriSP.initPlayer = function(config, metadata_url, libdir, platform_url) {
+ IriSP.configureDefaults(libdir, platform_url);
+ IriSP.loadLibs(IriSP.lib, config, metadata_url,
+ function() {
+
+ var layoutManager = new IriSP.LayoutManager(config.gui);
+
+ var pop = IriSP.configurePopcorn(layoutManager, config.player);
+
+ var widgets = IriSP.configureWidgets(pop, layoutManager, config.gui);
+ var modules = IriSP.configureModules(pop, config.modules);
+ });
+};
\ No newline at end of file