]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#t484] teardown checks for target, linting, explicit googlefeed delete
authorScottDowne <sdowne@learn.senecac.on.ca>
Mon, 16 May 2011 23:19:37 +0000 (19:19 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Mon, 16 May 2011 23:19:37 +0000 (19:19 -0400)
14 files changed:
plugins/attribution/popcorn.attribution.js
plugins/flickr/popcorn.flickr.js
plugins/footnote/popcorn.footnote.js
plugins/googlefeed/popcorn.googlefeed.js
plugins/googlefeed/popcorn.googlefeed.unit.js
plugins/googlemap/popcorn.googlemap.js
plugins/googlenews/popcorn.googlenews.js
plugins/image/popcorn.image.js
plugins/lastfm/popcorn.lastfm.js
plugins/mustache/popcorn.mustache.js
plugins/openmap/popcorn.openmap.js
plugins/tagthisperson/popcorn.tagthisperson.js
plugins/twitter/popcorn.twitter.js
plugins/webpage/popcorn.webpage.js

index 733122889968f89775eaa1e45ed7e10121264ae7..fe0c478739802e7cf890341ebc7c4da827576f1e 100644 (file)
           attrib += ", <a href='" + options.licenseurl + "' target='_blank'>license</a> ";
         }
         options._container.innerHTML  = attrib;
-        if ( document.getElementById( options.target ) ) {
-          document.getElementById( options.target ).appendChild( options._container );
-        }
+
+        document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( options._container );
       },
       /**
        * @member attribution 
         options._container.style.display = "none";
       },
       _teardown: function( options ) {
-        document.getElementById( options.target ).removeChild( options._container );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options._container );
       }
     };
   })());
index 37977bd8049270cdb99280fff01e1aaa1f396898..1009fea74cd301cc90050b98841c8cf7fa42b849 100644 (file)
           containerDiv.style.display = "none";       
       },
       _teardown: function( options ) {
-        document.getElementById( options.target ).removeChild( containerDiv );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( containerDiv );
       }
     };
   },
index 981d94aabdbf2192940c0243823df6db63e73cbf..2570da1e3c89893756a77028e9af5594b89eb60d 100644 (file)
@@ -44,9 +44,8 @@
       options._container = document.createElement( 'div' );
       options._container.style.display = "none";
       options._container.innerHTML  = options.text;
-      if ( document.getElementById( options.target ) ) {
-        document.getElementById( options.target ).appendChild( options._container );
-      }
+
+      document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( options._container );
     },
     /**
      * @member footnote 
@@ -67,7 +66,7 @@
       options._container.style.display = "none";
     },
     _teardown: function( options ) {
-      document.getElementById( options.target ).removeChild( options._container );
+      document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options._container );
     }
   });
 
index 4d24794dcd492c0574ab62256ed56a0455cdf795..1e9c0f30566c439dc6abd65136451f2ab5545a2f 100644 (file)
@@ -51,9 +51,8 @@
     newdiv.style.width = "100%";
     newdiv.style.height = "100%";
     i++;
-    if ( document.getElementById( options.target ) ) {
-      document.getElementById( options.target ).appendChild( newdiv );
-    }
+
+    document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( newdiv );
 
     var initialize = function() {
       //ensure that the script has been loaded
@@ -63,7 +62,7 @@
         }, 5);
       } else {
         // Create the feed control using the user entered url and title
-        var tmp = new GFdynamicFeedControl( options.url, newdiv, {
+        options.feed = new GFdynamicFeedControl( options.url, newdiv, {
           vertical:   options.orientation.toLowerCase() == "vertical" ? true : false,
           horizontal: options.orientation.toLowerCase() == "horizontal" ? true : false,
           title:      options.title = options.title || "Blog"
         newdiv.setAttribute( "style", "display:none" );
       },
       _teardown: function( options ) {
-        document.getElementById( options.target ).removeChild( newdiv );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( newdiv );
+        delete options.feed;
       }
     };
   },
index b2778c247bf3f886008c1cdd2b21bae3ebb0f8e6..5fbcfcc8c1d64f26df1cdcab5809bab6684d4a4a 100644 (file)
@@ -64,7 +64,7 @@ test("Popcorn Google Feed Plugin", function () {
          plus();
 
     popped.pause().removeTrackEvent( setupId );
-    ok( !document.getElementById('feed1').children[0], "removed footnote was properly destroyed"  );
+    ok( !document.getElementById('feed1').children[0], "removed feed was properly destroyed"  );
     plus();
   });
   
index 08198705bc8d224e9c20610cd8b8f2f2f2f3eb4a..954eea1489cedc8f5b54ef55a9b290ce7bb8e492 100644 (file)
@@ -189,7 +189,7 @@ var googleCallback;
       },
       _teardown: function( options ) {
         // the map must be manually removed
-        document.getElementById( options.target ).removeChild( newdiv );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( newdiv );
         newdiv = map = location = null;
       }
     };
index e12e0bf0b4b71c35782d42141e12e0d4b42a2434..e9b8876a5c3097537e96eec5a513637b25eaf69f 100644 (file)
       _teardown: function( options ) {
         // google news does not like this, throws an error "a is null"
         // doesn't hurt popcorn, and only happens once
-        document.getElementById( options.target ).removeChild( options.container );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options.container );
         options.newsShow = null;
       }
   });
index 2b77387a09c67dcc12c689bc7396aabc42667fe0..3a8b2926b327d9e9b50d21033d56a81de1ec33e4 100644 (file)
 
         var img = document.createElement( 'img' );
         img.addEventListener( "load", function() {
-          img.style.borderStyle = "none"; // borders look really bad, if someone wants it they can put it on their div target
+
+          // borders look really bad, if someone wants it they can put it on their div target
+          img.style.borderStyle = "none";
           
           if ( options.href ) {
             options.link.href = options.href;
           }
           options.link.target = "_blank";
-          if ( document.getElementById( options.target ) ) {
-            document.getElementById( options.target ).appendChild( options.link ); // add the widget's div to the target div
-          }
+
+          // add the widget's div to the target div
+          document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( options.link );
           
           var fontHeight = ( img.height / 12 ) + "px";
           
         options.link.style.display = "none";
       },
       _teardown: function( options ) {
-        document.getElementById( options.target ).removeChild( options.link );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options.link );
       }
   });
 
index b17b60392ad61591b45efe20d338284eef1edea6..9de8702d3d69b3128efdca5117d8e23fb47263cf 100644 (file)
         options._container.innerHTML = "";
         
         options.artist = options.artist.toLowerCase();
-        
-        if ( document.getElementById( options.target ) ) {
-          document.getElementById( options.target ).appendChild( options._container );
-        }
+
+        document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( options._container );
         
         if(!_artists[options.artist]) {
 
       _teardown: function( options ) {
         // cleaning possible reference to _artist array;
         --_artists[ options.artist ].count || delete _artists[ options.artist ];
-        document.getElementById( options.target ).removeChild( options._container );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options._container );
       }
     };
   })());
index 86f318fdae2cc99fcbe555f389fc369d7ec017de..97a8c769f58ffce53681afa6aff7516df5bf40bd 100644 (file)
         document.getElementById( options.target ).innerHTML = '';
       },
       _teardown: function( options ) {
-        getData, data, getTemplate, template = null;
+        getData = data = getTemplate = template = null;
       }
     };
   },
index ad7262e428749d58b20bbf9797f55c7fb060d21f..38a4f3661eb66fea627da39a90dce847acae10c8 100644 (file)
@@ -67,9 +67,9 @@ var openmapCallback;
     newdiv.style.width   = "100%";
     newdiv.style.height  = "100%";
     i++;
-    if ( document.getElementById( options.target ) ) {
-      document.getElementById( options.target ).appendChild( newdiv );
-    }
+
+    document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( newdiv );
+
     // callback function fires when the script is run
     var isGeoReady = function() {
       if ( !_mapLoaded ) {
@@ -253,7 +253,7 @@ var openmapCallback;
       },
       _teardown: function( options ) {
 
-        document.getElementById( options.target ).removeChild( newdiv );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( newdiv );
         newdiv = map = centerlonlat = projection = displayProjection = pointLayer = selectControl = popup = null;
       }
     };
index 029e50026a9d91239627c3a108ef21f5e129c457..c67a24ce57e55102d5afd5d4c568de0866f474b8 100644 (file)
@@ -90,9 +90,7 @@
         options._p.contains[ options.person ] = ( options.image ) ? "<img src='" + options.image + "'/> " : "" ;
         options._p.contains[ options.person ] += ( options.href ) ? "<a href='" + options.href + "' target='_blank'> " + options.person + "</a>" : options.person ;
 
-        if ( document.getElementById( options.target ) ) {
-          document.getElementById( options.target ).innerHTML = options._p.toString();
-        }
+        document.getElementById( options.target ).innerHTML = options._p.toString();
       },
       /**
        * @member tagthisperson 
        */
       end: function( event, options ){
         delete options._p.contains[ options.person ];
-        if ( document.getElementById( options.target ) ) {
-          document.getElementById( options.target ).innerHTML = options._p.toString();
-        }
+
+        document.getElementById( options.target ).innerHTML = options._p.toString();
       }
    };
   })());
