disabled buttons when cannot go forward/back

This commit is contained in:
nelsonlaquet 2013-09-01 14:35:05 -05:00
parent f4ee6c8add
commit 9e358a3fdc
3 changed files with 27 additions and 2 deletions

View file

@ -38,6 +38,10 @@ angular.module('ponyfm').factory('player', [
self.isPlaying = true
self.currentSound.play()
updateCanGo = () ->
self.canGoNext = self.playlistIndex < self.playlist.length - 1
self.canGoPrev = self.playlistIndex > 0
self =
ready: false
isPlaying: false
@ -47,6 +51,8 @@ angular.module('ponyfm').factory('player', [
playlistIndex: 0
volume: 0
readyDef: readyDef.promise()
canGoPrev: false
canGoNext: false
playPause: () ->
return if !self.ready
@ -58,6 +64,8 @@ angular.module('ponyfm').factory('player', [
self.currentSound.pause()
playNext: () ->
return if !self.canGoNext
self.currentSound.stop() if self.currentSound != null
self.playlistIndex++
if self.playlistIndex >= self.playlist.length
@ -68,8 +76,11 @@ angular.module('ponyfm').factory('player', [
return
play self.playlist[self.playlistIndex]
updateCanGo()
playPrev: () ->
return if !self.canGoPrev
self.currentSound.stop() if self.currentSound != null
self.playlistIndex--
if self.playlistIndex <= 0
@ -80,6 +91,7 @@ angular.module('ponyfm').factory('player', [
return
play self.playlist[self.playlistIndex]
updateCanGo()
seek: (progress) ->
return if !self.currentSound
@ -108,6 +120,7 @@ angular.module('ponyfm').factory('player', [
$rootScope.$broadcast 'player-starting-playlist', tracks
play tracks[index]
updateCanGo()
pfm.soundManager.done () ->
self.ready = true

View file

@ -112,6 +112,18 @@ body.is-logged {
}
}
&.disabled {
a {
color: #ccc;
cursor: default;
&:hover {
background: transparent;
color: #ccc;
}
}
}
&.volume {
position: relative;

View file

@ -4,14 +4,14 @@
<strong>{{player.currentTrack.progressSeconds | secondsDisplay}}</strong> /
<strong>{{player.currentTrack.duration | secondsDisplay}}</strong>
</li>
<li><a pfm-eat-click ng-click="playPrev()" class="previous" href="#"><i class="icon-fast-backward"></i></a></li>
<li ng-class="{disabled: !player.canGoPrev}"><a pfm-eat-click ng-click="playPrev()" class="previous" href="#"><i class="icon-fast-backward"></i></a></li>
<li>
<a pfm-eat-click ng-click="playPause()" class="play" href="#">
<i class="icon-pause" ng-show="player.currentTrack.isPlaying"></i>
<i class="icon-play" ng-hide="player.currentTrack.isPlaying"></i>
</a>
</li>
<li><a pfm-eat-click ng-click="playNext()" class="next" href="#"><i class="icon-fast-forward"></i></a></li>
<li ng-class="{disabled: !player.canGoNext}"><a pfm-eat-click ng-click="playNext()" class="next" href="#"><i class="icon-fast-forward"></i></a></li>
<li class="volume">
<a pfm-eat-click ng-click="" class="volume" href="#">
<i class="icon-volume-up"></i>