-
Notifications
You must be signed in to change notification settings - Fork 0
/
popcorn.pause.js
29 lines (26 loc) · 973 Bytes
/
popcorn.pause.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* Pause Popcorn Plug-in
*
* When this plugin is used, links on the webpage, when clicked, will pause
* popcorn videos that especified 'pauseOnLinkClicked' as an option. Links may
* cause a new page to display on a new window, or may cause a new page to
* display in the current window, in which case the videos won't be available
* anymore. It only affects anchor tags. It does not affect objects with click
* events that act as anchors.
*
* Example:
var p = Popcorn('#video', { pauseOnLinkClicked : true } )
.play();
*
*/
document.addEventListener( "click", function( event ) {
var targetElement = event.target;
//Some browsers use an element as the target, some use the text node inside
if ( targetElement.nodeName === "A" || targetElement.parentNode && targetElement.parentNode.nodeName === "A" ) {
Popcorn.instances.forEach( function( video ) {
if ( video.options.pauseOnLinkClicked ) {
video.pause();
}
});
}
}, false );