src/js/init.js
changeset 984 e034099276f6
parent 969 353b0881a0b9
child 986 f9d51dd4a3fe
--- a/src/js/init.js	Wed Nov 21 16:33:51 2012 +0100
+++ b/src/js/init.js	Thu Nov 29 17:11:23 2012 +0100
@@ -74,7 +74,7 @@
 IriSP.Metadataplayer.prototype.onLibsLoaded = function() {
     IriSP.log("IriSP.Metadataplayer.prototype.onLibsLoaded");
     if (typeof IriSP.jQuery === "undefined" && typeof window.jQuery !== "undefined") {
-        IriSP.jQuery = window.jQuery.noConflict();
+        IriSP.jQuery = window.jQuery;
     }
     if (typeof IriSP._ === "undefined" && typeof window._ !== "undefined") {
         IriSP._ = window._;
@@ -93,12 +93,28 @@
       
     this.widgets = [];
     var _this = this;
-    for(var i = 0; i < this.config.widgets.length; i++) {
-        this.loadWidget(this.config.widgets[i], function(_widget) {
-            _this.widgets.push(_widget)
+    IriSP._(this.config.widgets).each(function(widgetconf, key) {
+        _this.widgets.push(null);
+        _this.loadWidget(widgetconf, function(widget) {
+            _this.widgets[key] = widget;
         });
-    };
+    });
     this.$.find('.Ldt-Loader').detach();
+    
+    var endload = false;
+    
+    this.on("widget-loaded", function() {
+        if (endload) {
+            return;
+        }
+        var isloaded = !IriSP._(_this.widgets).any(function(w) {
+            return !(w && w.isLoaded())
+        });
+        if (isloaded) {
+            endload = true;
+            _this.trigger("widgets-loaded");
+        }
+    });   
 }
 
 IriSP.Metadataplayer.prototype.loadMetadata = function(_metadataInfo) {