123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
-
-
- (function ( Popcorn ) {
-
- var i = 0,
- createDefaultContainer = function( context, id ) {
-
- var ctxContainer = context.container = document.createElement( "div" ),
- style = ctxContainer.style,
- media = context.media;
-
- var updatePosition = function() {
- var position = context.position();
-
- style.fontSize = "18px";
- style.width = media.offsetWidth + "px";
- style.top = position.top + media.offsetHeight - ctxContainer.offsetHeight - 40 + "px";
- style.left = position.left + "px";
-
- setTimeout( updatePosition, 10 );
- };
-
- ctxContainer.id = id || Popcorn.guid();
- style.position = "absolute";
- style.color = "white";
- style.textShadow = "black 2px 2px 6px";
- style.fontWeight = "bold";
- style.textAlign = "center";
-
- updatePosition();
-
- context.media.parentNode.appendChild( ctxContainer );
-
- return ctxContainer;
- };
-
-
-
-
- Popcorn.plugin( "subtitle" , {
-
- manifest: {
- about: {
- name: "Popcorn Subtitle Plugin",
- version: "0.1",
- author: "Scott Downe",
- website: "http://scottdowne.wordpress.com/"
- },
- options: {
- start: {
- elem: "input",
- type: "text",
- label: "Start"
- },
- end: {
- elem: "input",
- type: "text",
- label: "End"
- },
- target: "subtitle-container",
- text: {
- elem: "input",
- type: "text",
- label: "Text"
- }
- }
- },
-
- _setup: function( options ) {
- var newdiv = document.createElement( "div" );
-
- newdiv.id = "subtitle-" + i++;
- newdiv.style.display = "none";
-
-
- ( !this.container && ( !options.target || options.target === "subtitle-container" ) ) &&
- createDefaultContainer( this );
-
-
- if ( options.target && options.target !== "subtitle-container" ) {
-
- options.container = document.getElementById( options.target ) || createDefaultContainer( this, options.target );
- } else {
-
- options.container = this.container;
- }
-
- document.getElementById( options.container.id ) && document.getElementById( options.container.id ).appendChild( newdiv );
- options.innerContainer = newdiv;
-
- options.showSubtitle = function() {
- options.innerContainer.innerHTML = options.text || "";
- };
- },
-
-
- start: function( event, options ){
- options.innerContainer.style.display = "inline";
- options.showSubtitle( options, options.text );
- },
-
-
- end: function( event, options ) {
- options.innerContainer.style.display = "none";
- options.innerContainer.innerHTML = "";
- },
-
- _teardown: function ( options ) {
- options.container.removeChild( options.innerContainer );
- }
-
- });
-
- })( Popcorn );
|