]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
target.options fixed [#256 state:peer-review-requested]
authorAnna Sobiepanek <annaopensource@gmail.com>
Tue, 11 Jan 2011 23:09:53 +0000 (18:09 -0500)
committerAnna Sobiepanek <annaopensource@gmail.com>
Tue, 11 Jan 2011 23:09:53 +0000 (18:09 -0500)
plugins/flickr/popcorn.flickr.js
plugins/footnote/popcorn.footnote.js
plugins/googleNews/popcorn.googleNews.js
plugins/image/popcorn.image.js
plugins/tagThisPerson/popcorn.tagThisPerson.js
plugins/twitter/popcorn.twitter.js
plugins/webpage/popcorn.webpage.js
plugins/wikipedia/popcorn.wikipedia.js

index 3a2b91fe44caa555646c6d7d9eeeff2b683bfa87..74b46ce6e7c9a1408e6b73b250b08186467f9bef 100644 (file)
@@ -60,7 +60,9 @@
       _setup: function( options ) {
         options.container = document.createElement( 'div' );
         options.container.style.display = "none";
-        document.getElementById( options.target ).appendChild( options.container );
+        if ( document.getElementById( options.target ) ) {
+          document.getElementById( options.target ).appendChild( options.container );
+        }
         var height  = options.height || "50px",
             width   = options.width || "50px",
             count   = options.numberofimages || 4,
index 960ba7d8c2ee48972ffd40b0cb0400a3dadc8a0f..1f52dec252b6089a6e999df9ba12d6f0663cb63f 100644 (file)
@@ -44,8 +44,9 @@
       options._container = document.createElement( 'div' );
       options._container.style.display = "none";
       options._container.innerHTML  = options.text;
-      options.target =  document.getElementById( options.target );
-      options.target.appendChild( options._container );
+      if ( document.getElementById( options.target ) ) {
+        document.getElementById( options.target ).appendChild( options._container );
+      }
     },
     /**
      * @member footnote 
index 3f17460873a5c937d9a2949ffb6ce7264adcceb1..69cfaf957916929ff533a921e958296279cd5919 100644 (file)
@@ -23,9 +23,9 @@
       _setup : function( options ) {
 
         options.container = document.createElement( 'div' );
-
-        document.getElementById( options.target ).appendChild( options.container );
-
+        if ( document.getElementById( options.target ) ) {
+          document.getElementById( options.target ).appendChild( options.container );
+        }
         var newsShow = new google.elements.NewsShow( options.container, {
           format : "300x250",
           queryList : [
index 90af8f18b48f8d56bc832da978b54563b9052b08..c2e43109482903262bff6a4ab234752ea0d0c6b3 100644 (file)
@@ -52,9 +52,9 @@
           options.link.href = options.href;
         }
         options.link.target = "_blank";
-
-        document.getElementById( options.target ).appendChild( options.link ); // add the widget's div to the target div
-
+        if ( document.getElementById( options.target ) ) {
+          document.getElementById( options.target ).appendChild( options.link ); // add the widget's div to the target div
+        }
         var img = document.createElement( 'img' );
         img.src = options.src;
         img.style.borderStyle = "none"; // borders look really bad, if someone wants it they can put it on their div target
index 34afbc709e78c47ababdebdc171ca20a5ca86c68..2d46575bc08adcb15d1ef3dbb0736372ade2d1d4 100644 (file)
@@ -81,7 +81,9 @@
        */
       start: function(event, options){
         options._p.contains[options.person] = options.person;
-        document.getElementById(options.target).innerHTML  = options._p.toString();
+        if (document.getElementById(options.target)) {
+          document.getElementById(options.target).innerHTML  = options._p.toString();
+        }
       },
       /**
        * @member tagthisperson 
@@ -91,7 +93,9 @@
        */
       end: function(event, options){
         delete options._p.contains[options.person];
-        document.getElementById(options.target).innerHTML  = options._p.toString();
+        if (document.getElementById(options.target)) {
+          document.getElementById(options.target).innerHTML  = options._p.toString();
+        }
       }
    };
   })());
index 0ebba9353226acda344b1f7fd2146eb4d6a7bbf8..107558c8723c4e7dc5ffe3ec4ec7e642ee78d89c 100644 (file)
@@ -64,8 +64,9 @@
         options.container = document.createElement( 'div' ); // create the div to store the widget
         options.container.setAttribute('id', Popcorn.guid()); // use this id to connect it to the widget
         options.container.style.display = "none"; // display none by default
-        document.getElementById( options.target ).appendChild( options.container ); // add the widget's div to the target div
-
+        if ( document.getElementById( options.target ) ) {
+          document.getElementById( options.target ).appendChild( options.container ); // add the widget's div to the target div
+        }
         // setup info for the widget
         var src     = options.src || "",
             width   = options.width || 250,
index 17c8e77789675f79676f28f98d5042a4d3c74965..5dc0eff4e2a3babeeda9f500e07dd595a2244efe 100644 (file)
@@ -45,7 +45,6 @@
         }
       },
       _setup : function( options ) {
-        options.target    = document.getElementById( options.target );
         // make an iframe 
         options._iframe  = document.createElement( 'iframe' ),
         options._iframe.setAttribute('width', "100%");
         options._iframe.id  = options.id;
         options._iframe.src = options.src;
         options._iframe.style.display = 'none';
-        // add the hidden iframe to the DON
-        options.target.appendChild(options._iframe);
+        // add the hidden iframe to the DOM
+        if ( document.getElementById( options.target ) ) {
+          document.getElementById( options.target ).appendChild(options._iframe);
+        }
         
       },
       /**
index ed85fbb5f66b167dba7124949068d86791e03979..75041ff9cd2a9c085e0d88a88938e71e62801be3 100644 (file)
@@ -67,9 +67,7 @@ var wikiCallback;
       if (typeof options.lang === 'undefined') { options.lang ="en"; }
       // if the user didn't specify number of words to use default to 200 
       options.numberofwords  = options.numberofwords || 200;
-      // replace the user specified target with the actual DOM element
-      options.target      = document.getElementById( options.target );
-      
+            
       // wiki global callback function with a unique id
       // function gets the needed information from wikipedia
       // and stores it by appending values to the options object
@@ -112,9 +110,11 @@ var wikiCallback;
         } else {
       
           if (options._link && options._desc) {
-            options.target.appendChild(options._link);
-            options.target.appendChild(options._desc);
-            options._added = true;
+            if ( document.getElementById( options.target ) ) {
+              document.getElementById( options.target ).appendChild(options._link);
+              document.getElementById( options.target ).appendChild(options._desc);
+              options._added = true;
+            }
           }
         }
       };
@@ -131,8 +131,8 @@ var wikiCallback;
       // ensure that the data was actually added to the 
       // DOM before removal
       if (options._added) {
-        options.target.removeChild(options._link);
-        options.target.removeChild(options._desc);
+        document.getElementById( options.target ).removeChild(options._link);
+        document.getElementById( options.target ).removeChild(options._desc);
       }
     }