index 8cdfe5e0af8848b2a227701ae506e6fbb8c6c4cb..b8aa8d910b26cb163d1b6c996f16d477f48842a3 100644 (file)
         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
-        if ( document.getElementById( options.target ) ) {
-          document.getElementById( options.target ).appendChild( options.container ); // add the widget's div to the target div
-        }
+
+         // add the widget's div to the target div
+        document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( options.container );
+
         // setup info for the widget
         var src     = options.src || "",
             width   = options.width || 250,
       },
       _teardown: function( options ) {
 
-        document.getElementById( options.target ).removeChild( options.container );
+        document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options.container );
       }
     });
 
index ecfabda9e5f7592542facf8e15a2ebe7701c95bc..632e1a1a1401d0c5c4a02fd6ba73913a7e719454 100644 (file)
       options._iframe.id  = options.id;
       options._iframe.src = options.src;
       options._iframe.style.display = 'none';
+
       // add the hidden iframe to the DOM
-      if ( document.getElementById( options.target ) ) {
-        document.getElementById( options.target ).appendChild(options._iframe);
-      }
+      document.getElementById( options.target ) && document.getElementById( options.target ).appendChild(options._iframe);
       
     },
     /**
@@ -79,7 +78,7 @@
     },
     _teardown: function( options ) {
 
-      document.getElementById( options.target ).removeChild( options._iframe );
+      document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options._iframe );
     }
   });
 })( Popcorn );