From 0116a06b7729e342160c93db1327abe34019e1a6 Mon Sep 17 00:00:00 2001 From: aljohnson1 Date: Thu, 27 Oct 2011 20:30:42 -0400 Subject: [PATCH] Added the pause feature to a footnote plugin after removing it from the core --- plugins/footnote/popcorn.footnote.js | 15 ++++++++++++++- popcorn.js | 23 +++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/plugins/footnote/popcorn.footnote.js b/plugins/footnote/popcorn.footnote.js index b8b01b206..5812ba3fe 100755 --- a/plugins/footnote/popcorn.footnote.js +++ b/plugins/footnote/popcorn.footnote.js @@ -65,7 +65,8 @@ * options variable */ start: function(event, options){ - options._container.style.display = "inline"; + options._container.style.display = "inline"; + }, /** * @member footnote @@ -78,8 +79,20 @@ }, _teardown: function( options ) { document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options._container ); + }, + + _pause: function(event, options) { + if(options != undefined && options.pause > 0){ + if(!Popcorn.instances[0].video.paused){ + window.setTimeout(function(){ + Popcorn.instances[0].play(); + }, options.pause * 1000 ); + Popcorn.instances[0].pause(); + } + } } }); + }); })( Popcorn ); diff --git a/popcorn.js b/popcorn.js index 880adac35..06988375e 100644 --- a/popcorn.js +++ b/popcorn.js @@ -441,6 +441,7 @@ Popcorn.addTrackEvent( this, { start: time, end: time + 1, + pause: time, _running: false, _natives: { start: fn || Popcorn.nop, @@ -622,7 +623,6 @@ return this; }, listen: function( type, fn ) { - var self = this, hasEvents = true, eventHook = Popcorn.events.hooks[ type ], @@ -967,6 +967,7 @@ while ( tracks.byStart[ start ] && tracks.byStart[ start ].start <= currentTime ) { byStart = tracks.byStart[ start ]; + var byPause = byStart; natives = byStart._natives; type = natives && natives.type; @@ -980,16 +981,9 @@ obj.data.disabled.indexOf( type ) === -1 ) { byStart._running = true; - - if ( byStart.pause ) { - window.setTimeout(function(){ - obj.play(); - }, byStart.pause * 1000 ); - obj.pause(); - } - - + natives.start.call( obj, event, byStart ); + natives._pause.call(obj,event,byPause); // If the `frameAnimation` option is used, // push the current byStart object into the `animating` cue @@ -999,7 +993,8 @@ animating.push( byStart ); } } - start++; + + start++; } else { // remove track event Popcorn.removeTrackEvent( obj, byStart._id ); @@ -1196,7 +1191,6 @@ if ( !options ) { return this; } -alert(options); // Storing the plugin natives var natives = options._natives = {}, compose = "", @@ -1236,10 +1230,11 @@ alert(options); // Checks for expected properties if ( !( "start" in options ) ) { options.start = 0; - } - + if( !( "pause" in options)){ + options.pause = 0; + } if ( !( "end" in options ) ) { options.end = this.duration() || Number.MAX_VALUE; }