Permalink
Browse files

Fix current playlist state bug on create. Separate out subscription p…

…laylists. Disable GA while PLAYLICK.debug is on
  • Loading branch information...
1 parent ed72a9e commit 79e5a322456cbf621510db30bd73e6ee5072d1f8 @jwheare committed Dec 17, 2009
Showing with 40 additions and 18 deletions.
  1. +16 −9 public/index.html
  2. +24 −9 src/js/controllers/playlist.controller.js
View
25 public/index.html
@@ -44,6 +44,11 @@ <h1 id="albumsTitle">Your favourite albums</h1>
<div class="sidebar_list">
<ul class="playlists" id="albums"></ul>
</div>
+
+ <h1 id="subscriptionsTitle">Your subscriptions</h1>
+ <div class="sidebar_list">
+ <ul class="playlists" id="subscriptions"></ul>
+ </div>
</div>
<div id="main">
@@ -260,15 +265,17 @@ <h1 id="createPlaylist">Create a new playlist</h1>
</script>
<script type="text/javascript">
-var _gaq = _gaq || [];
-_gaq.push(['_setAccount', 'UA-174601-6']);
-_gaq.push(['_trackPageview']);
-(function() {
- var ga = document.createElement('script');
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- ga.setAttribute('async', 'true');
- document.documentElement.firstChild.appendChild(ga);
-})();
+ if (!PLAYLICK.debug) {
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-174601-6']);
+ _gaq.push(['_trackPageview']);
+ (function() {
+ var ga = document.createElement('script');
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ ga.setAttribute('async', 'true');
+ document.documentElement.firstChild.appendChild(ga);
+ })();
+ }
</script>
</body>
</html>
View
33 src/js/controllers/playlist.controller.js
@@ -6,6 +6,8 @@ function Playlist () {
this.playlistsSidebarList = $('#playlists');
this.albumsSidebarTitleElem = $('h1#albumsTitle');
this.albumsSidebarList = $('#albums');
+ this.subscriptionsSidebarTitleElem = $('h1#subscriptionsTitle');
+ this.subscriptionsSidebarList = $('#subscriptions');
this.loadingPlaylistsElem = $('#loading_playlists');
this.createTitleElem = $('#createPlaylist');
this.headerElem = $('#playlistHeader');
@@ -93,6 +95,9 @@ Playlist.prototype = {
if (playlist.isAlbum()) {
this.albumsSidebarList.append(playlist.element);
this.albumsSidebarTitleElem.show();
+ } else if (playlist.isSubscription()) {
+ this.subscriptionsSidebarList.append(playlist.element);
+ this.subscriptionsSidebarTitleElem.show();
} else {
this.playlistsSidebarList.append(playlist.element);
}
@@ -106,17 +111,25 @@ Playlist.prototype = {
} else {
var playlistElements = [];
var albumElements = [];
+ var subscriptionElements = [];
var that = this;
var playlists = MODELS.Playlist.fetchAll(function callback (playlist) {
+ var element = playlist.element.get()[0];
if (playlist.isAlbum()) {
- albumElements.push(playlist.element.get()[0]);
+ albumElements.push(element);
+ } else if (playlist.isSubscription()) {
+ subscriptionElements.push(element);
} else {
- playlistElements.push(playlist.element.get()[0]);
+ playlistElements.push(element);
}
});
- if (playlistElements) {
+ if (playlistElements.length) {
this.playlistsSidebarList.append(playlistElements);
}
+ if (subscriptionElements.length) {
+ this.subscriptionsSidebarTitleElem.show();
+ this.subscriptionsSidebarList.append(subscriptionElements);
+ }
if (albumElements.length) {
this.albumsSidebarTitleElem.show();
this.albumsSidebarList.append(albumElements);
@@ -133,6 +146,9 @@ Playlist.prototype = {
if (playlist) {
this.current = playlist;
playlistItem = playlist.element;
+ // Update metadata and update sidebar
+ this.loadMetadata();
+ this.updateSidebarTitle(playlist);
} else {
// Create the playlist object
this.current = new MODELS.Playlist();
@@ -174,8 +190,6 @@ Playlist.prototype = {
this.setCurrent(playlist);
// Hide add track details
this.addTrackTable.hide();
- // Load metadata and track form
- this.loadMetadata();
// Hide footer and add track form while loading tracks
this.hideFooter();
this.addTrackForm.hide();
@@ -444,16 +458,13 @@ Playlist.prototype = {
this.current.save();
// Add the track to the playlist in the DOM
this.trackListElem.append(playlist_track.element);
- // Show playlist actions and footer
- this.loadFooter();
// Resolve
PLAYDAR.resolve_track(playlist_track);
},
onSave: function (playlist) {
if (playlist == this.current) {
- this.loadMetadata();
- this.updateSidebarTitle(playlist);
+ this.setCurrent(playlist);
PLAYDAR.showSM2Container();
}
},
@@ -500,6 +511,10 @@ Playlist.prototype = {
if (!this.albumsSidebarList.find('li').size()) {
this.albumsSidebarTitleElem.hide();
}
+ } else if (playlist.isSubscription()) {
+ if (!this.subscriptionsSidebarList.find('li').size()) {
+ this.subscriptionsSidebarTitleElem.hide();
+ }
}
if (playlist == this.current) {
this.create();

0 comments on commit 79e5a32

Please sign in to comment.