if(typeof sz=="undefined")var sz={};if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.feeds=="undefined")sz.tmpl.feeds={};
sz.tmpl.feeds.formatActors=function(b,c){var a=c||new soy.StringBuilder;if(b.actors.length==1)a.append('<a href="/user/',soy.$$escapeHtml(b.actors[0].username),'/">',soy.$$escapeHtml(b.actors[0].display_name),"</a>");else for(var e=b.actors,d=e.length,f=0;f<d;f++){var g=e[f];a.append(f<3?'<a href="/user/'+soy.$$escapeHtml(g.username)+'/">'+soy.$$escapeHtml(g.display_name)+"</a>"+(!(f==d-1||f==2)?f==1||f==b.actors.length-2?" and ":" ,":""):"")}if(!c)return a.toString()};
sz.tmpl.feeds.feedItemMessage=function(b,c){var a=c||new soy.StringBuilder;b.item.event_type=="listen"?(sz.tmpl.feeds.formatActors({actors:b.item.actors},a),a.append("&thinsp;",b.item.actors.length==1?"is":"are"," listening to:")):b.item.event_type=="thumbs_up"?(sz.tmpl.feeds.formatActors({actors:b.item.actors},a),a.append('&thinsp; gave "',soy.$$escapeHtml(b.item.song.title)," a 'thumbs up' on:")):b.item.event_type=="station_name_change"?(sz.tmpl.feeds.formatActors({actors:b.item.actors},a),a.append("&thinsp; changed the name of")):
b.item.event_type=="station_desc_change"?(sz.tmpl.feeds.formatActors({actors:b.item.actors},a),a.append("&thinsp; changed the description of")):b.item.event_type=="song_add"?(sz.tmpl.feeds.formatActors({actors:b.item.actors},a),a.append('&thinsp; added "',soy.$$escapeHtml(b.item.song.title)," to")):b.item.event_type=="simple_create"||b.item.event_type=="advanced_create"?(sz.tmpl.feeds.formatActors({actors:b.item.actors},a),a.append("&thinsp; created")):a.append(soy.$$escapeHtml(b.item.message));if(!c)return a.toString()};
sz.tmpl.feeds.feedList=function(b,c){var a=c||new soy.StringBuilder;if(b.fetching)a.append('<div class="szi-fetching">Fetching Feed</div>');else if(b.items.length>0){a.append("<ol>");for(var e=b.items,d=e.length,f=0;f<d;f++){var g=e[f];a.append("<li",f==d-1?' class="szi-last"':"",'><div class="sz-feed-item',g.is_new?" sz-feed-item-new":"",'"><div class="szi-actor"><img src="',soy.$$escapeHtml(g.actor_pic),'" /></div><div class="szi-body"><div class="szi-actors">');sz.tmpl.feeds.feedItemMessage({item:g},
a);a.append('</div><div class="szi-message"><a href="',soy.$$escapeHtml(g.station_url),'" data-sz-station-id="',soy.$$escapeHtml(g.station.id),'">',soy.$$escapeHtml(g.station.name),'</a></div><div class="szi-description">',g.station.description?soy.$$escapeHtml(g.station.description):"&nbsp;",'</div><div class="szi-time">',soy.$$escapeHtml(g.ts_text),'</div></div><div class="szi-action"><img src="',soy.$$escapeHtml(g.station.cover_url),'?size=50" /></div></div></li>')}a.append("</ol>")}else a.append('<div class="szi-empty">No Recent Items.</div>');
if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.shelf=="undefined")sz.tmpl.shelf={};sz.tmpl.shelf.deleteShelf=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-shelf-delete"><div class="szi-delete">Delete Shelf</div><div class="szi-confirm">Are you sure you want to delete this? <span class="szi-yes">Yes</span>, <span class="szi-no">No</span></div></div>');if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.situation=="undefined")sz.tmpl.situation={};sz.tmpl.situation.wizard=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-background"></div><div class="szi-content"><div class="szi-back">Back</div><div class="szi-views"></div></div>');if(!c)return a.toString()};
sz.tmpl.situation.select_one=function(b,c){var a=c||new soy.StringBuilder;a.append('<select class="',soy.$$escapeHtml(b.cssClass),'">');for(var e=b.options,d=e.length,f=0;f<d;f++){var g=e[f];a.append('<option value="',soy.$$escapeHtml(g.value),'"',g.value==b.selectedValue?" selected":"",">",soy.$$escapeHtml(g.label),"</option>")}a.append("</select>");if(!c)return a.toString()};
sz.tmpl.situation.startingContext=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-filter">It\'s');sz.tmpl.situation.select_one({cssClass:"szi-day",options:b.dow_options,selectedValue:b.dow_choice},a);sz.tmpl.situation.select_one({cssClass:"szi-time",options:b.time_options,selectedValue:b.time_choice},a);a.append('. Play music for</div><div class="szi-loading">Loading ...</div><div class="szi-list"></div>');if(!c)return a.toString()};
sz.tmpl.situation.situation=function(b,c){var a=c||new soy.StringBuilder;a.append("<h1>",soy.$$escapeHtml(b.situation.selected_message),'</h1><div class="szi-list"></div>');if(!c)return a.toString()};
sz.tmpl.situation.situationItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-situation-item',b.situation.icon?" sz-situation-item-icon":" sz-situation-item-noicon",'">',b.situation.icon?'<div class="szi-icon"></div>':"",'<div class="szi-title">',soy.$$escapeHtml(b.situation.title),"</div></div>");if(!c)return a.toString()};
sz.tmpl.situation.stationItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-situation-station-item"><div class="szi-quilt" style="background: url(\'',soy.$$escapeHtml(b.station.cover_url),'?size=230\');"><div class="szi-info"><div class="szi-title">',soy.$$escapeHtml(b.station.name),'</div><div class="szi-description">',soy.$$escapeHtml(b.station.description),"</div></div></div></div>");if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.visitorButton=="undefined")sz.tmpl.visitorButton={};sz.tmpl.visitorButton.button=function(b,c){var a=c||new soy.StringBuilder;a.append('<a href="/user/',soy.$$escapeHtml(b.user.username),'">',soy.$$escapeHtml(b.user.display_name),' <span class="szi-unread-count"></span></a>');if(!c)return a.toString()};
sz.tmpl.visitorButton.menu=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-visitor-menu"><div class="szi-options"><img src="',soy.$$escapeHtml(b.user.images.square),'" /><a href="/user/',soy.$$escapeHtml(b.user.username),'/followers/"><span class="szi-follower-count">',soy.$$escapeHtml(b.follower_count),'</span>Followers</a><a href="/user/',soy.$$escapeHtml(b.user.username),'/following/"><span class="szi-following-count">',soy.$$escapeHtml(b.following_count),'</span>Following</a><a href="/user/',
soy.$$escapeHtml(b.user.username),'/">My Playlists</a><a href="/logout/">Log Out</a></div><div class="szi-feed sz-station-context" data-sz-station-context-name="Visitor Button Feed"></div>');if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.stationEditor=="undefined")sz.tmpl.stationEditor={};
sz.tmpl.stationEditor.songSearch=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',soy.$$escapeHtml(b.query),'" placeholder="Type an artist or song ..." /><input type="button" value="Search" /></div></div><div class="szi-results"></div>');if(!c)return a.toString()};
sz.tmpl.stationEditor.searchSongListItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-search-song" data-sz-song-id="',soy.$$escapeHtml(b.song.id),'"><img src="',soy.$$escapeHtml(b.song.cover_url),'" /><span class="szi-title" title="',soy.$$escapeHtml(b.song.title),'">',soy.$$escapeHtml(b.song.title),'</span><span class="szi-artist" title="',soy.$$escapeHtml(b.song.artist.name),'">',soy.$$escapeHtml(b.song.artist.name),'</span><span class="szi-album" title="',soy.$$escapeHtml(b.song.album),
'">',soy.$$escapeHtml(b.song.album),'</span><span class="szi-action"><a href="#" class="szi-add">Add</a></span></div>');if(!c)return a.toString()};
sz.tmpl.stationEditor.stationSongListItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-station-song" data-sz-song-id="',soy.$$escapeHtml(b.song.id),'"><img src="',soy.$$escapeHtml(b.song.cover_url),'" /><span class="szi-title">',soy.$$escapeHtml(b.song.title),'</span><span class="szi-artist">',soy.$$escapeHtml(b.song.artist.name),"</span>",b.station.creator_id&&b.song.added_by&&b.station.creator_id!=b.song.added_by.id?'<span class="szi-added-by">Added by: '+soy.$$escapeHtml(b.song.added_by.display_name)+
"</span>":"",'<span class="szi-action">',b.song.status=="ADD"||b.song.status=="RECOMMENDED"?'<a href="#" class="szi-ban" data-sz-song-id="'+soy.$$escapeHtml(b.song.id)+'">Remove</a>':b.song.status=="BAN"?'<a href="#" class="szi-unban" data-sz-song-id="'+soy.$$escapeHtml(b.song.id)+'">Add Back</a>':"","</span></div>");if(!c)return a.toString()};
sz.tmpl.stationEditor.tab=function(b,c){var a=c||new soy.StringBuilder;a.append('<li><span class="szi-tab',b.value==b.current_value?" szi-selected":"",'" data-sz-type="',soy.$$escapeHtml(b.value),'"><span class="szi-name">',soy.$$escapeHtml(b.name),'</span><span class="szi-info">',soy.$$escapeHtml(b.info),"</span></span></li>");if(!c)return a.toString()};
sz.tmpl.stationEditor.songList=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-filter"><ul class="szi-type">');sz.tmpl.stationEditor.tab({name:"All",value:"all",current_value:b.type,info:b.stats.song_count.all},a);b.station.allow_song_adds&&!b.hide_contribute&&(sz.tmpl.stationEditor.tab({name:"Mine",value:"mine",current_value:b.type,info:b.stats.song_count.mine},a),sz.tmpl.stationEditor.tab({name:"Contributed",value:"contributed",current_value:b.type,info:b.stats.song_count.contributed},
a));sz.tmpl.stationEditor.tab({name:"Deleted",value:"deleted",current_value:b.type,info:b.stats.song_count.deleted},a);a.append('</ul><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',soy.$$escapeHtml(b.query),'" placeholder="Type an artist or song ..." /><input type="button" value="Search" /></div></div><div class="szi-duration">Duration: ',soy.$$escapeHtml(b.stats.total_duration),
'</div><div class="szi-song-list"></div>');if(!c)return a.toString()};sz.tmpl.stationEditor.requirement=function(b,c){var a=c||new soy.StringBuilder;a.append(b.left==0?"0 "+soy.$$escapeHtml(b.plural):b.left==1?soy.$$escapeHtml(b.left)+" "+soy.$$escapeHtml(b.singular):soy.$$escapeHtml(b.left)+" "+soy.$$escapeHtml(b.plural));if(!c)return a.toString()};
sz.tmpl.stationEditor.release=function(b,c){var a=c||new soy.StringBuilder;b.station.status=="UNRELEASED"?b.requirements.satisfied?a.append('<h3>Status: Ready</h3><p>Great! You\'ve added enough songs to release this playlist.</p><div class="szi-release-options"><span class="szi-release-now">Release Now</span><a href="',soy.$$escapeHtml(b.station_url),'" class="szi-release-later">Release Later</a></div>'):(a.append('<h3>Status: Not Ready</h3><div class="szi-requirements">'),sz.tmpl.stationEditor.requirement({left:b.requirements.songs.left,
singular:"song",plural:"songs"},a),a.append(",&nbsp;"),sz.tmpl.stationEditor.requirement({left:b.requirements.artists.left,singular:"artist",plural:"artists"},a),a.append("&nbsp;left</div><p>You'll need to add at least ",soy.$$escapeHtml(b.requirements.songs.total)," songs by ",soy.$$escapeHtml(b.requirements.artists.total)," different artists to be ready to release your playlist.</p>")):b.is_new?a.append('<h3>Congratulations, your playlist was released!</h3><div class="szi-release-options"><a href="',
soy.$$escapeHtml(b.station_url),'" class="szi-view">View Playlist</a></div>'):a.append('<h3>Status: Released</h3><p>Your playlist has been released.</p><div class="szi-release-options"><span class="szi-unrelease">Unrelease</span><a href="',soy.$$escapeHtml(b.station_url),'" class="szi-view">View Playlist</a></div>');if(!c)return a.toString()};
sz.tmpl.stationEditor.editor=function(b,c){var a=c||new soy.StringBuilder;a.append(b.is_new?'<h1 class="szi-title"><span>Contribute a Playlist</span></h1><h2 class="szi-title"><span>Playlist Info</span></h2>':"",'<div class="szi-station"><div class="szi-details-container"><div class="szi-details"><div class="szi-name"><label for="view-',soy.$$escapeHtml(b.view_id),'-name">Name</label><input id="view-',soy.$$escapeHtml(b.view_id),'-name" type="text" ',b.name?'value="'+soy.$$escapeHtml(b.name)+'"':
"",' placeholder="Name your playlist" /></div><div class="szi-description"><label for="view-',soy.$$escapeHtml(b.view_id),'-description">Description</label><textarea id="view-',soy.$$escapeHtml(b.view_id),'-description" rows="5" cols="37" placeholder="Describe your playlist">',b.description?soy.$$escapeHtml(b.description):"",'</textarea></div><div class="szi-allow_song_adds"><input type="checkbox" id="view-',soy.$$escapeHtml(b.view_id),'-allow_song_adds"',b.station&&b.station.allow_song_adds?" checked":
"",'/><label for="view-',soy.$$escapeHtml(b.view_id),'-allow_song_adds">Allow anyone to add songs</label></div></div>',b.is_admin?'<div class="szi-custom-image"><span class="szi-chooser-image"><input type="file" id="'+soy.$$escapeHtml(b.view_id)+'-image-file" accept="image/jpeg"></span><span class="szi-upload-image">Upload</span><span class="szi-delete-image">Delete</span></div>':"",'<div class="szi-station-quilt-image-container">',b.is_new&&!b.has_custom_image?'<img src="'+soy.$$escapeHtml(b.static_url)+
'images/station-default-cover-150.jpg" class="szi-station-quilt-image" />':'<img src="'+soy.$$escapeHtml(b.station.cover_url)+'?size=150" class="szi-station-quilt-image" />','</div></div><div class="szi-current-songs"><div class="szi-song-list"></div></div></div><div class="szi-mod"><div class="szi-release"></div><div class="szi-save-details"></div>',b.station.type!="stream"?'<div class="szi-add-songs"><h3 class="szi-title">Add Songs to Your Playlist</h3><div class="szi-song-search"></div></div>':
"","</div>");if(!c)return a.toString()};
sz.tmpl.stationEditor.addSongs=function(b,c){var a=c||new soy.StringBuilder;a.append('<h1 class="szi-title"><span>Contribute to a Playlist</span></h1><h2 class="szi-title"><span>Add Songs to: ',soy.$$escapeHtml(b.station.name),'</span></h2><div class="szi-station"><div class="szi-current-songs"><h3 class="szi-title">Songs to Be Added</h3><div class="szi-song-list"></div></div><div class="szi-release-options"><span class="szi-save">Save Songs</span></div></div><div class="szi-mod"><div class="szi-add-songs"><h3>Find Songs to Add</h3><div class="szi-song-search"></div></div></div>');if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.stationSave=="undefined")sz.tmpl.stationSave={};sz.tmpl.stationSave.button=function(b,c){var a=c||new soy.StringBuilder;a.append(b.collections.length==1?'Saved to "<span class="szi-playlist-title">'+soy.$$escapeHtml(b.collections[0].title)+'</span>"':b.collections.length>1?"Saved to "+soy.$$escapeHtml(b.collections.length)+" shelves":b.station_type=="stream"?"Save Station":"Save Playlist");if(!c)return a.toString()};
sz.tmpl.stationSave.menu=function(b,c){var a=c||new soy.StringBuilder;a.append(b.title?'<div class="szi-hd">'+soy.$$escapeHtml(b.title)+"</div>":"",b.collection_list.length==0?'<div class="szi-hd">Create a new shelf to save this to:</div>':"",'<div class="szi-bd">');if(b.collection_list.length==0)a.append('<ul><li>Example: "Party Playlists"</li></ul>');else{a.append("<ul>");for(var e=b.collection_list,d=e.length,f=0;f<d;f++){var g=e[f];a.append('<li class="',g.checked?"szi-checked":"",'"><input type="checkbox" value="',
soy.$$escapeHtml(g.id),'" id="',soy.$$escapeHtml(b.view_id),"-",soy.$$escapeHtml(g.id),'" ',g.checked?"checked":"",' /><label for="',soy.$$escapeHtml(b.view_id),"-",soy.$$escapeHtml(g.id),'" title="',soy.$$escapeHtml(g.title),'">',soy.$$escapeHtml(g.title),"</label></li>")}a.append('</ul><div class="szi-confirm"><input type="button" value="Done" class="szi-done" /> or <a href="#cancel" class="szi-cancel">Cancel</a></div>')}a.append('</div><div class="szi-ft"><a href="#new-shelf" class="szi-new-collection">Create new...</a><div class="szi-new-collection-form"><form><input type="text" placeholder="New Shelf Name" /><input type="submit" value="Create" class="szi-make-collection" /></form></div></div>');
if(!c)return a.toString()};
sz.tmpl.stationSave.anonymousMenu=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-station-save-anonymous-menu"><div class="szi-hd">',b.station_type=="stream"?"Save Your Stations For Easy Access:":"Save Your Playlists For Easy Access:",'</div><div class="szi-ft"><a href="',soy.$$escapeHtml(b.signup_url),'">Sign Up</a> or <a href="',soy.$$escapeHtml(b.login_url),'">Log In</a> to save this ',b.station_type=="stream"?" station.":" playlist.","</div></div>");if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.follow=="undefined")sz.tmpl.follow={};
sz.tmpl.follow.followButton=function(b,c){var a=c||new soy.StringBuilder;a.append(b.anonymous?'<div class="sz-follow sz-follow-anonymous"><div class="szi-follow">Follow</div><div class="szi-login-prompt completed"><a href="'+soy.$$escapeHtml(b.signup_url)+'">Sign up</a> or <a href="'+soy.$$escapeHtml(b.login_url)+'">Log in</a> to follow.</div></div>':'<div class="sz-follow '+(b.following?"sz-follow-following":"sz-follow-not-following")+'"><div class="szi-following completed">Following</div><div class="szi-unfollow">Unfollow</div><div class="szi-follow">Follow</div></div>');
if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.navigate=="undefined")sz.tmpl.navigate={};sz.tmpl.navigate.userView=function(b,c){var a=c||new soy.StringBuilder;a.append('<h2>Me</h2><ol><li><a href="',soy.$$escapeHtml(b.collection_url),'">My Playlists</li><li><a href="',soy.$$escapeHtml(b.collection_url),'">Recent</li><li><a href="',soy.$$escapeHtml(b.friends_url),'">Friends</li></ol>');if(!c)return a.toString()};
sz.tmpl.navigate.searchView=function(b,c){var a=c||new soy.StringBuilder;a.append('<h2>Search</h2><input type="search" placeholder="Playlist Search" />');if(!c)return a.toString()};
sz.tmpl.navigate.discoverView=function(b,c){var a=c||new soy.StringBuilder;a.append('<h2>Discover</h2><div class="nav">');for(var e=b.tags,d=e.length,f=0;f<d;f++){var g=e[f];a.append("<h3>",soy.$$escapeHtml(g.name),"</h3><div><ol>");for(var g=g.galleries,h=g.length,i=0;i<h;i++){var k=g[i];a.append('<li><a href="',soy.$$escapeHtml(k.url),'" class="gallery-link" data-sz-gallery-id="',soy.$$escapeHtml(k.id),'">',soy.$$escapeHtml(k.name),"</a></li>")}a.append("</ol></div>")}a.append("</div>");if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.curate=="undefined")sz.tmpl.curate={};sz.tmpl.curate.curate=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-navigator"></div><div class="szi-workspace"></div>');if(!c)return a.toString()};sz.tmpl.curate.workspace=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-container"></div>');if(!c)return a.toString()};
sz.tmpl.curate.modelEditor=function(b,c){var a=c||new soy.StringBuilder;a.append(b.title?"<h1>"+soy.$$escapeHtml(b.title)+"</h1>":"",'<div class="szi-errors"></div><div class="szi-editor"></div><div class="szi-ft"><div class="szi-delete">Delete</div><div class="szi-save">Save</div><div class="szi-cancel">Cancel</div></div>');if(!c)return a.toString()};
sz.tmpl.curate.tagItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-tag-curate-item',!b.tag.featured?" sz-tag-curate-item-not-featured":"",'" data-sz-tag-id="',soy.$$escapeHtml(b.tag.id),'"><div class="szi-name">',soy.$$escapeHtml(b.tag.name),"</div></div>");if(!c)return a.toString()};
sz.tmpl.curate.tagList=function(b,c){var a=c||new soy.StringBuilder;a.append('<h1>Tags</h1><div class="szi-bd"><div class="szi-actions"><span class="szi-new-tag">New Tag</span></div><div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',soy.$$escapeHtml(b.query),'" /><input type="button" value="Search" /></div></div><div class="szi-list"></div></div>');
if(!c)return a.toString()};
sz.tmpl.curate.tagDetails=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-hd"><h1>',soy.$$escapeHtml(b.tag.name),'</h1><div class="szi-actions"><span class="szi-edit">Edit</span>,<span class="szi-new-gallery">New Gallery</span>,<span class="szi-add-gallery">Add Gallery</span>,<span class="szi-organize-toggle">Organize</span></div><div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),
'-query" type="text" class="szi-query-input" value="',soy.$$escapeHtml(b.query),'" /><input type="button" value="Search" /></div></div></div><div class="szi-bd"><div class="szi-list"></div><div class="szi-organize-options"><span class="szi-organize-revert">Cancel</span><span class="szi-organize-save">Save</span></div></div>');if(!c)return a.toString()};
sz.tmpl.curate.galleryItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-gallery-curate-item" data-sz-gallery-id="',soy.$$escapeHtml(b.gallery.id),'"><div class="szi-name">',soy.$$escapeHtml(b.gallery.name),'</div><div class="szi-tags">');for(var e=b.gallery.tags,d=e.length,f=0;f<d;f++)a.append(soy.$$escapeHtml(e[f].name),f!=d-1?",":"");a.append('</div><div class="szi-count">',soy.$$escapeHtml(b.gallery.station_ids.length),'</div><div class="szi-organize-toggle-deleted"></div></div>');
if(!c)return a.toString()};
sz.tmpl.curate.galleryList=function(b,c){var a=c||new soy.StringBuilder;a.append('<h1>Galleries</h1><div class="szi-bd"><div class="szi-actions"><span class="szi-new-gallery">New Gallery</span></div><div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',soy.$$escapeHtml(b.query),'" /><input type="button" value="Search" /></div></div><div class="szi-list"></div></div>');if(!c)return a.toString()};
sz.tmpl.curate.gallerySearch=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-hd"><h1>Find a Gallery</h1><div class="szi-actions">&nbsp;</div><div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',soy.$$escapeHtml(b.query),'" /><input type="button" value="Search" /></div></div></div><div class="szi-bd"><div class="szi-gallery-list"></div></div>');
if(!c)return a.toString()};
sz.tmpl.curate.galleryDetails=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-hd"><h1>',soy.$$escapeHtml(b.gallery.name),'</h1><div class="szi-actions"><span class="szi-edit">Edit</span>,<span class="szi-add-station">Add Station</span>,<span class="szi-organize-toggle">Organize</span></div><div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',
soy.$$escapeHtml(b.query),'" /><input type="button" value="Search" /></div></div></div><div class="szi-bd"><div class="szi-list"></div><div class="szi-organize-options"><span class="szi-organize-revert">Cancel</span><span class="szi-organize-save">Save</span></div></div>');if(!c)return a.toString()};
sz.tmpl.curate.stationItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-station-curate-item" data-sz-station-id="',soy.$$escapeHtml(b.station.id),'"><div class="szi-image"><img src="',soy.$$escapeHtml(b.station.cover_url),'?size=50" class="szi-quilt" /></div><div class="szi-info"><div class="szi-name">',soy.$$escapeHtml(b.station.name),'</div><div class="szi-extended">',b.station.creator_id?soy.$$escapeHtml(b.station.creator_name)+" /&nbsp;":"",soy.$$escapeHtml(b.station.status),
" / ",soy.$$escapeHtml(b.station.song_count),' songs</div></div><div class="szi-organize-toggle-deleted"></div></div>');if(!c)return a.toString()};
sz.tmpl.curate.stationSearchList=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-hd"><h1>Search for Playlists</h1><div class="szi-actions"><span class="szi-done">Done</span></div><div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',soy.$$escapeHtml(b.query),'" /><input type="button" value="Search" /></div></div></div><div class="szi-bd"><div class="szi-station-list"></div></div>');
if(!c)return a.toString()};sz.tmpl.curate.promotionProductList=function(b,c){var a=c||new soy.StringBuilder;a.append('<h1>Promotions</h1><div class="szi-bd"><div class="szi-list"><ul>');for(var e=b.products,d=e.length,f=0;f<d;f++){var g=e[f];a.append('<li class="szi-product-item" data-sz-product="',soy.$$escapeHtml(g),'">',soy.$$escapeHtml(g),"</li>")}a.append("</ul></div></div>");if(!c)return a.toString()};
sz.tmpl.curate.promoDetails=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-hd"><h1>Promotions: ',soy.$$escapeHtml(b.product),'</h1><div class="szi-actions"><span class="szi-new-promo">New Promotion</span></div></div><div class="szi-bd"><div class="szi-list"></div></div>');if(!c)return a.toString()};
sz.tmpl.curate.promoItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-promo-curate-item" data-sz-promo-id="',soy.$$escapeHtml(b.promo.id),'"><div class="szi-name">',soy.$$escapeHtml(b.promo.station.name),'</div><div class="szi-status',b.promo.active?" szi-active":"",'">',b.promo.active?"Active":"Inactive",'</div><div class="szi-image"><img src="',soy.$$escapeHtml(b.promo.image_url),'" /></div></div>');if(!c)return a.toString()};
sz.tmpl.curate.situationList=function(b,c){var a=c||new soy.StringBuilder;a.append("<h1>",soy.$$escapeHtml(b.situation_name_plural),'</h1><div class="szi-bd"><div class="szi-actions"><span class="szi-new-situation">New ',soy.$$escapeHtml(b.situation_name_singular),'</span><span class="szi-organize-toggle">Organize</span></div><div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',
soy.$$escapeHtml(b.query),'" /><input type="button" value="Search" /></div>');sz.tmpl.curate.select_one({cssClass:"szi-device",options:b.device_options,selectedValue:b.device_choice},a);sz.tmpl.curate.select_one({cssClass:"szi-day",options:b.dow_options,selectedValue:b.dow_choice},a);sz.tmpl.curate.select_one({cssClass:"szi-time",options:b.time_options,selectedValue:b.time_choice},a);a.append('</div><div class="szi-list"></div><div class="szi-organize-options"><span class="szi-organize-revert">Cancel</span><span class="szi-organize-save">Save</span></div></div>');
if(!c)return a.toString()};sz.tmpl.curate.select_one=function(b,c){var a=c||new soy.StringBuilder;a.append('<select class="',soy.$$escapeHtml(b.cssClass),'">');for(var e=b.options,d=e.length,f=0;f<d;f++){var g=e[f];a.append('<option value="',soy.$$escapeHtml(g.value),'"',g.value==b.selectedValue?" selected":"",">",soy.$$escapeHtml(g.label),"</option>")}a.append("</select>");if(!c)return a.toString()};
sz.tmpl.curate.situationItem=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-situation-curate-item" data-sz-situation-id="',soy.$$escapeHtml(b.situation.id),'"><div class="szi-title">',soy.$$escapeHtml(b.situation.title),'</div><div class="szi-status',b.situation.active?" szi-active":"",'">',b.situation.active?"Active":"Inactive",'</div><div class="szi-organize-toggle-deleted"></div></div>');if(!c)return a.toString()};
sz.tmpl.curate.situationStationList=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-hd"><h1>Stations</h1><div class="szi-actions"><span class="szi-add-station">Add Station</span>,<span class="szi-organize-toggle">Organize</span></div><div class="szi-filter"><div class="szi-query"><label for="view-',soy.$$escapeHtml(b.view_id),'-query">Search:</label><input id="view-',soy.$$escapeHtml(b.view_id),'-query" type="text" class="szi-query-input" value="',soy.$$escapeHtml(b.query),
'" /><input type="button" value="Search" /></div></div></div><div class="szi-bd"><div class="szi-list"></div><div class="szi-organize-options"><span class="szi-organize-revert">Cancel</span><span class="szi-organize-save">Save</span></div></div>');if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.player=="undefined")sz.tmpl.player={};
sz.tmpl.player.rollSong=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-roll-song',b.song.vote=="up"?" szi-voted-up":"",b.song.vote=="down"?" szi-voted-down":"",'"><div class="szi-art"><img src="',soy.$$escapeHtml(b.song.image_url),'" /></div><div class="szi-title">',soy.$$escapeHtml(b.song.title),'</div><div class="szi-artist">',soy.$$escapeHtml(b.song.artist),'</div><div class="szi-actions">',b.song.streamSong?'<span data-sz-song-id="'+soy.$$escapeHtml(b.song_id)+'" title="Thumbs Up"   class="szi-vote-up-button">Thumbs Up</span><span data-sz-song-id="'+
soy.$$escapeHtml(b.song_id)+'" title="Thumbs Down" class="szi-vote-down-button">Thumbs Down</span>'+(b.station.creator_id==b.visitor.id?b.song.banned?'<span data-sz-song-id="'+soy.$$escapeHtml(b.song_id)+'" title="Add Song" class="szi-add-button">Add Song</span>':'<span data-sz-song-id="'+soy.$$escapeHtml(b.song_id)+'" title="Ban Song" class="szi-ban-button">Ban Song</span>':""):"","</div></div>");if(!c)return a.toString()};
sz.tmpl.player.player=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="szi-history"><div class="container"><h2><a href="',soy.$$escapeHtml(b.station_url),'">',soy.$$escapeHtml(b.station.name),"</a>",b.station.allow_song_adds&&b.visitor.id!=0?'<span class="szi-add_songs"><a href="'+soy.$$escapeHtml(b.station_edit_url)+'">Add Songs</a></span>':"","</h2>");if(b.history.length>0){a.append("<ul>");for(var e=b.history,d=e.length,f=0;f<d;f++){var g=e[f];a.append("<li",f==d-1?' class="szi-last"':
"",">");sz.tmpl.player.rollSong(g,a);a.append("</li>")}a.append("</ul>")}else a.append('<div class="szi-empty">There are currently no previously played songs in ',soy.$$escapeHtml(b.station.name),".</div>");a.append('</div></div><div class="szi-error"><div class="container"></div></div><\!-- essential control elements, everything that is always on the page. --\><div class="szi-essential"><div class="szi-progress"></div><div class="container"><\!-- control area, play/pause/skip buttons, song title, artist, and thumbs up/down --\><div class="szi-controls"><span class="szi-play-button"  title="Play">play</span><span class="szi-pause-button" title="Pause">pause</span><span class="szi-skip-button"  title="Skip">skip</span><div class="szi-volume"></div></div><div class="szi-song-display">');
b.song&&sz.tmpl.player.rollSong(b.song,a);a.append('<div class="szi-buffering"></div><div class="szi-no-song"><div class="szi-art"><img src="',soy.$$escapeHtml(b.station.cover_url),'?size=50" /></div><div class="szi-title">',soy.$$escapeHtml(b.station.name),'</div><div class="szi-subtitle"></div></div><div class="szi-fetching-next"><div class="szi-art"><img src="',soy.$$escapeHtml(b.station.cover_url),'?size=50" /></div><div class="szi-title">',soy.$$escapeHtml(b.station.name),'</div><div class="szi-subtitle">Loading next song ...</div></div></div><div class="szi-share-buttons"></div></div></div>');
if(!c)return a.toString()};typeof sz=="undefined"&&(sz={});if(typeof sz.tmpl=="undefined")sz.tmpl={};if(typeof sz.tmpl.station=="undefined")sz.tmpl.station={};
sz.tmpl.station.quilt=function(b,c){var a=c||new soy.StringBuilder;a.append('<div class="sz-station-quilt" data-sz-station-id="',soy.$$escapeHtml(b.station.id),'"><div class="szi-title"><a href="',soy.$$escapeHtml(b.station_url),'">',soy.$$escapeHtml(b.station.name),'</a></div><a href="',soy.$$escapeHtml(b.station_url),'" class="szi-image-anchor"><img src="',soy.$$escapeHtml(b.station.cover_url),'?size=150" /><span class="szi-play-button">Play</a></a></div>');if(!c)return a.toString()};define("songza/feeds",["songza/config","songza/base","songza/models","songza/utils"],function(b,c,a,e){var d={},f=Backbone.Collection.extend({model:a.FeedItem,comparator:function(a){return a.get("ts")}}),g=d.Viewer=c.View.extend({template:sz.tmpl.feeds.feedList,css:"sz-feed-viewer",initialize:function(a){g.__super__.initialize.call(this,a);_.bindAll(this,"fetchSuccess","fetchError","maybeFetch");this.itemFetcher=a.itemFetcher;this.pollIntervals=a.pollIntervals||b.timeouts.feedPollIntervals;this.maxItems=
a.maxItems||100;this.clientFetchAttemptDate=this.serverFetchDate=null;this.clientFetchHadDataDate=new Date;this.userLastReadTime=null;this.fetchState=0;this.items=new f;this.items.bind("add",this.render);this.items.bind("remove",this.render);this.items.bind("reset",this.render);this.bind("marked-all-read",this.render)},isNew:function(a){return this.userLastReadTime===null||a.get("ts")>this.userLastReadTime},unreadCount:function(){var a=this,b=0;this.items.each(function(e){a.isNew(e)&&(b+=1)});return b},
markAllRead:function(){this.userLastReadTime=this.serverFetchDate;this.trigger("marked-all-read")},maybeFetch:function(a){if(this.fetchState!==1&&(this.fetchState!==2||a))this.fetchState=1,a=this.itemFetcher(this.serverFetchDate),$.when(a).then(this.fetchSuccess,this.fetchError)},itemKey:function(a){var b,e=a.get("actors"),d=[],c=[a.get("event_type"),a.get("station").get("id")];for(b=0;b<e.length;b++)d.push(e[b].get("id"));d.sort();a.get("song")&&c.push(a.get("song").get("id"));return c.join("/")+
":"+d.join(",")},fetchSuccess:function(a){var b=this,e={};this.fetchState=2;this.clientFetchAttemptDate=new Date;this.serverFetchDate=a.server_time;if(a.items.length>0)this.clientFetchHadDataDate=this.clientFetchAttemptDate;this.items.each(function(a){e[b.itemKey(a)]=!0});a.items.each(function(a){e.hasOwnProperty(b.itemKey(a))||b.items.add(a,{suppress:!0})});this.items.length>this.maxItems&&this.items.reset(this.items.first(this.maxItems),{suppress:!0});this.queueFetch();this.items.trigger("reset")},
fetchError:function(){this.fetchState=0;this.clientFetchAttemptDate=new Date;this.queueFetch()},queueFetch:function(){var a=this,b=(this.clientFetchAttemptDate.getTime()-this.clientFetchHadDataDate.getTime())/1E3,e=0,d,c,f,g;for(g=0;g<this.pollIntervals.length;g++){c=this.pollIntervals[g][0];f=this.pollIntervals[g][1]||1;if(b>=e&&b<=e+c*f){d=c;break}e+=c*f}d===void 0&&(d=_.last(this.pollIntervals)[0]);setTimeout(function(){a.maybeFetch(!0)},d*1E3)},context:function(){var a=this,b;this.maybeFetch();
b={fetching:this.fetchState===1,items:[]};this.items.each(function(d){var c=d.toJSON();c.is_new=a.isNew(d);c.ts_text=e.DateHelper.time_ago_in_words(d.get("ts"));c.station_url=d.get("station").pageUrlPath();b.items.push(c)});b.items.reverse();return b}}),h=d.GroupViewer=c.View.extend({css:"sz-feed-group-viewer",initialize:function(a){var b=this;h.__super__.initialize.call(this,a);this.groups=a.groups;_.each(this.groups,function(a){a.viewer.items.bind("reset",function(){b.trigger("new-items",a)});a.viewer.bind("marked-all-read",
function(){b.trigger("marked-all-read",a)})})},markAllRead:function(a){var b=[];a?b.push(this.getGroup(a)):b=this.groups;_.each(b,function(a){a.viewer.markAllRead()})},getGroup:function(a){return _.filter(this.groups,function(b){return b.id===a})[0]},unreadCount:function(a){var b=[],e=0;a?b.push(this.getGroup(a)):b=this.groups;_.each(b,function(a){e+=a.viewer.unreadCount()});return e},render:function(){var a=$(this.el),b=$("<div>"),e=$("<ul>"),d=0;a.empty();a.append(b);b.append(e);_.each(this.groups,
function(a,c){var f="feed-"+a.viewer.cid,g=$("<a>").attr("href","#"+f).text(a.name),f=$("<div>").attr("id",f);f.append($("<p>").append(a.viewer.render().el));e.append($("<li>").append(g));b.append(f);a.selected&&(d=c)});b.tabs({selected:d});this.sync();return this}});return d});define("songza/sites/songza/ad-rotation",["songza/config"],function(b){if(_.indexOf(b.custom_plugins,"songza/sites/songza/ad-rotation")!==-1)return{register:function(b){var a=b.getInstance();a.bind("player-song-started",function(){$(a.view.el).find(".sz-ad-frame").each(function(){this.contentWindow.location.reload(!0)})})}}});define("songza/sites/songza/getsatisfaction",["songza/config"],function(b){function c(){new GSFN.feedback_widget({display:"overlay",company:b.getsatisfaction.company,placement:"left",color:"#222",style:"question",container:a})}if(_.indexOf(b.custom_plugins,"songza/sites/songza/getsatisfaction")!==-1&&b.getsatisfaction.company){var a="gsfn";return{register:function(){var b=("https:"==document.location.protocol?"https://s3.amazonaws.com/getsatisfaction.com/":"http://s3.amazonaws.com/getsatisfaction.com/")+
"javascripts/feedback-v2.js";$("body").append($("<div>").attr("id",a));var d=document.createElement("script");d.setAttribute("language","javascript");d.setAttribute("type","text/javascript");d.setAttribute("src",b);document.body.appendChild(d);$(d).load(c)}}}});define("songza/sites/black_planet/ad-zones",["songza/app","songza/config","songza/utils"],function(b,c,a){function e(a,b,e){var d=$("<iframe>");d.attr("src","/advertising/"+a+"/");d.attr("width",b);d.attr("height",e);d.attr("scrolling","no");d.attr("frameBorder","0");d.addClass("sz-ad-frame");return d}function d(){$("#ad-top").empty().append(e("top",728,90));$("#ad-bottom").empty().append(e("bottom",728,90));$("#ad-side").empty().append(e("side",300,600))}if(_.indexOf(c.custom_plugins,"songza/sites/black_planet/ad-zones")!==
-1){window.BP_AD_CONTEXT={zone:"_default",station:""};var f=[[/^\/$/,"home"],[/^\/login\/$/,"login"],[/^\/discover\/$/,"discover"],[/^\/contribute\/.*$/,"contribute"],[/^\/search\/.*$/,"search"],[/^\/user\/([^/]+)\/.*$/,"user-$1"],[/^\/discover\/([^/]+)\/$/,"tag-$1"],[/^\/discover\/[^/]+\/([^/]+)\/$/,"gallery-$1"],[/^\/discover\/[^/]+\/([^/]+)\/[^/]+\/$/,"gallery-$1"]],g={current:function(){var b=a.currentPath(),e,d;for(d=0;d<f.length;d++)if(e=b.match(f[d][0])){b=f[d][1];for(d=0;d<e.length;d++)b=
b.replace("$"+d,e[d]);return b}return"_default"},station:function(){var a=b.getInstance().getPlayer();return a?a.model.get("station").get("dasherized_name"):""}};b.postInit(function(){var a=b.getInstance(),e=!0;window.BP_AD_CONTEXT.zone=g.current();window.BP_AD_CONTEXT.station=g.station();d();a.bind("page-navigate",function(){window.BP_AD_CONTEXT.zone=g.current();d()});a.bind("player-station-started",function(){window.BP_AD_CONTEXT.station=g.station();e=!0});a.bind("player-station-stopped",function(){window.BP_AD_CONTEXT.station=
""});a.bind("player-song-started",function(){e?e=!1:d()})});return{register:function(){}}}});define("songza/sites/black_planet/getsatisfaction",["songza/config"],function(b){function c(){new GSFN.feedback_widget({display:"overlay",company:b.getsatisfaction.company,product:"interactive_one_blackplanet_radio",placement:"left",color:"#011D27",style:"praise",tag:"Feedback",container:a})}if(_.indexOf(b.custom_plugins,"songza/sites/black_planet/getsatisfaction")!==-1){var a="gsfn";b.getsatisfaction.company&&$(function(){var b=("https:"==document.location.protocol?"https://s3.amazonaws.com/getsatisfaction.com/":
"http://s3.amazonaws.com/getsatisfaction.com/")+"javascripts/feedback-v2.js";$("body").append($("<div>").attr("id",a));var d=document.createElement("script");d.setAttribute("language","javascript");d.setAttribute("type","text/javascript");d.setAttribute("src",b);document.body.appendChild(d);$(d).load(c)});return{register:function(){}}}});define("songza/sites/black_planet/omniture",["songza/config","songza/utils"],function(b,c){function a(){window.s&&d&&f()}function e(a){var b,d={},a=a||{};if(window.s){for(b in a)d[b]=s[b],s[b]=a[b];var a=window.s.t(),e=$("<div>").attr("id","bp-omniture");$("#bp-omniture").remove();$("body").append(e);a&&e.html(a);for(b in d)s[b]=d[b]}}var d;if(_.indexOf(b.custom_plugins,"songza/sites/black_planet/omniture")!==-1){require(["http://w.bpcdn.us/00062028/js/vs_code.js"],function(){if(window.s_gi){var b=
window.s_gi("cconbpradio");window.s=b;b.usePlugins=!0;b.doPlugins=function(a){var b=(new Date).getFullYear(),d=c.currentPath(),e=d==="/"?"Home":$("title").text();a.prop11=a.getTimeParting("h","-5",b.toString());a.prop12=a.getTimeParting("d","-5",b.toString());a.prop13=a.getTimeParting("w","-5",b.toString());a.Linkdownloadfiletypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,doc,pdf,xls";a.events="event2";a.linkTrackEvents="none";a.hier1="login";a.hier2="songza";a.linkInternalFilters="javascript:,"+document.domain;
a.trackingServer="vs.blackplanet.com";a.trackingServerSecure="vss.blackplanet.com";a.pageName=e;a.pageUrl=d;a.eVar2="songza:"+d;a.prop2="songza:"+d;a.linkLeaveQueryString=!1;a.trackDownloadLinks=!0;a.trackExternalLinks=!0;a.trackInlineStats=!0;a.prop5="";a.eVar5="";a.linkTrackVars="none"};require(["http://w.bpcdn.us/00062028/js/s_code.js"],a)}});var f=_.once(function(){e()});return{register:function(b){d=b.getInstance();d.bind("page-navigate",function(){e()});d.bind("player-song-started",function(a){e({prop14:a.station.get("name"),
prop15:a.song.get("title")})});a()}}}});define("songza/utils",["songza/base"],function(b){var c={firstMeta:function(){var a,b,d=["property","name"];for(a=0;a<arguments.length;a++)for(b=0;b<d.length;b++){var c=$("meta["+d[b]+"='"+arguments[a]+"']").attr("content");if(c=(c||"").replace(/^\s*([\S]*)\s*$/,"$1"))return c}return null}};c.pageId=function(){return c.firstMeta("sz:identifier")};c.commentUrl=function(){return c.firstMeta("sz:comment-url")};c.currentUrl=function(a){var b="",a=a||{};if(!a.no_protocol)b=window.location.protocol;b+=
window.location.host;b+=c.currentPath();return b};c.currentPath=function(){return"/"+Backbone.history.getFragment()};c.requestJSON=function(a,b,d,f){d=d||{};return $.ajax({url:a,data:c.formQuery(b||{}),type:f||"GET",dataType:"json",success:d.success,failure:d.error})};c.getJSON=function(a,b,d){return c.requestJSON(a,b,d,"GET")};c.postJSON=function(a,b,d){return c.requestJSON(a,b,d,"POST")};c.bindPromise=function(a,b){b&&$.when(a).then(b.success,b.error);return a};c.formQuery=function(a){var b,d,c,
g=[];for(b in a){d=_.isArray(a[b])?a[b]:[a[b]];for(c=0;c<d.length;c++)g.push(encodeURIComponent(b)+"="+encodeURIComponent(d[c]))}return g.join("&")};c.FilteredCollectionMixin={_filters:function(){this.hasOwnProperty("_collectionFilters")||(this._collectionFilters={});return this._collectionFilters},addFilter:function(a,b){this._filters()[a]=b},getFilter:function(a){var b=this._filters();if(b.hasOwnProperty(a))return b[a];throw Error("Filter "+a+" was not set for collection: "+this);},clearFilters:function(){delete this._collectionFilters},
url:function(){return this.urlBase+"?"+c.formQuery(this._filters())}};c.DateHelper={epoch_seconds_to_date:function(a){var b=new Date;b.setTime(a*1E3);return b},time_ago_in_words_with_parsing:function(a){var b=new Date;b.setTime(Date.parse(a));return this.time_ago_in_words(b)},time_ago_in_words:function(a){return this.distance_of_time_in_words(new Date,a)},distance_of_time_in_words:function(a,b){var d=Math.floor((a-b)/1E3/60);if(d<1)return"less than a minute ago";if(d===1)return"a minute ago";if(d<
45)return d+" minutes ago";if(d<90)return"about 1 hour ago";if(d<1440)return"about "+Math.floor(d/60)+" hours ago";if(d<2880)return"1 day ago";if(d<43200)return Math.floor(d/1440)+" days ago";if(d<86400)return"about 1 month ago";if(d<525960)return Math.floor(d/43200)+" months ago";if(d<1051199)return"about 1 year ago";return"over "+Math.floor(d/525960)+" years ago"},format_unit:function(a,b,d){return a===1?"One "+b:a+" "+d},time_span_in_words:function(a){var b=parseInt(a/86400),d=parseInt((a-86400*
b)/3600),f=parseInt((a-86400*b-3600*d)/60),a=parseInt(a-86400*b-3600*d-60*f),g=[];b>0?(g.push(c.DateHelper.format_unit(b,"day","days")),g.push(c.DateHelper.format_unit(d,"hour","hours"))):d>0?(g.push(c.DateHelper.format_unit(d,"hour","hours")),g.push(c.DateHelper.format_unit(f,"minute","minutes"))):(f>0&&g.push(c.DateHelper.format_unit(f,"minute","minutes")),g.push(c.DateHelper.format_unit(a,"second","seconds")));return g.join(", ")}};c.WordMatcher=function(a,b){var d=(a||"").toLowerCase().split(/\s+/);
return function(a){var a=b(a).toLowerCase(),c;for(c=0;c<d.length;c++)if(a.indexOf(d[c])<0)return!1;return!0}};c.FreshnessGuarantee=b.Class.extend({initialize:function(a){this.collection=a.collection;this.refreshInterval=a.fetchInterval;this.state=0;this.lastFetched=null},fetching:function(){return this.state===1},notFetched:function(){return this.state===0},fetched:function(){return this.state===2},isStale:function(){if(!this.lastFetched)return!1;return this.lastFetched.getTime()+this.refreshInterval*
1E3<(new Date).getTime()},ensureFreshness:function(){var a=this;if(!this.fetching()&&(this.notFetched()||this.isStale()))this.state=1,this.collection.fetch({success:function(){a.lastFetched=new Date;a.state=2;a.collection.trigger("fetch");a.trigger("state-change")},error:function(){a.state=0}})}});c.SimpleCollectionView=b.View.extend({collection:new Backbone.Collection([]),initialize:function(a){c.SimpleCollectionView.__super__.initialize.call(this,a);_.bindAll(this,"syncCollectionContainerEl");this.collection=
a.collection;this.mustFetch=a.mustFetch;this.useCid=a.useCid;this.modelContextName=a.modelContextName||"model";this.collectionFreshen=new c.FreshnessGuarantee({collection:this.collection,fetchInterval:a.fetchInterval});this.collection.bind("reset",this.syncCollectionContainerEl);this.collection.bind("add",this.syncCollectionContainerEl);this.collection.bind("remove",this.syncCollectionContainerEl);this.collection.bind("change",this.syncCollectionContainerEl)},collectionContainerEl:function(){return $("<div>")},
modelList:function(){return this.collection.models},syncCollectionContainerEl:function(){var a=this,b=this.collectionContainerEl(),d=this.modelList(),c=$("<ul>");b.empty();d.length==0?this.collectionFreshen.fetching?b.append($("<div>").addClass("szi-fetching").text("Fetching")):b.append($("<div>").addClass("szi-empty").text("No Models")):(_.each(d,function(b){var d={},e=$("<li>");d[a.modelContextName]=b.toJSON();e.html(a.modelTemplate(d));e.attr("data-sz-model-id",a.idForModel(b));c.append(e)}),b.append(c),
c.children("li:last-child").addClass("szi-last"))},idForModel:function(a){return this.useCid?a.cid:a.id},highlightModel:function(a){var b=this,d=this.collectionContainerEl().find("ul").first().children("li").filter(function(){return $(this).attr("data-sz-model-id")==b.idForModel(a)});this.collectionContainerEl().find("ul > li").removeClass("szi-highlighted");d.addClass("szi-highlighted");d.slideUp(0).slideDown(function(){b.collectionContainerEl().scrollTo(d);setTimeout(function(){d.removeClass("szi-highlighted")},
2E3)})},context:function(){var a={models:_.each(this.modelList(),function(a){return a.toJSON()})};this.mustFetch&&this.collectionFreshen.ensureFreshness();return a},render:function(){c.SimpleCollectionView.__super__.render.call(this);this.syncCollectionContainerEl();return this}});return c});define("songza/hashsignal",function(){function b(){if(d&&d.debug){var a=[new Date,"hashsignal"].concat(Array.prototype.slice.apply(arguments));window.console?window.console.log(a):alert(a.join(" "))}}function c(a){function b(a,d){d(a);for(var c=0,e=a.childNodes.length;c<e;c++)b(a.childNodes[c],d)}var d=/^ (end)?block ([^ ]*) ([0-9a-f]{32} )?$/,c={},a=a||e;(function(a,c){b(a,function(a){if(a.nodeType===8){var b=d.exec(a.nodeValue);b&&c(b[2],b[3],!b[1],a)}})})(a,function(a,b,d,e){c[a]===void 0&&(c[a]=
{nodes:[null,null],signature:b});c[a].nodes[d?0:1]=e});return c}function a(a,c){var e=/<link.+?(rel=["']?stylesheet["'\s])?.*?href=["']?(.+?)["'\s].*?(rel=["']?stylesheet["'\s])?.*?>/gi,i=[],k,j={},l=[];a.replace(/<\!-- (end)?block ([^ ]*) ([0123456789abcdef]{32} )?--\>/gi,function(a,c,f,g,u,o){if(c&&i.length===0)throw"Unexpected block nesting on match: "+a;!c&&!g&&b("WARNING: block found without signature",f);c?(k=i[i.length-1],f=k.name,i.length-=1,j[f]={html:o.slice(k.start,u),signature:k.signature},
d.inlineStylesheets&&j[f].html.replace(e,function(a,b,d,c){!isCrossDomain(d)&&(b&&b.toLowerCase().indexOf("stylesheet")!==-1||c&&c.toLowerCase().indexOf("stylesheet")!==-1)&&l.push($.ajax({dataType:"text",url:d}).done(function(b){j[f].html=j[f].html.replace(a,'<style type="text/css">'+b+"</style>")}))})):i.push({name:f,start:u+a.length,signature:g})});if(0!==i.length)throw"Unclosed block: "+i[i.length-1].name;l.length>0?$.when.apply($,l).then(function(){c(j)},function(){c(j)}):c(j)}var e=window.document,
d;d={excludeSelector:".no-ajax",beforeUpdate:function(){b("beforeUpdate")},afterUpdate:function(){b("afterUpdate")},errorUpdate:function(){b("errorUpdate")},onDocumentWrite:function(a){window.console&&window.console.error("jQuery.hashsignal received document.write: "+a)},debug:!1,disabled:!1,resolverId:"hashsignal-abs",inlineStylesheets:!1,replaceBlocksOnError:!1};return{replaceBlocks:function(d,g,h){function i(a,b){for(var d=[],c=a;c!==b;)c!==a&&d.push(c),c=c.nextSibling;return d}function k(a){var b=
{};$.each(a.attributes,function(a,d){if(!(!d||!d.name||"contentEditable".indexOf(d.name)!==-1)&&d.value)b[d.name]=d.value});return b}var j=[];b("replaceBlocks");var h=h||$.noop,l=c();a(d,function(a){var c=/<title>(.*)<\/title>/.exec(d);if(c)e.title=$("<div>").html(c[1]).text();var n=$("body"),c=/<body([^>]*)>/.exec(d),t,u,o;if(c){if(window.document.implementation&&window.document.implementation.createDocument)o=window.document.namespaceURI||"http://www.w3.org/1999/xhtml",u=window.document.implementation.createDocument(o,
"html",null),o=u.documentElement,o.innerHTML="<body "+c[1]+"></body>",o=$("body",o).get(0);else if(window.ActiveXObject)try{u=new ActiveXObject("Microsoft.XMLDOM"),u.async=!1,u.loadXML("<body "+c[1]+"></body>"),o=u.documentElement}catch(v){}o&&(c=k(n.get(0)),t=k(o),$.each(c,function(a,b){var d=t[a];d?(d!==b&&n.attr(a,d),delete t[a]):n.removeAttr(a)}),n.attr(t))}for(var r in a)r in l?(c=l[r],o=a[r],c.signature&&o.signature&&c.signature===o.signature&&!g?b("Not replacing block, signatures match.",r,
c.signature):($(i(c.nodes[0],c.nodes[1])).remove(),b("Replacing block",r,o.html,o),$.trim(o.html)&&(u=$(o.html),j.push(u),$(c.nodes[0]).after(u)),$(c.nodes[0]).replaceWith("<\!-- block "+r+" "+(o.signature||"")+"--\>"))):b("WARNING: unmatched block",r);h(j)})}}});define("songza/navigator",["songza/base","songza/models","songza/work"],function(b,c,a){var e={};e.UserView=b.View.extend({css:"sz-navigator-user",template:sz.tmpl.navigate.userView,initialize:function(a){e.UserView.__super__.initialize.call(this,a);this.user=a.user},context:function(){return{collection_url:"/collection/",friends_url:"/friends/"}}});e.SearchView=b.View.extend({css:"sz-navigator-search",template:sz.tmpl.navigate.searchView,context:function(){return{}}});e.DiscoverView=b.View.extend({css:"sz-navigator-discover",
template:sz.tmpl.navigate.discoverView,initialize:function(a){e.DiscoverView.__super__.initialize.call(this,a);this.tags=null;this.fetching=!1},maybeFetch:function(){if(!this.fetching){this.fetching=!0;var b=this,e=new a.Set({}),g=new a.Set({});c.Tag.getAll(e.backbone.proxy("tags"));e.after("tags",function(a){b.tags=a;a.each(function(a){a.galleries.fetch(g.backbone.proxy("gallery-"+a.get("id")))})});e.add("galleries",g);$.when(e).done(this.render)}},context:function(){var a={tags:[]};this.tags&&this.tags.each(function(b){var c=
b.toJSON();c.galleries=_.map(b.galleries.models,function(a){var d=a.toJSON();d.url="/discover/"+b.get("id")+"/"+a.get("id").replace(/^_curated-/,"")+"/";return d});a.tags.push(c)});return a},render:function(){var a=this;this.maybeFetch();$(this.el).html(this.template(this.context()));setTimeout(function(){a.$(".nav").accordion({fillSpace:!0})},0);this.sync();return this}});e.View=b.View.extend({css:"sz-navigator",initialize:function(a){e.View.__super__.initialize.call(this,a);this.modules=a.modules},
render:function(){var a=$(this.el);a.empty();_.each(this.modules,function(b){a.append(b.render().el)});this.sync();return this}});return e});define("songza/sharing",["songza/base"],function(b){function c(){var a,b,c=["property","name"];for(a=0;a<arguments.length;a++)for(b=0;b<c.length;b++){var g=$("meta["+c[b]+"='"+arguments[a]+"']").attr("content");if(g=(g||"").replace(/^\s*([\S]*)\s*$/,"$1"))return g}return null}var a={};a.SharePageItem=b.Model.extend({defaults:{title:null,description:null,url:null,image_url:null,share_text:null}},{forCurrentPage:function(){var b={title:c("og:title")||$("title").text(),url:c("share_url","og:url")||window.location.href,
description:c("og:description","description"),image_url:c("og:image"),share_text:c("share_text","og:title")||$("title").text()};return new a.SharePageItem(b)}});a.Button=b.View.extend({css:"sz-share-button",initialize:function(b){var d=this;a.Button.__super__.initialize.call(this,b);this.app=b.app;this.shareItem=b.shareItem;this.shareSystems=b.shareSystems;$(this.el).click(function(a){d.showMenu(a)})},removeMenu:function(){var a=this;this.overlay&&a.overlay.fadeOut("fast",function(){a.modal.fadeOut("fast",
function(){a.overlay.detach();a.modal.detach();a.overlay=null;a.modal=null})});this.menu.destroy();this.menu=null},showMenu:function(b){var d=this;b.stopPropagation();if(!this.menu){b=(new a.Menu({shareItem:this.shareItem,shareSystems:this.shareSystems})).render();b.bind("share-completed",function(){d.removeMenu()});var c=$("<div>").addClass("sz-share-menu-overlay"),g=$("<div>").addClass("sz-modal"),h=$("<span>").addClass("szi-close"),i=$("<div>").addClass("szi-title").text("Share with: ");c.append(i).append(h).append(b.el);
h.click(function(){d.removeMenu()});$(this.app.view.el).append(g);$(this.app.view.el).append(c);this.app.bind("page-navigate",function(){d.removeMenu()});c.css("position","absolute");c.css("top",($(window).height()-c.outerHeight())/2+$(window).scrollTop()+"px");c.css("left",($(window).width()-c.outerWidth())/2+$(window).scrollLeft()+"px");c.css("z-index",1003);g.css("z-index",1002);g.css("position","absolute");g.css("top","0");g.css("left","0");g.css("width",$(document).width());g.css("height",$(document).height());
c.css("display","none");g.css("display","none");g.fadeIn("fast",function(){c.fadeIn("fast")});this.overlay=c;this.modal=g;this.menu=b}},render:function(){$(this.el).text("Share");this.sync();return this}});a.Menu=b.View.extend({css:"sz-sharing-menu",initialize:function(b){var d=this;a.Menu.__super__.initialize.call(this,b);this.shareItem=b.shareItem;this.shareSystems=_.map(b.shareSystems,function(a){a=new a({shareItem:d.shareItem});a.bind("share-completed",function(a){d.trigger("share-completed",
a)});return a})},context:function(){return{shareItem:this.shareItem.toJSON()}},render:function(){var a=this,b=$("<ul>");$(this.el).empty().append(b);_.each(this.shareSystems,function(c,g){var h=$("<li>").append(c.render().el);a.shareSystems.length-1==g&&h.addClass("szi-last");b.append(h)});this.sync();return this}});return a});define("songza/systems/twitter",["songza/config","songza/utils","songza/base"],function(b,c,a){function e(){window.twttr&&d&&f()}var d;if(!b.twitter.handle)return{register:function(){}};var f=_.once(function(){var a=d.getInstance();twttr.events.bind("tweet",function(b){var c=$(b.target).data("sz-share-item");a.trigger("social-action",{source:"twitter",type:b.type,url:c?c.get("url"):window.location.href})})}),g=a.View.extend({css:"sz-sharing-twitter",initialize:function(a){g.__super__.initialize.call(this,
a);this.shareItem=a.shareItem},render:function(){var a=this,b=this.shareItem,e={via:d.getInstance().getConfig().twitter.handle||"",url:b.get("url"),text:b.get("share_text")||b.get("title")},e=$("<a>").text("Twitter").attr("href","https://twitter.com/intent/tweet?"+c.formQuery(e)).attr("title","Twitter").attr("data-sz-no-route","");e.data("sz-share-item",b);e.click(function(){a.trigger("share-completed",{shareItem:b})});$(this.el).empty().append(e);this.sync();return this}});return{register:function(a){a.addSharingSystem(g);
d=a;a=document.createElement("script");a.async=!0;a.src=document.location.protocol+"//platform.twitter.com/widgets.js";document.getElementsByTagName("head")[0].appendChild(a);$(a).load(e)}}});define("songza/systems/facebook",["songza/config","songza/models","songza/utils","songza/base"],function(b,c,a,e){function d(a){var b=j.getInstance();c.User.loginWithFacebook(a,{success:function(a){a.isNew&&b.trigger("visitor-signup",{visitor:a.user});b.setVisitor(new c.User(a.user));b.refresh()}})}function f(a,b){var e=j.getInstance(),g=e.getVisitor();a?g.isAnonymous()?d(a.accessToken):g.get("facebook_id")&&g.get("facebook_id")!=a.userID&&c.User.logout().done(function(){d(a.accessToken)}):b||(g=
c.User.logout(),$.when(g).done(function(){c.User.getCurrent({success:function(a){e.setVisitor(a);e.refresh()}})}))}function g(){j.getInstance().getVisitor().get("facebook_id")&&FB.getLoginStatus(function(){})}function h(){window.FB&&j&&m()}function i(){var a,b,c,d,e;if(a=j.getInstance())if(a=a.getPlayer())d=j.getInstance().getVisitor(),d.get("facebook_id")&&a.model.get("current")&&a.model.get("current").get("streamSong")&&(c=a.model.get("current").get("streamSong").get("song"),b=a.model.get("station"),
a.getState("state_play")?e={playing:!0,song:l+c.canonicalUrlPath(),radio_station:l+b.pageUrlPath(),user_id:d.get("facebook_id")}:a.getState("state_pause")?e={playing:!1,song:l+c.canonicalUrlPath(),radio_station:l+b.pageUrlPath(),user_id:d.get("facebook_id")}:a.getState("fetching_next_error")&&(e={error_code:4,playing:!1,user_id:d.get("facebook_id")}),e&&FB.Music.send("STATUS",e))}function k(b){var c=a.pageId(),d=a.commentUrl()||a.firstMeta("og:url")||a.currentUrl(),d=$("<div>").text(d).html().replace('"',
"&quot;"),e='<fb:comments numposts="5" publish_feed="true"';e+=c?' migrated="1" xid="'+c+'"':' href="'+d+'"';e+="/>";b.html(e);window.FB&&FB.XFBML.parse(b.get(0))}var j,l="http://songza.com";if(!b.facebook.app_id)return{register:function(){}};var m=_.once(function(){var a=j.getInstance(),b=a.getConfig();FB.init({appId:b.facebook.app_id,status:!0,cookie:!0,xfbml:!0,oauth:!0,music:b.features["systems.facebook.scrobbing"]});q.share();q.login();q.scrobbing();setInterval(g,18E5);FB.Event.subscribe("edge.create",
function(b){a.trigger("social-action",{source:"facebook",type:"like",url:b})});FB.Event.subscribe("edge.remove",function(b){a.trigger("social-action",{source:"facebook",type:"unlike",url:b})});FB.Event.subscribe("comment.create",function(b){a.trigger("social-action",{source:"facebook",type:"comment-add",url:b.href})});FB.Event.subscribe("comment.remove",function(b){a.trigger("social-action",{source:"facebook",type:"comment-remove",url:b.href})})}),q={share:function(){var a=j.getInstance();$(a.view.el);
b.features["systems.facebook.share"]&&j.addSharingSystem(n)},login:function(){var a=j.getInstance(),c=$(a.view.el);b.features["systems.facebook.auth"]&&(c.delegate(".sz-login-facebook","click",function(b){var c=a.getConfig().facebook.permissions,d;b.preventDefault();d=$(b.target).attr("data-sz-next")||"";FB.getLoginStatus(function(b){b.authResponse?f(b.authResponse):FB.login(function(b){f(b.authResponse,!0);d?(d[0]==="/"&&(d=d.substring(1)),Backbone.history.navigate(d)):a.refresh()},{scope:c})})}),
a.bind("visitor-change",function(a){a.oldVisitor.get("facebook_id")&&!a.newVisitor.get("facebook_id")&&FB.getLoginStatus(function(a){a.authResponse&&FB.logout()})}),FB.getLoginStatus(function(a){f(a.authResponse,!0)}),FB.Event.subscribe("auth.authResponseChange",function(a){f(a.authResponse)}))},scrobbing:function(){var a=j.getInstance();b.features["systems.facebook.scrobbing"]&&(a.bind("app-unload",function(){var b=a.getVisitor();b.get("facebook_id")&&FB.Music.send("STATUS",{offline:!0,user_id:b.get("facebook_id")})}),
a.bind("visitor-change",function(a){a.newVisitor.get("facebook_id")&&i()}),FB.Event.subscribe("fb.music.PLAY",function(b){c.Station.getByUrl(b.radio_station,{success:function(b){a.startStation(b,!0);i()}})}),FB.Event.subscribe("fb.music.RESUME",function(){var b=a.getPlayer();b&&b.play()}),FB.Event.subscribe("fb.music.PAUSE",function(){var b=a.getPlayer();b&&b.pause()}),FB.Event.subscribe("fb.music.STATUS",i),FB.Event.subscribe("fb.music.WINDOW_OPEN",i),FB.Event.subscribe("fb.music.USER_MISMATCH",
i),FB.Event.subscribe("fb.music.ALREADY_CONNECTED",i),FB.Event.subscribe("fb.music.BRIDGE_READY",i),a.bind("player-fetching-next-error",i),a.bind("player-song-started",i),a.bind("player-song-play",i),a.bind("player-song-pause",i),i())}},n=e.View.extend({css:"sz-sharing-facebook",initialize:function(a){var b=this;n.__super__.initialize.call(this,a);this.shareItem=a.shareItem;$(this.el).click(function(){b._share()})},render:function(){$(this.el).text("Facebook");this.sync();return this},_share:function(){var b=
this.shareItem,c=(window.screen.width-850)/2,d=(window.screen.height-500)/2,e="http://www.facebook.com/sharer.php?"+a.formQuery({u:b.get("url"),t:b.get("title")});window.open(e,"facebook_sharer",["toolbar=no,status=no,scrollbars=yes,resizable=yes,width=850,height=500","left="+c,"top="+d].join(","));this.trigger("share-completed",{shareItem:b})}});return{register:function(a){a.addCommentProvider("facebook",k);j=a;$("body").append($("<div>").attr("id","fb-root"));window.fbAsyncInit=h;a=document.createElement("script");
a.async=!0;a.src=document.location.protocol+"//connect.facebook.net/en_US/all/vb.js";document.getElementsByTagName("head")[0].appendChild(a)}}});define("songza/systems/google-analytics",["songza/config"],function(b){function c(){l&&(clearTimeout(l),l=null)}function a(){var a=h.getPlayer(),b=a.model.get("station"),d=f(b),a=parseInt(a.getListenTime()/1E3);c();m&&(clearTimeout(m),m=null);q||(q=!0,i._trackEvent(d,"Station Listen Time",b.get("name"),a))}function e(){var d=h.getPlayer().model.get("station"),e=f(d),g=h.view.getStationNavigationContext(d.get("id"));c();m&&(clearTimeout(m),m=null);q=!1;m=setTimeout(a,b.timeouts.stationTotalPlayTime*
1E3);g&&(n={stationId:d.get("id"),stationName:d.get("name"),contextName:g});i._trackEvent(e,"Station Started",d.get("name"))}function d(){var a=h.getVisitor(),b="songza";a.isAnonymous()||(a.get("black_planet_id")?b="black_planet":a.get("facebook_id")&&(b="facebook"),i._setCustomVar(k,"Member",b,j))}function f(a){return a.get("type")==="stream"?"Stream Station":a.get("type")==="basic"?"Basic Station":a.get("type")==="artist"?"Artist Station":"Unknown Station"}function g(){window._gat&&h&&t()}var h,
i,k=1,j=1,l,m,q,n;if(!b.google_analytics.account_id)return{register:function(){}};var t=_.once(function(){i=_gat._createTracker(h.getConfig().google_analytics.account_id);i._setDomainName(".songza.com");i._trackPageview();i._trackPageLoadTime();d();h.bind("visitor-signup",function(){i._trackEvent("Visitor","Visitor Sign Up")});h.bind("page-navigate",function(a){i._trackPageview(a.path)});h.bind("social-action",function(a){i._trackSocial(a.source,a.type,a.url)});h.bind("visitor-change",d);h.bind("player-song-play",
function(){c()});h.bind("player-song-pause",function(){l||(l=setTimeout(a,b.timeouts.stationMaxIdleTime*1E3))});h.bind("player-station-started",function(){e()});h.getPlayer()&&e();h.bind("player-station-stopped",function(){a()});h.bind("player-song-completed",function(a){var b=a.songState?parseInt(a.songState.position/1E3):0,d=f(a.station);i._trackEvent(d,"Station Song Played",a.station.get("name"),b);i._trackEvent("Artist","Artist Song Played",a.song.get("artist"),b);n&&(i._trackEvent(d,"Station Discovery - "+
n.contextName,n.stationName),n=null)});h.bind("player-song-skipped",function(a){var b=a.songState&&a.songState.position?parseInt(a.songState.position/1E3):0,d=f(a.station);i._trackEvent(d,"Station Song Skipped",a.station.get("name"),b);i._trackEvent("Artist","Artist Song Skipped",a.song.get("artist"),b)})});return{register:function(a){h=a.getInstance();a=document.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";
var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);$(a).load(g)}}});define("songza/systems/disqus",["songza/config","songza/utils"],function(b,c){function a(a){a.append($("<div>").attr("id","disqus_thread"));window.DISQUS?e():(a=document.createElement("script"),a.setAttribute("language","javascript"),a.setAttribute("type","text/javascript"),a.setAttribute("src","http://"+b.disqus.shortname+".disqus.com/embed.js"),document.body.appendChild(a),$(a).load(e))}function e(){if(window.DISQUS&&$("#disqus_thread").size()>0)try{window.DISQUS.reset({reload:!0,config:function(){this.page.url=
c.commentUrl()||c.currentUrl()}})}catch(a){}}if(b.disqus.shortname)window.disqus_shortname=b.disqus.shortname;else return{register:function(){}};if(b.debug)window.disqus_developer=1;return{register:function(b){b.addCommentProvider("disqus",a)}}});define("songza/systems/quantcast",["songza/config"],function(b){function c(){var a=_.map(b.quantcast.accounts,function(a){return{qacct:a}});window._qevents.push(a)}function a(){window.__qc&&e&&d()}var e;if(b.quantcast.accounts.length==0)return{register:function(){}};var d=_.once(function(){e.bind("page-navigate",c);c()});return{register:function(b){e=b.getInstance();var b=("https:"==document.location.protocol?"https://secure":"http://edge")+".quantserve.com/quant.js",d=document.createElement("script");
d.setAttribute("language","javascript");d.setAttribute("type","text/javascript");d.setAttribute("src",b);document.body.appendChild(d);$(d).load(a)}}});define("songza/systems/comscore",["songza/config","songza/utils"],function(b,c){function a(){window.COMSCORE.beacon({c1:2,c2:b.comscore.client_id,c3:c.currentUrl({no_protocol:!0})})}function e(){window.COMSCORE&&d&&f()}var d;if(!b.comscore.client_id)return{register:function(){}};var f=_.once(function(){d.bind("page-navigate",a);a()});return{register:function(a){d=a.getInstance();var a=("https:"==document.location.protocol?"https://sb":"http://b")+".scorecardresearch.com/beacon.js",b=document.createElement("script");
b.setAttribute("language","javascript");b.setAttribute("type","text/javascript");b.setAttribute("src",a);document.body.appendChild(b);$(b).load(e)}}});define("songza/systems/chartbeat",["songza/config"],function(b){function c(){window.pSUPERFLY&&a&&e()}var a;if(!b.chartbeat.user_id)return{register:function(){}};window._sf_async_config={uid:b.chartbeat.user_id,domain:window.location.hostname};var e=_.once(function(){a.bind("page-navigate",function(a){window.pSUPERFLY.virtualPage(a.path,document.title)})});return{register:function(b){a=b.getInstance();window._sf_endpt=(new Date).getTime();b=document.createElement("script");b.setAttribute("language",
"javascript");b.setAttribute("type","text/javascript");b.setAttribute("src",("https:"==document.location.protocol?"https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/":"http://static.chartbeat.com/")+"js/chartbeat.js");document.body.appendChild(b);$(b).load(c)}}});define("songza/player/view",["songza/base","songza/config","songza/models","songza/sharing","songza/player/managers"],function(b,c,a,e,d){a={};a.PlayerState=Backbone.Model.extend({defaults:{station:null,current:null,state:"pause"},initialize:function(){this.history=new Backbone.Collection([])}});var f=a.PlayerView=b.View.extend({template:sz.tmpl.player.player,historyTemplate:sz.tmpl.player.rollSong,events:{"click .szi-play-button":"play","click .szi-pause-button":"pause","click .szi-skip-button":"skip",
"click .szi-vote-up-button":"voteUp","click .szi-vote-down-button":"voteDown","click .szi-add-button":"addSong","click .szi-ban-button":"banSong"},elements:{".szi-volume":"volumeControl",".szi-error .container":"errorMessageEl",".szi-buffering":"bufferingEl"},css:"sz-player",states:{fixed:{set:!0,onCss:"sz-player-fixed"},starting:{set:!0,onCss:"sz-player-starting"},state_play:{set:!1,onCss:"sz-player-state-play"},state_pause:{set:!1,onCss:"sz-player-state-pause"},fetching_next:{set:!1,onCss:"sz-player-fetching-next"},
fetching_next_error:{set:!1,onCss:"sz-player-fetching-next-error"},buffering:{set:!1,onCss:"sz-player-buffering"},no_song:{set:!0,onCss:"sz-player-no-song"},no_skip:{set:!1,onCss:"sz-player-no-skip"}},initialize:function(a){var b=this;f.__super__.initialize.call(this,a);_.bindAll(this,"render");this.app=a.app;this.volumeCookieName="JS_PLAYER_VOLUME";this.errorMessage="";this.songPlayEmitted=!1;this.app.bind("visitor-change",this.render);this.model.history.bind("change",this.render);this.model.history.bind("add",
this.render);this.model.history.bind("remove",this.render);this.model.history.bind("reset",this.render);this.model.bind("change",this.render);this.model.bind("change:state",function(){_.each(["play","pause"],function(a){b.setState("state_"+a,!1)});b.setState("state_"+b.model.get("state"),!0);b.songTrigger(b.model.get("state"))});this.model.bind("change:current",function(){b.model.get("current")?b.setState("no_song",!1):b.setState("no_song",!0)});this.manager=this.model.get("station").get("stream")?
new d.Stream({station:this.model.get("station"),volume:this.getVolume()}):new d.Basic({station:this.model.get("station"),volume:this.getVolume()});this.manager.supportsNext()||this.setState("no_skip",!0);this.manager.bind("fetching-next",function(){b.errorMessageEl().empty();b.setState("fetching_next",!0);b.setState("fetching_next_error",!1)});this.manager.bind("fetching-next-error",function(a){b.errorMessage=a.message;b.errorMessageEl().empty().text(a.message);b.setState("fetching_next",!1);b.setState("fetching_next_error",
!0);b.trigger("fetching-next-error",a)});this.manager.bind("song-started",function(a){b._songStarted(a.song)});this.manager.bind("song-skipped",function(a){b.songPlayEmitted=!1;b.songTrigger("skipped");b._songEnded(a.song)});this.manager.bind("song-completed",function(a){b.songPlayEmitted=!1;b.songTrigger("completed");b._songEnded(a.song)});this.manager.bind("song-state",function(a){if(a=a.songState)a.buffering?b._startSpinner():b._stopSpinner(),b.setState("buffering",a.buffering),a.duration>0&&b.$(".szi-progress").css("width",
a.position/a.duration*100+"%")})},destroy:function(){f.__super__.destroy.call(this);this.manager.destroy()},updateProgress:function(){this.manager.songState()},songTrigger:function(a){this.model.get("current")&&this.trigger("song-"+a,{station:this.model.get("station"),song:this.model.get("current"),songState:this.manager.songState()})},songState:function(){return this.manager.songState()},getListenTime:function(){return this.manager.getListenTime()},start:function(){this.manager.start()},play:function(){this.manager.play();
this.model.set({state:"play"});return!1},pause:function(){this.manager.pause();this.model.set({state:"pause"});return!1},skip:function(){this.manager.next()},_songStarted:function(a){a.bind("change",this.render);this.setState("starting",!1);this.setState("fetching_next",!1);this.setState("fetching_next_error",!1);this.model.set({state:"play",current:a});this.songTrigger("started")},_songEnded:function(){var a=this.model.get("current");a&&(a.unbind("all"),this.model.history.add(a,{at:0}),this.model.set({current:null}));
this.model.history.models.length>3&&this.model.history.remove(this.model.history.last())},allSongs:function(){var a=this.model.history.models,b=this.model.get("current");return _.union(a,b?[b]:[])},songContext:function(a){return{song:a.toJSON(),song_id:a.cid,station:this.model.get("station").toJSON(),visitor:this.app.getVisitor().toJSON()}},render:function(){var a=this,b=this.model.get("station"),d=this.model.get("current"),f={visitor:this.app.getVisitor().toJSON(),station:b.toJSON(),station_url:b.pageUrlPath(),
station_edit_url:b.editUrlPath(),song:null,history:[]};d&&(f.song=this.songContext(d));this.model.history.each(function(b){f.history.push(a.songContext(b))});$(this.el).html(this.template(f));var j;d?(j="I'm listening to \""+d.get("title")+'"',j+=" by "+d.get("artist"),j+=" (on "+b.get("name")+")"):j="I'm listening to "+b.get("name");d=new e.SharePageItem({title:b.get("name"),description:b.get("description"),url:c.makeAbsolute(b.pageUrlPath()),image_url:b.get("cover_url"),share_text:j});b=$(".szi-share-buttons",
this.el);j=this.app.getSharingSystems();d=new e.Button({shareItem:d,shareSystems:j,app:this.app});b.empty().append(d.render().el);a.volumeControl().slider({range:"min",min:1,max:100,value:this.getVolume()});a.volumeControl().bind("slide",_.bind(function(a,b){this.setVolume(b.value)},this));this.sync();this.errorMessageEl().empty().text(this.errorMessage);this.getState("buffering")&&this._startSpinner();return this},_startSpinner:function(){this.spinner=new Spinner({lines:12,length:10,width:2,radius:3,
color:"#fff",speed:1,trail:50,shadow:!0});this.bufferingEl().empty().append(this.spinner.el);this.spinner.spin()},_stopSpinner:function(){this.spinner&&(this.spinner.stop(),delete this.spinner)},findSong:function(a){var b,d=this.allSongs();for(b=0;b<d.length;b++)if(d[b].cid==a)return d[b];throw Error("Unable to locate song with id["+a+"] in player"+a);},voteUp:function(a){var a=this.findSong($(a.target).attr("data-sz-song-id")),b=a.get("streamSong");b&&(a.set({vote:"up"}),b.voteUp());return!1},voteDown:function(a){var a=
this.findSong($(a.target).attr("data-sz-song-id")),b=a.get("streamSong");b&&(a.set({vote:"down"}),b.voteDown());a.cid===this.model.get("current").cid&&this.manager.next();return!1},addSong:function(a){var a=this.findSong($(a.target).attr("data-sz-song-id")),b=a.get("streamSong"),d=this.model.get("station");b&&(a.set({banned:!1}),d.addSongs([b.get("song")]));return!1},banSong:function(a){var a=this.findSong($(a.target).attr("data-sz-song-id")),b=a.get("streamSong"),d=this.model.get("station");b&&(a.set({banned:!0}),
d.banSongs([b.get("song")]));a.cid===this.model.get("current").cid&&this.manager.next();return!1},setVolume:function(a){a=parseInt(a);$.cookie(this.volumeCookieName,a,{expires:365,path:"/"});this.manager&&this.manager.setVolume(a)},getVolume:function(){var a=$.cookie(this.volumeCookieName);return a!==null?parseInt(a,10):50}});return a});define("songza/player/cores/jw",["songza/base","songza/config"],function(b,c){return b.Class.extend({initialize:function(a){this.volume=a.volume!==void 0?a.volume:50;$("#jwplayer").remove();a=$("<div id='jwplayer'>");$("body").append(a)},supportedFormats:function(){return["rtmp"]},play:function(){if(!this.isValid())return!1;this.__jwp.play();return!0},setVolume:function(a){this.volume=a;if(!this.isValid())return!1;this.__jwp.setVolume(a);return!0},pause:function(){if(!this.isValid())return!1;this.__jwp.pause();
return!0},songState:function(){return null},playStream:function(a){var b=a.split("/"),b=b[b.length-1],d=this;this.__jwp=jwplayer("jwplayer").setup({flashplayer:c.static_url+"swf/jwplayer/player.swf",file:b,type:"rtmp",streamer:a,width:1,height:1,volume:this.volume,events:{onMeta:function(a){"type"in a.metadata&&a.metadata.type==="metadata"&&d.trigger("meta",a.metadata)},onPlay:function(){d.trigger("song-play")},onBuffer:function(){d.trigger("song-buffer")},onIdle:function(){d.trigger("song-idle")},
onPause:function(){d.trigger("song-pause")},onComplete:function(){d.trigger("song-complete")}}});this.__jwp.play()},prep:function(a){a()},destroy:function(){this.__jwp.stop();this.__jwp=null;return!0},isPlaying:function(){return!1},isPaused:function(){return!1},isValid:function(){return this.__jwp}})});define("songza/player/cores/sm",["songza/base","songza/config"],function(b,c){function a(a,b){function d(){a.volume>5?(a.setVolume(a.volume/2),setTimeout(d,50)):b?a.stop():a.pause()}setTimeout(d,50)}var e=1,d=!1;$(function(){if(!soundManager)window.soundManager=new SoundManager,soundManager.url=c.static_url+"swf/soundmanager/",soundManager.debugMode=!1,soundManager.debugFlash=!1,soundManager.consoleOnly=!1,soundManager.onload=function(){d=!0},soundManager.flashLoadTimeout=0,soundManager.flashVersion=
9,soundManager.beginDelayedInit()});var f=b.Class.extend({initialize:function(a){this.__previousSmSound=this.__currentSmSound=null;this.volume=a.volume!==void 0?a.volume:50},supportedFormats:function(){return["aac","mp3"]},play:function(){if(!this.isValid())return!1;this.isPaused()?this.__currentSmSound.resume():this.isPlaying()||this.__currentSmSound.play();return!0},_adjustVolume:function(a){return Math.pow(a,2)/100},setVolume:function(a){this.volume=a;this.__currentSmSound&&this.__currentSmSound.setVolume(this._adjustVolume(a));
return!0},pause:function(){if(!this.isValid())return!1;this.isPaused()||this.__currentSmSound.pause();return!0},songState:function(){if(this.__currentSmSound){var a=this.__currentSmSound;return{position:a.position,duration:a.duration,buffering:a.isBuffering}}return null},playSong:function(b,c){var f=this;if(d){var g=c=="aac";if(this.__currentSmSound)a(this.__currentSmSound,!0),this.__previousSmSound=this.__currentSmSound;e+=1;this.__currentSmSound=soundManager.createSound({id:"sm"+e,url:b,volume:f._adjustVolume(f.volume),
onplay:function(){f.trigger("song-play")},onpause:function(){f.trigger("song-pause")},onresume:function(){f.trigger("song-resume")},onbufferchange:function(){f.trigger("song-play-state",f.songState())},whileplaying:function(){f.trigger("song-play-state",f.songState())},onfinish:function(){f.trigger("song-complete")},isMovieStar:g,autoPlay:!1});this.trigger("new-song");this.__currentSmSound.play()}else setTimeout(function(){f.playSong(b,c)},250)},prep:function(a){a()},destroy:function(){if(this.__currentSmSound)a(this.__currentSmSound),
this.__currentSmSound=null},isPlaying:function(){return this.__currentSmSound!=null&&this.__currentSmSound.playState},isPaused:function(){return this.__currentSmSound!=null&&this.__currentSmSound.paused},isValid:function(){return this.__currentSmSound!=null}}),g=f.extend({supportedFormats:function(){return["mp3"]},prep:function(a){soundManager.createSound({id:"sm-ios-prep",url:c.static_url+"1sec.mp3",onplay:a,autoPlay:!0})}});return{sm:f,sm_ios:g}});define("songza/player/models",function(){var b={},c=b.Song=Backbone.Model.extend({defaults:{title:null,artist:null,image_url:null,added_by:null,filler:!0,streamSong:null,vote:null,banned:null},toJSON:function(){var a=c.__super__.toJSON.call(this);if(this.get("song"))a.song=this.get("song").toJSON();if(this.get("added_by"))a.added_by=this.get("added_by").toJSON();return a}});return b});define("songza/player/core",["songza/player/cores/sm","songza/player/cores/jw"],function(b,c){return{getPlayer:function(a){if(a.stream&&a.stream.formats&&a.stream.formats.rtmp)return c;return Modernizr.ios?b.sm_ios:b.sm}}});define("songza/player/managers",["songza/base","songza/config","songza/models","songza/player/models","songza/player/core"],function(b,c,a,e,d){var f={};f.Base=b.Class.extend({initialize:function(a){f.Base.__super__.initialize.call(this,a);this.station=a.station;this.volume=a.volume;this.started=!1;this.song=null;this.listenTime=0;this.listenChunkStartTime=null},getListenTime:function(){if(!this.listenChunkStartTime)return this.listenTime;return this.listenTime+((new Date).getTime()-this.listenChunkStartTime.getTime())},
startListen:function(){if(!this.listenChunkStartTime)this.listenChunkStartTime=new Date},stopListen:function(){var a=new Date;if(this.listenChunkStartTime)this.listenTime+=a.getTime()-this.listenChunkStartTime.getTime(),this.listenChunkStartTime=null},play:function(){this.core.play()},pause:function(){this.core.pause()},songState:function(){return this.core.songState()},destroy:function(){this.core.unbind();this.core.destroy()},setVolume:function(a){this.volume=a;this.core.setVolume(a)},getVolume:function(){return this.volume},
_songTrigger:function(a){var b={station:this.station,song:this.song,songState:this.songState()};this.trigger("song-"+a,b)},start:function(){},next:function(){},supportsNext:function(){return!0}});var g=f.Basic=f.Base.extend({initialize:function(a){var b=this;g.__super__.initialize.call(this,a);_.bindAll(this,"_handleNextSong","_handleNextSongError");this.core=new (d.getPlayer(this.station.toJSON()))({volume:this.volume});this.core.bind("song-resume",function(){b.startListen()});this.core.bind("song-pause",
function(){b.stopListen()});this.core.bind("song-play-state",function(a){a.buffering?b.stopListen():b.startListen();b._songTrigger("state")});this.core.bind("song-complete",function(){b.stopListen();b._songTrigger("completed");b.next()})},start:function(){var a=this;if(this.started)throw Error("Manager has already been started");this.core.prep(function(){a.started=!0;a.next()})},next:function(){var a=this.songState(),a=a&&(a.position+2E4<a.duration||a.duration==0),b={params:{skip:a,cover_size:"m",
format:this.core.supportedFormats()[0]},success:this._handleNextSong,error:this._handleNextSongError};a&&this._songTrigger("skipped");this.song=null;this.trigger("fetching-next");this.station.nextSong(b)},_makeSong:function(b){var d=b.get("song"),b={title:d.get("title"),artist:d.get("artist").get("name"),image_url:d.get("cover_url"),added_by:b.get("song").get("added_by"),filler:b.get("status")==="FILLER",banned:b.get("status")==="BAN",vote:b.get("vote"),streamSong:b};if(!b.added_by)b.added_by=new a.User({}),
b.added_by.set(b.added_by.parse(c.songza_account));return new e.Song(b)},_handleNextSong:function(a){this.song=this._makeSong(a);this.core.playSong(a.get("listen_url"),a.get("version"));this._songTrigger("started")},_handleNextSongError:function(a){var b="advance_song_error",d="Whoops! We had a little trouble getting your next song.",c;if(a.status===403)try{if(c=$.parseJSON(a.responseText))c.code==="skip"?(b="skip_limit_reached",d="Sorry, but can't quite let ya skip anymore."):c.code==="end"&&(b=
"end_of_station",d="End of Playlist Reached")}catch(e){}this.trigger("fetching-next-error",{error:b,station:this.station,message:d})}}),h=f.Stream=f.Base.extend({initialize:function(a){var b=this;h.__super__.initialize.call(this,a);_.bindAll(this,"_handleMeta");this.core=new (d.getPlayer(this.station.toJSON()))({volume:this.volume});this.started=!1;this.song=null;this.meta={};this.metaFetching=!1;this.metaTimer=null;this.core.bind("meta",this._handleMeta);this.core.bind("song-play",function(){b.startListen()});
this.core.bind("song-pause",function(){b.stopListen()});this.core.bind("song-buffer",function(){b.stopListen()});this.core.bind("song-idle",function(){b.stopListen()});this.core.bind("song-complete",function(){b.stopListen()})},_getSecId:function(a){var a=parseUri(a).query||[],b=null;_.each(a.split("&"),function(a){var d=a.split("=")[0],a=a.split("=")[1];d==="sec"&&(b=decodeURIComponent(a))});return b},_fetchMetadata:function(a){var b=this,d=this.station.get("stream").metadata;!this.metaFetching&&
d&&$.ajax({url:d,complete:function(){b.metaFetching=!1},success:function(d){var c={};_.each(d,function(a){c[a.sec_id]=a});b.meta=c;b.song&&!a&&b._mergeMetadata(b.song)}})},_mergeMetadata:function(a){var b=a.get("_secId"),d={};if(this.meta.hasOwnProperty(b)){b=this.meta[b];if(b.artist)d.artist=b.artist;if(b.title)d.title=b.title;if(b.image.medium)d.image_url=b.image.medium;a.set(d)}},_extractSong:function(a){var b={};if(a.artist==="BREAK"||a.artist==="EVENT TIMEOUT"||a.artist==="TARGETSPOT")return null;
b.artist=a.artist;b.title=a.title;b.image_url=this.station.get("cover_url");b._secId=this._getSecId(a.url);a=new e.Song(b);this._mergeMetadata(a);return a},_endSong:function(){if(this.song)this._songTrigger("completed"),this.song=null},_handleMeta:function(a){console.log("new metadata",a);if(a=this._extractSong(a)){if(this.song&&a&&this.song.get("_secId")!==a.get("_secId")&&this._endSong(),a)this.song=a,this._songTrigger("started")}else this._endSong()},start:function(){var a=this,b=this.station.get("stream").formats.rtmp;
if(this.started)throw Error("Manager has already been started");this.station.listen();this._fetchMetadata();this.metaTimer=setInterval(function(){a._fetchMetadata()},12E4);this.core.prep(function(){a.started=!0;a.core.playStream(b)})},next:function(){throw Error("Next is not supported");},supportsNext:function(){return!1}});return f});define("songza/station-editor",["songza/base","songza/models","songza/utils","songza/config"],function(b,c,a,e){function d(a){return a.get("artist").get("name").toLowerCase()+a.get("title")}var f={},g=g=b.View.extend({template:sz.tmpl.stationEditor.songSearch,songTemplate:sz.tmpl.stationEditor.searchSongListItem,css:"sz-song-search",elements:{".szi-query-input":"queryInput",".szi-results":"resultsEl"},events:{"keyup .szi-query-input":"maybeSearch","click .sz-search-song":"addSong"},initialize:function(a){g.__super__.initialize.call(this,
a);_.bindAll(this,"syncResults");this.station=a.station;this.minQueryLength=a.hasOwnProperty("minQueryLength")?this.minQueryLength:2;this.searchDelay=a.hasOwnProperty("searchDelay")?this.searchDelay:200;this.query=a.query||"";this.results=new Backbone.Collection([]);this.stamp=0;this.results.bind("reset",this.syncResults);this.results.bind("add",this.syncResults);this.results.bind("remove",this.syncResults)},addSong:function(a){a.preventDefault();a.stopPropagation();(a=this.results.get(parseInt($(a.currentTarget).attr("data-sz-song-id"),
10)))&&this.trigger("song-add",a)},maybeSearch:function(){var a,b=this,d=$.trim(this.queryInput().val());d.length>=this.minQueryLength?(this.stamp+=1,a=this.stamp,setTimeout(function(){if(b.stamp==a){var e=c.Song.search(d,{limit:200});$.when(e).done(function(d){b.stamp===a&&b.results.reset(d.models)})}},this.searchDelay)):d.length===0&&(this.stamp+=1,this.results.reset())},context:function(){return{view_id:this.cid,query:this.query}},resultsData:function(){var a=[];this.results.each(function(b){a.push(b.toJSON())});
return a},syncResults:function(){var a=this.songTemplate,b=this.resultsEl();b.empty();this.results.each(function(d){b.append(a({song:d.toJSON()}))})}}),h=b.View.extend({template:sz.tmpl.stationEditor.songList,songTemplate:sz.tmpl.stationEditor.stationSongListItem,css:"sz-song-list",elements:{".szi-type":"typeSelect",".szi-query-input":"queryInput",".szi-song-list":"songList"},events:{"keyup  .szi-query-input":"maybeSearch","click  .szi-type .szi-tab":"onTypeClick","click  .szi-ban":"banSong","click  .szi-unban":"unBanSong"},
initialize:function(a){h.__super__.initialize.call(this,a);_.bindAll(this,"onSongAdd","onSongRemove","onSongsReset");this.user=a.user;this.station=a.station;this.songs=a.songs||[];this.hideContribute=a.hideContribute;this.query=a.query||"";this.type=a.type||"all";this.station.bind("change:allow_song_adds",this.render);this.station.songs.bind("reset",this.onSongsReset);this.station.songs.bind("add",this.onSongAdd);this.station.songs.bind("remove",this.onSongRemove);this.initSongs()},initSongs:function(){var a=
this;this.songs=this.station.songs.models.slice();_.each(this.songs,function(b){b.bind("change",a.render)});this.songs=_.sortBy(this.songs,d)},setType:function(a){if(this.type!==a)this.type=a,this.render()},onSongsReset:function(){this.initSongs();this.render()},onSongAdd:function(a){this.addSong(a);this.highlightSong(a)},onSongRemove:function(a){this.songs=_.without(this.songs,a);a.unbind("change",this.render);this.render()},addSong:function(a){if(!this.getSong(a.get("id"))){var b=_.sortedIndex(this.songs,
a,d);a.bind("change",this.render);this.songs.splice(b,0,a);this.render()}},getSongs:function(){return this.songs.slice()},highlightSong:function(a){var b=this.songList().find(".sz-station-song").filter(function(){return parseInt($(this).attr("data-sz-song-id"),10)===a.get("id")}).parents("li");this.songList().find("ul > li").removeClass("szi-highlighted");this.songList().find("ul").scrollTo(b);b.addClass("szi-highlighted");b.slideUp(0).slideDown()},getSong:function(a){return _.detect(this.songs,function(b){return b.get("id")===
a})},banSong:function(a){var b=$(a.currentTarget),d=b.parents("li"),b=this.getSong(parseInt(b.attr("data-sz-song-id"),10));a.preventDefault();a.stopPropagation();d.hide(200);b&&this.trigger("song-ban",b)},unBanSong:function(a){var b=$(a.currentTarget),d=b.parents("li"),b=this.getSong(parseInt(b.attr("data-sz-song-id"),10));a.preventDefault();a.stopPropagation();d.hide(200);b&&this.trigger("song-unban",b)},songTypeMatcher:function(){var a=this.type,b=this.user;return function(d){if(a==="all")return d.get("status")!==
"BAN";else if(a==="mine")return d.get("added_by")&&b.get("id")===d.get("added_by").get("id");else if(a==="contributed")return d.get("added_by")&&b.get("id")!==d.get("added_by").get("id");else if(a==="deleted")return d.get("status")==="BAN";return!1}},songQueryMatcher:function(){return a.WordMatcher(this.queryInput().val(),function(a){return a.get("artist").get("name")+" "+a.get("title")+" "+a.get("album")})},songMatcher:function(){var a=this.songTypeMatcher(),b=this.songQueryMatcher();return function(d){return a(d)&&
b(d)}},songContext:function(a){return{song:a.toJSON(),station:this.station.toJSON()}},syncSongList:function(){var a=this,b=this.type,d=this.songMatcher(),c=this.songTemplate,e=$("<ul>"),f=!1;this.songList().empty();_.each(this.songs,function(b){d(b)&&(b=$("<li>").html(c(a.songContext(b))),f=!0,e.append(b))});if(f)this.songList().append(e);else{var g="No songs";b==="deleted"?g="No deleted songs":b==="contributed"&&(g="No contributed songs");g+=this.queryInput().val()?" matched your query":" were found";
this.songList().append($("<div>").addClass("szi-empty").text(g))}},onTypeClick:function(a){this.type=$(a.currentTarget).attr("data-sz-type");this.render()},maybeSearch:function(){this.query=this.queryInput().val()||"";this.syncSongList()},context:function(){var b=this.user,d={view_id:this.cid,query:this.query,type:this.type,station:this.station.toJSON(),hide_contribute:this.hideContribute,stats:{song_count:{all:0,mine:0,contributed:0,deleted:0},total_duration_seconds:0,total_duration:""}},c=this.songTypeMatcher();
_.each(this.songs,function(a){c(a)&&(d.stats.total_duration_seconds+=a.get("duration"));a.get("status")!=="BAN"?(d.stats.song_count.all+=1,a.get("added_by").get("id")===b.get("id")?d.stats.song_count.mine+=1:d.stats.song_count.contributed+=1):d.stats.song_count.deleted+=1});d.stats.total_duration=a.DateHelper.time_span_in_words(d.stats.total_duration_seconds);return d},render:function(){$(this.el).html(this.template(this.context()));this.syncSongList();this.sync();return this}}),i=b.View.extend({template:sz.tmpl.stationEditor.release,
css:"sz-station-release",events:{"click .szi-release-now":"onReleaseNow","click .szi-unrelease":"onUnrelease"},initialize:function(a){i.__super__.initialize.call(this,a);this.station=a.station;this.adding=!1;this.songQueue=[];this.lastSaved=null;this.saveStation=_.bind(_.debounce(this.saveStationNow,500),this);this.station.songs.bind("reset",this.render);this.station.songs.bind("add",this.render);this.station.songs.bind("remove",this.render);this.station.songs.bind("change",this.render);this.station.bind("change:name",
this.saveStation);this.station.bind("change:description",this.saveStation);this.station.bind("change:allow_song_adds",this.saveStation);this.bind("station-saved",this.render)},onReleaseNow:function(){var a=this;this.trigger("station-saving",{message:"Releasing Playlist"});this.station.release({success:function(){a.trigger("station-saved")},error:function(){a.trigger("station-save-failed",{message:"Error while releasing"})}})},onUnrelease:function(){var a=this;this.station.get("status")==="NORMAL"&&
confirm("Are you sure you want to make your playlist private?")&&(this.trigger("station-saving",{message:"Unreleasing Playlist"}),this.station.unrelease({success:function(){a.trigger("station-saved")},error:function(){a.trigger("station-save-failed",{message:"Error while unreleasing"})}}))},_flushQueue:function(){var a=this;this.station.addSongs(this.songQueue,{success:function(){a.songQueue=[];a.trigger("station-saved")},error:function(){a.trigger("station-save-failed")}})},saveStationNow:function(){var a=
this;this.trigger("station-saving");this.station.isNew()?(this.station.get("name")||this.station.set({name:"Playlist in Progress"},{silent:!0}),this.adding=!0,this.station.save({},{success:function(){a.lastSaved=new Date;a.adding=!1;a._flushQueue()},error:function(){a.adding=!1;a.trigger("station-save-failed")}})):this.station.save({},{success:function(){a.trigger("station-saved")},error:function(){a.trigger("station-save-failed")}})},addSong:function(a){this.station.isNew()?(this.songQueue.push(a),
this.adding||this.saveStationNow()):this.station.addSongs([a])},banSong:function(a,b){this.station.banSongs([a],b)},unBanSong:function(a,b){this.station.unBanSongs([a],b)},requirements:function(){var a={},b=0,d=this.station.songs.filter(function(a){return a.get("status")!=="BAN"}),c={satisfied:!1,artists:{total:6,left:6},songs:{total:10,left:10}};_.each(d,function(b){b=b.get("artist").get("name").replace(/[^\w\d]/,"").toLowerCase();a[b]=!0});b=_.keys(a).length;c.songs.left=d.length>10?0:10-d.length;
c.artists.left=b>6?0:6-b;c.satisfied=c.songs.left===0&&c.artists.left===0;return c},context:function(){return{requirements:this.requirements(),station:this.station.toJSON(),station_url:this.station.pageUrlPath(),last_saved:this.lastSaved}}}),k=f.StationEditorView=b.View.extend({template:sz.tmpl.stationEditor.editor,css:"sz-station-editor",elements:{".szi-song-search":"songSearch",".szi-song-list":"songList",".szi-release":"release",".szi-name input":"name",".szi-description textarea":"description",
".szi-allow_song_adds input":"allowSongAdds",".szi-save-details":"saveDetails"},events:{"keyup  .szi-details input":"updateMeta","change .szi-details input":"updateMeta","keyup  .szi-details textarea":"updateMeta","change .szi-details textarea":"updateMeta","change .szi-allow_song_adds input":"updateMeta","click  .szi-allow_song_adds input":"updateMeta","click  .szi-upload-image":"handleUpload","click  .szi-delete-image":"handleDelete"},states:{saving:{set:!0,onCss:"sz-station-editor-saving"},saved:{set:!0,
onCss:"sz-station-editor-saved"},save_failed:{set:!0,onCss:"sz-station-editor-save_failed"}},initialize:function(a){k.__super__.initialize.call(this,a);this.user=a.user;this.station=a.station||new c.Station({});this.isNew=this.station.isNew();this.editAllSongs=this.station.isNew()||a.editAllSongs?!0:!1;this.fetchState=0;this.props={};this.songSearchView=new g({station:this.station});this.songListView=new h({station:this.station,user:this.user,songs:this.station.songs});this.stationReleaseView=new i({station:this.station,
isNew:this.isNew,user:this.user});var b=this,d=this.stationReleaseView;this.songSearchView.bind("song-add",function(a){var e=b.station.songs.get(a.get("id")),f=new c.StationSong(a.attributes);f.set({added_by:b.user});a=function(){b.songListView.setType("all");b.songListView.highlightSong(f)};e?e.get("status")==="BAN"?d.unBanSong(e,{success:a}):a():d.addSong(f,{success:a})});this.songListView.bind("song-ban",function(a){d.banSong(a)});this.songListView.bind("song-unban",function(a){d.unBanSong(a)});
this.stationReleaseView.bind("station-saving",function(a){b.saveDetails().text(a&&a.message?a.message:"Saving");b.setState("saving",!0);b.setState("saved",!1);b.setState("save_failed",!1)});this.stationReleaseView.bind("station-save-failed",function(a){b.saveDetails().text(a&&a.message?a.message:"Unable to Save");b.setState("saving",!1);b.setState("saved",!1);b.setState("save_failed",!0)});this.stationReleaseView.bind("station-saved",function(){var a=new Date,d=a.getHours(),c=a.getMinutes(),a=d>12?
d-12:d,c=c<10?"0"+c:c,d=d<12&&d!=0?"am":"pm";b.saveDetails().text("Last Saved "+a+":"+c+d);b.setState("saving",!1);b.setState("saved",!0);b.setState("save_failed",!1)})},updateMeta:function(){this.station.set({name:$.trim(this.name().val()),description:$.trim(this.description().val()),allow_song_adds:this.allowSongAdds().is(":checked")})},stationProp:function(a){if(this.props.hasOwnProperty(a))return this.props[a];if(this.station)return this.station.get(a)},maybeFetchSongs:function(){var a=this;if(!this.isNew&&
this.fetchState===0)this.fetchState=1,this.station.songs.fetch({success:function(){a.fetchState=2},error:function(){a.fetchState=0}})},context:function(){var a={view_id:this.cid,static_url:e.static_url,is_admin:this.user.isAdmin("songza"),is_new:this.isNew,has_custom_image:this.hasCustomImage,station:this.station.toJSON(),station_url:this.station.pageUrlPath(),name:this.stationProp("name"),description:this.stationProp("description")};this.maybeFetchSongs();return a},uploadEl:function(){return this.$("#"+
this.cid+"-image-file")},handleUpload:function(){var a=this.uploadEl().get(0),b;a.files.length===1&&(a=a.files[0],b=new XMLHttpRequest,b.upload.addEventListener("load",this.render,!1),b.open("POST",this.station.uploadImageUrlPath(),!0),b.setRequestHeader("Content-Type","image/jpeg"),b.send(a))},handleDelete:function(){this.station.deleteImage({success:this.render})},render:function(){$(this.el).html(this.template(this.context()));this.station.get("type")!=="stream"&&(this.songSearch().html(this.songSearchView.render().el),
this.songList().html(this.songListView.render().el));this.release().html(this.stationReleaseView.render().el);this.sync();return this}}),j=f.StationAddSongsView=b.View.extend({template:sz.tmpl.stationEditor.addSongs,css:"sz-station-add-songs",elements:{".szi-song-search":"songSearch",".szi-song-list":"songList"},events:{"click .szi-save":"onSave"},initialize:function(a){var b=this;j.__super__.initialize.call(this,a);this.user=a.user;this.station=a.station;this.songSearchView=new g({station:this.station});
this.songListView=new h({station:this.station,user:this.user,hideContribute:!0});this.songSearchView.bind("song-add",function(a){a=new c.StationSong(a.attributes);a.set({added_by:b.user,status:"ADD"});b.songListView.setType("all");b.songListView.addSong(a);b.songListView.highlightSong(a)});this.songListView.bind("song-ban",function(a){a.set({status:"BAN"})})},onSave:function(){var a=this;this.station.addSongs(_.select(this.songListView.getSongs(),function(a){return a.get("status")==="ADD"}),{success:function(){var b=
a.station.pageUrlPath();Backbone.history.navigate(b.substring(1),!0)}});return!1},context:function(){return{view_id:this.cid,station:this.station.toJSON(),station_url:this.station.pageUrlPath()}},render:function(){$(this.el).html(this.template(this.context()));this.songSearch().html(this.songSearchView.render().el);this.songList().html(this.songListView.render().el);this.sync();return this}});return f});define("songza/dom-enhancements/feeds",["songza/feeds"],function(b){function c(a,b){var c={limit:20};a?(c.sort="time",c.since=parseInt(a.getTime()/1E3)):(c.sort="time",c.since=parseInt((new Date).getTime()/1E3-2*f));b=_.defaults(_.clone(b),c);return d.feed(b)}function a(a){return c(a,{global:0})}function e(a){return c(a,{global:1})}var d,f=86400,g={user:function(){return a},global:function(){return e},station:function(a){var b=parseInt(a.attr("data-sz-station-id"),10);return function(a){return c(a,
{global:1,station:b})}}},h=function(a){$(".sz-feed-placeholder",a).each(function(){var a=$(this),d=a.attr("data-sz-feed-type");if(d=g[d])d=new b.Viewer({itemFetcher:d(a)}),a.empty(),a.append(d.render().el)})};return{register:function(a){var b=a.getInstance();d=b.getVisitor();a.addDOMEnhancement(h);b.bind("visitor-change",function(){d=b.getVisitor();h(b.view.el)})}}});define("songza/dom-enhancements/fixed-header",function(){function b(){a=$(".sz-header-tags .szi-nav").offset().top;e=$("#main-div").offset().top+$("#main-div").innerHeight()-50;c()}function c(){var b=$(window).scrollTop(),c=$("body");b>a?c.addClass("sz-header-fixed"):c.removeClass("sz-header-fixed");var b=$(".sz-gallery-page h1"),c=$(".sz-gallery-page .szi-gallery-list"),g=$(window).scrollTop()+$(window).height();b.size()!=0&&(b.css("display","block"),c.css("display","block"),$("body").hasClass("sz-header-fixed")?
(c.css("top",b.position().top+b.outerHeight()-$(window).scrollTop()),c.css("height",_.min([e,g])-c.offset().top-100+"px"),e<$(window).scrollTop()+150&&(b.css("display","none"),c.css("display","none"))):c.css("height",_.min([e,g])-c.offset().top+"px"))}var a,e;return{register:function(a){!$("html").hasClass("ie6")&&!$("html").hasClass("ie7")&&!Modernizr.touch&&(a.getInstance().bind("page-navigate",b),b(),$(window).scroll(c),$(window).resize(c))}}});define("songza/dom-enhancements/navigator",["songza/navigator"],function(b){var c,a=function(a){$(".sz-navigator-placeholder",a).each(function(){var a=c.getInstance(),a=new b.UserView({user:a.getVisitor()}),e=new b.SearchView({}),g=new b.DiscoverView({}),a=new b.View({modules:[a,e,g]});$(this).append(a.render().el)})};return{register:function(b){c=b;b.addDOMEnhancement(a)}}});define("songza/dom-enhancements/following",["songza/models"],function(b){function c(a){d=a;f=h;d.get("following").bind("add",m);d.get("following").bind("remove",m);d.get("following").bind("fetch",m);d.get("following").bind("reset",m)}function a(){if(d.isAnonymous())f=k;else if(f!==i&&(f===h||g.getTime()+j<(new Date).getTime()))f=i,d.get("following").fetch({success:function(){g=new Date;f=k;d.get("following").trigger("fetch")},error:function(){f=h}})}var e,d,f,g,h=0,i=1,k=3,j=14400;f=h;var l=function(c){$(".sz-follow-placeholder",
c).each(function(){var c=$(this),g=parseInt(c.attr("data-sz-user-id"),10),h=c.attr("data-sz-user-display-name");if(g!==d.get("id")&&(c.empty(),a(),f===k)){var q=d.get("following").find(function(a){return a.get("id")===g}),h={anonymous:d.isAnonymous(),display_name:h,following:q,login_url:e.loginUrlPath(),signup_url:e.signupUrlPath()},j=$(sz.tmpl.follow.followButton(h)),i=function(){b.User.get(g,{success:function(a){e.getVisitor().follow(a)}})},l=function(){b.User.get(g,{success:function(a){e.getVisitor().unfollow(a)}})};
c.append(j);d.isAnonymous()?(j.delegate(".szi-follow","click",function(a){a.preventDefault();j.addClass("sz-follow-anonymous-intent")}),j.delegate("a","click",function(){e.addPostLoginAction(i)})):(j.delegate(".szi-follow","click",function(a){a.preventDefault();i()}),j.delegate(".szi-unfollow","click",function(a){a.preventDefault();l()}))}})},m=function(){l($(e.view.el))};return{register:function(a){e=a.getInstance();c(e.getVisitor());a.addDOMEnhancement(l);e.bind("visitor-change",function(){c(e.getVisitor());
m(e.view.el)})}}});define("songza/dom-enhancements/sharing",["songza/sharing"],function(b){var c,a=function(a){$(".sz-share-placeholder",a).each(function(){var a=b.SharePageItem.forCurrentPage(),e=c.getSharingSystems(),a=new b.Button({shareItem:a,shareSystems:e,app:c.getInstance()});$(this).empty().append(a.render().el)})};return{register:function(b){c=b;b.addDOMEnhancement(a)}}});define("songza/dom-enhancements/input-placeholder",function(){var b=function(b){$("input",b).each(function(){$(this).placeholder()})};return{register:function(c){c.addDOMEnhancement(b)}}});define("songza/dom-enhancements/visitor-button",["songza/base","songza/feeds","songza/utils"],function(b,c,a){var e,d,f,g,h=b.View.extend({template:sz.tmpl.visitorButton.button,menuTemplate:sz.tmpl.visitorButton.menu,elements:{".szi-unread-count":"unreadCountEl"},events:{"click a":"onButtonClick"},states:{menuShown:{set:!1,onCss:"sz-visitor-button-menu-shown"},unread:{set:!1,onCss:"sz-visitor-button-unread"}},css:"sz-visitor-button",initialize:function(a){var b=this;h.__super__.initialize.call(this,
a);_.bindAll(this,"getFeed","syncUnread","handleBodyClick");this.user=a.user;this.following=a.following;this.followers=a.followers;this.menu=void 0;this.feed=new c.Viewer({itemFetcher:this.getFeed});this.feed.maybeFetch();this.feed.items.bind("reset",this.syncUnread);this.feed.items.bind("add",this.syncUnread);this.feed.items.bind("remove",this.syncUnread);this.feed.bind("marked-all-read",this.syncUnread);this.user.bind("change",this.render);this.following.collection.bind("add",this.render);this.following.collection.bind("remove",
this.render);this.following.collection.bind("reset",this.render);this.following.collection.bind("fetch",this.render);this.followers.collection.bind("add",this.render);this.followers.collection.bind("remove",this.render);this.followers.collection.bind("reset",this.render);this.followers.collection.bind("fetch",this.render);$("body").bind("click",this.handleBodyClick);e.bind("page-navigate",function(){b.toggleMenu(!1)})},handleBodyClick:function(a){this.menu&&this.getState("menuShown")&&!$.contains(this.menu.get(0),
a.target)&&(this.feed.markAllRead(),this.toggleMenu(!1))},getFeed:function(a){var b={global:0,limit:20,sort:"time"};b.since=a?parseInt(a.getTime()/1E3):parseInt((new Date).getTime()/1E3-172800);return this.user.feed(b)},syncUnread:function(){var a=this.feed.unreadCount();this.setState("unread",a>0);this.unreadCountEl().text(a>50?"50+":a)},onButtonClick:function(a){a.preventDefault();a.stopPropagation();this.toggleMenu()},toggleMenu:function(a){var b;if(!this.menu)this.menu=b=$(this.menuTemplate(this.context())),
b.find(".szi-feed").append(this.feed.el),$(e.view.el).append(b);a===void 0&&(a=!this.getState("menuShown"));a?this.menu.show().position({my:"right top",at:"right bottom",of:this.el,collision:"none",offset:"0 -2px"}):this.menu.hide();this.setState("menuShown",a)},context:function(){var a={user:this.user.toJSON(),following_count:this.following.collection.length,follower_count:this.followers.collection.length};this.following.ensureFreshness();this.followers.ensureFreshness();return a}}),i=function(a){$(".sz-visitor-button-placeholder",
a).each(function(){var a=$(this);$("<span>").addClass("szi-unread").text("0");a.empty();if(!d.isAnonymous()){var b=new h({user:d,following:f,followers:g});a.append(b.render().el)}})},k=function(b,c){d=b;f=new a.FreshnessGuarantee({collection:b.get("following"),fetchInterval:c.dataFreshness.following});g=new a.FreshnessGuarantee({collection:b.get("followers"),fetchInterval:c.dataFreshness.followers})};return{register:function(a){e=a.getInstance();k(e.getVisitor(),e.getConfig());a.addDOMEnhancement(i);
e.bind("visitor-change",function(){k(e.getVisitor(),e.getConfig());i(e.view.el)})}}});define("songza/dom-enhancements/station-save",["songza/station-save"],function(b){var c,a=function(a){var d=c.getInstance().getVisitor();$(".sz-station-save-button-placeholder",a).each(function(){var a=$(this),c=a.parents(),e=a.attr("data-sz-station-type"),i=parseInt(a.attr("data-sz-station-id"),10),c=$(a.attr("data-sz-station-save-menu-container"),c[c.length-1]),e=new b.StationSaveButton({user:d,stationId:i,stationType:e,menuContainer:c.get(0)});a.empty().append(e.render().el)})};return{register:function(b){c=
b;b.addDOMEnhancement(a)}}});define("songza/dom-enhancements/concierge",function(){var b=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],c=function(a){$(".sz-concierge",a).each(function(){var a=new Date,d=b[a.getDay()],c=a.getHours(),g=null,h=[];c<5?(g="night",d=a.getDay()==0?b[6]:b[a.getDay()-1]):g=c>=5&&c<11?"morning":c>=11&&c<17?"afternoon":c>=17&&c<=19?"evening":"night";$(".sz-concierge-item",this).each(function(){var a=$(this).attr("data-sz-time"),b=$(this).attr("data-sz-day");a===g&&b===d?h.push(this):
$(this).removeClass("sz-concierge-item-chosen")});if(h.length>0){$(".sz-concierge-default",this).addClass("sz-concierge-default-hidden");a=Math.floor(Math.random()*h.length);for(c=0;c<h.length;c++)c===a?$(h[c]).addClass("sz-concierge-item-chosen"):$(h[c]).removeClass("sz-concierge-item-chosen")}else $(".sz-concierge-default",this).removeClass("sz-concierge-default-hidden")})};return{register:function(a){a.addDOMEnhancement(c)}}});define("songza/dom-enhancements/station-playing-state",function(){var b,c=function(a){var d=b.getPlayer(),c,g,h;d&&(c=d.model.get("station"),g=d.model.get("current"),h=d.model.get("station").get("id"));$(".sz-station-page",a).each(function(){var a=$(this),b=parseInt(a.attr("data-sz-station-id"),10);a.removeClass("szi-player-state-play");a.removeClass("szi-player-state-pause");a.removeClass("szi-player-state-starting");b===h&&(a.addClass("szi-player-state-"+d.model.get("state")),a.hasClass("sz-station-page")&&
(b=g&&g.get("image_url")?g.get("image_url"):c.get("cover_url"),a.find(".szi-station-quilt-image img").attr("src",b),g?(b=$("<span>"),b.append($("<span>").addClass("szi-song").text(g.get("title"))),g.get("artist")&&(b.append($("<span>").addClass("szi-artist").text(" by ")),b.append($("<span>").addClass("szi-artist").text(g.get("artist")))),a.addClass("sz-station-song-displayed"),a.find(".szi-current-song").html(b)):a.removeClass("sz-station-song-displayed")))})},a=function(){c(b.view.el)};return{register:function(e){b=
e.getInstance();e.addDOMEnhancement(c);b.bind("player-station-started",a);b.bind("player-song-started",a);b.bind("player-song-completed",a);b.bind("player-song-play",a);b.bind("player-song-pause",a);a()}}});define("songza/dom-enhancements/station-details-on-hover",["songza/models","songza/utils"],function(){function b(){i&&(i.detach(),g=i=null)}function c(){l=setTimeout(function(){b();l=null},k)}function a(){l&&(clearTimeout(l),l=null)}function e(){j&&(clearTimeout(j),j=null);h=null}function d(d,e,n){g===d?a():h!==d&&(h=d,j=setTimeout(function(){var t="/station/"+d+"/details/";n&&(t+="?reason="+encodeURIComponent(n));$.get(t,function(n){d===h&&(h=null,g=d,i&&b(),i=$("<div>").addClass("sz-station-detail-overlay").append(n),
f.enhanceDOM(i),i.css("visibility","hidden"),$(f.getInstance().view.el).append(i),n=i,$("body").scrollTop()>e.offset().top-n.height()?n.position({my:"center top",at:"center bottom",of:e,collision:"none"}).addClass("sz-station-details-overlay-bottom"):n.position({my:"center bottom",at:"center top",of:e,collision:"fit"}).addClass("sz-station-details-overlay-top"),i.css("visibility","visible"),i.mouseenter(a),i.mouseleave(c))})},k))}var f,g,h,i,k=200,j,l;return{register:function(a){var g=a.getInstance();
f=a;_.each([".sz-station-quilt",".sz-grid-item"],function(a){$(g.view.el).delegate(a,"mouseenter",function(){var a=$(this),b=parseInt(a.attr("data-sz-station-id"),10),c=a.attr("data-sz-station-reason");d(b,a,c)});$(g.view.el).delegate(a,"mouseleave",e);$(g.view.el).delegate(a,"mouseleave",c)});g.bind("page-navigate-start",e);g.bind("page-navigate-start",b)}}});define("songza/dom-enhancements/delete-shelves",["songza/models"],function(b){var c,a=function(a){var d=c.getVisitor().get("id");$(".sz-shelf",a).each(function(){var a=$(this),c=a.attr("data-sz-shelf-type"),e=a.parents(".sz-user-page"),e=parseInt(e.attr("data-sz-user-id"),10);a.find(".szi-delete-shelf").detach();if(c==="user-collection"&&e===d){var i=parseInt(a.attr("data-sz-user-collection-id"),10),c=$(this).find(".szi-title"),k;c.append(sz.tmpl.shelf.deleteShelf());k=c.find(".sz-shelf-delete");
k.delegate(".szi-delete","click",function(){k.addClass("sz-shelf-delete-confirm")});k.delegate(".szi-no","click",function(){k.removeClass("sz-shelf-delete-confirm")});k.delegate(".szi-yes","click",function(){b.UserCollection.remove(i,{success:function(){a.animate({height:0},"fast",function(){a.detach()})}})})}})};return{register:function(b){c=b.getInstance();b.addDOMEnhancement(a);c.bind("visitor-change",function(){a(c.view.el)})}}});define("songza/dom-enhancements/comments",function(){var b,c=function(a){var c=b.getInstance().getConfig(),d=b.getCommentProvider(c.comment_provider);$(".sz-comments-placeholder",a).each(function(){var a=$(this);a.empty();d&&d(a)})};return{register:function(a){b=a;a.addDOMEnhancement(c)}}});define("songza/dom-enhancements/station-pile",function(){function b(a,b){var c,d,e=[],b=b===void 0?5:b;if(!k.hasOwnProperty(a))return[];d=k[a].actors;for(c=0;c<b&&c<d.length;c++)e.push(d[c]);return e}function c(){var b=parseInt((new Date).getTime()/1E3-4*i);e.isAnonymous()?d=h:d!==g&&d===f&&(d=g,b=e.feed({global:0,since:b,limit:100,sort:"time"}),$.when(b).then(function(b){b.items.each(function(a){_.each(a.get("actors"),function(b){var c=a.get("station");k.hasOwnProperty(c.get("id"))||(k[c.get("id")]=
{station:c,actors:[],actor_map:{}});c=k[c.get("id")];c.actor_map.hasOwnProperty(b.get("id"))||(c.actor_map[b.get("id")]=!0,c.actors.push(b))})});j(a.getInstance().view.el)}))}var a,e,d,f=0,g=1,h=2,i=86400,k={},j=function(a){$(".sz-station-pile-placeholder",a).each(function(){var a=$(this),d=parseInt(a.attr("data-sz-station-id"),10),d=b(d);a.empty();c();_.each(d,function(b){var c=$("<img>").attr("src",b.get("images").square),b=$("<a>").attr("title",b.get("display_name")).attr("href","/user/id/"+b.get("id"));
a.append(b.append(c))})})};return{register:function(b){a=b;e=b.getInstance().getVisitor();d=f;b.getInstance().bind("visitor-change",function(a){e=a.newVisitor;d=f;k={};j(b.getInstance().view.el)});b.addDOMEnhancement(j)}}});define("songza/dom-enhancements/station-scroll",["songza/app","songza/models","songza/work","songza/scrollable-view"],function(b,c,a,e){var d,f=function(a){a=$(sz.tmpl.station.quilt(a));b.enhanceDOM(a);return a},g=function(a,b,c){var d=$.Deferred();$.when(a).done(function(a){var e={},f=[];b.find(".sz-station-quilt").each(function(){e[parseInt($(this).attr("data-sz-station-id"),10)]=!0});a[c].each(function(a){e.hasOwnProperty(a.get("id"))||f.push({station:a.toJSON(),station_url:a.pageUrlPath()})});
d.resolve(f)}).fail(function(){d.reject()});return d.promise()},h={"user-collection":function(b){var d=b.attr("data-sz-user-collection-id");return function(){var e=new a.Set({});c.UserCollection.get(d,e.backbone.proxy("collection"));e.after("collection",function(a,b){c.Station.getBatch(a.get("station_ids"),b)},e.backbone.proxy("stations"));return g(e,b,"stations")}},gallery:function(b){var d=b.attr("data-sz-gallery-id");return function(){var e=new a.Set({});c.Galley.get(d,e.backbone.proxy("gallery"));
e.after("gallery",function(a,b){c.Station.getBatch(a.get("station_ids"),b)},e.backbone.proxy("stations"));return g(e,b,"stations")}},"just-for-you":function(b){var d=b.attr("data-sz-user-id");return function(){var e=new a.Set({});c.User.get(d,e.backbone.proxy("user"));e.after("user",function(a,b){a.get("recommendations").fetch(b)},e.backbone.proxy("stations"));return g(e,b,"stations")}},"user-recent":function(b){var d=b.attr("data-sz-user-id");return function(){var e=new a.Set({});c.User.get(d,e.backbone.proxy("user"));
e.after("user",function(a,b){a.get("recent").fetch(b)},e.backbone.proxy("stations"));return g(e,b,"stations")}},"user-created":function(b){var e=b.attr("data-sz-user-id");return function(){var f=new a.Set({});c.User.get(e,f.backbone.proxy("user"));f.after("user",function(a,b){d.getVisitor().get("id")===a.get("id")?a.get("allCreated").fetch(b):a.get("created").fetch(b)},f.backbone.proxy("stations"));return g(f,b,"stations")}}},i=function(a){$(".sz-station-scroll",a).each(function(){var a=$(this),b=
a.attr("data-sz-station-scroll-type"),c=a.attr("data-sz-station-scroll-load-more");a.attr("data-sz-station-scroll-template");var d=h[b],b=$("<div>").addClass("sz-station-scroll-prev"),g=$("<div>").addClass("sz-station-scroll-next"),c={el:this,itemFetcher:c&&d?d(a):null,itemTemplate:f,listSelector:"ol",prevSelector:b,nextSelector:g,autoScroll:!1};a.append(b).append(g);new e.ScrollableView(c)})};return{register:function(a){d=a.getInstance();a.addDOMEnhancement(i)}}});define("songza/station-save",["songza/base","songza/models","songza/work","songza/app"],function(b,c,a,e){function d(a){var b=g[a.get("id")];b||(b={fetch_state:h,last_fetched:null},g[a.get("id")]=b);if(a.isAnonymous())b.fetch_state=k;else if(b.fetch_state!==i&&(b.fetch_state===h||b.last_fetched.getTime()+j<(new Date).getTime()))b.fetch_state=i,a.get("collections").fetch({success:function(){b.last_fetched=new Date;b.fetch_state=k;a.get("collections").trigger("fetch")},error:function(){b.fetch_state=
h}})}var f={},g={},h=0,i=1,k=3,j=14400,l=f.StationSaveButton=b.View.extend({template:sz.tmpl.stationSave.button,css:"sz-station-save-button",states:{saved:{set:!1,onCss:"sz-station-save-button-saved"}},initialize:function(a){l.__super__.initialize.call(this,a);_.bindAll(this,"removeMenu","showMenu","onBodyClick","render");this.user=a.user;this.stationId=a.stationId;this.stationType=a.stationType||"basic";this.menuContainer=a.menuContainer;this.overlay=this.menu=null;this.user.get("collections").bind("fetch",
this.render);this.user.get("collections").bind("add",this.render);this.user.get("collections").bind("remove",this.render);this.user.get("collections").bind("change",this.render);$(this.el).bind("click",this.showMenu);$("body").bind("click",this.onBodyClick)},onBodyClick:function(a){this.overlay&&this.menu&&!$.contains(this.menu.el,a.target)&&this.removeMenu()},removeMenu:function(){if(this.overlay)this.overlay.detach(),this.overlay=null;this.menu.destroy();this.menu=null},showMenu:function(a){a.stopPropagation();
if(!this.menu){a=(new (this.user.isAnonymous()?f.StationSaveAnonymousMenu:f.StationSaveMenu)({user:this.user,stationId:this.stationId,stationType:this.stationType})).render();if(this.menuContainer)$(this.menuContainer).append(a.el);else{var b=$("<div>").addClass("sz-station-save-menu-overlay").append(a.el);this.overlay=b;$(e.getInstance().view.el).append(b);b.position({my:"left top",at:"left bottom",of:this.el,collision:"fit"})}this.menu=a}},context:function(){var a=[],b=this.stationId;d(this.user);
this.user.get("collections").each(function(c){c.containsStation(b)&&a.push(c.toJSON())});return{collections:a,station_type:this.stationType}}});f.StationSaveAnonymousMenu=b.View.extend({template:sz.tmpl.stationSave.anonymousMenu,initialize:function(a){this.stationType=a.stationType},context:function(){var a=e.getInstance();return{view_id:this.cid,station_type:this.stationType,login_url:a.loginUrlPath(),signup_url:a.signupUrlPath()}}});var m=f.StationSaveMenu=b.View.extend({template:sz.tmpl.stationSave.menu,
events:{"click  .szi-done":"onDone","click  .szi-cancel":"onCancel","click  .szi-new-collection":"onNewCollection","click  .szi-make-collection":"onMakeCollection",'change .szi-bd input[type="checkbox"]':"onChange",'click  .szi-bd input[type="checkbox"]':"onChange"},elements:{'.szi-new-collection-form input[type="text"]':"collectionNameInput"},css:"sz-station-save-menu",states:{changed:{set:!1,onCss:"sz-station-save-menu-changed"},creating:{set:!1,onCss:"sz-station-save-menu-creating"}},initialize:function(a){m.__super__.initialize.call(this,
a);this.user=a.user;this.stationId=a.stationId;this.stationType=a.stationType;this.title=a.title;this.autoSave=a.hasOwnProperty("autoSave")?a.autoSave:!0;this._checked={};this.user.get("collections").length===0&&this.setState("creating",!0);this.user.get("collections").bind("add",this.render);this.user.get("collections").bind("remove",this.render)},onDone:function(a){a.preventDefault();this.save()},_clearChecked:function(){this._checked={}},onCancel:function(a){a.preventDefault();a.stopPropagation();
this.cancel()},cancel:function(){this._clearChecked();this.setState("changed",!1);this.render()},onNewCollection:function(a){a.preventDefault();a.stopPropagation();this.setState("creating",!0)},onMakeCollection:function(b){b.preventDefault();b.stopPropagation();var d=this,b=new a.Set({}),e=this.collectionNameInput().val(),f=new c.UserCollection({title:e,user_id:this.user.get("id")});if(e=(e||"").replace(/^\s*([\S]*)\s*$/,"$1"))this.setState("creating",!1),f.save({},b.backbone.proxy("collection")),
b.after("collection",function(a,b){f.addStation(d.stationId,b)},b.backbone.proxy("station")),$.when(b).then(function(a){d.user.get("collections").add(a.collection)}).fail(function(){d.trigger("error",d,"Sorry, but we weren't able to create your shelf.")})},onChange:function(a){var a=$(a.target),b=a.closest("li");this._checked[a.val()]=a.is(":checked");a.is(":checked")?b.addClass("szi-checked"):b.removeClass("szi-checked");this.autoSave?this.save():this.setState("changed",!0)},save:function(){var b=
this,c,d,e,f=new a.Set({}),g=this.user.get("collections");d=$.Deferred().resolve();f.add("finalize",d.promise());for(c in this._checked){d=g.get(c);e=this._checked[c];var h=function(a,b){return function(){delete a[b]}}(e,d);e!==d.containsStation(this.stationId)&&(h=f.backbone.proxy("collection-"+d.get("id"),h),e?d.addStation(this.stationId,h):d.removeStation(this.stationId,h))}$.when(f).done(function(){b._clearChecked();b.setState("changed",!1);b.trigger("saved")}).fail(function(){b.trigger("error",
"Sorry, but we weren't able to save some of your changes.")});return f},context:function(){var a=this._checked,b=this.stationId,c={title:this.title,view_id:this.cid,station_type:this.stationType,collection_list:this.user.get("collections").map(function(d){var c=d.toJSON();c.checked=a.hasOwnProperty(d.get("id"))?a[d.get("id")]:d.containsStation(b);return c})};d(this.user);return c}});return f});define("songza/routers",["songza/config"],function(b){var c={};c.Default=Backbone.Router.extend({loadingPath:null,lastRequest:null,routes:{"*path":"loadContent"},initialize:function(a){this.app=a.app},requestContent:function(a,b,d,c){this.lastRequest=$.ajax({type:a,data:d,url:"/"+b,headers:{"X-HASHSIGNAL":1}});$.when(this.lastRequest).then(c.success,c.error)},getContent:function(a,b){this.requestContent("GET",a,"",b)},postContent:function(a,b,d){this.requestContent("POST",a,b,d)},requestAndInjectContent:function(a,
c,d){var f=this;f.app.trigger("page-navigate-start",{path:c});this.requestContent(a,c,d,{success:function(a,b,d){var b=!1,k;d.getResponseHeader("Content-Type")==="application/vnd.songza.hashsignal-route+json"?(a.redirectLocation.match(/^\s*http[s]?/i)?(d=parseUri(a.redirectLocation),k=d.path,d.protocol!=window.location.protocal&&d.host!=window.location.host&&(b=!0)):(b=!1,k=a.redirectLocation),b?window.location=a.redirectLocation:f.navigate(k.substr(1),!0)):c===f.loadingPath&&(f.app.view.updateContent(a),
f.app.trigger("page-navigate",{path:c}))},error:function(a){c===f.loadingPath&&(b.debug?f.app.view.showErrorDocument(a.responseText):a.status==404&&f.app.view.updateContent(a.responseText),f.app.trigger("page-navigate-failure",{path:c}))}});this.loadingPath=c},getAndInjectContent:function(a){this.requestAndInjectContent("GET",a)},postAndInjectContent:function(a,b){this.requestAndInjectContent("POST",a,b)},loadContent:function(a){a!=="_=_"&&(a.match(/^base_domain=/)||this.getAndInjectContent(a))},
loadSearchContent:function(a){this.getAndInjectContent("search/"+a+"/")},search:function(a){this.navigate("search/"+a,!0)}});return c});define("songza/app",["songza/base","songza/config","songza/site-views","songza/player/view","songza/routers","songza/models","songza/utils"],function(b,c,a,e,d,f,g){var h,i=["songza/systems/facebook","songza/systems/twitter","songza/systems/google-analytics","songza/systems/chartbeat","songza/systems/disqus","songza/systems/comscore","songza/systems/quantcast","songza/dom-enhancements/fixed-header","songza/dom-enhancements/input-placeholder","songza/dom-enhancements/station-scroll","songza/dom-enhancements/comments",
"songza/dom-enhancements/station-save","songza/dom-enhancements/station-details-on-hover","songza/dom-enhancements/sharing","songza/dom-enhancements/following","songza/dom-enhancements/feeds","songza/dom-enhancements/station-pile","songza/dom-enhancements/station-playing-state","songza/dom-enhancements/visitor-button","songza/dom-enhancements/concierge"],k=[],j=[],l={},m=[],q=!1;if(!window.console)window.console={};if(!window.console.log)window.console.log=function(){};var n=b.Class.extend({initialize:function(b){var e=
this;this.router=new d.Default({app:this});this.view=new a.Default({app:this});this.visitor=b.visitor;this.postLoginQueue=[];this.player=null;this.configHistory();c.debug&&console&&console.log&&this.bind("all",function(a,b){a!="player-song-play-state"&&console.log("songza-app: ["+a+"]",b)});this.bind("dom-node-inserted",function(a){n.enhanceDOM(a.node)});$(window).bind("beforeunload",function(){var a=e.getPlayer();a&&e.trigger("player-station-stopped",{station:a.model.get("station")});e.trigger("app-unload")})},
getConfig:function(){return c},getVisitor:function(){return this.visitor},setVisitor:function(a){var b=this.visitor,a=new f.User(a);if(a.get("id")!==b.get("id"))this.visitor=a,this.trigger("visitor-change",{oldVisitor:b,newVisitor:a}),b.get("id")===0&&a.get("id")&&_.each(this.postLoginQueue,function(a){a()}),this.postLoginQueue=[];$("html").removeClass("sz-user-anonymous");$("html").removeClass("sz-user-authenticated");a.isAnonymous()?$("html").addClass("sz-user-anonymous"):$("html").addClass("sz-user-authenticated")},
refresh:function(){Backbone.history.loadUrl(Backbone.history.getFragment())},configHistory:function(){Backbone.history.start({pushState:this.supportsHistory(),silent:!this.mustFetchInitialPage()})},supportsHistory:function(){return Modernizr.history},mustFetchInitialPage:function(){return window.location.hash},bind:Backbone.Events.bind,unbind:Backbone.Events.unbind,startStation:function(a,b){var c=this,d=new e.PlayerState({station:a});if(this.player){if(this.player.model.get("station").get("id")===
a.get("id")){b&&this.player.play();return}this.trigger("player-station-stopped",{station:a});this.player.destroy()}this.player=new e.PlayerView({model:d,app:this});this.player.bind("all",function(a,b){a.indexOf("song-")===0&&c.trigger("player-"+a,b)});$(this.view.el).append(this.player.render().el);this.player.start();this.trigger("player-station-started",{station:a})},getPlayer:function(){return this.player},addPostLoginAction:function(a){this.postLoginQueue.push(a)},authenticatedAction:function(a){if(this.getVisitor().isAnonymous()){a=
_.clone(a);if(!a.next)a.next="/"+Backbone.history.getFragment();a.action&&this.addPostLoginAction(a.action);g.formQuery({next:a.next});Backbone.history.navigate("login/?next="+encodeURIComponent(a.next),!0)}else a.action&&a.action()},loginUrlPath:function(){return"/login/?"+g.formQuery({next:"/"+Backbone.history.getFragment()})},signupUrlPath:function(){return"/signup/?"+g.formQuery({next:"/"+Backbone.history.getFragment()})},trigger:function(a,b){b=b||{};b.eventTime=new Date;b.eventName=a;Backbone.Events.trigger.call(this,
a,b)},enhanceDOM:function(a){n.enhanceDOM(a)},getSharingSystems:function(){return n.getSharingSystems()}},{loadPlugins:function(){function a(){(q=_.reduce(_.values(b),function(a,b){return a&&b}))&&_.each(m,function(a){a()})}var b={},d=_.union(i,c.custom_plugins);_.each(d,function(a){b[a]=!1});_.each(d,function(d){require([d],function(c){b[d]=!0;try{c.register(n)}catch(e){console.log("Failed to load plugin: "+d,c,e)}a()})})},addDOMEnhancement:function(a){k.push(a);a($(h.view.el))},enhanceDOM:function(a){_.each(k,
function(b){try{b(a)}catch(d){console.log("Failed to apply enhancement",d)}})},addCommentProvider:function(a,b){l[a]=b},getCommentProvider:function(a){return l[a]},addSharingSystem:function(a){j.push(a)},getSharingSystems:function(){return j},init:function(a){n.initInstance(new f.User(a));n.loadPlugins()},initInstance:function(a){h=new n({visitor:a})},getInstance:function(){if(!h)throw Error("Application instance has not been created. Perhaps you forgot to call App.init first?");return h},postInit:function(a){q?
a():m.push(a)}});$(n.loadDOMEnhancements);return n});define("songza/models",["songza/config","songza/base","songza/utils"],function(b,c,a){var e={},d=b.api.root,f=b.site,g=/^[a-zA-Z0-9][\w-]*[a-zA-Z0-9]$/;e.Utils={Promise:function(){return $.Deferred().promise()},parseIntoModels:function(a,b,d){var c,e=[],p=_.isArray(b)?b:[b];for(c=0;c<p.length;c++){var f=new a({});f.set(d).set(f.parse(p[c]));e.push(f)}return _.isArray(b)?new (Backbone.Collection.extend({model:a}))(e):e[0]}};var h=e.User=c.Model.extend({defaults:{id:null,username:null,display_name:null,
email:null,facebook_id:null,collections:null,recommendations:null,recent:null,created:null,followers:null,following:null,image_url:null,images:null,image_default:null,admin:null,admin_sites:[]},initialize:function(){_.bindAll(this,"_initDependents");this._initDependents();this.bind("change:id",this._initDependents)},_initDependents:function(){var a=new z,b=new A,d=new y,c=new x,e=new w,p=new B,f=new C;a.addFilter("user_id",this.get("id"));b.addFilter("user_id",this.get("id"));d.addFilter("user_id",
this.get("id"));c.addFilter("user_id",this.get("id"));e.addFilter("user_id",this.get("id"));p.addFilter("user_id",this.get("id"));f.addFilter("user_id",this.get("id"));this.set({collections:a,recommendations:b,recent:d,created:c,allCreated:e,followers:f,following:p})},isAnonymous:function(){return this.get("id")===0},isAdmin:function(a){return _.indexOf(this.get("admin_sites"),a)!=-1},follow:function(b,c){var e=this,p=a.postJSON(d+"/follow",{user_id:b.get("id")});p.done(function(){e.get("following").add(b)});
return a.bindPromise(p,c)},unfollow:function(b,c){var e=this,p=a.postJSON(d+"/unfollow",{user_id:b.get("id")});p.done(function(){e.get("following").remove(b.get("id"))});return a.bindPromise(p,c)},profilePath:function(){return"/user/"+this.get("username")},feed:function(b){var c=d+"/feed/user/"+this.get("id");return a.getJSON(c,b).pipe(function(b){b.items=e.Utils.parseIntoModels(v,b.items);b.server_time=a.DateHelper.epoch_seconds_to_date(b.server_time);return b})},urlRoot:d+"/user"},{getCurrent:function(a){var a=
_.clone(a),b=new h({});a.url=d+"/get-user";return b.fetch(a)},get:function(a,b){var c=_.clone(b);return(new h({id:a})).fetch(c)},logout:function(){return a.getJSON(d+"/logout")},loginWithFacebook:function(b,c){var p;p=a.postJSON(d+"/login/fb",{fb_token:b,site:f});return a.bindPromise(p.pipe(function(a){var b=p.getResponseHeader("X-SZ-New")==="Y";return{user:e.Utils.parseIntoModels(h,a),isNew:b}}),c)}}),i=e.Tag=c.Model.extend({defaults:{id:null,name:null,slug:null,site:null,featured:null},schema:{name:{},
slug:{},featured:{type:"Checkbox"}},initialize:function(){_.bindAll(this,"_initDependents");this._initDependents();this.bind("change:id",this._initDependents)},_initDependents:function(){this.galleries=new (Backbone.Collection.extend({model:o,parse:function(a){return e.Utils.parseIntoModels(o,a).models},url:d+"/gallery/tag/"+this.get("id")}))},url:function(){return this.isNew()?d+"/tags/create":d+"/tags/id/"+this.get("id")},validate:function(a){if(a.hasOwnProperty("name")&&a.name.match(/^\s*$/))return"Name must not be empty";
if(a.hasOwnProperty("slug")&&!a.slug.match(g))return"Slug must not be empty and must only consist of letters, numbers, dashes and underscores"},setGalleriesById:function(b,c){var e={tag_id:this.get("id"),gallery_id:b},e=a.postJSON(d+"/tags/set-galleries",e);return a.bindPromise(e,c)}},{getAll:function(b){var c=a.getJSON(d+"/tags").pipe(function(a){return e.Utils.parseIntoModels(i,a)});return a.bindPromise(c,b)}});e.TagList=Backbone.Collection.extend(_.extend(a.FilteredCollectionMixin,{filters:{site:"site",
featured:"featured"}},{model:i,parse:function(a){return e.Utils.parseIntoModels(i,a).models},urlBase:d+"/tags",url:function(){return this.urlBase+"?"+a.formQuery({site:this.getFilter("site"),featured:this.getFilter("featured")})}}));var k=e.TimePeriod=c.Model.extend({defaults:{day:0,period:0},schema:{day:{title:"Day",type:"Select",options:_.map(b.situations.dow,function(a){return{val:a.value,label:a.label}})},period:{title:"Time",type:"Select",options:_.map(b.situations.time_periods,function(a){return{val:a.value,
label:a.label}})}},toString:function(){var a=this,c=_.find(b.situations.dow,function(b){return b.value==a.get("day")}),d=_.find(b.situations.time_periods,function(b){return b.value==a.get("period")});return c.label+" / "+d.label}}),j=e.Situation=c.Model.extend({defaults:{id:null,title:null,selected_message:null,site:null,active:!0,order:1,start_date:null,end_date:null,devices:null,time_periods:null,situations:null,station_ids:null},schema:{title:{},selected_message:{title:"Selected Message"},active:{type:"Checkbox"},
start_date:{type:"Date",title:"Start Date",datepicker:{dateFormat:"yy-mm-dd"}},end_date:{type:"Date",title:"End Date"},devices:{type:"Checkboxes",options:_.map(b.situations.devices,function(a){return{val:a.value,label:a.label}})},time_periods:{title:"Day/Time",type:"List",listType:"NestedModel",model:k}},initialize:function(){this.get("devices")||this.set({devices:[]});this.get("time_periods")||this.set({time_periods:[]});this.get("situations")||this.set({situations:new Backbone.Collection});this.get("station_ids")||
this.set({station_ids:[]})},parse:function(a){if(a.start_date)a.start_date=new Date(a.start_date*1E3);if(a.end_date)a.end_date=new Date(a.end_date*1E3);a.situations=e.Utils.parseIntoModels(j,a.situations||[]);return a},toJSON:function(){var a=j.__super__.toJSON.apply(this,arguments);a.start_date=a.start_date?a.start_date.getTime()/1E3:null;a.end_date=a.end_date?a.end_date.getTime()/1E3:null;a.situations=a.situations.map(function(a){return a.toJSON()});return a},validate:function(a){if(a.hasOwnProperty("title")&&
a.title.match(/^\s*$/))return"Title must not be empty"},toString:function(){return this.get("title")},url:function(){return this.isNew()?d+"/situation/create":d+"/situation/id/"+this.get("id")},sync:Backbone.sync},{getTargeted:function(b,c){var p={current_date:(b.current_date?b.current_date:new Date).getTime()/1E3,req_day:b.req_day,req_period:b.req_period,device:b.device||"web",site:b.site||f},p=a.getJSON(d+"/situation/targeted/",p).pipe(function(a){return e.Utils.parseIntoModels(j,a)});return a.bindPromise(p,
c)}});e.SituationList=Backbone.Collection.extend(_.extend(a.FilteredCollectionMixin,{filters:{site:"site"}},{model:j,parse:function(a){return e.Utils.parseIntoModels(j,a).models},urlBase:d+"/situation",url:function(){return this.urlBase+"?"+a.formQuery({site:this.getFilter("site")})}}));var l=e.UserCollection=c.Model.extend({defaults:{id:null,title:null,user_id:null,station_ids:[]},initialize:function(a){a.station_ids||this.set({station_ids:[]})},urlRoot:d+"/collection",url:function(){return this.isNew()?
d+"/collection/user/"+this.get("user_id")+"/create":this.urlRoot+"/"+this.get("id")},containsStation:function(a){return _.detect(this.get("station_ids"),function(b){return b===a})?!0:!1},addStation:function(b,c){var d=this,e=a.postJSON(this.url()+"/add-station",{station:b});e.done(function(){var a=d.get("station_ids").splice();a.push(b);d.set({station_ids:a})});return a.bindPromise(e,c)},removeStation:function(b,c){var d=this,e=a.postJSON(this.url()+"/remove-station",{station:b});e.done(function(){var a=
_.without(d.get("station_ids"),b);d.set({station_ids:a})});return a.bindPromise(e,c)}},{get:function(a,b){var c=_.clone(b);return(new l({id:a})).fetch(c)},remove:function(b,c){var e=a.postJSON(d+"/collection/delete",{collection_id:b});return a.bindPromise(e,c)}}),m=e.Station=c.Model.extend({defaults:{id:null,name:null,global_station:null,dasherized_name:null,description:null,url:null,cover_url:null,fan_count:null,song_count:null,fan:null,creator_id:null,creator_name:null,xid:null,allow_song_adds:!1,
status:"UNRELEASED",stream:null},initialize:function(){var a=this;this.songs=new (Backbone.Collection.extend({model:t,parse:function(a){return e.Utils.parseIntoModels(t,a).models},url:function(){return a.url()+"/songs"}}))([])},urlRoot:d+"/station",url:function(){return this.isNew()?this.urlRoot+"/create":this.urlRoot+"/"+this.get("id")},nextSong:function(b){var c=this,d=_.clone(b.params);d.skip=d.skip?"1":"0";d.buffer=d.buffer?"1":"0";d=a.getJSON(this.url()+"/next",d).pipe(function(a){a=e.Utils.parseIntoModels(u,
a);a.station=c;return a});return a.bindPromise(d,b)},listen:function(b){var c=a.getJSON(this.url()+"/listen");return a.bindPromise(c,b)},pageUrlPath:function(){return"/listen/"+encodeURIComponent(this.get("dasherized_name"))+"/"},editUrlPath:function(){return"/station/"+this.get("id")+"/edit/"},canonicalUrlPath:function(){return"/station/"+this.get("id")},uploadImageUrlPath:function(){return d+"/station/"+this.get("id")+"/upload-image"},deleteImageUrlPath:function(){return d+"/station/"+this.get("id")+
"/delete-image"},deleteImage:function(b){var c=a.postJSON(this.deleteImageUrlPath());return a.bindPromise(c,b)},addSongs:function(b,c){var d=this,e=_.map(b,function(a){return a.get("id")}),e=a.postJSON(this.url()+"/songs/add",{song_id:e});e.done(function(){_.each(b,function(a){a.set({status:"ADD"});d.songs.get(a.get("id"))||d.songs.add(a)})});return a.bindPromise(e,c)},banSongs:function(b,c){var d=_.map(b,function(a){return a.get("id")}),d=a.postJSON(this.url()+"/songs/ban",{song_id:d});d.done(function(){_.each(b,
function(a){a.set({status:"BAN"})})});return a.bindPromise(d,c)},unBanSongs:function(b,c){var d=_.map(b,function(a){return a.get("id")}),d=a.postJSON(this.url()+"/songs/unban",{song_id:d});d.done(function(){_.each(b,function(a){a.set({status:"ADD"})})});return a.bindPromise(d,c)},release:function(b){var c=this,d=a.postJSON(this.url()+"/release",{released:"1"});d.done(function(){c.set({status:"NORMAL"})});return a.bindPromise(d,b)},unrelease:function(b){var c=this,d=a.postJSON(this.url()+"/release",
{released:"0"});d.done(function(){c.set({status:"UNRELEASED"})});return a.bindPromise(d,b)},validate:function(a){if(a.hasOwnProperty("name")&&a.name.match(/^\s*$/))return"Name must not be empty"}},{get:function(a,b){var c=_.clone(b);return(new m({id:a})).fetch(c)},getByDasherizedName:function(b,c){var p=a.getJSON(d+"/station/dname/"+b).pipe(function(a){return e.Utils.parseIntoModels(m,a)});return a.bindPromise(p,c)},getByUrl:function(a,b){var c;if(c=a.match(/.*\/station\/(\d+)\/?$/))return m.get(parseInt(c[1],
10),b);if(c=a.match(/.*\/listen\/([^\/]+)\/?$/))return m.getByDasherizedName(c[1],b);throw Error("Unable to parse station id from url: "+a);},getBatch:function(b,c){var p=a.getJSON(d+"/station/multi",{id:b}).pipe(function(a){return e.Utils.parseIntoModels(m,a)});return a.bindPromise(p,c)},search:function(b,c){var p=a.getJSON(d+"/search/station",{query:b}).pipe(function(a){return e.Utils.parseIntoModels(m,a)});return a.bindPromise(p,c)}}),k=m.extend({defaults:{reason:null}}),q=e.Artist=c.Model.extend({defaults:{name:null}}),
n=e.Song=c.Model.extend({defaults:{id:null,title:null,artist:null,album:null,duration:null,cover_url:null},parse:function(a){a.artist=e.Utils.parseIntoModels(q,a.artist);return a},toJSON:function(){var a=n.__super__.toJSON.apply(this,arguments);a.artist=this.get("artist").toJSON();return a},canonicalUrlPath:function(){return"/station/song_data/"+this.get("id")}},{search:function(b,c){var p=a.getJSON(d+"/search/song",{query:b,limit:c.limit||100}).pipe(function(a){return e.Utils.parseIntoModels(n,a.songs)});
return a.bindPromise(p,c)}}),t=e.StationSong=e.Song.extend({defaults:{status:null,added_by:null},parse:function(){var a=t.__super__.parse.apply(this,arguments);a.added_by=e.Utils.parseIntoModels(h,a.added_by);return a},toJSON:function(){var a=t.__super__.toJSON.apply(this,arguments);if(a.added_by)a.added_by=a.added_by.toJSON();return a}}),u=e.StationStreamSong=c.Model.extend({defaults:{station:null,song:null,listen_url:null,version:null,vote:null},parse:function(a){a.song=e.Utils.parseIntoModels(t,
a.song);return a},_url:function(){return d+"/station/"+this.station.get("id")+"/song/"+this.get("song").get("id")},voteUp:function(b){var c=this,d=a.postJSON(this._url()+"/vote/up");d.done(function(){c.set({vote:"up"})});return a.bindPromise(d,b)},voteDown:function(b){var c=this,d=a.postJSON(this._url()+"/vote/down");d.done(function(){c.set({vote:"down"})});return a.bindPromise(d,b)}}),o=e.Gallery=c.Model.extend({defaults:{id:null,name:null,slug:null,score:null,tags:null,station_ids:null,keywords:null,
just_for_you_eligible:null},schema:{name:{},slug:{},keywords:{type:"TextArea"},just_for_you_eligible:{type:"Checkbox"}},initialize:function(){this.get("station_ids")||this.set({station_ids:[]});_.bindAll(this,"_initDependents");this._initDependents();this.bind("change:id",this._initDependents)},_initDependents:function(){var b=this;this.stations=new (Backbone.Collection.extend({model:m,url:function(){return d+"/station/multi?"+a.formQuery({id:b.get("station_ids")})}}))},parse:function(a){a.tags=e.Utils.parseIntoModels(i,
a.tags).models;return a},toJSON:function(){var a=o.__super__.toJSON.apply(this,arguments);a.tags=_.map(this.get("tags"),function(a){return a.toJSON()});return a},url:function(){return this.isNew()?d+"/gallery/create":d+"/gallery/id/"+this.get("id")},validate:function(a){if(a.hasOwnProperty("name")&&a.name.match(/^\s*$/))return"Name must not be empty";if(a.hasOwnProperty("slug")&&!a.slug.match(g))return"Slug must not be empty and must only consist of letters, numbers, dashes and underscores"}},{get:function(a,
b){var c=_.clone(b);return(new o({id:a})).fetch(c)},getBatch:function(b,c){var p=a.getJSON(d+"/gallery/multi",{ids:b}).pipe(function(a){return e.Utils.parseIntoModels(o,a)});return a.bindPromise(p,c)}});e.GalleryList=Backbone.Collection.extend(_.extend(a.FilteredCollectionMixin,{filters:{site:"site"}},{model:o,parse:function(a){return e.Utils.parseIntoModels(o,a).models},urlBase:d+"/gallery/list/",url:function(){return this.urlBase+this.getFilter("site")}}));var v=e.FeedItem=c.Model.extend({defaults:{message:null,
station:null,song:null,icon:null,actor_pic:null,actors:null,event_type:null,ts:null},parse:function(b){b.ts=a.DateHelper.epoch_seconds_to_date(b.ts);b.actors=e.Utils.parseIntoModels(h,b.actors).models;b.station=e.Utils.parseIntoModels(m,b.station);if(b.song)b.song=e.Utils.parseIntoModels(n,b.song);return b},toJSON:function(){var a=v.__super__.toJSON.apply(this,arguments);a.station=this.get("station").toJSON();if(this.get("song"))a.song=this.get("song").toJSON();a.actors=_.map(this.get("actors"),function(a){return a.toJSON()});
return a}}),r=Backbone.Collection.extend(_.extend({},a.FilteredCollectionMixin,{filters:{user_id:"user_id"}})),z=r.extend({model:l,urlBase:d+"/collection/user/",parse:function(a){return a},url:function(){return this.urlBase+this.getFilter("user_id")},comparator:function(a){return a.get("title").toLowerCase()}}),A=r.extend({model:k,urlBase:d+"/just-for-you/user/",url:function(){return this.urlBase+this.getFilter("user_id")}}),y=r.extend({model:m,urlBase:d+"/user/",url:function(){return this.urlBase+
this.getFilter("user_id")+"/stations?limit=40&recent=1"},parse:function(a){return a.recent.stations}}),x=r.extend({model:m,urlBase:d+"/user/",url:function(){return this.urlBase+this.getFilter("user_id")+"/stations?limit=40&created=1&all_created=0"},parse:function(a){return a.created.stations}}),w=r.extend({model:m,urlBase:d+"/user/",url:function(){return this.urlBase+this.getFilter("user_id")+"/stations?limit=40&all_created=1"},parse:function(a){return a.all_created.stations}}),C=r.extend({model:h,
urlBase:d+"/get-followers/",url:function(){return this.urlBase+this.getFilter("user_id")}}),B=r.extend({model:h,urlBase:d+"/get-follows/",url:function(){return this.urlBase+this.getFilter("user_id")}}),p=e.Promotion=c.Model.extend({defaults:{id:null,site:null,product:null,station_id:null,station:null,image_url:null,active:null},schema:{station_id:{},image_url:{},active:{type:"Checkbox"}},url:function(){return this.isNew()?d+"/promotion/create":d+"/promotion/id/"+this.get("id")},parse:function(a){a.station=
e.Utils.parseIntoModels(m,a.station);return a},toJSON:function(){var a=p.__super__.toJSON.call(this);if(this.get("station"))a.station=this.get("station").toJSON();return a},validate:function(a){if(a.hasOwnProperty("site")&&a.site.match(/^\s*$/))return"Site must not be empty";if(a.hasOwnProperty("product")&&a.product.match(/^\s*$/))return"Product must not be empty";if(a.hasOwnProperty("station_id")&&isNaN(parseInt(a.station_id)))return"Station Id must not be empty";if(a.hasOwnProperty("image_url")&&
a.image_url.match(/^\s*$/))return"Image must not be empty"}});e.PromotionList=Backbone.Collection.extend(_.extend(a.FilteredCollectionMixin,{filters:{site:"site",product:"product"}},{model:p,parse:function(a){return e.Utils.parseIntoModels(p,a).models},urlBase:d+"/promotion",url:function(){return this.urlBase+"?"+a.formQuery({site:this.getFilter("site"),product:this.getFilter("product")})}}));return e});define("songza/work",["songza/base"],function(b){var c={};c.Set=b.Class.extend({initialize:function(b){c.Set.__super__.initialize.call(this,b);this._tasks={};this._dfd=$.Deferred();this.backbone=new a({host:this});this._dfd.promise(this)},_scanTasks:function(){var a,b={};for(a in this._tasks){var c=this._tasks[a].done;b[a]=this._tasks[a].value;if(c===void 0)return;else c||this._dfd.reject()}this._dfd.resolve(b)},_taskDone:function(a,b){this._tasks[a].done=!0;this._tasks[a].value=b;this._scanTasks()},
_taskFailed:function(a){this._tasks[a].done=!1;this._scanTasks()},add:function(a,b){var c=this;this._tasks[a]={promise:b,done:void 0,value:void 0};$.when(b).done(function(b){c._taskDone(a,b)}).fail(function(){c._taskFailed(a)});return this},get:function(a){if(!this._tasks.hasOwnProperty(a))throw Error("Unknown task: "+a);return this._tasks[a].promise},after:function(a,b,c){$.when(this.get(a)).done(function(){b.apply(this,Array.prototype.slice.apply(arguments).concat(c||[]))});return this}});var a=
b.Plugin.extend({namespace:"backbone",proxy:function(a,b,c){var g=$.Deferred(),b=g.promise().done(b,c);this.host.add(a,b);return{success:function(a){g.resolve(a)},error:function(){g.reject()}}}});return c});define("songza/scrollable-view",["songza/base","songza/config"],function(b,c){var a={},e=a.ScrollableView=b.View.extend({initialize:function(a){var b=this;e.__super__.initialize.call(this,a);this.itemTemplate=a.itemTemplate;this.itemFetcher=a.itemFetcher;this.scrollable=function(){return b.$(a.listSelector||"ul")};this.fetchState=0;this.threshhold=40;this.scrolling=!1;this.scrollDir="left";this.autoScroll=a.autoScroll!==void 0?a.autoScroll:!0;_.bindAll(this,"handleMouseMove","handleMouseLeave","fetchSuccess",
"fetchError","maybeTriggerNext","maybeFetch");this.scrollable().carouFredSel({circular:this.autoScroll?!1:!0,infinite:this.autoScroll?!1:!0,auto:{play:!1},prev:{button:a.prevSelector,onAfter:this.autoScroll?this.maybeTriggerNext:null},next:{button:a.nextSelector,onAfter:this.autoScroll?this.maybeTriggerNext:null},scroll:{duration:500,easing:"linear",pauseDuration:0,queue:!0}});this.autoScroll?($(this.el).bind("mousemove",this.handleMouseMove),$(this.el).bind("mouseleave",this.handleMouseLeave)):$(this.el).bind("mouseenter",
this.maybeFetch)},maybeFetch:function(){if(this.itemFetcher&&this.fetchState===0){this.fetchState=1;var a=this.itemFetcher();$.when(a).then(this.fetchSuccess,this.fetchError)}},loadingItem:function(){return $("<li>").addClass("szi-loading").text("Loading")},endItem:function(){return $("<li>").addClass("szi-end").text("End of List")},fetchSuccess:function(a){this.scrollable();var b=this.itemTemplate,c=this.scrollable();this.fetchState=2;_.each(a,function(a){a=$("<li>").html(b(a));c.trigger("insertItem",
a,"start",!0)});c.trigger("configuration",["circular",!0])},fetchError:function(){this.fetchState=3},stopScroll:function(){this.scrolling=!1},startScroll:function(a,b){var c=this;this.scrolling=!0;this.scrollDir=a||this.scrollDir;this.maybeFetch();b===void 0?this.maybeTriggerNext():_.delay(function(){c.maybeTriggerNext()},b)},maybeTriggerNext:function(){this.scrolling&&this.scrollable().trigger(this.scrollDir==="left"?"next":"prev",1)},handleMouseLeave:function(){this.stopScroll()},handleMouseMove:function(a){var b,
e=$(this.el).offset(),a=a.pageX-e.left;a<this.threshhold?b="right":$(this.el).width()-a<this.threshhold&&(b="left");!b&&this.scrolling?this.stopScroll():b&&!this.scrolling&&this.startScroll(b,c.timeouts.shelfAutoScrollDelay)}});return a});define("songza/site-views",["songza/config","songza/base","songza/hashsignal","songza/utils"],function(b,c,a,e){var d={};d.Default=c.View.extend({el:"#body-delegate",elements:{"#menu-bar":"menuEl"},events:{"click  a":"onAnchorClick","submit form":"onFormSubmit"},initialize:function(a){d.Default.__super__.initialize.call(this,a);_.bindAll(this,"startSpinner","stopSpinner");this.app=a.app;this.stationNavigationContext=this.errorFrame=this.spinner=this.spinnerTimeout=null;this.app.bind("page-navigate-start",
this.startSpinner);this.app.bind("page-navigate",this.stopSpinner);this.app.bind("page-navigate-failure",this.stopSpinner)},startSpinner:function(){var a=this;this.stopSpinner();this.spinnerTimeout=setTimeout(function(){var b=(new Spinner({lines:12,length:7,width:2,radius:3,color:"#888",speed:1,trail:50,shadow:!1})).spin();$(b.el).css("position","fixed");$(b.el).css("bottom","30px");$(b.el).css("right","30px");$("body").append(b.el);a.spinnerTimeout=null;a.spinner=b},b.timeouts.pageNavigateProgress)},
stopSpinner:function(){this.spinnerTimeout&&clearTimeout(this.spinnerTimeout);if(this.spinner)this.spinner.stop(),$(this.spinner.el).detach(),this.spinner=null},showErrorDocument:function(a){var b=$('<iframe src="javascript:0">').addClass("sz-error-page"),a=$($.trim(a));this.errorFrame&&this.errorFrame.detach();b.css("min-height",$(this.el).outerHeight());$(this.el).append(b);b.contents().find("html").empty().append(a);this.errorFrame=b},updateContent:function(b){var c=this;this.errorFrame&&this.errorFrame.detach();
a.replaceBlocks(b,!1,function(a){_.each(a,function(a){c.app.trigger("dom-node-inserted",{node:a})})});$(document).scrollTop()>150&&$("html,body").animate({scrollTop:0})},setStationNavigationContext:function(a,b){this.stationNavigationContext={stationId:a,contextName:b}},getStationNavigationContext:function(a){if(this.stationNavigationContext&&this.stationNavigationContext.stationId===a)return this.stationNavigationContext.contextName;return"Unknown"},onAnchorClick:function(a){var b=$(a.currentTarget),
c=b.attr("href"),d=null,k=null,d=null;if(!c||b.attr("data-sz-no-route")!==void 0)return!0;b.attr("data-sz-station-id")!==void 0&&(k=parseInt(b.attr("data-sz-station-id"),10),d=b.parents(".sz-station-context").attr("data-sz-station-context-name"),this.setStationNavigationContext(k,d||"Unknown"));if(c.match(/^\s*http[s]?/i))if(d=parseUri(c),d.protocol!=window.location.protocal&&d.host!=window.location.host)return!0;else k=d.path,d.query&&(k+="?"+d.query);else if(c.match(/^\s*javascript:/i))return!0;
else if(c==="#")return!1;else k=c;a.preventDefault();k[0]==="/"&&(k=k.substring(1));d=b.attr("data-sz-add-next");d!==void 0&&(k+="?"+e.formQuery({next:d?d:"/"+Backbone.history.getFragment()}));Backbone.history.navigate(k,!0);return!1},onFormSubmit:function(a){var a=$(a.currentTarget),b=(a.attr("method")||"GET").toUpperCase(),c=a.attr("action");if(!c||c.match(/^\s*http[s]?/))return!0;c.match(/\//)&&(c=c.substr(1));if(b==="GET")return Backbone.history.navigate(c+"?"+a.serialize(),!1),this.app.router.getAndInjectContent(c+
"?"+a.serialize()),!1;else if(b==="POST")return Backbone.history.navigate(c,!1),this.app.router.postAndInjectContent(c,a.serialize()),!1}});return d});define("songza/situation-viewer",["songza/base","songza/models","songza/utils","songza/config","songza/app"],function(b,c,a,e,d){function f(a){var b;a.wrapInner("<div/>");var c=a.find("div")[0],d=a.height();for(b=c.scrollHeight;b>d;)b=parseInt(a.css("font-size"),10),a.css("font-size",b-1),b=c.scrollHeight}var g={},h=[{url:e.static_url+"/images/situation/morning.jpg",periods:[0,1,2]},{url:e.static_url+"/images/situation/night.jpg",periods:[3,4,5]}],i=g.Context=Backbone.Model.extend({defaults:{day:null,
period:null},initialize:function(){var a,b=new Date;this.get("day")===null&&(a=_.find(e.situations.dow,function(a){return a.day_value===b.getDay()}),this.set({day:a.value}));this.get("period")===null&&(a=_.find(e.situations.time_periods,function(a){var c=a.hours_range[0],a=a.hours_range[1];return b.getHours()>=c&&b.getHours()<=a}),this.set({period:a.value}),a===6&&(a=this.get("day")===0?6:this.get("day")-1,this.set({day:a})))}}),k=g.Wizard=b.View.extend({template:sz.tmpl.situation.wizard,css:"sz-situation-wizard",
elements:{".szi-background":"backgroundEl",".szi-views":"viewsEl"},events:{"click .szi-back":"handleBack"},states:{has_history:{set:!1,onCss:"sz-situation-wizard-has-history"}},initialize:function(a){k.__super__.initialize.call(this,a);_.bindAll(this,"handleSituationClick","handlePeriodChange");this.situationContext=new i({});this.situationContext.bind("change:period",this.handlePeriodChange);this.background=this.backgroundForContext();a=new l({situationContext:this.situationContext});a.bind("situation-clicked",
this.handleSituationClick);this.views=[a]},handleSituationClick:function(a){a.get("station_ids").length>1?a=new q({situation:a}):(a=new m({situation:a}),a.bind("situation-clicked",this.handleSituationClick));this.addView(a)},addView:function(a){var b=this;this.activeView().hide().then(function(){b.viewsEl().children().addClass("szi-view-inactive");b.views.push(a);b.syncHistory();b.viewsEl().append(a.render().el);a.show()})},popView:function(){var a=this;this.activeView().hide().then(function(){a.views.pop().destroy();
a.viewsEl().children().last().removeClass("szi-view-inactive");a.syncHistory();a.activeView().show()})},activeView:function(){return this.views[this.views.length-1]},syncHistory:function(){this.setState("has_history",this.views.length>1)},handleBack:function(){this.views.length>1&&this.popView()},backgroundForContext:function(){var a=this.situationContext.get("period");return _.find(h,function(b){return _.contains(b.periods,a)})},handlePeriodChange:function(){this.backgroundForContext()!==this.background&&
this.updateBackground()},updateBackground:function(){var a=this,b=this.backgroundForContext(),c=new Image;c.onload=function(){a.background=b;a.doUpdateBackground()};c.src=b.url},doUpdateBackground:function(){var a=this.backgroundEl(),b=$("<div>"),c=a.children().first();a.append(b);c.addClass("szi-previous").removeClass("szi-current");b.addClass("szi-current").css("opacity",0).css("background-image","url("+this.background.url+")");c.animate({opacity:0},"slow",function(){c.detach()});b.animate({opacity:1},
"slow")},render:function(){k.__super__.render.call(this);this.viewsEl().append(this.activeView().render().el);return this},show:function(){var a=this;this.updateBackground();_.delay(function(){a.activeView().show()},400)}}),b=function(){var a=$.Deferred();$(this.el).animate({opacity:0},"fast",function(){a.resolve()});return a},j=function(){var a=$.Deferred(),b=this.collectionContainerEl().find("li");$(this.el).css("opacity",0);b.css("opacity",0);$(this.el).animate({opacity:1},"slow");b.each(function(a,
b){$(b).delay(300*a).animate({opacity:1},"slow","swing")});_.delay(function(){a.resolve()},b.length*300);return a},l=g.StartingContext=a.SimpleCollectionView.extend({template:sz.tmpl.situation.startingContext,modelTemplate:sz.tmpl.situation.situationItem,css:"sz-situation-starting-context",elements:{".szi-list":"collectionContainerEl",".szi-filter .szi-day":"dayFilter",".szi-filter .szi-time":"timeFilter"},events:{"change .szi-filter .szi-day":"fetchSituations","change .szi-filter .szi-time":"fetchSituations",
"click  .szi-list ul > li":"handleClick"},states:{loading:{set:!0,onCss:"sz-situation-starting-context-loading"}},initialize:function(a){a.collection=new Backbone.Collection;a.modelContextName="situation";a.mustFetch=!1;a.useCid=!0;l.__super__.initialize.call(this,a);this.situationContext=a.situationContext;this.fetchSituations()},fetchSituations:function(){var a=this;this.setState("loading",!0);this.timeFilter().length&&this.dayFilter().length&&this.situationContext.set({day:parseInt(this.dayFilter().val(),
10),period:parseInt(this.timeFilter().val(),10)});c.Situation.getTargeted({req_day:this.situationContext.get("day"),req_period:this.situationContext.get("period")},{success:function(b){a.collection.reset(b.models);a.setState("loading",!1);a.show()}})},handleClick:function(a){this.trigger("situation-clicked",this.collection.getByCid($(a.currentTarget).attr("data-sz-model-id")))},context:function(){var a=l.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,device_options:_.union([{value:"",
label:"Device"}],e.situations.devices),device_choice:"all",dow_options:_.union([{value:"",label:"Day"}],e.situations.dow),dow_choice:this.situationContext.get("day"),time_options:_.union([{value:"",label:"Time"}],e.situations.time_periods),time_choice:this.situationContext.get("period")})},syncCollectionContainerEl:function(){var a=this;l.__super__.syncCollectionContainerEl.call(this);_.defer(function(){$(a.el).find(".sz-situation-item-noicon .szi-title").each(function(){f($(this))})});return this},
hide:b,show:j}),m=g.SituationView=a.SimpleCollectionView.extend({template:sz.tmpl.situation.situation,modelTemplate:sz.tmpl.situation.situationItem,css:"sz-situation-viewer-context",elements:{".szi-list":"collectionContainerEl"},events:{"click .szi-list ul > li":"handleClick"},initialize:function(a){a.collection=a.situation.get("situations");a.modelContextName="situation";a.mustFetch=!1;a.useCid=!0;m.__super__.initialize.call(this,a)},handleClick:function(a){this.trigger("situation-clicked",this.collection.getByCid($(a.currentTarget).attr("data-sz-model-id")))},
context:function(){var a=m.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,situation:this.options.situation.toJSON()})},syncCollectionContainerEl:function(){var a=this;m.__super__.syncCollectionContainerEl.call(this);_.defer(function(){$(a.el).find(".sz-situation-item-noicon .szi-title").each(function(){f($(this))})});return this},hide:b,show:j}),q=g.SituationStationView=a.SimpleCollectionView.extend({template:sz.tmpl.situation.situation,modelTemplate:sz.tmpl.situation.stationItem,
css:"sz-situation-station",elements:{".szi-list":"collectionContainerEl"},events:{"click .szi-list ul > li":"handleClick"},states:{loading:{set:!0,onCss:"sz-situation-station-loading"}},initialize:function(a){a.collection=new Backbone.Collection;a.modelContextName="station";a.mustFetch=!1;a.useCid=!0;q.__super__.initialize.call(this,a);this.fetchStations()},fetchStations:function(){var a=this;this.setState("loading",!0);c.Station.getBatch(this.options.situation.get("station_ids"),{success:function(b){a.collection.reset(b.models);
a.setState("loading",!1);a.show()}})},handleClick:function(a){a=this.collection.getByCid($(a.currentTarget).attr("data-sz-model-id"));d.getInstance().startStation(a)},context:function(){var a=q.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,situation:this.options.situation.toJSON()})},hide:b,show:j});return g});define("songza/curate",["songza/base","songza/models","songza/utils","songza/config","songza/station-editor","songza/app"],function(b,c,a,e,d,f){function g(a,b){a.bind("cancelled",function(){b.removeView(a)});a.bind("deleted",function(){b.removeView(a)});a.bind("saved",function(){b.removeView(a)})}function h(a){return Backbone.Form.editors.Base.extend({events:{"click .szi-choose":"showSearch"},initialize:function(a){Backbone.Form.editors.Base.prototype.initialize.call(this,a);this.station=this.model.get("station");
this.stationChooser=null},render:function(){this.setValue(this.value);return this},getValue:function(){if(this.station)return this.station.get("id");return""},setValue:function(){var a=$(this.el);a.empty();this.station&&a.append($("<div>").text(this.station.get("name")));a.append($("<div>").text("Choose another").addClass("szi-choose"))},showSearch:function(){var b=this,c=new r({workspace:a});c.bind("station-clicked",function(a){b.station=a;b.setValue(a.get("id"))});this.stationChooser&&a.removeView(this.stationChooser);
a.addView(c);this.stationChooser=c}})}function i(a,b){f.getInstance().getVisitor();return new o({model:a,title:b})}function k(a,b,c){f.getInstance().getVisitor();a={model:a,title:b,schema:{station_id:{type:h(c)},image_url:{},active:{type:"Checkbox"}}};return new o(a)}var j={},l=e.site,m={organizeToggle:function(){if(this.getState("initializing"))return!1;this.workspace&&this.workspace.removeViewAfter(this);this.getState("organize")?this.organizeStop(!1):this.organizeStart()},organizeStart:function(){this.$(".szi-filter").find("input, select").val("");
this.$(".szi-filter").find("input, select").attr("disabled","disabled");this.syncCollectionContainerEl();this.setState("organize",!0);this.collectionContainerEl().find("ul").first().sortable().sortable("enable");this.trigger("organize-started")},organizeModelFromId:function(a){return this.collection.get(a)},organizeStop:function(a){var b=this,c=this.collectionContainerEl().find("ul").first(),d=[],e=[];this.setState("organize",!1);this.$(".szi-filter").find("input, select").attr("disabled",null);c.sortable("disable");
a?(c.children().each(function(){var a=$(this),c=a.attr("data-sz-model-id"),c=b.organizeModelFromId(c);a.hasClass("szi-pending-remove")?e.push(c):d.push(c)}),this.collection.reset(d),this.trigger("organize-completed",{keep:d,remove:e})):(this.syncCollectionContainerEl(),this.trigger("organize-cancelled"))},organizeRevert:function(){this.organizeStop(!1)},organizeSave:function(){this.organizeStop(!0)},organizeToggleDeleted:function(a){$(a.target).parents("li[data-sz-model-id=*]").toggleClass("szi-pending-remove")}},
q=j.TagListView=a.SimpleCollectionView.extend({template:sz.tmpl.curate.tagList,modelTemplate:sz.tmpl.curate.tagItem,css:"sz-curate-tag-list",elements:{".szi-query-input":"queryInput",".szi-list":"collectionContainerEl"},events:{"keyup .szi-query-input":"maybeSearch","click .sz-tag-curate-item":"handleClick","click .szi-new-tag":"handleNewTag"},initialize:function(a){a.collection=new c.TagList([]);a.modelContextName="tag";a.mustFetch=!0;a.fetchInterval=1800;a.collection.addFilter("site",l);a.collection.addFilter("featured",
0);q.__super__.initialize.call(this,a);this.workspace=a.workspace;this.searchDelay=a.hasOwnProperty("searchDelay")?this.searchDelay:200;this.query=a.query||"";this.queueSearch=_.debounce(this.runSearch,this.searchDelay)},handleClick:function(a){this.trigger("tag-clicked",this.collection.get($(a.currentTarget).attr("data-sz-tag-id")))},handleNewTag:function(){var a=this,b=new c.Tag({site:l}),b=new o({model:b,title:"New Tag"});this.workspace.setRootView(b);g(b,this.workspace);b.bind("saved",function(b){a.collection.add(b);
a.highlightModel(b);a.trigger("tag-added",b)})},maybeSearch:function(){this.queueSearch()},runSearch:function(){this.syncCollectionContainerEl()},getMatchString:function(a){return a.get("name")+a.get("slug")},modelList:function(){return this.collection.filter(a.WordMatcher(this.queryInput().val(),this.getMatchString))},context:function(){var a=q.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,query:this.query})}}),n=j.GalleryListView=a.SimpleCollectionView.extend({template:sz.tmpl.curate.galleryList,
modelTemplate:sz.tmpl.curate.galleryItem,css:"sz-curate-gallery-list",elements:{".szi-query-input":"queryInput",".szi-list":"collectionContainerEl"},events:{"keyup .szi-query-input":"maybeSearch","click .sz-gallery-curate-item":"handleClick","click .szi-new-gallery":"handleNewGallery"},initialize:function(a){a.collection=new c.GalleryList([]);a.modelContextName="gallery";a.mustFetch=!0;a.fetchInterval=1800;a.collection.addFilter("site",l);n.__super__.initialize.call(this,a);this.workspace=a.workspace;
this.searchDelay=a.hasOwnProperty("searchDelay")?this.searchDelay:200;this.query=a.query||"";this.queueSearch=_.debounce(this.runSearch,this.searchDelay)},handleClick:function(a){this.trigger("gallery-clicked",this.collection.get($(a.currentTarget).attr("data-sz-gallery-id")))},handleNewGallery:function(){var a=this,b=new c.Gallery({site:l}),b=i(b,"New Gallery");this.workspace.setRootView(b);g(b,this.workspace);b.bind("saved",function(b){a.collection.add(b);a.highlightModel(b);a.trigger("gallery-added",
b)})},maybeSearch:function(){this.queueSearch()},runSearch:function(){this.syncCollectionContainerEl()},getMatchString:function(a){return a.get("name")+a.get("slug")},modelList:function(){return this.collection.filter(a.WordMatcher(this.queryInput().val(),this.getMatchString))},context:function(){var a=n.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,query:this.query})}}),t=j.GallerySearchView=j.GalleryListView.extend({template:sz.tmpl.curate.gallerySearch}),u=j.TagDetails=a.SimpleCollectionView.extend(_.extend(_.clone(m),
{template:sz.tmpl.curate.tagDetails,modelTemplate:sz.tmpl.curate.galleryItem,elements:{".szi-query-input":"queryInput",".szi-editor":"editorEl",".szi-list":"collectionContainerEl"},css:"sz-curate-tag-details",events:{"keyup .szi-query-input":"maybeSearch","click .sz-gallery-curate-item":"handleGalleryClick","click .szi-edit":"handleEdit","click .szi-new-gallery":"handleNewGallery","click .szi-add-gallery":"handleAddGallery","click .szi-organize-toggle":"organizeToggle","click .szi-organize-revert":"organizeRevert",
"click .szi-organize-save":"organizeSave","click .szi-organize-toggle-deleted":"organizeToggleDeleted"},states:{organize:{set:!1,onCss:"sz-curate-organize"},initializing:{set:!0,onCss:"sz-curate-initializing"}},initialize:function(a){var b=this;a.collection=a.tag.galleries;a.modelContextName="gallery";a.mustFetch=!0;a.fetchInterval=1800;u.__super__.initialize.call(this,a);this.tag=a.tag;this.workspace=a.workspace;this.searchDelay=a.hasOwnProperty("searchDelay")?this.searchDelay:200;this.query=a.query||
"";this.queueSearch=_.debounce(this.runSearch,this.searchDelay);this.collectionFreshen.bind("state-change",function(){this.fetched&&b.setState("initializing",!1)});this.tag.bind("change:name",this.render);this.tag.bind("destroy",function(){b.trigger("destroy-request")});this.bind("organize-completed",function(a){b.handleOrganizeCompletion(a)})},handleEdit:function(){var a=new o({model:this.tag,title:"Edit Tag"});if(this.getState("initializing"))return!1;this.organizeStop();this.workspace.addView(a,
this);g(a,this.workspace)},handleOrganizeCompletion:function(a){var b=this;this.tag.setGalleriesById(_.map(a.keep,function(a){return a.id}),{success:function(){b.collection.fetch()},error:function(){alert("Unable to save changes")}})},_addGallery:function(a){var b=this;a.get("tags").push(b.tag);this.tag.galleries.add(a);this.tag.setGalleriesById(this.tag.galleries.pluck("id"));setTimeout(function(){b.highlightModel(a)},0)},handleNewGallery:function(){if(this.getState("initializing"))return!1;var a=
this,b=new c.Gallery({site:l}),b=i(b,"New Gallery");this.organizeStop();this.workspace.addView(b,this);g(b,this.workspace);b.bind("saved",function(b){a._addGallery(b)})},handleAddGallery:function(){if(this.getState("initializing"))return!1;var a=this,b=new t({});this.organizeStop();this.workspace.addView(b,this);b.bind("gallery-clicked",function(b){a._addGallery(b)})},handleGalleryClick:function(a){var b=this,a=this.collection.get($(a.currentTarget).attr("data-sz-gallery-id"));if(this.getState("organize"))return!1;
var c=new v({gallery:a,workspace:this.workspace});this.workspace.addView(c,this);c.bind("destroy-request",function(){b.workspace.removeView(c)})},maybeSearch:function(){this.queueSearch()},runSearch:function(){this.syncCollectionContainerEl()},getMatchString:function(a){return a.get("name")+a.get("slug")},modelList:function(){return this.collection.filter(a.WordMatcher(this.queryInput().val(),this.getMatchString))},context:function(){var a=q.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,
query:this.query,tag:this.tag.toJSON()})}})),o=j.ModelEditor=b.View.extend({template:sz.tmpl.curate.modelEditor,css:"sz-curate-model-editor",events:{"click .szi-cancel":"handleCancel","click .szi-save":"handleSave","click .szi-delete":"handleDelete"},elements:{".szi-errors":"errorEl",".szi-editor":"editorEl"},states:{creating:{set:!1,onCss:"sz-curate-model-editor-creating"}},initialize:function(a){o.__super__.initialize.call(this,a);this.form=new Backbone.Form(a);this.title=a.title;a.model.isNew()&&
this.setState("creating",!0)},handleCancel:function(){this.trigger("cancelled")},handleSave:function(){this.model.clone();var a=this.form.commit();a?(a=_.values(a),this.errorEl().empty().text(a.join(", "))):this.doSave(this.model)},doSave:function(a){var b=this;a.save({},{success:function(){b.trigger("saved",a)},error:function(a,c){a:{var d=b.errorEl();try{var e=$.parseJSON(c.responseText);if(e&&e.message){d.empty().text(e.message);break a}}catch(p){}d.empty().text("Internal Error While Saving")}b.model.set(backup.attributes)}})},
handleDelete:function(){confirm("Are you sure you want to delete this?")&&this.doDelete(this.model)},doDelete:function(a){var b=this;a.destroy({success:function(){b.trigger("deleted",a)},error:function(){b.errorEl().empty().text("Unable to delete")}})},context:function(){return{title:this.title}},render:function(){o.__super__.render.call(this);this.editorEl().empty().append(this.form.render().el);return this}}),v=j.GalleryDetails=a.SimpleCollectionView.extend(_.extend(_.clone(m),{template:sz.tmpl.curate.galleryDetails,
modelTemplate:sz.tmpl.curate.stationItem,elements:{".szi-editor":"editorEl",".szi-query-input":"queryInput",".szi-list":"collectionContainerEl"},events:{"keyup .szi-query-input":"maybeSearch","click .szi-add-station":"handleAddStation","click .sz-station-curate-item":"handleClick","click .szi-edit":"handleEdit","click .szi-organize-toggle":"organizeToggle","click .szi-organize-revert":"organizeRevert","click .szi-organize-save":"organizeSave","click .szi-organize-toggle-deleted":"organizeToggleDeleted"},
states:{organize:{set:!1,onCss:"sz-curate-organize"},initializing:{set:!0,onCss:"sz-curate-initializing"}},css:"sz-curate-gallery-details",initialize:function(a){var b=this;a.collection=a.gallery.stations;a.modelContextName="station";a.mustFetch=!0;a.fetchInterval=1800;v.__super__.initialize.call(this,a);this.gallery=a.gallery;this.workspace=a.workspace;this.searchDelay=a.hasOwnProperty("searchDelay")?this.searchDelay:200;this.query=a.query||"";this.queueSearch=_.debounce(this.runSearch,this.searchDelay);
this.collectionFreshen.bind("state-change",function(){this.fetched&&b.setState("initializing",!1)});this.gallery.bind("change:name",this.render);this.gallery.bind("destroy",function(){b.trigger("destroy-request")});this.bind("organize-completed",function(a){b.handleOrganizeCompletion(a)})},handleEdit:function(){if(this.getState("initializing"))return!1;var a=i(this.gallery,"Edit Gallery");this.organizeStop();this.workspace.addView(a,this);g(a,this.workspace)},organizeModelFromId:function(a){return this.collection.get(parseInt(a,
10))},handleOrganizeCompletion:function(a){var b=this;this.gallery.save({station_ids:_.map(a.keep,function(a){return a.id})},{success:function(){b.collection.fetch()},error:function(){alert("Unable to save changes")}})},handleAddStation:function(){if(this.getState("initializing"))return!1;var a=this,b=f.getInstance().getVisitor(),b=new r({user:b,workspace:this.workspace});this.organizeStop();this.workspace.addView(b,this);b.bind("station-clicked",function(b){a.collection.get(b.get("id"))||(a.collection.add(b),
a.gallery.save({station_ids:a.collection.pluck("id")}));a.highlightModel(b)})},handleClick:function(a){a=$(a.currentTarget);a=this.collection.get(parseInt(a.attr("data-sz-station-id"),10));if(this.getState("organize"))return!1;a=new d.StationEditorView({station:a,user:f.getInstance().getVisitor()});$("body").append(a.render().el);$(a.el).dialog({title:"Edit Station",show:"fade",hide:"fade",width:1E3})},maybeSearch:function(){this.queueSearch()},runSearch:function(){this.syncCollectionContainerEl()},
getMatchString:function(a){return a.get("name")},modelList:function(){return this.collection.filter(a.WordMatcher(this.queryInput().val(),this.getMatchString))},context:function(){var a=v.__super__.context.call(this);return a=_.extend(a,{gallery:this.gallery.toJSON(),view_id:this.cid,query:this.query})}})),r=j.StationSearchView=a.SimpleCollectionView.extend({template:sz.tmpl.curate.stationSearchList,modelTemplate:sz.tmpl.curate.stationItem,css:"sz-curate-station-search-list",elements:{".szi-query-input":"queryInput",
".szi-station-list":"collectionContainerEl"},events:{"keyup .szi-query-input":"maybeSearch","click .sz-station-curate-item":"handleClick","click .szi-done":"handleDone"},initialize:function(a){a.collection=new Backbone.Collection([]);a.modelContextName="station";a.mustFetch=!1;r.__super__.initialize.call(this,a);this.workspace=a.workspace;this.stamp=0;this.query=a.query||"";this.queueSearch=_.debounce(this.runSearch,this.searchDelay)},handleClick:function(a){a=$(a.currentTarget);this.trigger("station-clicked",
this.collection.get(parseInt(a.attr("data-sz-station-id"),10)))},handleDone:function(){this.workspace.removeView(this)},maybeSearch:function(){this.queueSearch()},extractDasherized:function(a){var b,c,d=[/\/listen\/([^/]+)\/?/,/\/discover\/[^/]+\/[^/]+\/([^/]+)\/?/];for(c=0;c<d.length;c++)if(b=a.match(d[c]))return b[1];return null},runSearch:function(){var a=this,b=this.queryInput().val(),d=++this.stamp;if(b){var e=this.extractDasherized(b);e?c.Station.getByDasherizedName(e,{success:function(b){a.collection.reset([b])}}):
c.Station.search(b,{success:function(b){a.stamp==d&&a.collection.reset(b.models)}})}else this.collection.reset()},context:function(){return{view_id:this.cid,query:this.query}}}),z=j.WorkspaceView=b.View.extend({template:sz.tmpl.curate.workspace,css:"sz-workspace-view",elements:{".szi-container":"containerEl"},initialize:function(a){z.__super__.initialize.call(this,a);this.views=[]},presentView:function(a){a=$(a.el);a.css("opacity",0);a.animate({opacity:1},{queue:!0},"fast")},setRootView:function(a){this.views=
[];this.containerEl().empty();this.addView(a)},nextView:function(a){var b,c,d=!1;b=0;for(c=this.views.length;b<c;b++){if(d)return this.views[b].view;this.views[b].view===a&&(d=!0)}return null},allocateWidth:function(){var a=this,b=$(this.el).width()-15*this.views.length;_.each(this.views,function(c,d){c.item.css("width",(d==a.views.length-1?a.views.length>1?b/2:b:b/2/(a.views.length-1))+"px")})},addView:function(a,b){var c=$("<div>").addClass("szi-item");if(b){var d=this.nextView(b);d&&this.removeView(d,
!0)}this.views.push({item:c,view:a});c.append(a.render().el);this.containerEl().append(c);this.allocateWidth();this.presentView(a)},removeViewAfter:function(a){(a=this.nextView(a))&&this.removeView(a)},removeView:function(a,b){var c,d,e=this,f=!1,g=[],h=[];c=0;for(d=this.views.length;c<d;c++)f?g.push(this.views[c]):this.views[c].view===a?(f=!0,g.push(this.views[c])):h.push(this.views[c]);this.views=h;_.each(g,function(a){var c=a.view,a=function(){$(c.el).parents(".szi-item").remove();c.destroy();
e.allocateWidth()};b?a():$(c.el).animate({opacity:0},{queue:!0,duration:"fast",complete:a})})},context:function(){return{}}}),A=j.PromotionProductListView=b.View.extend({template:sz.tmpl.curate.promotionProductList,css:"sz-curate-promotion-product-list",events:{"click li":"handleClick"},initialize:function(a){A.__super__.initialize.call(this,a);this.workspace=a.workspace},handleClick:function(a){this.trigger("product-clicked",$(a.currentTarget).attr("data-sz-product"))},context:function(){return{products:e.promo_product_list}}}),
y=j.PromotionDetails=a.SimpleCollectionView.extend({template:sz.tmpl.curate.promoDetails,modelTemplate:sz.tmpl.curate.promoItem,elements:{".szi-list":"collectionContainerEl"},css:"sz-curate-promo-details",events:{"click .sz-promo-curate-item":"handlePromoClick","click .szi-new-promo":"handleNewPromo"},states:{initializing:{set:!0,onCss:"sz-curate-initializing"}},initialize:function(a){var b=this;a.collection=new c.PromotionList([]);a.modelContextName="promo";a.mustFetch=!0;a.fetchInterval=1800;a.collection.addFilter("site",
a.site);a.collection.addFilter("product",a.product);y.__super__.initialize.call(this,a);this.site=a.site;this.product=a.product;this.workspace=a.workspace;this.collectionFreshen.bind("state-change",function(){this.fetched&&b.setState("initializing",!1)})},handleNewPromo:function(){if(this.getState("initializing"))return!1;var a=this,b=new c.Promotion({site:this.site,product:this.product}),b=k(b,"New Promo",this.workspace);this.workspace.addView(b,this);g(b,this.workspace);b.bind("saved",function(b){a.collection.add(b)})},
handlePromoClick:function(a){a=this.collection.get($(a.currentTarget).attr("data-sz-promo-id"));a=k(a,"Edit Promo",this.workspace);this.workspace.addView(a,this);g(a,this.workspace)},context:function(){var a=y.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,product:this.product,site:this.site})}}),x=j.SituationListView=a.SimpleCollectionView.extend(_.extend(_.clone(m),{template:sz.tmpl.curate.situationList,modelTemplate:sz.tmpl.curate.situationItem,css:"sz-curate-situation-list",
elements:{".szi-filter .szi-query-input":"queryInput",".szi-filter .szi-device":"filterDevice",".szi-filter .szi-day":"filterDay",".szi-filter .szi-time":"filterTime",".szi-list":"collectionContainerEl"},events:{"keyup  .szi-filter .szi-query-input":"maybeSearch","change .szi-filter .szi-device":"runSearch","change .szi-filter .szi-day":"runSearch","change .szi-filter .szi-time":"runSearch","click  .sz-situation-curate-item":"handleClick","click  .szi-new-situation":"handleNewSituation","click  .szi-organize-toggle":"organizeToggle",
"click  .szi-organize-revert":"organizeRevert","click  .szi-organize-save":"organizeSave","click  .szi-organize-toggle-deleted":"organizeToggleDeleted"},states:{organize:{set:!1,onCss:"sz-curate-organize"},initializing:{set:!0,onCss:"sz-curate-initializing"}},initialize:function(a){a.situation?(a.collection=a.situation.get("situations"),a.useCid=!0,a.mustFetch=!1):(a.collection=new c.SituationList([]),a.mustFetch=!0,a.fetchInterval=1800,a.collection.addFilter("site",l),a.collection.addFilter("featured",
0));a.modelContextName="situation";x.__super__.initialize.call(this,a);this.setState("initializing",!1);this.workspace=a.workspace;this.situation_name_singular=a.situation_name_singular||"Situation";this.situation_name_plural=a.situation_name_plural||"Situations";this.searchDelay=a.hasOwnProperty("searchDelay")?this.searchDelay:200;this.query=a.query||"";this.queueSearch=_.debounce(this.runSearch,this.searchDelay)},showSituations:function(){this.setState("showStations",!1);this.setState("showSituations",
!0)},showStations:function(){this.setState("showSituations",!1);this.setState("showStations",!0)},handleClick:function(a){a=$(a.currentTarget).attr("data-sz-situation-id");if(this.getState("organize"))return!1;this.trigger("situation-clicked",this.collection.get(a))},handleNewSituation:function(){this.organizeStop();this.trigger("situation-new")},maybeSearch:function(){this.queueSearch()},runSearch:function(){this.syncCollectionContainerEl()},getMatchString:function(a){return a.get("title")},modelList:function(){var b=
this.filterDevice().val(),c=this.filterDay().val(),d=this.filterTime().val(),e=function(a,b,c){if(a===void 0||a==="")return function(){return!0};return function(d){return _.find(d.get(b),function(b){return c(a,b)})!==void 0}},f=a.WordMatcher(this.queryInput().val(),this.getMatchString),g=e(b,"devices",function(a,b){return b===a}),h=e(c,"time_periods",function(a,b){return b.get("day")===a}),i=e(d,"time_periods",function(a,b){return b.get("period")===a});return this.collection.filter(function(a){return f(a)&&
g(a)&&h(a)&&i(a)})},context:function(){var a=x.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,situation_name_singular:this.situation_name_singular,situation_name_plural:this.situation_name_plural,query:this.query,device_options:_.union([{value:"",label:"Device"}],e.situations.devices),device_choice:"all",dow_options:_.union([{value:"",label:"Day"}],e.situations.dow),dow_choice:"all",time_options:_.union([{value:"",label:"Time"}],e.situations.time_periods),time_choice:"all"})}})),
w=j.SituationEditor=o.extend({initialize:function(a){var b=this;w.__super__.initialize.call(this,a);this.workspace=a.workspace;this.parentModel=a.parentModel;$(this.el).addClass("sz-curate-situation-editor");$(this.el).delegate(".szi-show-situations","click",function(){$(b.el).addClass("sz-curate-situation-editor-show-situations");$(b.el).removeClass("sz-curate-situation-editor-show-stations")});$(this.el).delegate(".szi-show-stations","click",function(){$(b.el).addClass("sz-curate-situation-editor-show-stations");
$(b.el).removeClass("sz-curate-situation-editor-show-situations")});this.model.get("station_ids").length>0||this.parentModel?$(this.el).addClass("sz-curate-situation-editor-show-stations"):$(this.el).addClass("sz-curate-situation-editor-show-situations");if(!this.parentModel)this.situationList=new x({situation:this.model,situation_name_singular:"Filter",situation_name_plural:"Filters"}),this.situationList.bind("situation-clicked",function(a){b._situationEditor(a)}),this.situationList.bind("situation-new",
function(){b._situationEditor(new c.Situation({site:e.site}))});this.stationList=new C({situation:this.model,workspace:this.workspace})},_situationEditor:function(a){a=new w({title:a.isNew()?"New Filter":a.get("title"),model:a,parentModel:this.model,workspace:this.workspace});g(a,this.workspace);this.workspace.addView(a,this)},render:function(){w.__super__.render.call(this);this.situationList&&this.stationList&&(this.editorEl().append($("<span>").addClass("szi-show-situations").text("Next Choice is a Filter")),
this.editorEl().append($("<span>").addClass("szi-show-stations").text("Next Choice is a Playlist")));this.situationList&&this.editorEl().append(this.situationList.render().el);this.editorEl().append(this.stationList.render().el);return this},doSave:function(a){this.parentModel?(this.parentModel.get("situations").getByCid(a)||this.parentModel.get("situations").add([a]),this.trigger("saved",a)):w.__super__.doSave.call(this,a)},doDelete:function(a){this.parentModel?this.parentModel.get("situations").remove(a):
w.__super__.doDelete.call(this,a)}}),C=j.SituationStationListView=a.SimpleCollectionView.extend(_.extend(_.clone(m),{template:sz.tmpl.curate.situationStationList,modelTemplate:sz.tmpl.curate.stationItem,css:"sz-curate-situation-station-list",elements:{".szi-query-input":"queryInput",".szi-list":"collectionContainerEl"},events:{"keyup .szi-query-input":"maybeSearch","click .szi-add-station":"handleAddStation","click .szi-organize-toggle":"organizeToggle","click .szi-organize-revert":"organizeRevert",
"click .szi-organize-save":"organizeSave","click .szi-organize-toggle-deleted":"organizeToggleDeleted"},states:{organize:{set:!1,onCss:"sz-curate-organize"},initializing:{set:!0,onCss:"sz-curate-initializing"}},initialize:function(a){var b=this;a.collection=new Backbone.Collection;a.modelContextName="station";C.__super__.initialize.call(this,a);_.bindAll(this,"syncStationIds");this.situation=a.situation;this.workspace=a.workspace;this.searchDelay=a.hasOwnProperty("searchDelay")?this.searchDelay:200;
this.query=a.query||"";this.queueSearch=_.debounce(this.runSearch,this.searchDelay);this.bind("organize-completed",function(a){b.handleOrganizeCompletion(a)});this.collection.bind("reset",this.syncStationIds);this.collection.bind("add",this.syncStationIds);this.collection.bind("remove",this.syncStationIds);this.situation.get("station_ids").length>0?c.Station.getBatch(this.situation.get("station_ids"),{success:function(a){b.collection.add(a.models);b.setState("initializing",!1)}}):b.setState("initializing",
!1)},syncStationIds:function(){this.situation.set({station_ids:this.collection.pluck("id")})},handleOrganizeCompletion:function(a){this.station_ids=_.map(a.keep,function(a){return a.id});this.collection.reset(stations)},handleAddStation:function(){if(this.getState("initializing"))return!1;var a=this,b=f.getInstance().getVisitor(),b=new r({user:b,workspace:this.workspace});this.organizeStop();this.workspace.addView(b,this);b.bind("station-clicked",function(b){a.collection.get(b.get("id"))||a.collection.add(b);
a.highlightModel(b)})},maybeSearch:function(){this.queueSearch()},runSearch:function(){this.syncCollectionContainerEl()},getMatchString:function(a){return a.get("name")+a.get("slug")},modelList:function(){return this.collection.filter(a.WordMatcher(this.queryInput().val(),this.getMatchString))},context:function(){var a=n.__super__.context.call(this);return a=_.extend(a,{view_id:this.cid,query:this.query})}})),B=j.CurateView=b.View.extend({template:sz.tmpl.curate.curate,css:"sz-curate-view",elements:{".szi-navigator":"navigatorEl",
".szi-workspace":"workspaceEl"},initialize:function(a){var b=this;B.__super__.initialize.call(this,a);this.workspaceView=new z({});this.tagListView=new q({workspace:this.workspaceView});this.galleryListView=new n({workspace:this.workspaceView});this.promotionListView=new A({workspace:this.workspaceView});this.situationListView=new x({workspace:this.workspaceView});this.tagListView.bind("tag-clicked",function(a){b.setTagWorkspace(a)});this.tagListView.bind("tag-added",function(a){b.setTagWorkspace(a)});
this.galleryListView.bind("gallery-clicked",function(a){b.setGalleryWorkspace(a)});this.galleryListView.bind("gallery-added",function(a){b.setGalleryWorkspace(a)});this.promotionListView.bind("product-clicked",function(a){b.setPromotionWorkspace(a)});this.situationListView.bind("situation-clicked",function(a){b.setSituationWorkspace(a)});this.situationListView.bind("situation-new",function(a){a=new c.Situation({site:e.site});b.setSituationWorkspace(a)})},setTagWorkspace:function(a){var b=this,c=new u({tag:a,
workspace:this.workspaceView});c.bind("destroy-request",function(){b.workspaceView.removeView(c)});this.workspaceView.setRootView(c)},setGalleryWorkspace:function(a){var b=this,c=new v({gallery:a,workspace:this.workspaceView});c.bind("destroy-request",function(){b.workspaceView.removeView(c)});this.workspaceView.setRootView(c)},setPromotionWorkspace:function(a){this.workspaceView.setRootView(new y({site:e.site,product:a,workspace:this.workspaceView}))},setSituationWorkspace:function(a){var b=this,
a=new w({title:a.isNew()?"New Situation":a.get("title"),model:a,workspace:this.workspaceView});g(a,this.workspaceView);a.bind("saved",function(a){b.situationListView.collection.add(a);b.situationListView.highlightModel(a)});this.workspaceView.setRootView(a)},context:function(){return{}},render:function(){var a=this;B.__super__.render.call(this);this.navigatorEl().append(this.tagListView.render().el).append(this.galleryListView.render().el).append(this.promotionListView.render().el);l=="songza"&&this.navigatorEl().append(this.situationListView.render().el);
this.navigatorEl().find(".szi-bd").hide();this.navigatorEl().find(".szi-bd").first().show();this.navigatorEl().find("h1").click(function(){a.navigatorEl().find(".szi-bd").not(this).hide();$(this).next().toggle("fast");return!1});this.workspaceEl().append(this.workspaceView.render().el);return this}});return j});define("songza/base",function(){var b={};b.Class=Toolbox.Base.extend({constructor:function(a){this.initialize(a)},initialize:function(a){this._plugins=a.plugins||[];this._initPlugins()},_getPlugins:function(){return this._plugins.splice()},_initPlugins:function(){var a=this;_.each(this._getPlugins(),function(b){b=new b({host:a});a[b.namespace]=b})},plug:function(a){this._plugins.push(a)},bind:Backbone.Events.bind,unbind:Backbone.Events.unbind,trigger:Backbone.Events.trigger});b.Class.extend=function(a,
b){var c=Toolbox.Base.extend.call(this,a,b);_.extend(c,{_plugins:[],plug:function(a){c._plugins.push(a)},getPlugins:function(){for(var a=[];c;){a=a.concat(c._plugins);break}return a}});return c};var c={create:"POST",update:"POST","delete":"DELETE",read:"GET"};b.Model=Backbone.Model.extend({sync:function(a,b,d){d=_.extend({type:c[a],dataType:"json",processData:!0},d);if(!d.url){var f;f=!b||!b.url?null:_.isFunction(b.url)?b.url():b.url;d.url=f||urlError()}if(!d.data&&b&&(a=="create"||a=="update")){d.contentType=
"application/x-www-form-urlencoded";var g,a=b.toJSON(),h=[];for(g in a){b=_.isArray(a[g])?a[g]:[a[g]];for(f=0;f<b.length;f++)h.push(encodeURIComponent(g)+"="+encodeURIComponent(b[f]))}g=h.join("&");d.data=g}return $.ajax(d)}});b.Plugin=Toolbox.Base.extend({namespace:"plugin",constructor:function(a){this.initialize(a)},initialize:function(a){this.host=a.host}});b.View=Backbone.View.extend({initialize:function(){_.bindAll(this,"sync","render");this._state={};this.bind("stateChange",this.sync);this._bindElements()},
_bindElements:function(){var a=this,b;if(this.elements)for(b in this.elements)this[this.elements[b]]=function(b){return function(){return a.$(b)}}(b)},$:function(a){return $(a,this.el)},getDefaultState:function(a){var b=this.states;if(b&&b.hasOwnProperty(a))return b[a].set;throw Error("Unrecognized state: "+a);},getState:function(a){if(this._state.hasOwnProperty(a))return this._state[a];return this.getDefaultState(a)},setState:function(a,b){this._state[a]=b;this.trigger("stateChange",a,b)},sync:function(){var a,
b,c,f=$(this.el),g=this.states;this.css&&(f.hasClass(this.css)||f.addClass(this.css));for(a in g)b=this.getState(a),c=g[a],c.onCss&&f.removeClass(c.onCss),c.offCss&&f.removeClass(c.offCss),f.addClass(b?c.onCss:c.offCss)},context:function(){return{}},render:function(){$(this.el).html(this.template(this.context()));this.sync();return this},destroy:function(){$(this.el).detach()}});return b});

