#= require public/custom/jquery.min.js
#= require jquery_ujs
#= require public/custom/popper.min.js
#= require public/bootstrap/bootstrap.min.js
#= require public/custom/plugins.min.js
#= require public/custom/custom.min.js



@scroll_ajust = () ->
  var_scroll = $(window).scrollTop()
  

@resize = () ->
  window.jQuery = window.$ = jQuery;
  
  $('.price_line_config_elements_column').css('height', $('.p_config_products_column').height());
  $(".with_ratio").each ->
    ratio = parseFloat($(this).data("ratio"))
    height = $(this).width()*ratio
    
    $(this).css("height",height+"px")
  
  $(".vertical_center").each ->
    margin= 1
    if $(window).width() > 800
      height = $(this).parent().height()
      margin = ((height-$(this).outerHeight())/ 2)

    $(this).css('margin-top', (margin-1)+"px")
    
  $('.column_inner').each ->
    $(this).css('margin-top', "0px")
    margin= 1
    if $(window).width() > 800
      height = $(this).closest('.row').height()
      margin = ((height-$(this).outerHeight())/ 2)

    $(this).css('margin-top', (margin-1)+"px")
    
    
  
  
$ ->
  $(window).on "resize", ->
    resize()


  $(document).on 'click', 'input.datepicker', ->
    $(this).datetimepicker(
      language: 'fr'
      pickTime: false
    ).focus();
    
  $(document).on 'click', 'input.datetimepicker', ->
    $(this).datetimepicker(
      use24hours: true
      format: 'DD/MM/YYYY HH:mm'
      minuteStepping:15
      language: 'fr'
    ).focus();
    
    
  $(document).on 'click', 'input.timepicker', ->
    $(this).datetimepicker(
      use24hours: true
      format: 'DD/MM/YYYY hh:mm'
      minuteStepping:15
      pickDate: false
      language: 'fr'
    ).focus();
  
  
  resize()
  
  $(".flashs .remove").click ->
    $(this).parent().parent().remove()
    
  $(document).on "scroll", ->
    scroll_ajust()
  
  $(document).on "touchmove", ->
    scroll_ajust()
  
  $(".top_link").click ->
    $('html,body').animate({scrollTop: 0},'slow');
  
  $('body').on "click",'.qte_more', ->
    qte = $(this).closest('.qte_wrapper').find('.qte')
    qte.val(parseFloat(qte.val())+1)
    qte.trigger 'change'
    return false

  $('body').on "click",'.qte_less', ->
    qte = $(this).closest('.qte_wrapper').find('.qte')
    new_qte = parseFloat(qte.val())-1
    if new_qte > 0
      qte.val(new_qte)
      qte.trigger 'change'
    
    return false
    
    



  



