Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ <h4 id="playerUser" class="player_user"></h4>
<span class="player_nextSong" ng-click="nextSong($event)">
<i class="fa fa-step-forward thin"></i>
</span>
<span class="player_lock" ng-click="lock($event)">
<i class="fa fa-lock thin"></i>
</span>
<span class="player_repeat" ng-click="repeat($event)">
<i class="fa fa-repeat thin"></i>
<small class="player_repeat_locked">1</small>
</span>
<span class="player_shuffle" ng-click="shuffle($event)">
<i class="fa fa-random thin"></i>
Expand Down
27 changes: 18 additions & 9 deletions app/public/js/common/playerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ app.factory('playerService', function($rootScope, $log, $timeout, $window, $stat
$rootScope.isPlaylistPlaying = false;
$rootScope.shuffle = false;
$rootScope.repeat = false;
$rootScope.repeatLocked = false;
$rootScope.lock = false;

/**
* Get a number between min index and max index
Expand Down Expand Up @@ -240,13 +240,17 @@ app.factory('playerService', function($rootScope, $log, $timeout, $window, $stat
* @method playPrevSong
*/
player.playPrevSong = function() {
if ( $rootScope.shuffle ) {

if ( $rootScope.lock ) {
return false;
}

if ( $rootScope.shuffle && ! $rootScope.repeat ) {
shuffle();
} else if ( ! $rootScope.repeat && ! $rootScope.repeatLocked ) {
} else if ( ! $rootScope.repeat ) {
queueService.prev();
} else if ( $rootScope.repeatLocked ) {
return false;
}

this.playNewSong();
};

Expand All @@ -257,13 +261,18 @@ app.factory('playerService', function($rootScope, $log, $timeout, $window, $stat
* @method playPrevSong
*/
player.playNextSong = function() {
if ( $rootScope.shuffle ) {

$log.log('lock', $rootScope.lock);
if ( $rootScope.lock ) {
return false;
}

if ( $rootScope.shuffle && ! $rootScope.repeat ) {
shuffle();
} else if ( ! $rootScope.repeat && ! $rootScope.repeatLocked ) {
} else if ( ! $rootScope.repeat ) {
queueService.next();
} else if ( $rootScope.repeatLocked ) {
return false;
}

this.playNewSong();
};

Expand Down
34 changes: 18 additions & 16 deletions app/public/js/player/playerCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,33 @@ app.controller('PlayerCtrl', function ($scope, $rootScope, playerService, hotkey
}
};

$scope.lock = function($event) {
$event.currentTarget.classList.toggle('active');

$log.log('lock', $rootScope.lock);

if ( $rootScope.lock ) {
$rootScope.lock = false;
} else {
$rootScope.lock = true;
}

$log.log('lock end', $rootScope.lock);
};

$scope.repeat = function($event) {
var button = $event.currentTarget;
$event.currentTarget.classList.toggle('active');

if ( button.classList.contains('active') &&
button.classList.contains('locked')
) { // both states are true therefore remove classes
button.classList.remove('active', 'locked');
$rootScope.repeat = false;
$rootScope.repeatLocked = false;
} else if ( button.classList.contains('active') &&
! button.classList.contains('locked')
) { // active state is true but locked is false, add locked class
button.classList.add('locked');
if ( $rootScope.repeat ) {
$rootScope.repeat = false;
$rootScope.repeatLocked = true;
} else if ( ! button.classList.contains('active') ) { // both states are false, add active class
button.classList.add('active');
} else {
$rootScope.repeat = true;
$rootScope.repeatLocked = false;
}
};

$scope.shuffle = function($event) {
$event.currentTarget.classList.toggle('active');

if ( $rootScope.shuffle ) {
$rootScope.shuffle = false;
} else {
Expand All @@ -92,7 +95,6 @@ app.controller('PlayerCtrl', function ($scope, $rootScope, playerService, hotkey
};

$scope.toggleQueue = function($event) {

$event.currentTarget.classList.toggle('active');
document.querySelector('.queueList').classList.toggle('active');
};
Expand Down
18 changes: 1 addition & 17 deletions app/public/stylesheets/sass/_components/_player.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
flex-grow: 1;
}

.player_lock,
.player_repeat,
.player_shuffle,
.player_queueList {
Expand All @@ -209,21 +210,4 @@
&.active .fa {
color: $scColor;
}
}

.player_repeat {
position: relative;

& .player_repeat_locked {
display: none;
position: absolute;
bottom: 0;
right: 4px
}

&.locked {
& .player_repeat_locked {
display: block;
}
}
}