vita_app/app/assets/javascripts/public.js.coffee
Nicolas Bally 1d3af87d4c initial
2016-04-28 10:07:08 +02:00

96 lines
1.7 KiB
CoffeeScript
Executable File

#= require jquery
#= require jquery_ujs
#= require vendor/jquery-ui
#= require ./vendor/jquery.flexslider
#= require ./vendor/jquery.elevatezoom
#=require ./popover
$ ->
$(".menu_burger").click ->
$("#cat_menu_overflow").fadeIn 200
$("#cat_menu").fadeIn()
return false;
$("#cat_menu_overflow").click ->
$("#cat_menu_overflow").fadeOut()
$("#cat_menu").fadeOut()
return false;
$(".menu_hide").click ->
$("#cat_menu_overflow").fadeOut()
$("#cat_menu").fadeOut()
return false;
top = 0
resize = () ->
$(".menu_itemlink_content").css("height", "auto");
$(".menu_itemlink_content").each ->
ratio = parseFloat($(this).data("ratio"))
height = $(this).width()*ratio
$(this).css("height",height+"px")
title_height = $(this).find(".title").height()
margin = (height-title_height-2)/ 2
$(this).find(".title").css("margin-top",margin+"px")
$("#home_slider").css("height", ($("#main").width()*(640 / 1200))+"px")
$(window).on "resize", ->
resize()
resize()
$(document).on "scroll", ->
scroll_ajust()
$(document).on "touchmove", ->
scroll_ajust()
scroll_ajust = () ->
var_scroll = $(window).scrollTop()
cat_menu_height = $("#cat_menu .inner").outerHeight()
max_scroll = ($(document).height() - $(window).height() - $("#footer").outerHeight())
cat_menu_top = 0
if var_scroll > top
$(".top_bar").addClass("move_top")
else
$(".top_bar").removeClass("move_top")
if var_scroll > 100
$(".top_link").css
"opacity" : 1
else
$(".top_link").css
"opacity" : 0
$(".top_link").click ->
$('html,body').animate({scrollTop: 0},'slow');