]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#657] Adds text alias to footnote plugin
authorRick Waldron <waldron.rick@gmail.com>
Wed, 20 Jul 2011 18:40:28 +0000 (14:40 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Wed, 20 Jul 2011 18:40:28 +0000 (14:40 -0400)
plugins/footnote/popcorn.footnote.js

index 2570da1e3c89893756a77028e9af5594b89eb60d..fba5771f281c18503423438bbcde048f328e0b9f 100755 (executable)
@@ -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({
         } )
    *
    */
-  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 );