#721 ✓ staged
Rick

Move automagical data-timeline-source logic to own module

Reported by Rick | September 15th, 2011 @ 09:05 PM | in 0.9 (closed)

There, I said it. We can build this into popcorn-complete, no one will know the difference

This is the part that gets moved:


document.addEventListener( "DOMContentLoaded", function() {

  //  Supports non-specific elements
  var dataAttr = "data-timeline-sources",
      medias = document.querySelectorAll( "[" + dataAttr + "]" );

  Popcorn.forEach( medias, function( idx, key ) {

    var media = medias[ key ],
        hasDataSources = false,
        dataSources, data, popcornMedia;

    //  Ensure that the DOM has an id
    if ( !media.id ) {

      media.id = Popcorn.guid( "__popcorn" );
    }

    //  Ensure we're looking at a dom node
    if ( media.nodeType && media.nodeType === 1 ) {

      popcornMedia = Popcorn( "#" + media.id );

      dataSources = ( media.getAttribute( dataAttr ) || "" ).split( "," );

      if ( dataSources[ 0 ] ) {

        Popcorn.forEach( dataSources, function( source ) {

          // split the parser and data as parser!file
          data = source.split( "!" );

          // if no parser is defined for the file, assume "parse" + file extension
          if ( data.length === 1 ) {

            data = source.split( "." );
            data[ 0 ] = "parse" + data[ data.length - 1 ].toUpperCase();
            data[ 1 ] = source;
          }

          //  If the media has data sources and the correct parser is registered, continue to load
          if ( dataSources[ 0 ] && popcornMedia[ data[ 0 ] ] ) {

            //  Set up the media and load in the datasources
            popcornMedia[ data[ 0 ] ]( data[ 1 ] );

          }
        });

      }

      //  Only play the media if it was specified to do so
      if ( !!popcornMedia.autoplay ) {
        popcornMedia.play();
      }

    }
  });
}, false );

We can put it a new dir maybe... /modules/ then /modules/timeline-sources/? This will be where non-core, non-player, non-plugin stuff goes. Possibly move the Popcorn.sequence submodule to here as well?

It would have to be built into popcorn-complete immediately following core.

This will break some tests in core, but that's ok, just move those tests to a new test runner of it's own in timeline-sources

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Popcorn.js is an HTML5 video framework that lets you bring elements of the web into your videos.

Popcorn.js is a project of Web Made Movies, Mozilla's Open Video Lab.

Shared Ticket Bins

Referenced by

Pages