Browse files

Added the pause feature to a footnote plugin after removing it from t…

…he core
  • Loading branch information...
1 parent dbf19c3 commit 0116a06b7729e342160c93db1327abe34019e1a6 @aljohnson1 committed Oct 27, 2011
Showing with 23 additions and 15 deletions.
  1. +14 −1 plugins/footnote/popcorn.footnote.js
  2. +9 −14 popcorn.js
View
15 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 );
View
23 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;
}

0 comments on commit 0116a06

Please sign in to comment.