Sha256: d349dd1f7ea840a10117de42827575d8aeb6d6c7bdd5926f2661249732e2e40f

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

//= require libs/jplayer
//= require transit/views/audio_player

(function(transit){
	
	var audio = function( element, options ){
		var self   = this;	
		var data   = transit.context.data( element, true ) || {},
			config = transit.merge( options, data ),
			conf   = transit.config['audio'],
			uid    = _.uniqueId(),
			ui     = transit.template.parse('transit/views/audio_player', { uid: uid }),
			player_element = jQuery("<div class='player_instance' id='transit_audio_"+ uid +"'></div>");
		
		jQuery.extend(self, {
			play:  function(){ element.jPlayer('play'); },
			pause: function(){ element.jPlayer('pause'); },
			stop:  function(){ element.jPlayer("stop"); }
		});
		
		conf.ready = function(){
			var opts = {}, ext = config.ext;
			if( typeof ext == 'undefined' ) ext = /[^.]+$/.exec(config.source);
			opts[ext] = config.source;				
			jQuery(player_element).jPlayer('setMedia', opts);
		};
				
		conf.cssSelectorAncestor = '#transit_media_interface_' + uid;
		element.append(player_element);
		element.append(jQuery(ui)).addClass('media-audio');
		player_element.jPlayer(conf);				
		
		return self;
	};
	
	transit.context.add("audio", audio);
	
	
})(transit);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transit-0.0.2 app/assets/javascripts/transit/contexts/audio.js