--- a/src/js/init.js Mon Nov 14 16:12:13 2011 +0100
+++ b/src/js/init.js Mon Nov 14 17:19:26 2011 +0100
@@ -3,92 +3,94 @@
*/
-IriSP.configurePopcorn = function (layoutManager, options) {
- var pop;
- var containerDiv = layoutManager.createDiv();
-
- switch(options.type) {
- /*
- todo : dynamically create the div/video tag which
- will contain the video.
- */
- case "html5":
- var tmpId = Popcorn.guid("video");
- IriSP.jQuery("#" + containerDiv).append("<video src='" + options.file + "' id='" + tmpId + "'></video>");
- pop = Popcorn("#" + tmpId).mediafragment({start : 0});
- break;
-
- case "jwplayer":
- var opts = IriSP.jQuery.extend({}, options);
- delete opts.container;
- pop = Popcorn.jwplayer("#" + containerDiv, "", opts).mediafragment({start : 0});
- break;
+define(["IriSP"], function() {
+ IriSP.configurePopcorn = function (layoutManager, options) {
+ var pop;
+ var containerDiv = layoutManager.createDiv();
- case "youtube":
- var opts = IriSP.jQuery.extend({}, options);
- delete opts.container;
- opts.controls = 0;
- opts.autostart = false;
- templ = "width: {{width}}px; height: {{height}}px;";
- var str = Mustache.to_html(templ, {width: opts.width, height: opts.height});
- // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div.
- IriSP.jQuery("#" + containerDiv).attr("style", str);
+ switch(options.type) {
+ /*
+ todo : dynamically create the div/video tag which
+ will contain the video.
+ */
+ case "html5":
+ var tmpId = Popcorn.guid("video");
+ IriSP.jQuery("#" + containerDiv).append("<video src='" + options.file + "' id='" + tmpId + "'></video>");
+ pop = Popcorn("#" + tmpId).mediafragment({start : 0});
+ break;
- pop = Popcorn.youtube("#" + containerDiv, opts.video, opts).mediafragment({start : 0});
- break;
+ case "jwplayer":
+ var opts = IriSP.jQuery.extend({}, options);
+ delete opts.container;
+ pop = Popcorn.jwplayer("#" + containerDiv, "", opts).mediafragment({start : 0});
+ break;
- default:
- pop = undefined;
- };
-
- return pop;
-};
-
-IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) {
-
- var dt = new IriSP.DataLoader();
- var serialFactory = new IriSP.SerializerFactory(dt);
-
- var params = {width: guiOptions.width, height: guiOptions.height};
-
- var ret_widgets = [];
- var index;
-
- for (index = 0; index < guiOptions.widgets.length; index++) {
- var widgetConfig = guiOptions.widgets[index];
- var widget = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, widgetConfig);
- ret_widgets.push(widget);
-
+ case "youtube":
+ var opts = IriSP.jQuery.extend({}, options);
+ delete opts.container;
+ opts.controls = 0;
+ opts.autostart = false;
+ templ = "width: {{width}}px; height: {{height}}px;";
+ var str = Mustache.to_html(templ, {width: opts.width, height: opts.height});
+ // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div.
+ IriSP.jQuery("#" + containerDiv).attr("style", str);
+
+ pop = Popcorn.youtube("#" + containerDiv, opts.video, opts).mediafragment({start : 0});
+ break;
+
+ default:
+ pop = undefined;
+ };
+
+ return pop;
};
- return ret_widgets;
-};
+ IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) {
-IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig) {
- var container = layoutManager.createDiv();
- var arr = IriSP.jQuery.extend({}, widgetConfig);
- arr.container = container;
+ var dt = new IriSP.DataLoader();
+ var serialFactory = new IriSP.SerializerFactory(dt);
- var serializer = serialFactory.getSerializer(widgetConfig.metadata);
-
- if (typeof serializer == "undefined")
- debugger;
-
- // instantiate the object passed as a string
- var widget = new IriSP[widgetConfig.type](popcornInstance, arr, serializer);
+ var params = {width: guiOptions.width, height: guiOptions.height};
+
+ var ret_widgets = [];
+ var index;
- if (widgetConfig.hasOwnProperty("requires")) {
- // also create the widgets this one depends on.
- // the dependency widget is available in the parent widget context as
- // this.WidgetName (for instance, this.TipWidget);
+ for (index = 0; index < guiOptions.widgets.length; index++) {
+ var widgetConfig = guiOptions.widgets[index];
+ var widget = IriSP.instantiateWidget(popcornInstance, serialFactory, layoutManager, widgetConfig);
+ ret_widgets.push(widget);
+
+ };
+
+ return ret_widgets;
+ };
+
+ IriSP.instantiateWidget = function(popcornInstance, serialFactory, layoutManager, widgetConfig) {
+ var container = layoutManager.createDiv();
+ var arr = IriSP.jQuery.extend({}, widgetConfig);
+ arr.container = container;
+
+ var serializer = serialFactory.getSerializer(widgetConfig.metadata);
+
+ if (typeof serializer == "undefined")
+ debugger;
- 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]);
- }
- }
-
- serializer.sync(IriSP.wrap(widget, function() { this.draw(); }));
- return widget;
-};
\ No newline at end of file
+ // instantiate the object passed as a string
+ var widget = new IriSP[widgetConfig.type](popcornInstance, arr, serializer);
+
+ if (widgetConfig.hasOwnProperty("requires")) {
+ // also create the widgets this one depends on.
+ // the dependency widget is available in the parent widget context as
+ // this.WidgetName (for instance, this.TipWidget);
+
+ 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]);
+ }
+ }
+
+ serializer.sync(IriSP.wrap(widget, function() { this.draw(); }));
+ return widget;
+ };
+});
\ No newline at end of file