1
0
mirror of https://github.com/danbee/mpd-client synced 2025-03-04 08:39:09 +00:00

Implement back button.

This commit is contained in:
Dan Barber 2014-05-01 14:00:30 +01:00
parent 9d3916c892
commit ed34cf4c91
2 changed files with 17 additions and 2 deletions

View File

@ -1,11 +1,14 @@
mpdClient.controller('library', function ($scope, api) {
$scope.show = false
$scope.title = 'Library'
$scope.$on('library:show', function () { $scope.show = true })
$scope.hide = function () { $scope.show = false }
var rootPane = {
path: '/root',
title: 'Library',
entries: [
{ label: 'Artists', path: '/artists' },
@ -26,12 +29,23 @@ mpdClient.controller('library', function ($scope, api) {
$scope.newPane = function (path, params, queryParams) {
$scope.panes.push({
path: path,
title: params.title,
entries: api.getItems(path).query(queryParams)
})
$scope.currentPaneIndex += 1
$scope.title = params.title
$scope.currentPanelTemplate = 'panels' + path + '.html'
}
$scope.back = function() {
lastPane = $scope.panes.pop()
currentPane = $scope.panes[$scope.panes.length - 1]
$scope.currentPaneIndex -= 1
$scope.title = currentPane.title
$scope.currentPanelTemplate = 'panels' + currentPane.path + '.html'
}
})

View File

@ -1,7 +1,8 @@
<div id="library" ng-controller="library" ng-class="{ show: show }">
<header>
<a class="back" href="#" ng-click="back()" ng-if="currentPaneIndex > 0">Back</a>
<a class="close" href="#" ng-click="hide()">Close</a>
<h1>Library</h1>
<h1>{{ title }}</h1>
</header>
<ng-include src="currentPanelTemplate"></ng-include>
</div>