When changing song, if fancybox is open, opens the new song's cover art in it

- Fixes a bug with the Page service. There was an error when changing songs.
- Removes fancyboxOpenImage from utils, it's directly in the main controller so we can call it from the directive. It didn't need to be in a service anymore since we have a player directive.
This commit is contained in:
Hyzual 2015-01-11 13:21:07 +01:00
parent c478f0116f
commit 3324113af8
5 changed files with 28 additions and 18 deletions

View file

@ -148,7 +148,20 @@ angular.module('JamStash')
}; };
$scope.fancyboxOpenImage = function (url) { $scope.fancyboxOpenImage = function (url) {
utils.fancyboxOpenImage(url); $.fancybox.open({
helpers : {
overlay : {
css : {
'background' : 'rgba(0, 0, 0, 0.15)'
}
}
},
hideOnContentClick: true,
type: 'image',
openEffect: 'none',
closeEffect: 'none',
href: url
});
}; };
$('#audiocontainer .scrubber').mouseover(function (e) { $('#audiocontainer .scrubber').mouseover(function (e) {

View file

@ -49,7 +49,7 @@ angular.module('jamstash.page', ['jamstash.settings', 'jamstash.utils'])
} }
t.push(" "); t.push(" ");
if (timer !== undefined) { if (timer !== undefined) {
timer.cancel(); $interval.cancel(timer);
} }
timer = $interval(function () { timer = $interval(function () {
var f = shift[opts.dir]; var f = shift[opts.dir];

View file

@ -8,22 +8,6 @@ angular.module('jamstash.utils', ['jamstash.settings'])
.service('utils', ['$rootScope', 'globals', function ($rootScope, globals) { .service('utils', ['$rootScope', 'globals', function ($rootScope, globals) {
'use strict'; 'use strict';
this.fancyboxOpenImage = function (url) {
$.fancybox.open({
helpers : {
overlay : {
css : {
'background' : 'rgba(0, 0, 0, 0.15)'
}
}
},
hideOnContentClick: true,
type: 'image',
openEffect: 'none',
closeEffect: 'none',
href: url
});
};
this.safeApply = function (fn) { this.safeApply = function (fn) {
var phase = $rootScope.$root.$$phase; var phase = $rootScope.$root.$$phase;
if (phase === '$apply' || phase === '$digest') { if (phase === '$apply' || phase === '$digest') {

View file

@ -92,6 +92,9 @@ angular.module('jamstash.player.directive', ['jamstash.player.service', 'jamstas
if(newSong !== undefined) { if(newSong !== undefined) {
scope.currentSong = newSong; scope.currentSong = newSong;
Page.setTitleSong(newSong); Page.setTitleSong(newSong);
if($.fancybox.isOpen) {
scope.fancyboxOpenImage(newSong.coverartfull);
}
$player.jPlayer('setMedia', {'mp3': newSong.url}); $player.jPlayer('setMedia', {'mp3': newSong.url});
if(playerService.loadSong === true) { if(playerService.loadSong === true) {
// Do not play, only load // Do not play, only load

View file

@ -45,6 +45,7 @@ describe("jplayer directive", function() {
deferred = $q.defer(); deferred = $q.defer();
}); });
spyOn(Page, "setTitleSong"); spyOn(Page, "setTitleSong");
$.fancybox.isOpen = false;
$player = element.children('div'); $player = element.children('div');
}); });
@ -94,6 +95,15 @@ describe("jplayer directive", function() {
expect(notifications.showNotification).toHaveBeenCalledWith(playingSong); expect(notifications.showNotification).toHaveBeenCalledWith(playingSong);
}); });
}); });
it("if fancybox is open, it sets it up with the new song's cover art", function() {
$.fancybox.isOpen = true;
scope.fancyboxOpenImage = jasmine.createSpy("fancyboxOpenImage");
scope.$apply();
expect(scope.fancyboxOpenImage).toHaveBeenCalledWith(playingSong.coverartfull);
});
}); });
it("When the player service's restartSong flag is true, it restarts the current song, resets the restart flag to false and resets the scrobbled flag to false", function() { it("When the player service's restartSong flag is true, it restarts the current song, resets the restart flag to false and resets the scrobbled flag to false", function() {