<div class="popover-content">
  <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-product-name-{{ product_id }}">
	{% for language in languages %}
	  <div class="input-group">
	    <span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>
		<input maxlength="255" type="text" name="product_description[{{ language.language_id }}][name]" value="{{ product_description[language.language_id] ? product_description[language.language_id].name }}" placeholder="{{ entry_name }}" class="form-control" />
	  </div>
	{% endfor %}
  </form>
</div>
<div class="popover-footer">
  <a data-form="form-product-name-{{ product_id }}" class="button-save btn btn-primary btn-sm"><i class="fa fa-save fa-fw"></i></a><a id="clear-product-name-{{ product_id }}" class="btn btn-danger btn-sm"><i class="fa fa-eraser fa-fw"></i></a>
</div>
<script type="text/javascript" src="view/javascript/bootstrap/js/bootstrap-maxlength.js"></script>
<script type="text/javascript"><!--
$('input[maxlength], textarea[maxlength]').maxlength();
//--></script>
<script type="text/javascript"><!--
$('.button-save').on('click', function() {	
	var name = $('input[name="product_description[{{ config_language_id }}][name]"]').val(); 
	$.ajax({
		url: $('#' + $(this).data('form')).attr('action'),
		type: 'post',
		dataType: 'json',
		data: $('#form-product-name-{{ product_id }} input[type=\'text\']'),
		success: function(json) {									
			if (json['error']) {								
				$('.messages-body').html('<div class="alert alert-danger alert-messages"><i class="fa fa-check-circle"></i> ' + json['error'] + '</div>');$('.maxy-backdrop, .messages-body').show().delay(1500).fadeOut(500);
			}
									
			if (json['success']) {
				$('.messages-body').html('<div class="alert alert-success alert-messages"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');$('.maxy-backdrop, .messages-body').show().delay(1000).fadeOut(500);			
				
				$('#product-name{{ product_id }}').html(name);
				$('#close-name-{{ product_id }}').trigger('click');
			}
		}
	});
}); 

$('#close-name-{{ product_id }}').on('click', function() {
	$('#form-product-name-{{ product_id }}').empty();
	$('#product-name-{{ product_id }}').popoverMaxy('hide');
});	

$('#product-name-{{ product_id }}').on('hide.bs.modal', function () {
	$('#form-product-name-{{ product_id }}').empty();
});

$('#clear-product-name-{{ product_id }}').on('click', function() {
	$('#form-product-name-{{ product_id }}').find('input').val('');
});  
//--></script>