From: Rick Waldron Date: Wed, 20 Jul 2011 18:40:28 +0000 (-0400) Subject: [#657] Adds text alias to footnote plugin X-Git-Tag: v0.8^2~24^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=5b25ec2269b0b2af3ada0de0485192a934f82d2b;p=popcorn-js.git [#657] Adds text alias to footnote plugin --- diff --git a/plugins/footnote/popcorn.footnote.js b/plugins/footnote/popcorn.footnote.js index 2570da1..fba5771 100755 --- a/plugins/footnote/popcorn.footnote.js +++ b/plugins/footnote/popcorn.footnote.js @@ -1,19 +1,19 @@ -// PLUGIN: Footnote +// PLUGIN: Footnote/Text (function (Popcorn) { - + /** - * Footnote popcorn plug-in + * Footnote popcorn plug-in * Adds text to an element on the page. * Options parameter will need a start, end, target and text. * Start is the time that you want this plug-in to execute - * End is the time that you want this plug-in to stop executing + * End is the time that you want this plug-in to stop executing * Text is the text that you want to appear in the target - * Target is the id of the document element that the text needs to be + * Target is the id of the document element that the text needs to be * attached to, this target element must exist on the DOM - * + * * @param {Object} options - * + * * Example: var p = Popcorn('#video') .footnote({ @@ -24,50 +24,59 @@ } ) * */ - Popcorn.plugin( "footnote" , { - - manifest: { - about:{ - name: "Popcorn Footnote Plugin", - version: "0.1", - author: "@annasob", - website: "annasob.wordpress.com" + + Popcorn.forEach( [ "footnote", "text" ], function( name ) { + + Popcorn.plugin( name , { + + manifest: { + about:{ + name: "Popcorn " + name + " Plugin", + version: "0.2", + author: "@annasob, @rwaldron", + website: "annasob.wordpress.com" + }, + options:{ + start : {elem:'input', type:'text', label:'In'}, + end : {elem:'input', type:'text', label:'Out'}, + target : name + '-container', + text : {elem:'input', type:'text', label:'Text'} + } }, - options:{ - start : {elem:'input', type:'text', label:'In'}, - end : {elem:'input', type:'text', label:'Out'}, - target : 'footnote-container', - text : {elem:'input', type:'text', label:'Text'} - } - }, - _setup: function(options) { - options._container = document.createElement( 'div' ); - options._container.style.display = "none"; - options._container.innerHTML = options.text; + _setup: function(options) { + options._container = document.createElement( 'div' ); + options._container.style.display = "none"; + options._container.innerHTML = options.text; - document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( options._container ); - }, - /** - * @member footnote - * The start function will be executed when the currentTime - * of the video reaches the start time provided by the - * options variable - */ - start: function(event, options){ - options._container.style.display = "inline"; - }, - /** - * @member footnote - * The end function will be executed when the currentTime - * of the video reaches the end time provided by the - * options variable - */ - end: function(event, options){ - options._container.style.display = "none"; - }, - _teardown: function( options ) { - document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options._container ); - } + var target = document.getElementById( options.target ); + + target && target.appendChild( options._container ); + }, + /** + * @member footnote + * The start function will be executed when the currentTime + * of the video reaches the start time provided by the + * options variable + */ + start: function(event, options){ + options._container.style.display = "inline"; + }, + /** + * @member footnote + * The end function will be executed when the currentTime + * of the video reaches the end time provided by the + * options variable + */ + end: function(event, options){ + options._container.style.display = "none"; + }, + _teardown: function( options ) { + + var target = document.getElementById( options.target ); + + target && target.removeChild( options._container ); + } + }); }); })( Popcorn );