mirror of
https://github.com/danbee/mpd-client
synced 2025-03-04 08:39:09 +00:00
Browser panes refactor.
This commit is contained in:
parent
1e22b99617
commit
5fcde8c60b
@ -14,6 +14,7 @@ body
|
|||||||
height: 100%
|
height: 100%
|
||||||
max-width: 320px
|
max-width: 320px
|
||||||
margin: 0 auto
|
margin: 0 auto
|
||||||
|
overflow: hidden
|
||||||
|
|
||||||
#content
|
#content
|
||||||
height: 100%
|
height: 100%
|
||||||
|
|||||||
@ -1,21 +1,25 @@
|
|||||||
#library
|
#library
|
||||||
background: white
|
background: white
|
||||||
display: none
|
|
||||||
position: absolute
|
position: absolute
|
||||||
top: 0
|
top: 100%
|
||||||
padding: 2.5em 0 0
|
|
||||||
height: 100%
|
height: 100%
|
||||||
width: 100%
|
width: 100%
|
||||||
z-index: 2
|
z-index: 2
|
||||||
&.show
|
@include transition(top 0.35s ease-in-out)
|
||||||
display: block
|
|
||||||
header
|
header
|
||||||
|
top: 100%
|
||||||
|
z-index: 1
|
||||||
@extend .header
|
@extend .header
|
||||||
|
@include transition(top 0.35s ease-in-out)
|
||||||
a.close
|
a.close
|
||||||
position: absolute
|
position: absolute
|
||||||
right: 10px
|
right: 10px
|
||||||
top: 8px
|
top: 8px
|
||||||
@include button
|
@include button
|
||||||
|
&.show
|
||||||
|
top: 0
|
||||||
|
header
|
||||||
|
top: 0
|
||||||
.browser
|
.browser
|
||||||
position: absolute
|
position: absolute
|
||||||
height: 100%
|
height: 100%
|
||||||
@ -26,11 +30,14 @@
|
|||||||
left: -$interface-width * 2
|
left: -$interface-width * 2
|
||||||
&[data-pane="4"]
|
&[data-pane="4"]
|
||||||
left: -$interface-width * 3
|
left: -$interface-width * 3
|
||||||
ul, ol
|
ol, ul
|
||||||
|
@extend .list
|
||||||
|
div
|
||||||
position: absolute
|
position: absolute
|
||||||
width: $interface-width
|
width: $interface-width
|
||||||
@extend .list
|
|
||||||
height: 100%
|
height: 100%
|
||||||
|
padding: 2.5em 0 0
|
||||||
|
overflow: auto
|
||||||
&:first-child
|
&:first-child
|
||||||
left: 0
|
left: 0
|
||||||
&:nth-child(2)
|
&:nth-child(2)
|
||||||
|
|||||||
@ -2,11 +2,11 @@ var Library = can.Control.extend({
|
|||||||
|
|
||||||
init: function(element, options) {
|
init: function(element, options) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.browser = new can.Model({ pane: 1 });
|
this.browser = new can.Model({ title: 'Library', pane: 1 });
|
||||||
element.html(
|
element.html(
|
||||||
can.view('views/library.ejs', { browser: this.browser })
|
can.view('views/library.ejs', { browser: this.browser })
|
||||||
);
|
);
|
||||||
var rootControl = new Pane('#library .root', { show: 'root' })
|
var rootControl = new Pane('#library .root', { show: 'root' });
|
||||||
this.panes = new can.List([rootControl]);
|
this.panes = new can.List([rootControl]);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -26,11 +26,27 @@ var Library = can.Control.extend({
|
|||||||
this.browser.attr('pane', this.browser.attr('pane') - 1);
|
this.browser.attr('pane', this.browser.attr('pane') - 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addPane: function(data) {
|
||||||
|
var newElement = document.createElement('div');
|
||||||
|
newElement.className = data.show;
|
||||||
|
$('.browser', this.element).append(newElement);
|
||||||
|
var newPane = new Pane(newElement, data);
|
||||||
|
this.panes.push(newPane);
|
||||||
|
this.nextPane();
|
||||||
|
},
|
||||||
|
|
||||||
'a.close click': 'hide',
|
'a.close click': 'hide',
|
||||||
|
|
||||||
|
'route': function(data) {
|
||||||
|
this.hide();
|
||||||
|
},
|
||||||
|
|
||||||
':page route': function(data) {
|
':page route': function(data) {
|
||||||
if (data.page == 'library') {
|
if (data.page == 'library') {
|
||||||
this.show();
|
this.show();
|
||||||
|
if (data.show) {
|
||||||
|
this.addPane(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +54,7 @@ var Library = can.Control.extend({
|
|||||||
|
|
||||||
var Pane = can.Control.extend({
|
var Pane = can.Control.extend({
|
||||||
|
|
||||||
init: function(element, data, pane) {
|
init: function(element, data) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.renderPane[data.show].call(this, data);
|
this.renderPane[data.show].call(this, data);
|
||||||
@ -51,13 +67,13 @@ var Pane = can.Control.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
artists: function(data) {
|
artists: function(data) {
|
||||||
Artist.findAll({}, renderCallback('artists'));
|
Artist.findAll({}, this.renderCallback('artists'));
|
||||||
},
|
},
|
||||||
albums: function(data) {
|
albums: function(data) {
|
||||||
Album.findAll({ artist: data.artist }, renderCallback('albums'));
|
Album.findAll({ artist: data.artist }, this.renderCallback('albums'));
|
||||||
},
|
},
|
||||||
songs: function(data) {
|
songs: function(data) {
|
||||||
Song.findAll({ artist: data.artist, album: data.album }, renderCallback('songs'));
|
Song.findAll({ artist: data.artist, album: data.album }, this.renderCallback('songs'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<header>
|
<header>
|
||||||
<a class="close" href="#!">Close</a>
|
<a class="close" href="#!">Close</a>
|
||||||
<h1>Library</h1>
|
<h1><%= browser.attr('title') %></h1>
|
||||||
</header>
|
</header>
|
||||||
<div class="browser" data-pane="<%= browser.attr('pane') %>">
|
<div class="browser" data-pane="<%= browser.attr('pane') %>">
|
||||||
<div class="root"></div>
|
<div class="root"></div>
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<ol class="albums">
|
<ol class="albums">
|
||||||
<% list(albums, function(album) { %>
|
<% list(items, function(album) { %>
|
||||||
<li id="<%= album.attr('id') %>">
|
<li id="<%= album.attr('id') %>">
|
||||||
<%== can.route.link(album.attr('title'), {
|
<%== can.route.link(album.attr('title'), {
|
||||||
page: 'library',
|
page: 'library',
|
||||||
show: 'songs',
|
show: 'songs',
|
||||||
artist: album.attr('artist'),
|
artist: album.attr('artist'),
|
||||||
album: album.attr('album')
|
album: album.attr('title')
|
||||||
}) %>
|
}) %>
|
||||||
</li>
|
</li>
|
||||||
<% }) %>
|
<% }) %>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<ol class="artists">
|
<ol class="artists">
|
||||||
<% list(artists, function(artist) { %>
|
<% list(items, function(artist) { %>
|
||||||
<li id="<%= artist.attr('id') %>">
|
<li id="<%= artist.attr('id') %>">
|
||||||
<%== can.route.link(artist.attr('name'), {
|
<%== can.route.link(artist.attr('name'), {
|
||||||
page: 'library',
|
page: 'library',
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<ol class="songs">
|
<ol class="songs">
|
||||||
<% list(songs, function(song) { %>
|
<% list(items, function(song) { %>
|
||||||
<li id="<%= song.attr('id') %>">
|
<li id="<%= song.attr('id') %>">
|
||||||
<%= song.attr('title') %>
|
<%= song.attr('title') %>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user