diff --git a/assets/css/includes/button.css.sass b/assets/css/includes/button.css.sass index 009939a..25e2915 100644 --- a/assets/css/includes/button.css.sass +++ b/assets/css/includes/button.css.sass @@ -3,3 +3,5 @@ background: none color: $highlight font-size: 0.8em + text-decoration: none + padding: 5px diff --git a/assets/css/library.css.sass b/assets/css/library.css.sass index f6174c1..a01ba9b 100644 --- a/assets/css/library.css.sass +++ b/assets/css/library.css.sass @@ -16,3 +16,26 @@ right: 10px top: 8px @include button + .browser + position: absolute + height: 100% + @include transition(left 0.25s ease-in-out) + &[data-pane="2"] + left: -$interface-width + &[data-pane="3"] + left: -$interface-width * 2 + &[data-pane="4"] + left: -$interface-width * 3 + ul, ol + position: absolute + width: $interface-width + @extend .list + height: 100% + &:first-child + left: 0 + &:nth-child(2) + left: $interface-width + &:nth-child(3) + left: $interface-width * 2 + &:nth-child(4) + left: $interface-width * 3 diff --git a/assets/js/controls/library.js b/assets/js/controls/library.js index 0067d52..9f5fb7f 100644 --- a/assets/js/controls/library.js +++ b/assets/js/controls/library.js @@ -1,10 +1,13 @@ var Library = can.Control.extend({ init: function(element, options) { - this.element = element + this.element = element; + this.browser = new can.Model({ pane: 1 }); element.html( - can.view('views/library.ejs') + can.view('views/library.ejs', { browser: this.browser }) ); + var rootControl = new Pane('#library .root', { show: 'root' }) + this.panes = new can.List([rootControl]); }, show: function() { @@ -15,13 +18,55 @@ var Library = can.Control.extend({ $(this.element).removeClass('show'); }, + nextPane: function() { + this.browser.attr('pane', this.browser.attr('pane') + 1); + }, + + previousPane: function() { + this.browser.attr('pane', this.browser.attr('pane') - 1); + }, + 'a.close click': 'hide', ':page route': function(data) { - console.log(data); if (data.page == 'library') { this.show(); } } }); + +var Pane = can.Control.extend({ + + init: function(element, data, pane) { + this.element = element; + this.data = data; + this.renderPane[data.show].call(this, data); + }, + + renderPane: { + root: function() { + this.element.html( + can.view('views/library/root.ejs', {}) + ); + }, + artists: function(data) { + Artist.findAll({}, renderCallback('artists')); + }, + albums: function(data) { + Album.findAll({ artist: data.artist }, renderCallback('albums')); + }, + songs: function(data) { + Song.findAll({ artist: data.artist, album: data.album }, renderCallback('songs')); + } + }, + + renderCallback: function(type) { + return function(items) { + $(this.element).html( + can.view('views/library/' + type + '.ejs', { items: items }) + ); + }.bind(this) + } + +}); diff --git a/lib/mpd_client/song.rb b/lib/mpd_client/song.rb index d50c8df..8af0ed2 100644 --- a/lib/mpd_client/song.rb +++ b/lib/mpd_client/song.rb @@ -24,7 +24,7 @@ module MPDClient end def <=>(other) - [artist, album, title] <=> [other.artist, other.album, other.title] + [artist, album, track] <=> [other.artist, other.album, other.track] end def to_h diff --git a/public/views/library.ejs b/public/views/library.ejs index daa04ed..9770005 100644 --- a/public/views/library.ejs +++ b/public/views/library.ejs @@ -2,6 +2,7 @@ Close