<div class="popover-content">
  <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-attribute-name-{{ attribute_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 type="text" name="attribute_description[{{ language.language_id }}][name]" value="{{ attribute_description[language.language_id] ? attribute_description[language.language_id].name }}" placeholder="{{ entry_name }}" class="form-control" />
	  </div>
	{% endfor %}
  </form>
</div>
<div class="popover-footer">
  <a data-form="form-attribute-name-{{ attribute_id }}" class="button-save btn btn-primary btn-sm"><i class="fa fa-save fa-fw"></i></a><a id="clear-attribute-name-{{ attribute_id }}" class="btn btn-danger btn-sm"><i class="fa fa-eraser fa-fw"></i></a>
</div>
<script type="text/javascript"><!--
$('.button-save').on('click', function() {	
	var name = $('input[name="attribute_description[{{ config_language_id }}][name]"]').val(); 	
	$.ajax({
		url: $('#' + $(this).data('form')).attr('action'),
		type: 'post',
		dataType: 'json',
		data: $('#form-attribute-name-{{ attribute_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);			
								
				$('#attribute-name{{ attribute_id }}').html(name);
				$('#close-name-{{ attribute_id }}').trigger('click');
			}
		}
	});
}); 

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

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

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