From: Anna Sobiepanek Date: Tue, 11 Jan 2011 23:09:53 +0000 (-0500) Subject: target.options fixed [#256 state:peer-review-requested] X-Git-Tag: v0.2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0249621d943ae25a6262819b727d121904655445;p=popcorn-js.git target.options fixed [#256 state:peer-review-requested] --- diff --git a/plugins/flickr/popcorn.flickr.js b/plugins/flickr/popcorn.flickr.js index 3a2b91f..74b46ce 100644 --- a/plugins/flickr/popcorn.flickr.js +++ b/plugins/flickr/popcorn.flickr.js @@ -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, diff --git a/plugins/footnote/popcorn.footnote.js b/plugins/footnote/popcorn.footnote.js index 960ba7d..1f52dec 100644 --- a/plugins/footnote/popcorn.footnote.js +++ b/plugins/footnote/popcorn.footnote.js @@ -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 diff --git a/plugins/googleNews/popcorn.googleNews.js b/plugins/googleNews/popcorn.googleNews.js index 3f17460..69cfaf9 100644 --- a/plugins/googleNews/popcorn.googleNews.js +++ b/plugins/googleNews/popcorn.googleNews.js @@ -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 : [ diff --git a/plugins/image/popcorn.image.js b/plugins/image/popcorn.image.js index 90af8f1..c2e4310 100644 --- a/plugins/image/popcorn.image.js +++ b/plugins/image/popcorn.image.js @@ -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 diff --git a/plugins/tagThisPerson/popcorn.tagThisPerson.js b/plugins/tagThisPerson/popcorn.tagThisPerson.js index 34afbc7..2d46575 100644 --- a/plugins/tagThisPerson/popcorn.tagThisPerson.js +++ b/plugins/tagThisPerson/popcorn.tagThisPerson.js @@ -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(); + } } }; })()); diff --git a/plugins/twitter/popcorn.twitter.js b/plugins/twitter/popcorn.twitter.js index 0ebba93..107558c 100644 --- a/plugins/twitter/popcorn.twitter.js +++ b/plugins/twitter/popcorn.twitter.js @@ -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, diff --git a/plugins/webpage/popcorn.webpage.js b/plugins/webpage/popcorn.webpage.js index 17c8e77..5dc0eff 100644 --- a/plugins/webpage/popcorn.webpage.js +++ b/plugins/webpage/popcorn.webpage.js @@ -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%"); @@ -53,8 +52,10 @@ 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); + } }, /** diff --git a/plugins/wikipedia/popcorn.wikipedia.js b/plugins/wikipedia/popcorn.wikipedia.js index ed85fbb..75041ff 100644 --- a/plugins/wikipedia/popcorn.wikipedia.js +++ b/plugins/wikipedia/popcorn.wikipedia.js @@ -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); } }