less useless code - required widgets now support defaultOptions too.
--- 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);
}
}
--- 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"},