
=semantic_form_for( [:portlet, @block_content], :remote => true) do |form|
  -if !@block_content.id
    %table
      %tr
        %td Nombre de colonnes :
        %td
      
          %p
            =form.radio_button :nbr_columns, 1
            Une colonne
          %p
            =form.radio_button :nbr_columns, 2
            Deux colonnes
            
          %p
            =form.radio_button :nbr_columns, 3
            Trois colonnes
            
          %p
            =form.radio_button :nbr_columns, 4
            Quatre colonnes
  
  -else
    
    
    #column_sliders{:style => "height:22px;"}
      -for i in 1..(@block_content.nbr_columns.to_i-1)
    
        .column_slider{:"data-slider-value"=>eval("@block_content.row#{i}_value.to_i"), :style => "width:100%;"}
      

  
    :javascript
      function compareNumbers(a, b)
      {
          return a - b;
      }

      $(".column_slider").slider({
        max: 12,
        min: 0,
        step:1
      }).on("slide", function(ev) 
      {      
        var return_array = new Array();
      
        $("#column_sliders .column_slider").each(function(){      
          return_array.push($(this).data('slider').getValue());
        
        });
      
        var cols_values = [];
        prev_value= 0;
        $.each(return_array.sort(compareNumbers), function(index, value) {
          cols_values.push(value-prev_value);
        
        
          prev_value = value;
        
        });
      
        cols_values.push(12-prev_value);
      
        $.each(cols_values, function(index, value) {
        
          $("#row"+(index+1)).val(value);
        
        
        });
      
      
        
      });
  
  =form.hidden_field :row1, :id => "row1"
  =form.hidden_field :row2, :id => "row2"
  =form.hidden_field :row3, :id => "row3"
  =form.hidden_field :row4, :id => "row4"
  
  -if BlockContent::STYLES.size > 0
    Style :
    = form.select :style, BlockContent::STYLES
  =form.inputs do
    = form.input :center, :label => "Centrer le bloc au milieu de la page" 
    = form.input :image_file_id, :label => "Image de fond :" , :as => :qi_image_select
    = form.input :background_color, :label => "couleur de fond :" 
    = form.input :margin_top, :label => "Marge haut :" 
    = form.input :margin_bottom, :label => "Marge bas :" 
    = form.input :margin_left, :label => "Marge gauche :" 
    = form.input :margin_right, :label => "Marge droite :" 
    = form.input :padding_top, :label => "Marge intérieure haut :" 
    = form.input :padding_bottom, :label => "Marge intérieure bas :" 
    = form.input :padding_left, :label => "Marge intérieure gauche :" 
    = form.input :padding_right, :label => "Marge intérieure droite :"
  
  
