
=semantic_form_for( [:portlet, @block_content], :remote => true) do |f|
	-if !@block_content.id
		%table
			%tr
				%td Nombre de colonnes :
				%td
			
					%p
						=f.radio_button :nbr_columns, 1
						Une colonne
					%p
						=f.radio_button :nbr_columns, 2
						Deux colonnes
						
					%p
						=f.radio_button :nbr_columns, 3
						Trois colonnes
						
					%p
						=f.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);
			  
			  
				});
			
			
				
			});
	
	=f.hidden_field :row1, :id => "row1"
	=f.hidden_field :row2, :id => "row2"
	=f.hidden_field :row3, :id => "row3"
	=f.hidden_field :row4, :id => "row4"
	
	-if BlockContent::STYLES.size > 0
		Style :
		= f.select :style, BlockContent::STYLES
	%br
	
	
	= f.submit "Sauvegarder", :class => "btn btn-primary"
	

