mirror of
https://github.com/danbee/mpd-client
synced 2025-03-04 08:39:09 +00:00
Root panel works as a component.
This commit is contained in:
parent
ff3bb3bdec
commit
013d79d721
@ -32,12 +32,15 @@
|
|||||||
.browser
|
.browser
|
||||||
position: absolute
|
position: absolute
|
||||||
height: 100%
|
height: 100%
|
||||||
|
width: 100%
|
||||||
@include transition(left 0.25s ease-in-out)
|
@include transition(left 0.25s ease-in-out)
|
||||||
|
ul, ol
|
||||||
|
width: 100%
|
||||||
ul.root, ol.artists, ol.albums
|
ul.root, ol.artists, ol.albums
|
||||||
@extend .list
|
@extend .list
|
||||||
ol.songs
|
ol.songs
|
||||||
@extend .song-list
|
@extend .song-list
|
||||||
div
|
panel
|
||||||
position: absolute
|
position: absolute
|
||||||
width: $interface-width
|
width: $interface-width
|
||||||
height: 100%
|
height: 100%
|
||||||
|
|||||||
39
assets/js/components/panel.js
Normal file
39
assets/js/components/panel.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
can.Component.extend({
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
console.log('Initializing');
|
||||||
|
},
|
||||||
|
|
||||||
|
tag: 'panel',
|
||||||
|
|
||||||
|
template: can.view('views/panel.mustache'),
|
||||||
|
|
||||||
|
scope: {
|
||||||
|
show: '@',
|
||||||
|
artist: '@',
|
||||||
|
album: '@',
|
||||||
|
title: function() {
|
||||||
|
if (this.show == 'root')
|
||||||
|
return 'Library';
|
||||||
|
},
|
||||||
|
fetchItems: {
|
||||||
|
root: new can.Map,
|
||||||
|
artists: Artist.findAll({}),
|
||||||
|
albums: Album.findAll({ artist: this.artist }),
|
||||||
|
songs: Song.findAll({ artist: this.artist, album: this.album })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
events: {
|
||||||
|
inserted: function() {
|
||||||
|
console.log('Panel inserted.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
helpers: {
|
||||||
|
renderItems: function() {
|
||||||
|
return can.view.render('views/library/' + this.show, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
@ -4,7 +4,7 @@ var Library = can.Control.extend({
|
|||||||
this.element = element;
|
this.element = element;
|
||||||
this.browser = new can.Model({ title: 'Library', currentPane: 0 });
|
this.browser = new can.Model({ title: 'Library', currentPane: 0 });
|
||||||
element.html(
|
element.html(
|
||||||
can.view('views/library.ejs', { browser: this.browser })
|
can.view('views/library.mustache', { 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]);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* CanJS - 2.0.3
|
* CanJS - 2.0.3
|
||||||
* http://canjs.us/
|
* http://canjs.us/
|
||||||
* Copyright (c) 2013 Bitovi
|
* Copyright (c) 2013 Bitovi
|
||||||
* Tue, 26 Nov 2013 18:21:40 GMT
|
* Thu, 19 Dec 2013 10:56:42 GMT
|
||||||
* Licensed MIT
|
* Licensed MIT
|
||||||
* Includes: can/view/ejs
|
* Includes: can/view/ejs
|
||||||
* Download from: http://canjs.com
|
* Download from: http://canjs.com
|
||||||
|
|||||||
6951
assets/js/libs/can.jquery.js
Normal file
6951
assets/js/libs/can.jquery.js
Normal file
File diff suppressed because it is too large
Load Diff
8
assets/js/libs/can.jquery.min.js
vendored
8
assets/js/libs/can.jquery.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,10 +1,11 @@
|
|||||||
//= require ./libs/jquery-2.0.3.min
|
//= require ./libs/jquery-2.0.3.min
|
||||||
//= require ./libs/can.jquery.min.js
|
//= require ./libs/can.jquery.js
|
||||||
//= require ./libs/can.ejs.js
|
//= require ./libs/can.ejs.js
|
||||||
|
|
||||||
//= require ./routes.js
|
//= require ./routes.js
|
||||||
//= require_tree ./models/
|
//= require_tree ./models/
|
||||||
//= require_tree ./helpers/
|
//= require_tree ./helpers/
|
||||||
//= require_tree ./controls/
|
//= require_tree ./controls/
|
||||||
|
//= require_tree ./components/
|
||||||
//= require_tree ./constructs/
|
//= require_tree ./constructs/
|
||||||
//= require ./application.js
|
//= require ./application.js
|
||||||
|
|||||||
@ -10,6 +10,6 @@
|
|||||||
data-current-pane="<%= browser.attr('currentPane') %>"
|
data-current-pane="<%= browser.attr('currentPane') %>"
|
||||||
style="left: -<%= browser.attr('currentPane') * 20 %>em;">
|
style="left: -<%= browser.attr('currentPane') * 20 %>em;">
|
||||||
|
|
||||||
<div class="root" style="left: 0;"></div>
|
<panel show="root" style="left: 0;"></panel>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
5
public/views/library.mustache
Normal file
5
public/views/library.mustache
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<div class="browser">
|
||||||
|
|
||||||
|
<panel show="root" style="left: 0;"></panel>
|
||||||
|
|
||||||
|
</div>
|
||||||
5
public/views/library/root.mustache
Normal file
5
public/views/library/root.mustache
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<ul class="root">
|
||||||
|
<li>{{can.route.link('Artists', { page: 'library', show: 'artists', pane: pane + 1 })}}</li>
|
||||||
|
<li>{{can.route.link('Albums', { page: 'library', show: 'albums', pane: pane + 1 })}}</li>
|
||||||
|
<li>{{can.route.link('Songs', { page: 'library', show: 'songs', pane: pane + 1 })}}</li>
|
||||||
|
</ul>
|
||||||
6
public/views/panel.mustache
Normal file
6
public/views/panel.mustache
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<header>
|
||||||
|
<a class="close" href="#!">Close</a>
|
||||||
|
<h1>{{title}}</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{{{renderItems}}}
|
||||||
Loading…
Reference in New Issue
Block a user