new_ads_app/app/assets/javascripts/application.coffee
2014-08-19 09:51:36 +02:00

220 lines
4.7 KiB
CoffeeScript

#= require jquery
#= require jquery_ujs
#= require jquery.superslides
#= require jquery.easing.1.3
#= require jquery.animate-enhanced.min
#= require jquery.tagcanvas
#= require jquery.bxslider.min
@scrollToAnchor = (aid) ->
aTag = $("#" + aid )
$("html,body").animate({scrollTop: aTag.offset().top}, 1000)
return
bottom = 0
prev_link = ""
$("document").ready ->
position_img_now = ->
$("#large .large-img").css("margin-top", (( $(window).height() - $("#large .large-img").height() - 100) / 2 )+"px")
position_img = ->
$("#large .large-img").one "load", ->
position_img_now()
$("#rea-gal a").click ->
prev_link = $(this)
$("body").append "<div id='large'></div>"
$("#large").fadeIn(500)
$("#large").append "<img src='/arrow-next.png' class='next' />"
$("#large").append "<img src='/arrow-prev.png' class='prev' />"
$("#large").append "<img src="+$(this).attr("href")+" class='large-img' />"
position_img();
false
$("body").on "click", "#large", ->
$(this).fadeOut 300, ->
$(this).remove()
$("body").on "click" ,"#large .prev",->
if prev_link.prev("a").length > 0
link = prev_link.closest("a").prev("a")
else
link = prev_link.closest("div").children("a:last")
#titre = photo.find("h3")
$('#large .large-img').fadeOut 300, ->
$('#large .large-img').attr("src", link.attr("href"))
$('#large .large-img').fadeIn()
position_img();
prev_link = link
false
$("body").on "click" ,"#large .next",->
if prev_link.next("a").length > 0
link = prev_link.closest("a").next("a")
else
link = prev_link.closest("div").children("a:first")
#titre = photo.find("h3")
$('#large .large-img').fadeOut 300, ->
$('#large .large-img').attr("src", link.attr("href"))
$('#large .large-img').fadeIn()
position_img();
prev_link = link
false
$('.gal').bxSlider
adaptiveHeight: true,
auto: true,
speed:1000,
pause:5000,
# $(".infos").hide();
$(".infos-button").click ->
$(this).next(".infos").slideToggle()
$("html,body").animate({scrollTop: ($(this).offset().top-60)}, 500)
left =0
top = 0
offset= 0
resize = ->
$("#rea-gal img").css "width", ($(window).width() - 6 * 5 )/ 5
$(".slider").css({"height": ($(window).height())+"px","width": $(window).width()+"px" })
$("#brainstorming").css({"height": ($(window).height())+"px","width": $(window).width()+"px" })
$("#myCanvas").attr({height: ($(window).height()-160),"width": $(window).width() })
$("#menu-container").css("top",($(window).height()-50)+"px")
$("#main").css("top",($(window).height()))
$("#logo").one("load", ->
#offset = $("#logo").offset().top-100
left = ($(window).width() - $("#logo").width()) / 2
bottom = ($(window).height() - $("#logo").height() - $("#baseline").height() - 40)/ 1.10
$("#logo").css({"top": bottom+"px","left": left+"px"})
$("#baseline").css({"top": (bottom+$("#logo").height())+"px","left": left+"px"})
#baseline
antiGrav = (ele) -> # anti-gravity floating on an element ;)
distance = 5
$(ele).animate
left: "=" + top + distance + "px"
, 2000, "easeInOutBounce", ->
$(ele).animate
left: "=" + top - distance + "px"
, 1800, "easeInOutBounce", ->
antiGrav ele
return
return
return
antiGrav2 = (ele) -> # anti-gravity floating on an element ;)
distance = 4
$(ele).animate
top: "-=" + distance + "px"
, 2000, "swing", ->
$(ele).animate
top: "+=" + distance + "px"
, 2300, "swing", ->
antiGrav2 ele
return
return
return
antiGrav2(".wide-container")
).each ->
$(this).load() if @complete
return
position_img_now();
$(window).on "scroll", ->
top = $(window).scrollTop()
#$(".wide-container").css("top", top-10)
if $(window).scrollTop() > ($(window).height()-50)
$("#menu").css("position", "fixed")
else
$("#menu").css("position", "relative")
if $(window).scrollTop() > bottom-100
$("#logo").fadeOut()
$("#baseline").fadeOut()
$("#logo-min").fadeIn()
else if $(window).scrollTop() < bottom+100
$("#logo").fadeIn()
$("#baseline").fadeIn()
$("#logo-min").fadeOut()
resize()
$(window).on "resize", ->
resize()