mirror of
https://github.com/danbee/mpd-client
synced 2025-03-04 08:39:09 +00:00
Switching panels is now event driven!
This commit is contained in:
parent
60479a8d04
commit
900d6bad23
@ -46,7 +46,7 @@ can.Component.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
' showPanel': function(el, ev, data) {
|
' switchPanel': function(el, ev, data) {
|
||||||
this.scope.attr('currentDepth', data);
|
this.scope.attr('currentDepth', data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,13 +4,6 @@ can.Component.extend({
|
|||||||
|
|
||||||
template: can.view('views/panels/albums.mustache'),
|
template: can.view('views/panels/albums.mustache'),
|
||||||
|
|
||||||
init: function() {
|
|
||||||
var self = this;
|
|
||||||
Album.findAll({ artist: this.scope.artist }, function(data) {
|
|
||||||
self.scope.attr('items', data);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
scope: {
|
scope: {
|
||||||
depth: "@",
|
depth: "@",
|
||||||
artist: "@",
|
artist: "@",
|
||||||
@ -24,9 +17,19 @@ can.Component.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
events: {
|
||||||
|
init: function() {
|
||||||
|
var self = this;
|
||||||
|
Album.findAll({ artist: this.scope.artist }, function(data) {
|
||||||
|
self.scope.attr('items', data);
|
||||||
|
self.element.trigger('switchPanel', self.scope.depth);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
helpers: {
|
helpers: {
|
||||||
link: function(item) {
|
link: function(item) {
|
||||||
return can.route.link(item.name, {
|
return can.route.link(item.title, {
|
||||||
type: 'library',
|
type: 'library',
|
||||||
show: 'songs',
|
show: 'songs',
|
||||||
artist: item.artist,
|
artist: item.artist,
|
||||||
|
|||||||
@ -4,19 +4,20 @@ can.Component.extend({
|
|||||||
|
|
||||||
template: can.view('views/panels/artists.mustache'),
|
template: can.view('views/panels/artists.mustache'),
|
||||||
|
|
||||||
init: function() {
|
|
||||||
var self = this;
|
|
||||||
Artist.findAll({}, function(data) {
|
|
||||||
console.log(data);
|
|
||||||
self.scope.attr('items', data);
|
|
||||||
self._control.element.trigger('showPanel', self.scope.depth);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
scope: {
|
scope: {
|
||||||
depth: "@"
|
depth: "@"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
events: {
|
||||||
|
init: function() {
|
||||||
|
var self = this;
|
||||||
|
Artist.findAll({}, function(data) {
|
||||||
|
self.scope.attr('items', data);
|
||||||
|
self.element.trigger('switchPanel', self.scope.depth);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
helpers: {
|
helpers: {
|
||||||
link: function(item) {
|
link: function(item) {
|
||||||
return can.route.link(item.name, {
|
return can.route.link(item.name, {
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<ol class="albums">
|
<ol class="albums">
|
||||||
{{#each items}}
|
{{#items}}
|
||||||
<li>{{{link .}}}</li>
|
<li>{{{link .}}}</li>
|
||||||
{{/each}}
|
{{/items}}
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user