From: David Seifried Date: Wed, 22 Jun 2011 14:25:11 +0000 (-0400) Subject: [#556] Added some styling changes, rearranged some stuff, and wrote a unit test X-Git-Tag: v0.7^2~28^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=ae88accb352b56632a980e71778cc09d63ecbbfc;p=popcorn-js.git [#556] Added some styling changes, rearranged some stuff, and wrote a unit test --- diff --git a/plugins/googlefeed/popcorn.googlefeed.js b/plugins/googlefeed/popcorn.googlefeed.js index 7b4417b..d2ce8b8 100755 --- a/plugins/googlefeed/popcorn.googlefeed.js +++ b/plugins/googlefeed/popcorn.googlefeed.js @@ -24,7 +24,7 @@ // Checking if the css file is already included for ( ; k < len; k++ ){ - if ( links[ k ].href == "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css" ) { + if ( links[ k ].href === "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css" ) { dontLoad = true; } } @@ -98,6 +98,12 @@ } }; + // Default to vertical orientation if empty or incorrect input + if( !options.orientation || ( options.orientation.toLowerCase() !== "vertical" && + options.orientation.toLowerCase() !== "horizontal" ) ) { + options.orientation = "vertical"; + } + newdiv.style.display = "none"; newdiv.id = "_feed" + i; newdiv.style.width = "100%"; @@ -117,11 +123,6 @@ */ start: function( event, options ){ newdiv.setAttribute( "style", "display:inline" ); - // Default to vertical orientation if empty or incorrect input - if( !options.orientation || ( options.orientation.toLowerCase() !== "vertical" && - options.orientation.toLowerCase() !== "horizontal" ) ) { - options.orientation = "vertical"; - } }, /** * @member webpage @@ -147,30 +148,30 @@ }, options: { start: { - elem:"input", - type:"text", - label:"In" + elem: "input", + type: "text", + label: "In" }, end: { - elem:"input", - type:"text", - label:"Out" + elem: "input", + type: "text", + label: "Out" }, target: "feed-container", url: { - elem:"input", - type:"text", - label:"url" + elem: "input", + type: "text", + label: "url" }, title: { - elem:"input", - type:"text", - label:"title" + elem: "input", + type: "text", + label: "title" }, orientation: { - elem:"select", - options:["Vertical","Horizontal"], - label:"orientation" + elem: "select", + options: [ "Vertical","Horizontal" ], + label: "orientation" } } }); diff --git a/plugins/googlefeed/popcorn.googlefeed.unit.js b/plugins/googlefeed/popcorn.googlefeed.unit.js index 7fcada9..027625b 100755 --- a/plugins/googlefeed/popcorn.googlefeed.unit.js +++ b/plugins/googlefeed/popcorn.googlefeed.unit.js @@ -1,21 +1,21 @@ test("Popcorn Google Feed Plugin", function () { - var popped = Popcorn("#video"), - expects = 11, + var popped = Popcorn( "#video" ), + expects = 12, setupId, count = 0; expect(expects); function plus() { - if ( ++count===expects) { + if ( ++count === expects) { start(); } } stop(); - ok ('googlefeed' in popped, "googlefeed is a method of the popped instance"); + ok ( 'googlefeed' in popped, "googlefeed is a method of the popped instance" ); plus(); ok ( document.getElementById('feed').innerHTML === "", "initially, there is nothing inside the feed" ); plus(); @@ -28,7 +28,6 @@ test("Popcorn Google Feed Plugin", function () { target: "feed", url: "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml", title: "Planet Feed", - orientation: "Vertical" }) .googlefeed({ start: 2, // seconds @@ -43,23 +42,25 @@ test("Popcorn Google Feed Plugin", function () { setupId = popped.getLastTrackEventId(); popped.exec( 1, function() { - ok(google.load, "Google Feed is available"); + ok( google.load, "Google Feed is available"); plus(); - ok(GFdynamicFeedControl, "Dynamic Feed Control Available"); + ok( GFdynamicFeedControl, "Dynamic Feed Control Available"); plus(); - ok (document.getElementById('_feed1'), "First feed is on the page" ); + ok ( document.getElementById('_feed1'), "First feed is on the page" ); plus(); - equals (document.getElementById('_feed1').offsetParent.id, "feed", "First feed is inside the 'feed' div" ); + equals ( document.getElementById('_feed1').offsetParent.id, "feed", "First feed is inside the 'feed' div" ); + plus(); + equals( popped.data.trackEvents.byStart[1].orientation, "vertical", "Defaulting to vertical orientation" ); plus(); }); popped.exec( 2, function() { - ok (document.getElementById('_feed2'), "Second feed is on the page" ); + ok ( document.getElementById('_feed2'), "Second feed is on the page" ); plus(); - equals (document.getElementById('_feed2').offsetParent.id, "feed1", "Second feed is inside the 'feed2' div" ); + equals ( document.getElementById('_feed2').offsetParent.id, "feed1", "Second feed is inside the 'feed2' div" ); plus(); }); popped.exec( 3, function() { - ok (document.getElementById('_feed2').style.display === "none" && + ok ( document.getElementById('_feed2').style.display === "none" && document.getElementById('_feed1').style.display === "none", "Both feeds are no lnger visible" ); plus();