Skip to content

Commit

Permalink
added some track->event restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
secretrobotron committed Jun 20, 2011
1 parent d49d4f9 commit 39649a8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
6 changes: 3 additions & 3 deletions index.html
Expand Up @@ -25,11 +25,11 @@
restrictToKnownPlugins: true,
});

trackline.createTrack('Track1').createTrackEvent( 'default', { start: 1, end: 5, label: 'awesome' } );
trackline.createTrack('Track2').createTrackEvent( 'default', { start: 0, end: 2,
trackline.createTrack('Should\'t Work').createTrackEvent( 'default', { start: 1, end: 5, label: 'awesome' } );
trackline.createTrack('Should Work 1', 'default').createTrackEvent( { start: 0, end: 2,
classes: ['test-class'],
});
trackline.createTrack('Track3').createTrackEvent( 'default', {
trackline.createTrack('Should Work 2', 'default').createTrackEvent( 'default', {
start: 4,
end: 7,
css: {
Expand Down
36 changes: 29 additions & 7 deletions trackliner.js
Expand Up @@ -77,10 +77,10 @@
eventCount = 0;
};

this.createTrack = function( name ) {
this.createTrack = function( name, type ) {

//index = ~index || ~trackArray.length;
var track = new Track(),
var track = new Track( name, type ),
element = track.getElement();

container.appendChild( element );
Expand Down Expand Up @@ -146,12 +146,23 @@

this.setScale(scale);

var Track = function(inc) {
var Track = function( name, type ) {

var trackId = "trackLiner" + trackCount++,
events = {},
that = this,
element = document.createElement( "div" );
element = document.createElement( "div" ),
pluginType = typeof(type) === 'string' ? (restrictToKnownPlugins && plugins[ type ] ? type : undefined) : (restrictToKnownPlugins ? undefined : 'default'),
pluginDef = plugins[ type ],
name = name || trackId;

this.name = function () {
return name;
}; //name

this.type = function () {
return pluginType;
};

element.className = 'trackliner-track';
element.id = trackId;
Expand Down Expand Up @@ -222,9 +233,20 @@
var trackEvent = {},
eventId = "trackEvent" + eventCount++,
inputOptions = typeof(type) === 'string' ? inputOptions : type,
type = typeof(type) === 'string' ? type : (restrictToKnownPlugins ? undefined : 'default'),
pluginDef = plugins[ type ];

pluginDef;

if ( pluginType ) {
type = ( pluginType === type || typeof( type ) === 'object' ) ? pluginType : undefined;
}
else if ( restrictToKnownPlugins ) {
type = undefined;
}
else {
type = 'default';
} //if

pluginDef = plugins[ type ];

if (pluginDef) {

var trackOptions = plugins[ type ].setup( that, inputOptions, event, ui );
Expand Down

0 comments on commit 39649a8

Please sign in to comment.