]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Added unit tests, also made a few changes to simplify the use a bit
authorDavid Seifried <david.c.seifried@gmail.com>
Tue, 17 May 2011 16:04:39 +0000 (12:04 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Tue, 17 May 2011 16:04:39 +0000 (12:04 -0400)
plugins/googlemap/popcorn.googlemap.html
plugins/googlemap/popcorn.googlemap.js
plugins/googlemap/popcorn.googlemap.unit.html
plugins/googlemap/popcorn.googlemap.unit.js

index a351a57a3fe1d30fd5cc1e306da3e68d054cb2a0..d0cac6429c181c08213a1f3f0680eaf8ea4c4f1e 100644 (file)
@@ -31,7 +31,7 @@
         heading: "180",
         pitch: "1",
                                interval: 1000,
-                               endLoc: "York university"
+                               tween: "York university"
       })
       .googlemap({
         start: 0, // seconds
@@ -45,7 +45,7 @@
         heading: "180",
         pitch: "1",
                                interval: 1000,
-                               endLoc: "Ottawa"
+                               tween: "Ottawa"
       })
       .googlemap({
         start: 0, // seconds
   </div>
 </body>
 </html>
+
index 4dc4d01f584d322821bcbccb0eadf21d8c86cc9e..3214b770420109dd5ccfe3f2741e1e844361c9f7 100644 (file)
@@ -49,13 +49,13 @@ var googleCallback;
      * cause and error.\r
      *\r
      * Tweening works using the following specifications:\r
-     * -Location is the start point when using an auto generated route\r
-     * -endLoc is the end location when using an auto generated route\r
-     * Note that both location and endLoc must be present when using an auto generated route, or the map will not tween\r
-     * -Interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds )\r
+     * -location is the start point when using an auto generated route\r
+     * -tween when used in this context is a string which specifies the end location for your route\r
+     * Note that both location and tween must be present when using an auto generated route, or the map will not tween\r
+     * -interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds )\r
      * Heading, Zoom, and Pitch streetview values are also used in tweening with the autogenerated route\r
      *\r
-     * -Tween is an array of objects, each containing data for one frame of a tween\r
+     * -tween is an array of objects, each containing data for one frame of a tween\r
      * -position is an object with has two paramaters, lat and lng, both which are mandatory for a tween to work\r
      * -pov is an object which houses heading, pitch, and zoom paramters, which are all optional, if undefined, these values default to 0\r
      * -interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds )\r
@@ -186,14 +186,14 @@ var googleCallback;
 \r
 \r
                                 );\r
-                                                             \r
+                                         \r
                                 //  Function to handle tweening using a set timeout\r
                                 var tween = function ( rM, t ) {\r
 \r
                                   setTimeout( function () {\r
-\r
+          \r
                                     //  Checks whether this is a generated route or not\r
-                                    if( options.tween ){\r
+                                    if( typeof options.tween === "array" ){\r
 \r
                                       for ( var i = 0; i < rM.length; i++ ) {\r
 \r
@@ -244,7 +244,7 @@ var googleCallback;
                                 //  Determines if we should use hardcoded values ( using options.tween ),\r
                                 //  or if we should use a start and end location and let google generate\r
                                 //  the route for us\r
-                                if ( !options.tween && ( options.location && options.endLoc ) ){\r
+                                if ( options.location && typeof options.tween === "string" ){\r
 \r
                                 //  Creating another variable to hold the streetview map for tweening,\r
                                 //  Doing this because if there was more then one streetview map, the tweening would sometimes appear in other maps\r
@@ -262,7 +262,7 @@ var googleCallback;
 \r
                                   var request = {\r
                                     origin:      options.location,\r
-                                    destination: options.endLoc,\r
+                                    destination: options.tween,\r
                                     travelMode:  google.maps.TravelMode.DRIVING\r
                                   };\r
 \r
@@ -289,7 +289,7 @@ var googleCallback;
 \r
                                   }\r
                                 }\r
-                                else if( options.tween ){\r
+                                else if( typeof options.tween === "array" ){\r
 \r
                                   //  Same as the above to stop streetview maps from overflowing into one another\r
                                   var sView3 = sView;\r
index 476d0bf4b8b45d40b3a0cb50151ecf1ee8e7bb2b..e37ab4f669d3d36b0ec077b123caec77d4343506 100644 (file)
@@ -39,6 +39,8 @@
 
   </video> 
   <div id="map" style="position:relative;float:left;width:300px;height:400px"></div> 
-  <div id="map2" style="position:relative;float:left;width:300px;height:400px"></div>   
+  <div id="map2" style="position:relative;float:left;width:300px;height:400px"></div>
+  <div id="map3" style="position:relative;float:left;width:300px;height:400px"></div>    
 </body>
 </html>
+
index 778a59d285abdf7a93a2ae3c42e47561e4e9fe30..a4d6b53dfa7e2e6826c69167d2e2cf9aed412566 100644 (file)
@@ -24,6 +24,9 @@ test("Popcorn Google Map Plugin", function () {
   ok ( document.getElementById('map2').innerHTML === "", "initially, there is nothing inside the map2" );
   plus();
   
+  ok ( document.getElementById('map3').innerHTML === "", "initially, there is nothing inside the map3" );
+  plus();
+  
   popped.googlemap({
     start: 0, // seconds
     end: 5, // seconds
@@ -34,23 +37,26 @@ test("Popcorn Google Map Plugin", function () {
     zoom: 10
   })
   .googlemap({
-    start: 0, // seconds
-    end: 5, // seconds
-    type: 'SATELLITE',
-    target: 'map2',
-    location:'boston',
-    zoom: 15
-  })
-  .volume(0);
-
-    popped.googlemap({
       start: 0, // seconds
       end: 10, // seconds
       type: 'SATELLITE',
       target: 'map2',
       location:'toronto',
       zoom: 15
-    });
+  });
+  var mapz = popped.googlemap({
+    start: 0, // seconds
+    end: 15, // seconds
+    type: "STREETVIEW",
+    target: "map3",
+    location: "6th Line, Oakville, Ontario",
+    zoom: "1",
+    heading: "180",
+    pitch: "1",
+         interval: 1000,
+         tween: "York university"
+  })
+  .volume(0);
 
   setupId = popped.getLastTrackEventId();
 
@@ -72,18 +78,25 @@ test("Popcorn Google Map Plugin", function () {
     plus();
   });
 
-  popped.exec( 6, function() {
+  popped.exec( 4, function() {
+    equals (document.getElementById('actualmap3').offsetParent.id, "map3", "Tweening map is inside the 'map3' div" );
+    plus();
+  });
+
+  popped.exec( 20, function() {
     ok (document.getElementById('actualmap2').style.display === "none" && 
-        document.getElementById('actualmap1').style.display === "none", "Both maps are no longer visible" );
+        document.getElementById('actualmap1').style.display === "none" &&
+        document.getElementById('actualmap3').style.display === "none", "All maps are no longer visible" );
     plus();
     popped.pause();
 
     popped.removeTrackEvent( setupId );
 
-    ok( !document.getElementById('actualmap3'), "removed map was properly destroyed"  );
+    ok( !document.getElementById('actualmap4'), "removed map was properly destroyed"  );
     plus();
   });
 
   popped.play();
   
 });
+