From 52012c52176fbba5033c84eb090e23e5611d0cc3 Mon Sep 17 00:00:00 2001 From: Anna Sobiepanek Date: Sun, 5 Dec 2010 17:02:26 -0500 Subject: [PATCH] fixed plugin and the unit tests --- plugins/webpage/popcorn.webpage.js | 14 ++++---- plugins/webpage/popcorn.webpage.unit.html | 2 +- plugins/webpage/popcorn.webpage.unit.js | 43 ++++++++++++----------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/plugins/webpage/popcorn.webpage.js b/plugins/webpage/popcorn.webpage.js index b582552..259fe11 100644 --- a/plugins/webpage/popcorn.webpage.js +++ b/plugins/webpage/popcorn.webpage.js @@ -19,9 +19,10 @@ // set the style of the iframe iframe.setAttribute('width', "100%"); iframe.setAttribute('height', "100%"); - - - + iframe.id= options.id; + iframe.src = options.src; + var temp = document.getElementById( options.target ); + // get the options that the user included if ( typeof options === "object" && "join" in options ) { page = options; @@ -33,14 +34,13 @@ // loop threw all of the webpages Popcorn.forEach(page, function ( thispage ) { - var temp = document.getElementById( thispage.target ); - iframe.setAttribute('id', thispage.id); + var exists = document.getElementById( thispage.id ); if ( this.currentTime() >= thispage.start && !exists && this.currentTime() <= thispage.end) { //div.innerHTML = div.innerHTML + thispage.html; // set the source of the webpage that this plugin should display - iframe.setAttribute('src', thispage.src); + temp.appendChild(iframe); } @@ -49,6 +49,8 @@ } }, this); }); + + return this; }); })(Popcorn); \ No newline at end of file diff --git a/plugins/webpage/popcorn.webpage.unit.html b/plugins/webpage/popcorn.webpage.unit.html index 8b2f866..7ae70c9 100644 --- a/plugins/webpage/popcorn.webpage.unit.html +++ b/plugins/webpage/popcorn.webpage.unit.html @@ -45,6 +45,6 @@

Your user agent does not support the HTML5 Video element.

- +
diff --git a/plugins/webpage/popcorn.webpage.unit.js b/plugins/webpage/popcorn.webpage.unit.js index d482566..b5f2f18 100644 --- a/plugins/webpage/popcorn.webpage.unit.js +++ b/plugins/webpage/popcorn.webpage.unit.js @@ -1,38 +1,39 @@ test("Popcorn Webpage Plugin", function () { + var popped = Popcorn("#video") + expects = 2, + count = 0 + ; - // needs expectation - - var popped = Popcorn("#video"), - expects = 4, - count = 0; - expect(expects); - - function plus (){ - if(++count === expects){ - stop(); + + function plus() { + if( ++count===expects) { + start(); } } + stop(); + + + ok( 'webpages' in popped, "webpages is a mehtod of the popped instance"); + plus(); + popped.webpages({ id: "webpages-a", - start: 0, // seconds - end: 5, // seconds + start: 1, // seconds + end: 30, // seconds src: 'http://www.webmademovies.org', target: 'webpagediv' - }); - - popped.play(); + }).play(); - ok( 'data' in popped, "popped has the data prop and therefore is a Popcorn object" ) - ok( 'webpages' in popped, "webpages is a mehtod of the popped instance"); + setTimeout(function() { + ok( !!document.getElementsByTagName('iframe')[0], "iframe was created" ); + plus(); + }, 5000); + - ok( typeof popped.webpages === "function" , "webpages is a function"); - popped.exec(2, function(){ - ok( document.getElementById('webpages-a') , "iframe exists"); - }) }); -- 2.43.0