mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-02-21 12:24:22 +01:00
Fixed cross origin issues and player layout
This commit is contained in:
parent
1edff69571
commit
3901313ed5
7 changed files with 38 additions and 14 deletions
|
@ -24,6 +24,7 @@ module.exports = angular.module('ponyfm').controller "application", [
|
||||||
$scope.notifActive = false
|
$scope.notifActive = false
|
||||||
$scope.nCount = 0
|
$scope.nCount = 0
|
||||||
$scope.nCountFormatted = '0'
|
$scope.nCountFormatted = '0'
|
||||||
|
$scope.isPlaying = false
|
||||||
$loadingElement = null
|
$loadingElement = null
|
||||||
loadingStateName = null
|
loadingStateName = null
|
||||||
|
|
||||||
|
@ -49,6 +50,14 @@ module.exports = angular.module('ponyfm').controller "application", [
|
||||||
if !$scope.notifActive
|
if !$scope.notifActive
|
||||||
notifications.markAllAsRead()
|
notifications.markAllAsRead()
|
||||||
|
|
||||||
|
$rootScope.$on 'player-starting-track', () ->
|
||||||
|
$scope.isPlaying = true
|
||||||
|
windowHeight = $(window).height()
|
||||||
|
$('.site-body').height windowHeight - ($('.top-bar').height() + $('.now-playing').height())
|
||||||
|
|
||||||
|
$rootScope.$on 'player-stopping', () ->
|
||||||
|
$scope.isPlaying = false
|
||||||
|
|
||||||
$rootScope.$on 'notificationsUpdated', () ->
|
$rootScope.$on 'notificationsUpdated', () ->
|
||||||
$scope.nCount = notifications.getUnreadCount()
|
$scope.nCount = notifications.getUnreadCount()
|
||||||
if $scope.nCount > 99
|
if $scope.nCount > 99
|
||||||
|
|
|
@ -27,16 +27,18 @@ module.exports = angular.module('ponyfm').controller "artist", [
|
||||||
artists.fetch($state.params.slug, force)
|
artists.fetch($state.params.slug, force)
|
||||||
.done (artistResponse) ->
|
.done (artistResponse) ->
|
||||||
$scope.artist = artistResponse.artist
|
$scope.artist = artistResponse.artist
|
||||||
|
$scope.headerStyle = {'background-image': createGradient(artistResponse.artist.avatar_colors[0], artistResponse.artist.avatar_colors[1])}
|
||||||
|
|
||||||
tempImg = document.createElement('img')
|
tempImg = document.createElement('img')
|
||||||
tempImg.setAttribute 'src', artistResponse.artist.avatars.small
|
tempImg.setAttribute 'src', artistResponse.artist.avatars.small + '?' + new Date().getTime()
|
||||||
tempImg.setAttribute 'crossOrigin', ''
|
tempImg.setAttribute 'crossOrigin', ''
|
||||||
tempImg.crossOrigin = 'Anonymous'
|
tempImg.crossOrigin = 'Anonymous'
|
||||||
|
|
||||||
tempImg.addEventListener 'load', ->
|
tempImg.addEventListener 'load', ->
|
||||||
colorThief = new ColorThief();
|
colorThief = new ColorThief();
|
||||||
palette = colorThief.getPalette(tempImg, 2)
|
palette = colorThief.getPalette(tempImg, 2)
|
||||||
|
|
||||||
$('.top-bar').css('background': selectHeaderColour(palette[0], palette[1]))
|
$('.top-bar').css('background': selectHeaderColour(palette[0], palette[1]))
|
||||||
$scope.headerStyle = {'background-image': createGradient(palette[0], palette[1])}
|
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
|
|
||||||
rgbArrayToCss = (array) ->
|
rgbArrayToCss = (array) ->
|
||||||
|
@ -45,8 +47,15 @@ module.exports = angular.module('ponyfm').controller "artist", [
|
||||||
hslArrayToCss = (array) ->
|
hslArrayToCss = (array) ->
|
||||||
'hsl(' + array[0] + ',' + array[1] + '%,' + array[2] + '%)'
|
'hsl(' + array[0] + ',' + array[1] + '%,' + array[2] + '%)'
|
||||||
|
|
||||||
|
hexToRgb = (hex) ->
|
||||||
|
h = '0123456789ABCDEF'
|
||||||
|
r = h.indexOf(hex[1]) * 16 + h.indexOf(hex[2])
|
||||||
|
g = h.indexOf(hex[3]) * 16 + h.indexOf(hex[4])
|
||||||
|
b = h.indexOf(hex[5]) * 16 + h.indexOf(hex[6])
|
||||||
|
return [r,g,b]
|
||||||
|
|
||||||
dimColor = (colour) ->
|
dimColor = (colour) ->
|
||||||
hsl = rgbToHsl(colour)
|
hsl = rgbToHsl(hexToRgb(colour))
|
||||||
|
|
||||||
if hsl[2] >= 50
|
if hsl[2] >= 50
|
||||||
hsl[2] = 50
|
hsl[2] = 50
|
||||||
|
@ -54,13 +63,13 @@ module.exports = angular.module('ponyfm').controller "artist", [
|
||||||
hsl[1] = 30
|
hsl[1] = 30
|
||||||
return hslToRgb(hsl)
|
return hslToRgb(hsl)
|
||||||
else
|
else
|
||||||
return colour
|
return hexToRgb(colour)
|
||||||
|
|
||||||
createGradient = (vib, dark) ->
|
createGradient = (vib, dark) ->
|
||||||
if $(window).width() <= 480
|
if $(window).width() <= 480
|
||||||
'linear-gradient(180deg, ' + rgbArrayToCss(vib) + ' 5%, ' + rgbArrayToCss(dimColor(dark)) + ' 95%)'
|
'linear-gradient(180deg, ' + vib + ' 5%, ' + rgbArrayToCss(dimColor(dark)) + ' 95%)'
|
||||||
else
|
else
|
||||||
'linear-gradient(170deg, ' + rgbArrayToCss(vib) + ' 15%, ' + rgbArrayToCss(dark) + ' 110%)'
|
'linear-gradient(170deg, ' + vib + ' 15%, ' + dark + ' 110%)'
|
||||||
|
|
||||||
findHighestSaturation = (hsl1, hsl2) ->
|
findHighestSaturation = (hsl1, hsl2) ->
|
||||||
if hsl1[1] > hsl2[1]
|
if hsl1[1] > hsl2[1]
|
||||||
|
|
|
@ -56,6 +56,7 @@ module.exports = angular.module('ponyfm').factory('player', [
|
||||||
onstop: () -> $rootScope.safeApply ->
|
onstop: () -> $rootScope.safeApply ->
|
||||||
track.isPlaying = false
|
track.isPlaying = false
|
||||||
self.isPlaying = false
|
self.isPlaying = false
|
||||||
|
$rootScope.$broadcast 'player-stopping'
|
||||||
|
|
||||||
onplay: () -> $rootScope.safeApply ->
|
onplay: () -> $rootScope.safeApply ->
|
||||||
track.isPlaying = true
|
track.isPlaying = true
|
||||||
|
|
|
@ -20,10 +20,7 @@ window.handleResize = () ->
|
||||||
isMobile = windowWidth <= 480
|
isMobile = windowWidth <= 480
|
||||||
$siteBody = $ '.site-body'
|
$siteBody = $ '.site-body'
|
||||||
|
|
||||||
if isMobile
|
$siteBody.height windowHeight - $('.top-bar').height()
|
||||||
$siteBody.height windowHeight - ($('.top-bar').height() + $('.now-playing').height() + $('.search').height())
|
|
||||||
else
|
|
||||||
$siteBody.height windowHeight - ($('.top-bar').height() + $('.now-playing').height())
|
|
||||||
|
|
||||||
$('.dropdown-menu').each () ->
|
$('.dropdown-menu').each () ->
|
||||||
$this = $ this
|
$this = $ this
|
||||||
|
|
5
resources/assets/styles/content.less
vendored
5
resources/assets/styles/content.less
vendored
|
@ -686,3 +686,8 @@ i {
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canvas {
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
9
resources/assets/styles/layout.less
vendored
9
resources/assets/styles/layout.less
vendored
|
@ -25,12 +25,10 @@ html body {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||||
padding: 0px !important;
|
padding: 0px !important;
|
||||||
overflow-x: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
|
|
||||||
|
|
||||||
.user-details {
|
.user-details {
|
||||||
float: right;
|
float: right;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
|
@ -80,6 +78,11 @@ header {
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
z-index: 1010;
|
z-index: 1010;
|
||||||
box-shadow: 0 0 6px rgba(0,0,0,0.3);
|
box-shadow: 0 0 6px rgba(0,0,0,0.3);
|
||||||
|
transform: translateY(70px);
|
||||||
|
transition: transform 0.5s @swift-ease-out;
|
||||||
|
&.playing {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
@endif
|
@endif
|
||||||
<a href="#" ng-click="toggleSearchBar()" class="search-button"><i class="material-icons">search</i></a>
|
<a href="#" ng-click="toggleSearchBar()" class="search-button"><i class="material-icons">search</i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="now-playing">
|
<div class="now-playing" ng-class="{'playing': isPlaying}">
|
||||||
<pfm-player></pfm-player>
|
<pfm-player></pfm-player>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
Loading…
Reference in a new issue