Skip to content

Commit

Permalink
Merge branch 'develop' of git://github.com/cadecairos/popcorn-js into…
Browse files Browse the repository at this point in the history
… 1.2

* 'develop' of git://github.com/cadecairos/popcorn-js:
  switch readyState check to >= 3 [#843]
  changes to offsetHeight and offsetWidth youtube tests...PART TWO [#843]
  changes to offsetHeight and offsetWidth youtube tests [#843]
  Changes assignment of width and height values to use offsetWidth/offsetHeight [#843]
  1. Changes to defining offsetWidth and offsetHeight 2. coerce muted baseplayer property into boolean [#843]
  removed offsetHeight and offsetWidth getters from the players in favour of the default on in baseplayer. changes to the unit test html file for youtube [843]
  removed use of Object.prototype.toString.call
  Tweaks to offsetWidth and offsetHeight Tests for offsetHeight and offsetWidth in youtube and Vimeo
  media.offsetHeight/offsetWidth is always undefined at this point in the code
  Defined offsetWidth and offsetHeight on each player type, allowing subtitle to position itself properly over a player. [#843]
  [#831] popcorn.player to archaic list
  [830] whitespace
  [830] protected names unit test
  [#867] IE9 fix: cleared children via DOM manipulation
  [#858] Refactor internal getItems => getKeys;
  • Loading branch information
rwaldron committed Jan 20, 2012
2 parents 8499808 + 2aaf4b1 commit 9921cf0
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 72 deletions.
4 changes: 2 additions & 2 deletions players/vimeo/popcorn.vimeo.js
Expand Up @@ -29,8 +29,8 @@
media.appendChild( vimeoContainer );

// setting vimeo player's height and width, default to 560 x 315
width = media.style.width ? ""+media.offsetWidth : "560";
height = media.style.height ? ""+media.offsetHeight : "315";
width = media.style.width ? "" + media.offsetWidth : "560";
height = media.style.height ? "" + media.offsetHeight : "315";

var vimeoInit = function() {

Expand Down
1 change: 1 addition & 0 deletions players/vimeo/popcorn.vimeo.unit.html
Expand Up @@ -26,5 +26,6 @@ <h2 id="qunit-userAgent"></h2>

<div id="player_1" style="width: 400px; height: 400px;"></div>
<div id="player_2" style="width: 400px; height: 400px;"></div>
<div id="player_3" ></div>
</body>
</html>
46 changes: 37 additions & 9 deletions players/vimeo/popcorn.vimeo.unit.js
Expand Up @@ -45,7 +45,7 @@ test( "Update Timer", function() {
forwardEnd = false,
backwardStart = false,
backwardEnd = false,
wrapperRunning = { one: false, two: false, };
wrapperRunning = { one: false, two: false };

function plus() {
if ( ++count === expects ) {
Expand Down Expand Up @@ -268,17 +268,17 @@ test( "Plugin Factory", function() {

ok( "media" in this, "executor instance has `media` property" );
plus();
ok( Object.prototype.toString.call( popped.media ) === "[object Object]", "video property is a HTML DIV element" );
ok( typeof popped.media === "object", "video property is a HTML DIV element" );
plus();

ok( "data" in this, "executor instance has `data` property" );
plus();
ok( Object.prototype.toString.call( popped.data ) === "[object Object]", "data property is an object" );
ok( typeof popped.data === "object", "data property is an object" );
plus();

ok( "trackEvents" in this.data, "executor instance has `trackEvents` property" );
plus();
ok( Object.prototype.toString.call( popped.data.trackEvents ) === "[object Object]", "executor trackEvents property is an object" )
ok( typeof popped.data.trackEvents === "object", "executor trackEvents property is an object" );
plus();
},
end: function() {
Expand Down Expand Up @@ -314,17 +314,17 @@ test( "Plugin Factory", function() {

ok( "media" in this, "complicator instance has `media` property" );
plus();
ok( Object.prototype.toString.call( popped.media ) === "[object Object]", "video property is a HTMLVideoElement" );
ok( typeof popped.media === "object", "video property is a HTMLVideoElement" );
plus();

ok( "data" in this, "complicator instance has `data` property" );
plus();
ok( Object.prototype.toString.call( popped.data ) === "[object Object]", "complicator data property is an object" );
ok( typeof popped.data === "object", "complicator data property is an object" );
plus();

ok( "trackEvents" in this.data, " complicatorinstance has `trackEvents` property" );
plus();
ok( Object.prototype.toString.call( popped.data.trackEvents ) === "[object Object]", "complicator trackEvents property is an object" )
ok( typeof popped.data.trackEvents === "object", "complicator trackEvents property is an object" );
plus();
},
end: function() {
Expand Down Expand Up @@ -389,11 +389,11 @@ test( "Popcorn vimeo Plugin Url Regex Test", function() {
var urlTests = [
{ name: "standard",
url: "http://player.vimeo.com/video/6960892",
expected: "http://player.vimeo.com/video/6960892",
expected: "http://player.vimeo.com/video/6960892"
},
{ name: "short url",
url: "http://vimeo.com/6960892",
expected: "http://vimeo.com/6960892",
expected: "http://vimeo.com/6960892"
}
];

Expand Down Expand Up @@ -422,3 +422,31 @@ test( "Popcorn vimeo Plugin Url Regex Test", function() {
});
});
});

test( "Popcorn Vimeo Plugin offsetHeight && offsetWidth Test", function() {

QUnit.reset();
var popped,
elem,
expects = 2,
count = 0;

expect( expects );

function plus() {
if ( ++count === expects ) {
start();
}
}
popped = Popcorn.vimeo( "#player_3", "http://player.vimeo.com/video/6960892" );

popped.listen( "loadeddata", function() {
elem = document.querySelector( "div#player_3 object" );
equals( elem.height, popped.media.offsetHeight, "The media object is reporting the correct offsetHeight" );
plus();
equals( elem.width, popped.media.offsetWidth, "The media object is reporting the correct offsetWidth" );
plus();
});

stop();
});
5 changes: 2 additions & 3 deletions players/youtube/popcorn.youtube.js
Expand Up @@ -192,7 +192,6 @@ Popcorn.player( "youtube", {
media.duration = youtubeObject.getDuration();
media.dispatchEvent( "durationchange" );
volumeupdate();

media.dispatchEvent( "loadeddata" );
};

Expand All @@ -216,8 +215,8 @@ Popcorn.player( "youtube", {
query = ( media.src.split( "?" )[ 1 ] || "" ).replace( /v=.{11}/, "" );

// setting youtube player's height and width, default to 560 x 315
width = media.style.width ? ""+media.offsetWidth : "560";
height = media.style.height ? ""+media.offsetHeight : "315";
width = media.style.width ? "" + media.offsetWidth : "560";
height = media.style.height ? "" + media.offsetHeight : "315";

swfobject.embedSWF( "//www.youtube.com/e/" + src + "?" + query + "&enablejsapi=1&playerapiid=" + container.id + "&version=3",
container.id, width, height, "8", null, flashvars, params, attributes );
Expand Down
7 changes: 4 additions & 3 deletions players/youtube/popcorn.youtube.unit.html
Expand Up @@ -4,7 +4,7 @@
<title>Popcorn YouTube Player</title>
<link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
<script src="../../test/qunit/qunit.js"></script>
<!--
<!--
do not move - this must be called immediately prior to popcorn.js.
-->
<script src="../../popcorn.js"></script>
Expand All @@ -18,11 +18,11 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"></div>

<p>
Note about this set of tests:
</p>

<p>
The test assumes that the YouTube video is mostly loaded, before it is run.
Therefore, if failures occur for the first time, just run it again. Likely,
Expand All @@ -36,6 +36,7 @@ <h2 id="qunit-userAgent"></h2>
<div id="video3" style="width: 360px; height: 300px" ></div>
<div id="video4"></div>
<div id="video5" style="width: 0px; height: 0px" ></div>
<div id="video6" style="width: 360px; height: 300px"></div>
</body>
</html>

81 changes: 60 additions & 21 deletions players/youtube/popcorn.youtube.unit.js
Expand Up @@ -12,7 +12,7 @@ test("Update Timer", function () {
forwardEnd = false,
backwardStart = false,
backwardEnd = false,
wrapperRunning = { one: false, two: false, };
wrapperRunning = { one: false, two: false };

function plus() {
if ( ++count === expects ) {
Expand Down Expand Up @@ -166,7 +166,7 @@ test("Update Timer", function () {
p2.play();
});

p2.currentTime(3);
p2.volume( 0 ).currentTime(3);

});

Expand Down Expand Up @@ -207,17 +207,17 @@ test("Plugin Factory", function () {

ok( "media" in this, "executor instance has `media` property" );
plus();
ok( Object.prototype.toString.call(popped.media) === "[object Object]", "video property is a HTML DIV element" );
ok( typeof popped.media === "object", "video property is a HTML DIV element" );
plus();

ok( "data" in this, "executor instance has `data` property" );
plus();
ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" );
ok( typeof popped.data === "object", "data property is an object" );
plus();

ok( "trackEvents" in this.data, "executor instance has `trackEvents` property" );
plus();
ok( Object.prototype.toString.call(popped.data.trackEvents) === "[object Object]", "executor trackEvents property is an object" )
ok( typeof popped.data.trackEvents === "object", "executor trackEvents property is an object" );
plus();
},
end: function () {
Expand Down Expand Up @@ -253,17 +253,17 @@ test("Plugin Factory", function () {

ok( "media" in this, "complicator instance has `media` property" );
plus();
ok( Object.prototype.toString.call(popped.media) === "[object Object]", "video property is a HTMLVideoElement" );
ok( typeof popped.media === "object", "video property is a HTMLVideoElement" );
plus();

ok( "data" in this, "complicator instance has `data` property" );
plus();
ok( Object.prototype.toString.call(popped.data) === "[object Object]", "complicator data property is an object" );
ok( typeof popped.data === "object", "complicator data property is an object" );
plus();

ok( "trackEvents" in this.data, " complicatorinstance has `trackEvents` property" );
plus();
ok( Object.prototype.toString.call(popped.data.trackEvents) === "[object Object]", "complicator trackEvents property is an object" )
ok( typeof popped.data.trackEvents === "object", "complicator trackEvents property is an object" );
plus();
},
end: function () {
Expand All @@ -285,7 +285,7 @@ test("Plugin Factory", function () {
end: 5
});

popped.currentTime(0).play();
popped.volume( 0 ).currentTime( 0 ).play();

});

Expand Down Expand Up @@ -318,7 +318,7 @@ test( "Popcorn YouTube Plugin Url and Duration Tests", function() {
popcorn.pause();
});

popcorn.play();
popcorn.volume( 0 ).play();
});

test( "Popcorn YouTube Plugin Url Regex Test", function() {
Expand All @@ -328,28 +328,28 @@ test( "Popcorn YouTube Plugin Url Regex Test", function() {
var urlTests = [
{ name: 'standard',
url: 'http://www.youtube.com/watch?v=9oar9glUCL0',
expected: 'http://www.youtube.com/watch?v=9oar9glUCL0',
expected: 'http://www.youtube.com/watch?v=9oar9glUCL0'
},
{ name: 'share url',
url: 'http://youtu.be/9oar9glUCL0',
expected: 'http://youtu.be/9oar9glUCL0',
expected: 'http://youtu.be/9oar9glUCL0'
},
{ name: 'long embed',
url: 'http://www.youtube.com/embed/9oar9glUCL0',
expected: 'http://www.youtube.com/embed/9oar9glUCL0',
expected: 'http://www.youtube.com/embed/9oar9glUCL0'
},
{ name: 'short embed 1 (e)',
url: 'http://www.youtube.com/e/9oar9glUCL0',
expected: 'http://www.youtube.com/e/9oar9glUCL0',
expected: 'http://www.youtube.com/e/9oar9glUCL0'
},
{ name: 'short embed 2 (v)',
url: 'http://www.youtube.com/v/9oar9glUCL0',
expected: 'http://www.youtube.com/v/9oar9glUCL0',
expected: 'http://www.youtube.com/v/9oar9glUCL0'
},
{ name: 'contains underscore',
url: 'http://www.youtube.com/v/GP53b__h4ew',
expected: 'http://www.youtube.com/v/GP53b__h4ew',
},
expected: 'http://www.youtube.com/v/GP53b__h4ew'
}
];

var count = 0,
Expand All @@ -373,7 +373,7 @@ test( "Popcorn YouTube Plugin Url Regex Test", function() {

start();
}
});
}).volume( 0 );
});
});

Expand All @@ -387,13 +387,15 @@ test( "Controls and Annotations toggling", function() {
targetDiv = document.getElementById( "video" );
testTarget = targetDiv.querySelector( "object" ).data;

popcorn.volume( 0 );

ok( !/controls/.test( testTarget ), "controls are defaulted to 1 ( displayed )" );
ok( !/iv_load_policy/.test( testTarget ), "annotations ( iv_load_policy ) are defaulted to ( enabled )" );

targetDiv.innerHTML = "";

popcorn = Popcorn.youtube( "#video", "http://www.youtube.com/watch?v=9oar9glUCL0&controls=1&iv_load_policy=1" );

popcorn.volume( 0 );
testTarget = targetDiv.querySelector( "object" ).data;
ok( /controls=1/.test( testTarget ), "controls is set to 1 ( displayed )" );
ok( /iv_load_policy=1/.test( testTarget ), "annotations ( iv_load_policy ) is set to 1 ( enabled )" );
Expand Down Expand Up @@ -432,9 +434,47 @@ test( "Player height and width", function() {
}
};

popcorn1.volume( 0 );
popcorn2.volume( 0 );

readyStatePoll();
});

test( "Popcorn Youtube Plugin offsetHeight && offsetWidth Test", function() {

QUnit.reset();
var popped,
elem,
expects = 2,
count = 0;

expect( expects );

function plus() {
if ( ++count === expects ) {
start();
}
}
popped = Popcorn.youtube( "#video6", "http://www.youtube.com/watch?v=9oar9glUCL0" );

var runner = function() {
popped.volume( 0 );
elem = document.querySelector( "div#video6 object" );
equals( elem.height, popped.media.offsetHeight, "The media object is reporting the correct offsetHeight" );
plus();
equals( elem.width, popped.media.offsetWidth, "The media object is reporting the correct offsetWidth" );
plus();
};

if ( popped.readyState >= 2 ) {
runner();
} else {
popped.listen( "loadeddata", runner);
}

stop( 10000 );
});

test( "Player Errors", function() {
QUnit.reset();
expect( 1 );
Expand All @@ -445,5 +485,4 @@ test( "Player Errors", function() {
ok( true, "error trigger by invalid URL" );
start();
});
});

});
5 changes: 4 additions & 1 deletion plugins/lowerthird/popcorn.lowerthird.js
Expand Up @@ -120,7 +120,10 @@
* options variable
*/
end: function( event, options ) {
options.container.innerHTML = "";
// Empty child nodes
while ( options.container.firstChild ) {
options.container.removeChild( options.container.firstChild );
}
}

});
Expand Down

0 comments on commit 9921cf0

Please sign in to comment.