]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
added manifest to webpage also changed the way plug-in works [#237 state:peer-review...
authorAnna Sobiepanek <annaopensource@gmail.com>
Wed, 22 Dec 2010 20:27:49 +0000 (15:27 -0500)
committerAnna Sobiepanek <annaopensource@gmail.com>
Wed, 22 Dec 2010 20:27:49 +0000 (15:27 -0500)
plugins/webpage/popcorn.webpage.html
plugins/webpage/popcorn.webpage.js
plugins/webpage/popcorn.webpage.unit.js

index 8d93137413f0ea4e8d8af6a98a7d301a0c0a23a1..563272cba5f7f880070b299539f61eaebc8362d0 100644 (file)
@@ -8,18 +8,19 @@
   <script>
     document.addEventListener('DOMContentLoaded', function () {
       var p = Popcorn('#video')
+      .volume(0)
       .play() 
       .webpage({
         id: "webpages-a", 
-        start: 5, // seconds
-        end: 15, // seconds
-        src: 'http://www.webmademovies.org',
+        start: 0, // seconds
+        end: 5, // seconds
+        src: 'http://webmademovies.org/',
         target: 'webpagediv'
       } )
       .webpage({
         id: "webpages-b", 
-        start: 20, // seconds
-        end: 45, // seconds
+        start: 0, // seconds
+        end: 10, // seconds
         src: 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js',
         target: 'webpagediv2'
       } );
@@ -30,8 +31,8 @@
 </head>
 <body>
   <h1 id="qunit-header">Popcorn WebPage Plug-in Demo</h1>
-  <p> A Webpage displaying webmademovies.org will appear at 5 seconds and disappear at 15 seconds.</p>
-  <p> A Webpage displaying zenit Processing.js wiki will appear at 20 seconds and disappear at 45 seconds.</p>
+  <p> A Webpage displaying webmademovies.org will appear at 0 seconds and disappear at 5 seconds.</p>
+  <p> A Webpage displaying zenit Processing.js wiki will appear at 0 seconds and disappear at 15 seconds.</p>
   <div>
     <video id='video' 
       controls preload='none' 
index d34dc9d37cd2d821167820055e4a0fe742a331cc..17c8e77789675f79676f28f98d5042a4d3c74965 100644 (file)
    *
    */
   Popcorn.plugin( "webpage" , (function(){
-      
-    var exists, iframe, temp;
-    iframe  = document.createElement( 'iframe' ),
-    iframe.setAttribute('width', "100%");
-    iframe.setAttribute('height', "100%");
-    
-    
+     
     return {
+      manifest: {
+        about:{
+          name: "Popcorn Webpage Plugin",
+          version: "0.1",
+          author: "@annasob",
+          website: "annasob.wordpress.com"
+        },
+        options:{
+          id     : {elem:'input', type:'text', label:'Id'},
+          start  : {elem:'input', type:'text', label:'In'},
+          end    : {elem:'input', type:'text', label:'Out'},
+          src    : {elem:'input', type:'text', label:'Src'},
+          target : 'iframe-container'
+        }
+      },
+      _setup : function( options ) {
+        options.target    = document.getElementById( options.target );
+        // make an iframe 
+        options._iframe  = document.createElement( 'iframe' ),
+        options._iframe.setAttribute('width', "100%");
+        options._iframe.setAttribute('height', "100%");
+        options._iframe.id  = options.id;
+        options._iframe.src = options.src;
+        options._iframe.style.display = 'none';
+        // add the hidden iframe to the DON
+        options.target.appendChild(options._iframe);
+        
+      },
       /**
        * @member webpage 
        * The start function will be executed when the currentTime 
        * options variable
        */
       start: function(event, options){
-        temp    = document.getElementById( options.target );
-        iframe.id  = options.id;
-        iframe.src = options.src;
-        temp.appendChild(iframe);
+        // make the iframe visible
+        options._iframe.style.display = 'inline';
       },
       /**
        * @member webpage 
@@ -54,7 +74,8 @@
        * options variable
        */
       end: function(event, options){
-        temp.removeChild(iframe);
+        // make the iframe invisible
+        options._iframe.style.display = 'none';
       }
       
     };
index a402670c0e861098924baa3922b5a52ab6344198..7ba514b6e3426de1bb023f079e7d4e9b82003358 100644 (file)
@@ -1,7 +1,7 @@
 test("Popcorn Webpage Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 11, 
+      expects = 10, 
       count = 0,
       iframeInterval,
       iframeInterval2,
@@ -26,28 +26,29 @@ test("Popcorn Webpage Plugin", function () {
   
   popped.webpage({
       id: "webpages-a", 
-      start: 5, // seconds
-      end: 25, // seconds
+      start: 0, // seconds
+      end: 5, // seconds
       src: 'http://webmademovies.org',
       target: 'webpagediv'
     })
     .webpage({
       id: "webpages-b", 
-      start: 35, // seconds
-      end: 50, // seconds
+      start: 7, // seconds
+      end: 10, // seconds
       src: 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js',
       target: 'webpagediv'
     })
+    .volume(0)
     .play();
   
   
   iframeInterval = setInterval( function() {
-    if( popped.currentTime() > 7 && popped.currentTime() <= 25 ) {
+    if( popped.currentTime() > 1 && popped.currentTime() <= 5 ) {
       ok (!!theiFrame[0], "iframe was created" );
       plus();
-      equals (theiFrame.length, 1, "there is only one iframe on the page" );
+      equals (theiFrame.length, 2, "there is only two iframes on the page" );
       plus();
-      equals (theiFrame[0].id, "webpages-a", "iframe has the id 'webpages-a'" );
+      equals (theiFrame[0].id, "webpages-a", "the first iframe has the id 'webpages-a'" );
       plus();
       equals (theiFrame[0].src, "http://webmademovies.org/", "iframe has the src 'http://webmademovies.org/'" );
       plus();
@@ -56,22 +57,20 @@ test("Popcorn Webpage Plugin", function () {
   }, 5000);
   
   iframeInterval2 = setInterval( function() {
-    if( popped.currentTime() > 27 && popped.currentTime() < 35  ) {
-      equals (theiFrame.length, 0, "the iframe has been removed" );
+    if( popped.currentTime() > 10 ) {
+      ok (theiFrame[0].style.display === 'none' && theiFrame[1].style.display === 'none', "both iframes are hidden" );
       plus();
       clearInterval( iframeInterval2 );
     }
-  }, 5000);
+  }, 15000);
   
   iframeInterval3 = setInterval( function() {
-    if( popped.currentTime() > 37 && popped.currentTime() <= 50 ) {
-      ok (!!theiFrame[0], "iframe was created" );
-      plus();
-      equals (theiFrame.length, 1, "there is only one iframe on the page" );
+    if( popped.currentTime() > 8 && popped.currentTime() <= 10 ) {
+      ok (!!theiFrame[1], "iframe was created" );
       plus();
-      equals (theiFrame[0].id, "webpages-b", "iframe has the id 'webpages-b'" );
+      equals (theiFrame[1].id, "webpages-b", "iframe second has the id 'webpages-b'" );
       plus();
-      equals (theiFrame[0].src,"http://zenit.senecac.on.ca/wiki/index.php/Processing.js", "iframe has the src 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js'" );
+      equals (theiFrame[1].src,"http://zenit.senecac.on.ca/wiki/index.php/Processing.js", "iframe has the src 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js'" );
       plus();
       clearInterval( iframeInterval3 );
     }