]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
moved googlefeed scriptloading into setup
authorChristopher De Cairos <chris.decairos@gmail.com>
Tue, 13 Sep 2011 18:53:01 +0000 (14:53 -0400)
committerChristopher De Cairos <chris.decairos@gmail.com>
Tue, 13 Sep 2011 18:53:01 +0000 (14:53 -0400)
plugins/googlefeed/popcorn.googlefeed.js

index 1a6d1cd4f21c04524485173826a41137c9b61de0..bca198588a40c6239d44262c0a608e743719a580 100755 (executable)
@@ -17,7 +17,7 @@
 
       Popcorn.getScript( resource + "js", function() {
         scriptLoaded = true;
-      }); 
+      });
 
     } else {
       scriptLoaded = true;
     }
   };
 
-  if ( !window.google ) {
-
-    Popcorn.getScript( "http://www.google.com/jsapi", function() {
-
-      google.load( "feeds", "1", {
-
-        callback: function () {
-
-          dynamicFeedLoad();              
-        }
-      });
-    });
-
-  } else {
-    dynamicFeedLoad();
-  }
-
   /**
    * googlefeed popcorn plug-in
    * Adds a feed from the specified blog url at the target div
@@ -86,9 +69,9 @@
         target = document.getElementById( options.target ),
     initialize = function() {
       //ensure that the script has been loaded
-      if ( !scriptLoaded ) {
+      if ( !scriptLoaded || !window.GFdynamicFeedControl ) {
         setTimeout( function () {
-          initialize(); 
+          initialize();
         }, 5 );
       } else {
         // Create the feed control using the user entered url and title
     }
     target && target.appendChild( newdiv );
 
-    initialize();
-    
     return {
+      /**
+       * @member webpage
+       * The setup function will be executed when a googlefeed plugin is created.
+       */
+      _setup: function( options ) {
+
+        if ( !window.google ) {
+
+          Popcorn.getScript( "http://www.google.com/jsapi", function() {
+
+            var readyCheck = function() {
+
+                               if ( window.google ) {
+                                       google.load( "feeds", "1", {
+
+                                                                       callback: function () {
+
+                                                                               dynamicFeedLoad();
+
+                                                                       }
+                       });
+                       } else {
+                               setTimeout( readyCheck, 10 );
+                       }
+               };
+               readyCheck();
+
+          });
+
+        }
+
+        initialize();
+      },
       /**
        * @member webpage
        * The start function will be executed when the currentTime
     },
     options: {
       start: {
-        elem: "input", 
-        type: "text", 
-        label: "In" 
+        elem: "input",
+        type: "text",
+        label: "In"
       },
-      end: { 
-        elem: "input", 
-        type: "text", 
-        label: "Out" 
+      end: {
+        elem: "input",
+        type: "text",
+        label: "Out"
       },
       target: "feed-container",
-      url: { 
-        elem: "input", 
-        type: "text", 
-        label: "url" 
+      url: {
+        elem: "input",
+        type: "text",
+        label: "url"
       },
-      title: { 
-        elem: "input", 
-        type: "text", 
-        label: "title" 
+      title: {
+        elem: "input",
+        type: "text",
+        label: "title"
       },
       orientation: {
-        elem: "select", 
-        options: [ "Vertical","Horizontal" ], 
-        label: "orientation" 
+        elem: "select",
+        options: [ "Vertical","Horizontal" ],
+        label: "orientation"
       }
     }
   });
-  
+
 })( Popcorn );