Pony.fm/resources/assets/scripts/shared/layout.coffee

78 lines
2.3 KiB
CoffeeScript
Raw Normal View History

# Pony.fm - A community for pony fan music.
# Copyright (C) 2015 Peter Deltchev
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2016-07-17 14:17:09 +02:00
window.isPlaying = false
2015-08-31 17:42:21 +02:00
window.handleResize = () ->
windowHeight = $(window).height()
windowWidth = $(window).width()
isMobile = windowWidth <= 480
2015-08-31 17:42:21 +02:00
$siteBody = $ '.site-body'
#if window.isPlaying
# $siteBody.height windowHeight - ($('.top-bar').height() + $('.now-playing').height())
#else
# $siteBody.height windowHeight - $('.top-bar').height()
2015-08-31 17:42:21 +02:00
$('.dropdown-menu').each () ->
$this = $ this
newMaxHeight = windowHeight - $this.parent().offset().top - $this.parent().height() - 5
$this.css
'max-height': newMaxHeight
2016-08-07 15:35:34 +02:00
$('.site-content').each () ->
2016-07-17 14:25:27 +02:00
$this = $ this
newHeight = windowHeight - $this.offset().top
if isMobile
newHeight = newHeight - 5
if window.isPlaying
newHeight = newHeight - $('.now-playing').height()
if newHeight > 0
$this.height newHeight
2015-08-31 17:42:21 +02:00
$('.revealable').each () ->
$this = $ this
return if $this.data 'real-height'
$this.data 'real-height', $this.height()
$this.css
2016-08-07 17:08:22 +02:00
maxHeight: '15em'
2015-08-31 17:42:21 +02:00
$this.find('.reveal').click (e) ->
e.preventDefault()
$this.css {height: 'auto'}
$(this).fadeOut 200
2016-08-07 15:35:34 +02:00
$('.blurred-background').each () ->
$this = $ this
$this.height $('.resource-details header').height() + 55
$('.resource-details .single-player button').each () ->
$this = $ this
$this.css 'top', $('.resource-details header').height() + 5
2015-08-31 17:42:21 +02:00
window.alignVertically = (element) ->
$element = $(element)
$parent = $element.parent()
$element.css 'top', $parent.height() / 2 - $element.height() / 2
window.handleResize()
$(window).resize window.handleResize
$('.site-content').empty()
2016-08-04 04:42:46 +02:00
$(document).ready () ->
$('body').removeClass('loading');