src/js/init.js
branchpopcorn-port
changeset 743 69a9969daa41
parent 707 1ebfd2a7366b
child 756 f971fb0f2a3e
child 767 645d06da3d5b
equal deleted inserted replaced
741:9925bc81b8a8 743:69a9969daa41
   205     }       
   205     }       
   206      
   206      
   207     serializer.sync(IriSP.wrap(widget, function() { this.draw(); }));
   207     serializer.sync(IriSP.wrap(widget, function() { this.draw(); }));
   208     return widget;
   208     return widget;
   209 };
   209 };
       
   210 
       
   211 /** Go through the defaults to set a reasonable value */
       
   212 IriSP.configureDefaults = function(libdir, platform_url) {
       
   213   /* the defaults configuration is messy and complicated. There are two things to know :
       
   214      - we want to allow overwriting of defaults - that's why we have IriSP.widgetDefaults
       
   215        and IriSP.defaults.widgetDefaults. The first is filled by the embedder and then fleshed out
       
   216        with the contents of the first. We use underscore.defaults for that, but there's one problem with
       
   217        this function : it doesn't work recursively.
       
   218      - we need to compute some values at runtime instead of at compile time
       
   219   */
       
   220     
       
   221   IriSP.lib = IriSP.underscore.defaults(IriSP.lib, IriSP.defaults.lib(libdir));
       
   222   
       
   223   /* get the factory defaults for the widgets and merge them with the default the user
       
   224      may have defined 
       
   225   */
       
   226   var factory_defaults = IriSP.defaults.widgetsDefaults(platform_url);
       
   227   for(var widget in factory_defaults) {
       
   228   
       
   229       /* create the object if it doesn't exists */
       
   230       if (IriSP.null_or_undefined(IriSP.widgetsDefaults[widget]))
       
   231         IriSP.widgetsDefaults[widget] = {};
       
   232         
       
   233       IriSP.widgetsDefaults[widget] = IriSP.underscore.defaults(IriSP.widgetsDefaults[widget], factory_defaults[widget]);
       
   234   }
       
   235   
       
   236   IriSP.paths = IriSP.underscore.defaults(IriSP.paths, IriSP.defaults.paths);
       
   237   IriSP.default_templates_vars = IriSP.underscore.defaults(IriSP.default_templates_vars, 
       
   238                                        IriSP.defaults.default_templates_vars());
       
   239 };
       
   240 
       
   241 /** single point of entry for the metadataplayer */
       
   242 IriSP.initPlayer = function(config, metadata_url, libdir, platform_url) {
       
   243     IriSP.configureDefaults(libdir, platform_url);
       
   244     IriSP.loadLibs(IriSP.lib, config, metadata_url,
       
   245       function() {   
       
   246               
       
   247               var layoutManager = new IriSP.LayoutManager(config.gui);
       
   248 
       
   249               var pop = IriSP.configurePopcorn(layoutManager, config.player);
       
   250               
       
   251               var widgets = IriSP.configureWidgets(pop, layoutManager, config.gui); 
       
   252               var modules = IriSP.configureModules(pop, config.modules); 
       
   253       });
       
   254 };