51 return ret_widgets; |
51 return ret_widgets; |
52 }; |
52 }; |
53 |
53 |
54 IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig) { |
54 IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig) { |
55 var container = layoutManager.createDiv(); |
55 var container = layoutManager.createDiv(); |
56 var arr = IriSP.jQuery.extend({}, widget); |
56 var arr = IriSP.jQuery.extend({}, widgetConfig); |
57 arr.container = container; |
57 arr.container = container; |
58 |
58 |
59 var serializer = serialFactory.getSerializer(widgetConfig.metadata); |
59 var serializer = serialFactory.getSerializer(widgetConfig.metadata); |
60 |
60 |
|
61 if (typeof serializer == "undefined") |
|
62 debugger; |
|
63 |
61 // instantiate the object passed as a string |
64 // instantiate the object passed as a string |
62 var widget = new IriSP[widgetConfig.type](popcornInstance, arr, serializer); |
65 var widget = new IriSP[widgetConfig.type](popcornInstance, arr, serializer); |
63 |
66 |
64 if (widgetConfig.hasOwnProperty("requires")) { |
67 if (widgetConfig.hasOwnProperty("requires")) { |
65 // also create the widgets this one depends on. |
68 // also create the widgets this one depends on. |
66 // the dependency widget is available in the parent widget context as |
69 // the dependency widget is available in the parent widget context as |
67 // this.WidgetName (for instance, this.TipWidget); |
70 // this.WidgetName (for instance, this.TipWidget); |
68 |
71 |
69 for(var j in widgetConfig.requires) { |
72 var i = 0; |
70 var widgetName = widgetConfig.requires[j]["type"]; |
73 for(i = 0; i < widgetConfig.requires.length; i++) { |
71 widget[widgetName] = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, widgetConfig.requires[j]); |
74 var widgetName = widgetConfig.requires[i]["type"]; |
|
75 widget[widgetName] = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, widgetConfig.requires[i]); |
72 } |
76 } |
73 } |
77 } |
74 |
78 |
75 serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); |
79 serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); |
76 return widget; |
80 return widget; |
77 }; |
81 }; |