text: /*! StickyPlayer v0.1.0 */ !function(a){var b=function(a){if(this._options=a,this._playerElement=null,this._artworkElement=null,this._titleElement=null,this._progressElement=null,this._waveformElement=null,this._elapsedElement=null,this._durationElement=null,this._currentElement=null,this._durationMS=0,this._visible=!1,!a||!a.playerId)throw new Error("Player Id required (options.playerId)");if(!a.observeElementId)throw new Error("Observe Element Id required (options.observeElementId)");if(!a.playButtonClass)throw new Error("Play button class required (options.playButtonClass)");this.createPlayerDOM(),this._player=new CrossPlayer({elementId:"players-container",scClientId:this._options.scClientId}),this._player.onStopped(this.onStopped.bind(this)),this._player.onLoading(this.onLoading.bind(this)),this._player.onPlaying(this.onPlaying.bind(this)),this._player.onPaused(this.onPaused.bind(this)),this._player.onEnded(this.onEnded.bind(this)),this._player.onProgress(this.onProgress.bind(this)),this._player.onTrackData(this.onTrackData.bind(this)),this._player.onInteractionRequired(this.onInteractionRequired.bind(this)),jQuery(".playpause",this._playerElement).click(this.playPause.bind(this)),jQuery(".progress-container",this._playerElement).click(this.seek.bind(this)),this.observeDOM(jQuery("#"+this._options.observeElementId)[0],this.enablePlayButtons.bind(this)),this.enablePlayButtons()};b.prototype.createPlayerDOM=function(){this._playerElement=jQuery("#"+this._options.playerId).addClass("sticky-player"),this._artworkElement=jQuery('<div class="artwork"></div>'),this._titleElement=jQuery('<div class="title"></div>'),this._progressElement=jQuery('<div class="progress-bar progress-bar-custom progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"><span class="sr-only">0% Complete</span></div>'),this._waveformElement=jQuery('<div class="waveform"></div>'),this._elapsedElement=jQuery('<div class="time elapsed"></div>'),this._durationElement=jQuery('<div class="time duration"></div>');jQuery('<div class="playpause"></div>');this._playerElement.append(jQuery('<div class="container"></div>').append(jQuery('<div class="artwork-container"></div>').append(jQuery('<div class="players" id="players-container"></div>')).append(this._artworkElement).append(jQuery('<div class="loading"></div>')).append(jQuery('<div class="playpause"></div>'))).append(jQuery('<div class="title-container"></div>').append(this._titleElement)).append(jQuery('<div class="progress-container"></div>').append(jQuery('<div class="progress"></div>').append(this._progressElement).append(this._waveformElement).append(this._elapsedElement).append(this._durationElement))))},b.prototype.observeDOM=function(){var a=window.MutationObserver||window.WebKitMutationObserver,b=window.addEventListener;return function(c,d){if(a){var e=new a(function(a,b){(a[0].addedNodes.length||a[0].removedNodes.length)&&d()});e.observe(c,{childList:!0,subtree:!0})}else b&&(c.addEventListener("DOMNodeInserted",d,!1),c.addEventListener("DOMNodeRemoved",d,!1))}}(),b.prototype.enablePlayButtons=function(){var a=this;jQuery("."+this._options.playButtonClass).each(function(b,c){jQuery(c).data("events")||jQuery(c).click(function(b){a.play(this)})})},b.prototype.durationFromMs=function(a){var b=~~(a/1e3),c=~~(b/60);return c+":"+this.pad(b%60,2,"0")},b.prototype.pad=function(a,b,c){return c=c||"0",a+="",a.length>=b?a:new Array(b-a.length+1).join(c)+a},b.prototype.open=function(){this._visible||(this._playerElement.addClass("open"),jQuery("body").addClass("sticky-player-open"),this._visible=!0)},b.prototype.close=function(){this._visible&&(this._playerElement.removeClass("open"),jQuery("body").removeClass("sticky-player-open"),this._visible=!1)},b.prototype.play=function(a){if(this._visible||this.open(),this._currentElement&&this._currentElement[0]==jQuery(a)[0])return void this._player.togglePlayPause();this._currentElement=jQuery(a);var b=jQuery(a).attr("stream-link"),c=jQuery(a).attr("title"),d=jQuery(a).attr("artwork"),e=this._player.playUrl(b);jQuery(a).addClass("sticky-player-loading"),this._titleElement.text(c),this._playerElement.removeClass("soundcloud youtube dropbox weblink").addClass(e),this._artworkElement.css("background-image",'url("'+d+'")')},b.prototype.playPause=function(){this._player.togglePlayPause()},b.prototype.seek=function(a){a.stopPropagation();var b=a.offsetX/a.currentTarget.offsetWidth*100;this.updateProgressFast(b);var c=b/100*this._durationMS;this._elapsedElement.text(this.durationFromMs(c)),this._player.seek(c)},b.prototype.updateProgressFast=function(a){this._progressElement.addClass("shorttransition"),this._progressElement.css("width",a+"%"),this._progressElement[0].offsetHeight,this._progressElement.removeClass("shorttransition")},b.prototype.onStopped=function(){jQuery(".sticky-player-loading, .sticky-player-playing, .sticky-player-paused").removeClass("sticky-player-loading sticky-player-playing sticky-player-paused"),this._playerElement.removeClass("playing paused loading"),this._titleElement.text(""),this._artworkElement.css("background-image","none"),this._elapsedElement.text(""),this._durationElement.text(""),this._progressElement.removeClass("active"),this.updateProgressFast(0),jQuery(".sticky-player-loading").removeClass("sticky-player-loading")},b.prototype.onLoading=function(){this._currentElement.removeClass("sticky-player-paused sticky-player-playing").addClass("sticky-player-loading"),this._playerElement.addClass("loading").removeClass("paused playing"),this._progressElement.removeClass("active")},b.prototype.onPlaying=function(){jQuery(".sticky-player-loading").removeClass("sticky-player-loading"),this._currentElement.removeClass("sticky-player-paused sticky-player-loading").addClass("sticky-player-playing"),this._progressElement.addClass("active"),this._playerElement.addClass("playing").removeClass("paused loading interaction-required")},b.prototype.onPaused=function(){jQuery(".sticky-player-loading").removeClass("sticky-player-loading"),this._currentElement.removeClass("sticky-player-playing sticky-player-loading").addClass("sticky-player-paused"),this._playerElement.addClass("paused").removeClass("playing loading"),this._progressElement.removeClass("active")},b.prototype.onEnded=function(){var a,b=jQuery("."+this._options.playButtonClass).index(this._currentElement);if(b==-1){var c=jQuery('[stream-link="'+this._currentElement.attr("stream-link")+'"]:last');a=jQuery("."+this._options.playButtonClass).eq(jQuery("."+this._options.playButtonClass).index(c)+1)}else a=jQuery("."+this._options.playButtonClass).eq(b+1);a.attr("stream-link")==this._currentElement.attr("stream-link")&&(a=jQuery("."+this._options.playButtonClass).eq(b+2)),0==a.length&&(a=jQuery("."+this._options.playButtonClass).eq(0)),0==a.length?this.close():a.click()},b.prototype.onProgress=function(a){this._durationMS=a.durationMS,this._progressElement.css("width",a.elapsedMS/a.durationMS*100+"%"),jQuery(".sr-only",this._progressElement).text(Math.round(a.elapsedMS/a.durationMS*100*10)/10+"% Complete"),this._elapsedElement.text(this.durationFromMs(a.elapsedMS)),this._durationElement.text(this.durationFromMs(a.durationMS))},b.prototype.onTrackData=function(a){a.waveform_url&&this._waveformElement.css("background-image",'url("'+a.waveform_url+'")')},b.prototype.onInteractionRequired=function(a){this._playerElement.addClass("interaction-required")},a.StickyPlayer=b}(this);