<div class="modal-header">
  <button type="button" class="pull-right btn btn-danger btn-sm" data-dismiss="modal" aria-hidden="true"><i class="fa fa-close"></i></button>
  <h4 class="modal-title">{{ entry_meta_data }}</h4>
</div>
<div class="modal-body" id="body-mass-product-meta-title">
  <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-mass-product-meta-data" class="form-horizontal">	
	<div class="alert alert-info">{{ text_generator_info }}</div>
	<div class="form-group">
	  <label class="col-sm-2 control-label">{{ entry_generator }}</label>
	  <div class="col-sm-10">
		<div class="input-group"><span class="input-group-addon"><i class="fa fa-random fa-fw"></i></span>
		  <select name="generator_meta_data" class="form-control">
		    <option value="1">{{ text_yes }}</option>
			<option value="0" selected="selected">{{ text_no }}</option>
		  </select>
		</div>
	  </div>
	</div>
	<div class="form-group{% if seo_type == 'meta_title' %} required{% endif %}" id="meta-data-custom">	
	  <label class="col-sm-2 control-label">{{ entry_meta_data }}</label>
	  <div class="col-sm-10">
		{% for language in languages %}
		  <div class="input-group input-edit-list">
			<span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>
			{% if seo_type == 'meta_description' %}
			  <textarea maxlength="255" name="product_description[{{ language.language_id }}][meta_description]" rows="3" placeholder="{{ entry_meta_data }}" class="form-control"></textarea>
			  {% else %}
			  <input{% if seo_type != 'tag' %} maxlength="255"{% endif %} type="text" name="product_description[{{ language.language_id }}][{{ seo_type }}]" value="" placeholder="{{ entry_meta_data }}" class="form-control" />
		    {% endif %}
		  </div>
	    {% endfor %}
	  </div>
	</div>
	<div class="form-group" id="meta-data-template">
	  <label class="col-sm-2 control-label">{{ entry_template }}</label>
	  <div class="col-sm-10">
		<input type="{% if seo_type == 'meta_title' %}text{% else %}hidden{% endif %}" name="seo_template_product_meta_title" value="{{ seo_template_product_meta_title }}" placeholder="{{ entry_template }}" class="form-control" />
		<input type="{% if seo_type == 'meta_h1' %}text{% else %}hidden{% endif %}" name="seo_template_product_meta_h1" value="{{ seo_template_product_meta_h1 }}" placeholder="{{ entry_template }}" class="form-control" />
		<input type="{% if seo_type == 'meta_description' %}text{% else %}hidden{% endif %}" name="seo_template_product_meta_description" value="{{ seo_template_product_meta_description }}" placeholder="{{ entry_template }}" class="form-control" />
		<input type="{% if seo_type == 'meta_keyword' %}text{% else %}hidden{% endif %}" name="seo_template_product_meta_keyword" value="{{ seo_template_product_meta_keyword }}" placeholder="{{ entry_template }}" class="form-control" />
		<input type="{% if seo_type == 'tag' %}text{% else %}hidden{% endif %}" name="seo_template_product_tag" value="{{ seo_template_product_tag }}" placeholder="{{ entry_template }}" class="form-control" />
		<br />
		<div class="alert alert-success"><i class="fa fa-info-circle"></i> {{ text_meta_tags }}</div>
	  </div>
	</div>
  </form>
</div>
<div class="modal-footer">
  <div class="text-center"><a data-form="form-mass-product-meta-data" class="button-save btn btn-primary"><i class="fa fa-save"></i> {{ button_save }}</a></div>
</div>
<script type="text/javascript"><!--
$(".button-save").on('click', function(){		
	if (!confirm('{{ text_rewrite }}')) return;

	$.ajax({
		url: $('#' + $(this).data('form')).attr('action'),
		type: 'post',
		dataType: 'json',
		data: $('#product-list input[type=\'checkbox\']:checked, #' + $(this).data('form') + ' input[type=\'text\'], #' + $(this).data('form') + ' input[type=\'hidden\'], #' + $(this).data('form') + ' input[type=\'checkbox\']:checked, #' + $(this).data('form') + ' select, #' + $(this).data('form') + ' textarea'),
		success: function(json) {
			if (json['error']) {
				$('#form-mass-product-meta-data').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
					
				$('.alert-danger').delay(1500).fadeOut(500);	
			}
									
			if (json['success']) {
				$('#form-mass-product-meta-data').before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');	
				
				setTimeout(function(){
					$('#modal-product-edit').modal('hide');
				}, 1000)
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}		
	});
});  
//--></script>
<script type="text/javascript"><!--
$(document).ready(function() {
	$('#form-mass-product-meta-data select[name=\'generator_meta_data\']').on('change', function() {
		if ($('#form-mass-product-meta-data select[name=\'generator_meta_data\']').val() == '1') {
			$('#meta-data-custom').addClass('hidden');	
			$('#meta-data-template').removeClass('hidden');			
		} else {
			$('#meta-data-custom').removeClass('hidden');
			$('#meta-data-template').addClass('hidden');
		}
	});	
	
	$('#form-mass-product-meta-data select[name=\'generator_meta_data\']').trigger('change');
});
//--></script>