<audio id='audio' src="italia.ogg" data-timeline-sources="data/parserData.json" controls>
</audio>
+
+
+ <!-- Position Tests Adapted From jQuery offsets/dimensions Tests -->
+ <style type="text/css" media="screen">
+ #position-tests { display:none;margin:0; position: fixed;top:0px;left:0px; }
+
+ div.absolute { position: absolute; margin: 0px; width: 100px; height: 100px; background: #fff; }
+ #absolute-1 { top: 0; left: 0; }
+ #absolute-1-1 { top: 1px; left: 1px; }
+ #absolute-1-1-1 { top: 1px; left: 1px; }
+ #absolute-2 { top: 19px; left: 19px; }
+
+ div.relative { position: relative; top: 0; left: 0; width: 100px; height: 100px; background: #fff; overflow: hidden; }
+ #relative-2 { top: 20px; left: 20px; }
+
+ div.fixed { position: fixed; width: 100px; height: 100px; background: #fff; overflow: hidden; }
+ #fixed-1 { top: 0; left: 0; }
+ #fixed-2 { top: 20px; left: 20px; }
+
+ div.static { position: static; top: 0; left: 0; width: 100px; height: 100px; background: #fff; overflow: hidden; }
+ #static-2 { top: 20px; left: 20px; }
+
+ </style>
+
+ <div id="position-tests">
+ <div id="absolute-1" class="absolute"><video id="vid-absolute-1" src="trailer.ogv" style="visibility:hidden"></video>
+ <div id="absolute-1-1" class="absolute"><video id="vid-absolute-1-1"" src="trailer.ogv" style="visibility:hidden"></video>
+ <div id="absolute-1-1-1" class="absolute"><video id="vid-absolute-1-1-1" src="trailer.ogv" style="visibility:hidden"></video></div>
+ </div>
+ </div>
+ <div id="absolute-2" class="absolute"><video id="vid-absolute-2" src="trailer.ogv" style="visibility:hidden"></video></div>
+
+ <div id="relative-1" class="relative"><video id="vid-relative-1" src="trailer.ogv" style="visibility:hidden"></video>
+ <div id="relative-1-1" class="relative"><video id="vid-relative-1-1" src="trailer.ogv" style="visibility:hidden"></video>
+ <div id="relative-1-1-1" class="relative"><video id="vid-relative-1-1-1" src="trailer.ogv" style="visibility:hidden"></video></div>
+ </div>
+ </div>
+ <div id="relative-2" class="relative"><video id="vid-relative-2" src="trailer.ogv" style="visibility:hidden"></video></div>
+
+
+ <div id="fixed-1" class="fixed"><video id="vid-fixed-1" src="trailer.ogv" style="visibility:hidden"></video></div>
+ <div id="fixed-2" class="fixed"><video id="vid-fixed-2" src="trailer.ogv" style="visibility:hidden"></video></div>
+
+ <div id="static-1" class="static"><video id="vid-static-1" src="trailer.ogv" style="visibility:hidden">
+ <div id="static-1-1" class="static"><video id="vid-static-1-1" src="trailer.ogv" style="visibility:hidden">
+ <div id="static-1-1-1" class="static"><video id="vid-static-1-1-1" src="trailer.ogv" style="visibility:hidden"></div>
+ </div>
+ </div>
+ <div id="static-2" class="static"><video id="vid-static-2" src="trailer.ogv" style="visibility:hidden"></div>
+
+ </div>
+
+
</body>
</html>
module("Popcorn Position");
test("position", function () {
- var pops = [ Popcorn("#pos-1"),
- Popcorn("#pos-2"),
- Popcorn("#pos-3"),
- Popcorn("#pos-4")
- ],
- expects = 22,
- count = 0,
- tests = [
- {"top":0,"height":150,"width":300,"bottom":150,"left":1123,"right":1423},
- {"top":100,"height":150,"width":300,"bottom":250,"left":1023,"right":1323},
- {"height":150,"width":300,"left":1366,"right":1666},
- {"top":0,"height":150,"width":300,"bottom":150,"left":1123,"right":1423}
- ],
- bounds,
- against,
- styles;
-
- expect( expects );
-
- function plus(){
- if ( ++count == expects ) {
- start();
- }
- }
-
- stop( 10000 );
+ expect(24);
+
+ var $absolute = $(".absolute"),
+ $relative = $(".relative"),
+ $fixed = $(".fixed"),
+ $static = $(".static"),
+ tests;
+
+ $("#position-tests").show();
+// console.log( $absolute );
+// console.log( $fixed );
+// console.log( $relative );
+// console.log( $static );
+
+ tests = [
+ { id: "absolute-1", top: 0, left: 0 },
+ { id: "absolute-1-1", top: 1, left: 1 },
+ { id: "absolute-1-1-1", top: 2, left: 2 },
+ { id: "absolute-2", top: 19, left: 19 }
+ ];
+
+ Popcorn.forEach( tests, function( test ) {
+ equals( Popcorn( "#vid-" + test.id ).position().top, test.top, "Popcorn('#vid-" + test.id + "').position().top" );
+ equals( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
+ });
- pops.forEach(function( pop, idx ) {
+ tests = [
+ { id: "relative-1", top: 0, left: 0 },
+ { id: "relative-2", top: 120, left: 20 }
+ ];
+
+ Popcorn.forEach( tests, function( test ) {
+ equals( Popcorn( "#vid-" + test.id ).position().top, test.top, "Popcorn('#vid-" + test.id + "').position().top" );
+ equals( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
+ });
+
+ tests = [
+ { id: "fixed-1", top: 0, left: 0 },
+ { id: "fixed-2", top: 20, left: 20 }
+ ];
+
+ Popcorn.forEach( tests, function( test ) {
+ equals( Popcorn( "#vid-" + test.id ).position().top, test.top, "Popcorn('#vid-" + test.id + "').position().top" );
+ equals( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
+ });
+
+ tests = [
+ { id: "static-1", top: 200, left: 0 },
+ { id: "static-1-1", top: 0, left: 0 },
+ { id: "static-1-1-1", top: 0, left: 0 },
+ { id: "static-2", top: 300, left: 0 }
+ ];
+
+ Popcorn.forEach( tests, function( test ) {
+ equals( Popcorn( "#vid-" + test.id ).position().top, test.top, "Popcorn('#vid-" + test.id + "').position().top" );
+ equals( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
+ });
- bounds = pop.position();
- against = tests[ idx ];
- styles = document.getElementById( pop.video.id ).style;
- for ( var p in bounds ) {
- if ( p in against ) {
- equal( bounds[ p ], against[ p ], "video#" + pop.video.id + ": " + p );
- plus();
- }
- }
- });
+ $("#position-tests").hide();
});
test("position called from plugin", function () {