# HG changeset patch # User hamidouk # Date 1329236876 -3600 # Node ID b9dd62e35e304c94f19e1b6397e40bdb5bfc437d # Parent 85a278e12495ae6722a1ce88d49220c6995cf677 less useless code - required widgets now support defaultOptions too. diff -r 85a278e12495 -r b9dd62e35e30 src/js/init.js --- a/src/js/init.js Tue Feb 14 17:15:13 2012 +0100 +++ b/src/js/init.js Tue Feb 14 17:27:56 2012 +0100 @@ -150,8 +150,7 @@ var index; for (index = 0; index < guiOptions.widgets.length; index++) { - var widgetConfig = IriSP.underscore.defaults(guiOptions.widgets[index], default_options); - var widget = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, widgetConfig); + var widget = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, guiOptions.widgets[index], default_options); ret_widgets.push(widget); }; @@ -185,8 +184,14 @@ @param serialFactory serializer factory to instantiate the widget with @param layoutManager layout manager @param widgetConfig configuration options for the widget + @param defaultOptions a dictionnary with some options defined for every widget. */ -IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig) { +IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig, defaultOptions) { + + if (IriSP.null_or_undefined(defaultOptions)) + defaultOptions = {}; + + widgetConfig = IriSP.underscore.defaults(widgetConfig, defaultOptions); var arr = IriSP.jQuery.extend({}, widgetConfig); @@ -216,7 +221,7 @@ var i = 0; for(i = 0; i < widgetConfig.requires.length; i++) { var widgetName = widgetConfig.requires[i]["type"]; - widget[widgetName] = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, widgetConfig.requires[i]); + widget[widgetName] = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, widgetConfig.requires[i], defaultOptions); } } diff -r 85a278e12495 -r b9dd62e35e30 test/integration/polemic.htm --- a/test/integration/polemic.htm Tue Feb 14 17:15:13 2012 +0100 +++ b/test/integration/polemic.htm Tue Feb 14 17:27:56 2012 +0100 @@ -42,9 +42,6 @@ type: "TooltipWidget", width: 180, heigh: 160, - metadata : { - type:'empty' - } }], }, {type: "SparklineWidget", @@ -59,9 +56,6 @@ type: "TooltipWidget", width: 180, heigh: 160, - metadata : { - type:'empty' - } }], }, {type: "SliceWidget"},