src/js/widgets.js
branchplayers-as-widgets
changeset 959 ee11ed1b739e
parent 958 2aa7fdb0762a
child 965 eadb7290c325
--- a/src/js/widgets.js	Mon Sep 17 22:44:59 2012 +0900
+++ b/src/js/widgets.js	Tue Sep 18 15:39:28 2012 +0900
@@ -47,7 +47,15 @@
     
     /* Call draw when loaded */
     this.source.onLoad(function() {
-        _this.media = this.getCurrentMedia();
+        if (_this.media_id) {
+            _this.media = this.getElement(_this.media_id);
+        } else {
+            var _mediaopts = {
+                is_mashup: _this.is_mashup || false
+            }
+            _this.media = this.getCurrentMedia(_mediaopts);
+        }
+        
         _this.draw();
     });
    
@@ -109,9 +117,6 @@
 }
 
 IriSP.Widgets.Widget.prototype.onMediaEvent = function(_eventName, _functionOrName) {
-    if (typeof this.media === "undefined" || typeof this.media.on === "undefined") {
-        console.log("Error on widget "+this.type, this.media);
-    }
     this.media.on(_eventName, this.getFunctionOrName(_functionOrName));
 }
 
@@ -126,7 +131,7 @@
     });
 }
 
-IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _propname, _widgetoptions) {
+IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _widgetoptions, _propname) {
     var _id = _selector.attr("id"),
         _this = this,
         _type = _widgetoptions.type,
@@ -143,7 +148,9 @@
     }
     $L.wait(function() {
         _this.player.loadWidget(_widgetoptions, function(_widget) {
-            _this[_propname] = _widget;
+            if (_propname) {
+                _this[_propname] = _widget;
+            }
         });
     });
 }