added default options for the widgets. popcorn-port
authorhamidouk
Tue, 14 Feb 2012 17:15:13 +0100
branchpopcorn-port
changeset 810 85a278e12495
parent 809 1997dae651c6
child 811 b9dd62e35e30
added default options for the widgets.
src/js/init.js
test/integration/polemic-festival.htm
test/integration/polemic.htm
--- a/src/js/init.js	Tue Feb 14 17:14:57 2012 +0100
+++ b/src/js/init.js	Tue Feb 14 17:15:13 2012 +0100
@@ -142,13 +142,17 @@
   var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader);
   var params = {width: guiOptions.width, height: guiOptions.height};
 
+  var default_options = guiOptions.default_options;
+  if (IriSP.null_or_undefined(default_options))
+    default_options = {};
+  
   var ret_widgets = [];
   var index;
   
   for (index = 0; index < guiOptions.widgets.length; index++) {    
-    var widgetConfig = guiOptions.widgets[index];
+    var widgetConfig = IriSP.underscore.defaults(guiOptions.widgets[index], default_options);
     var widget = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, widgetConfig);
-        
+   
     ret_widgets.push(widget);   
   };
 
--- a/test/integration/polemic-festival.htm	Tue Feb 14 17:14:57 2012 +0100
+++ b/test/integration/polemic-festival.htm	Tue Feb 14 17:15:13 2012 +0100
@@ -30,6 +30,13 @@
             height:2100,              
             container:'LdtPlayer',
             css:'../../src/css/LdtPlayer.css',
+			default_options : {
+			 metadata:{
+                          format:'cinelab',
+                          src:json_url,
+                          type:'json'}
+            },
+			
             widgets: [
             {type: "StackGraphWidget",
                 tags : [
@@ -63,38 +70,14 @@
                }],
             },            
             {type: "AnnotationsListWidget",
-             container: "AnnotationsListContainer",             
-                         metadata:{
-                          format:'cinelab',
-                          src:json_url,
-                          type:'json'}
-                        },
+             container: "AnnotationsListContainer"},                                   
             {type: "SparklineWidget",
              width: 640, /* required for this widget */
-             height: 50,            
-                         metadata:{
-                          format:'cinelab',
-                          src:json_url,
-                          type:'json'}
-                        },
-            {type: "SliderWidget",
-                         metadata:{
-                          format:'cinelab',
-                          src:json_url,
-                          type:'json'}
-                        },        
-            {type: "PlayerWidget", // please note that type refers directly to the constructor of the widget.
-             mode: "radio",
-             metadata:{
-              format:'cinelab',
-              src:json_url,
-              type:'json'}
-            },
-            {type: "SegmentsWidget",
-             metadata:{
-              format:'cinelab',
-              src:json_url,
-              type:'json'},
+             height: 50,
+			},
+            {type: "SliderWidget"},        
+            {type: "PlayerWidget"},
+            {type: "SegmentsWidget",             
              requires: [{
               type: "TooltipWidget",
               width: 180,
@@ -104,24 +87,11 @@
               }
              }],
             },                     
-            {type: "ArrowWidget",
-             metadata:{
-              format:'cinelab',
-              src:json_url,
-              type:'json'}
+            {type: "ArrowWidget",           
             },
-            {type: "TweetsWidget",
-                         metadata:{
-                          format:'cinelab',
-                          src:json_url,
-                          type:'json'}
-                        },
-            {type: "createAnnotationWidget",
-                         metadata:{
-                          format:'cinelab',
-                          src:json_url,
-                          type:'json'}
-                        }      
+            {type: "TweetsWidget",                       
+            },
+            {type: "createAnnotationWidget"}   
             ]
         },
       player:{
--- a/test/integration/polemic.htm	Tue Feb 14 17:14:57 2012 +0100
+++ b/test/integration/polemic.htm	Tue Feb 14 17:15:13 2012 +0100
@@ -27,66 +27,17 @@
             width:650,
             height:2100,              
             container:'LdtPlayer',
+			default_options: {
+				metadata:{
+				  format:'cinelab',
+				  src:file,
+				  type:'json'}
+			},
             css:'../../src/css/LdtPlayer.css',
             widgets: [
-              {type: "PolemicWidget",
-             width: 640, /* required for this widget */
-             height: 50,
-             metadata:{
-              format:'cinelab',
-              src:file,
-              type:'json'},
-              
-             requires: [{
-              type: "TooltipWidget",
-              width: 180,
-              heigh: 160,
-              metadata : {
-                format:'cinelab',
-                src:'polemic.json',
-                type:'empty'
-              }
-             }],
-            },
-            {type: "SparklineWidget",
+            {type: "PolemicWidget",
              width: 640, /* required for this widget */
-             height: 50,
-						 metadata:{
-						  format:'cinelab',
-						  src:file,
-						  type:'json'}
-						},
-            {type: "TagCloudWidget",             
-                         metadata:{
-                          format:'cinelab',
-                          src:file,
-                          type:'json'}
-                        },
-            {type: "SliderWidget",
-						 metadata:{
-						  format:'cinelab',
-						  src:file,
-						  type:'json'}
-						},
-            {type: "AnnotationsListWidget",
-             container: "AnnotationsListContainer",             
-						 metadata:{
-						  format:'cinelab',
-						  src:file,
-						  type:'json'}
-						},
-            {type: "PlayerWidget", // please note that type refers directly to the constructor of the widget.
-             mode: "radio",
-             metadata:{
-              format:'cinelab',
-              src:file,
-              type:'json'}
-            },
-            {type: "SegmentsWidget",
-             metadata:{
-              format:'cinelab',
-              src:file,
-              type:'json'},
+             height: 50,              
              requires: [{
               type: "TooltipWidget",
               width: 180,
@@ -95,39 +46,31 @@
                 type:'empty'
               }
              }],
-            },            
-            {type: "SliceWidget",
-             metadata:{
-              format:'cinelab',
-              src:file,
-              type:'json'}
+            },
+            {type: "SparklineWidget",
+             width: 640, /* required for this widget */
+             height: 50},
+            {type: "SliderWidget"},
+            {type: "AnnotationsListWidget",
+             container: "AnnotationsListContainer"},
+            {type: "PlayerWidget"},
+            {type: "SegmentsWidget",
+             requires: [{
+              type: "TooltipWidget",
+			  width: 180,
+              heigh: 160,
+			  metadata : {
+                type:'empty'
+              }
+              }],
             },            
-            {type: "ArrowWidget",
-             metadata:{
-              format:'cinelab',
-              src:file,
-              type:'json'}
-            },
+            {type: "SliceWidget"},            
+            {type: "ArrowWidget"},
 
 
-            {type: "AnnotationsWidget",
-						 metadata:{
-						  format:'cinelab',
-						  src:file,
-						  type:'json'}
-						},
-            {type: "TweetsWidget",
-						 metadata:{
-						  format:'cinelab',
-						  src:file,
-						  type:'json'}
-						},
-            {type: "createAnnotationWidget",
-						 metadata:{
-						  format:'cinelab',
-						  src:file,
-						  type:'json'}
-						}      
+            {type: "AnnotationsWidget"},
+            {type: "TweetsWidget"},
+            {type: "createAnnotationWidget"}
             ]
         },
       player:{
@@ -139,11 +82,11 @@
       },
       modules: [
                { type: "MediaFragment",
-  			     		 metadata:{
-	  	  			   format:'cinelab',
-		  				   src:file,
-						     type:'json'}
-						}]
+                            metadata:{
+                           format:'cinelab',
+                             src:file,
+                             type:'json'}
+                        }]
 
     };