{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-color" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
        <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i>{{ error_warning }}<button type="button" class="close" data-dismiss="alert">&times;</button></div>{% endif %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i>{{ text_form }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-banner" class="form-horizontal">
          <div class="form-group required">
            <label class="col-sm-2 control-label" for="input-name">{{ entry_name }}</label>
            <div class="col-sm-10">
              <input type="text" name="name" value="{{ name }}" placeholder="{{ entry_name }}" id="input-name" class="form-control" />
              {% if error_name %}
				<div class="text-danger">{{ error_name }}</div>
			  {% endif %}
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
            <div class="col-sm-10">
              <select name="status" id="input-status" class="form-control">
                 {% if status %}
                  <option value="1" selected="selected">{{ text_enabled }}</option>
                  <option value="0">{{ text_disabled }}</option>
                {% else %}
                  <option value="1">{{ text_enabled }}</option>
                  <option value="0" selected="selected">{{ text_disabled }}</option>
                {% endif %}
              </select>
            </div>
          </div>
          <br />
          <ul class="nav nav-tabs" id="language">
            {% for language in languages %}
			 <li><a href="#language{{ language.language_id }}" data-toggle="tab"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</a></li>
            {% endfor %}
          </ul>
          <div class="tab-content">
            {% set image_row = 0 %}
            {% for language in languages %}
            <div class="tab-pane" id="language{{ language.language_id }}">
              <table id="images{{ language.language_id }}" class="table table-striped table-bordered table-hover">
                <thead>
                  <tr>
                    <td class="text-left">{{ entry_title }}</td>
                    <td class="text-left">{{ entry_link }}</td>
                    <td class="text-center">{{ entry_image }}</td>
                    <td class="text-right">{{ entry_sort_order }}</td>
                    <td></td>
                  </tr>
                </thead>
                <tbody>
				  {% if banner_images[language.language_id] %}
                  {% for banner_image in banner_images[language.language_id] %}
                  <tr id="image-row{{ image_row }}">
                    <td class="text-left">
					<input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][pretitle]" value="{{ banner_image.pretitle }}" placeholder="{{ entry_pretitle }}" class="form-control" />
					<input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][title]" value="{{ banner_image.title }}" placeholder="{{ entry_title }}" class="form-control" />
				    {% if error_banner_image[language.language_id][image_row] %}
                    <div class="text-danger">{{ error_banner_image[language.language_id][image_row] }}</div>
                    {% endif %}
					<input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][destitle]" value="{{ banner_image.destitle }}" placeholder="{{ entry_destitle }}" class="form-control" />  					  
					  <div class="bgpicker{{ image_row }}">
                        <input name="banner_image[{{ language.language_id }}][{{ image_row }}][color]" type="text" value="{{ banner_image.color }}" class="form-control bgpicker">
                        <span class="delcolor" onclick="delcolor('{{ image_row }}');">x</span>
                      </div>  
					  </td>
                    <td class="text-left" style="width: 30%;"><input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][link]" value="{{ banner_image.link }}" placeholder="{{ entry_link }}" class="form-control" /></td>
                    <td class="text-center"><a href="" id="thumb-image{{ image_row }}" data-toggle="image" class="img-thumbnail"><img src="{{ banner_image.thumb }}" alt="" title="" data-placeholder="{{ placeholder }}" /></a>
                    <input type="hidden" name="banner_image[{{ language.language_id }}][{{ image_row }}][image]" value="{{ banner_image.image }}" id="input-image{{ image_row }}" />

				<div class="form-group">
                  <label class="col-sm-2 control-label">Размеры</label>
                  <div class="col-sm-10">
					<input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][width]" value="{{ banner_image.width }}" placeholder="ширина" class="form-control" />
					<input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][height]" value="{{ banner_image.height }}" placeholder="высота" class="form-control" />
					<input type="hidden" name="banner_image[{{ language.language_id }}][{{ image_row }}][fullbg]" value="0"/>
                  </div>
                </div>
					  </td>
                     <td class="text-right" style="width: 10%;"><input type="text" name="banner_image[{{ language.language_id }}][{{ image_row }}][sort_order]" value="{{ banner_image.sort_order }}" placeholder="{{ entry_sort_order }}" class="form-control" /></td>
                    <td class="text-left"><button type="button" onclick="$('#image-row{{ image_row }}, .tooltip').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
                  </tr>
                  {% set image_row = image_row + 1 %}
                  {% endfor %}
                  {% endif %}
                </tbody>
                <tfoot>
                  <tr>
                    <td colspan="4"></td>
                    <td class="text-left"><button type="button" onclick="addImage('{{ language.language_id }}');" data-toggle="tooltip" title="{{ button_banner_add }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
                  </tr>
                </tfoot>
              </table>
            </div>
            {% endfor %}
          </div>
        </form>
      </div>
    </div>
  </div>
    <script type="text/javascript"><!--
var image_row = {{ image_row }};

function addImage(language_id) {
	html  = '<tr id="image-row' + image_row + '">';
    html += '  <td class="text-left"><input type="text" name="banner_image[' + language_id + '][' + image_row + '][pretitle]" value="" placeholder="{{ entry_pretitle }}" class="form-control" />';
    html += '<input type="text" name="banner_image[' + language_id + '][' + image_row + '][title]" value="" placeholder="{{ entry_title }}" class="form-control" />';
    html += '<input type="text" name="banner_image[' + language_id + '][' + image_row + '][destitle]" value="" placeholder="{{ entry_destitle }}" class="form-control" /><div class="bgpicker' + image_row + '"><input name="banner_image[' + language_id + '][' + image_row + '][color]" type="text" value="" class="form-control bgpicker"><span class="delcolor" onclick="delcolor(' + image_row + ');">x</span></div></td>';	
	html += '  <td class="text-left" style="width: 30%;"><input type="text" name="banner_image[' + language_id + '][' + image_row + '][link]" value="" placeholder="{{ entry_link }}" class="form-control" /></td>';	
	html += '  <td class="text-center"><a href="" id="thumb-image' + image_row + '" data-toggle="image" class="img-thumbnail"><img src="{{ placeholder }}" alt="" title="" data-placeholder="{{ placeholder }}" /></a><input type="hidden" name="banner_image[' + language_id + '][' + image_row + '][image]" value="" id="input-image' + image_row + '" />';
	html += '<div class="form-group">';
    html += '              <label class="col-sm-2 control-label">Размеры</label>';
    html += '              <div class="col-sm-10">';
	html += '				<input type="text" name="banner_image[' + language_id + '][' + image_row + '][width]" value="" placeholder="ширина" class="form-control" />';
	html += '				<input type="text" name="banner_image[' + language_id + '][' + image_row + '][height]" value="" placeholder="высота" class="form-control" />';
	html += '				<input type="hidden" name="banner_image[' + language_id + '][' + image_row + '][fullbg]" value="0"/>';
    html += '              </div>';
    html += '           </div>';
	html += '</td>';
	html += '  <td class="text-right" style="width: 10%;"><input type="text" name="banner_image[' + language_id + '][' + image_row + '][sort_order]" value="" placeholder="{{ entry_sort_order }}" class="form-control" /></td>';
	html += '  <td class="text-left"><button type="button" onclick="$(\'#image-row' + image_row  + ', .tooltip\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
	html += '</tr>';
	
	$('#images' + language_id + ' tbody').append(html);
	bgpicker(image_row);
	image_row++;
}
//--></script> 
  <script type="text/javascript"><!--
$('#language a:first').tab('show');
//--></script> 
    <script>
function bgpicker() {	
$(function(){	
  var colpick = $('.bgpicker').each( function() {
    $(this).minicolors({
      //control: $(this).attr('data-control') || 'hue',
      inline: $(this).attr('data-inline') === 'true',
      letterCase: 'lowercase',
      opacity: false,
      change: function(hex, opacity) {
        if(!hex) return;
        if(opacity) hex += ', ' + opacity;
        try {
          console.log(hex);
        } catch(e) {}
        $(this).select();
      },
      theme: 'bootstrap'
    });
  });
});	
};	
	
	
$('.bgpicker').each(function(index) {
	bgpicker(index);
});	
	

function delcolor(sec) {
$('.bgpicker'+sec+' input').val("");
$('.bgpicker'+sec+' .minicolors-swatch-color').css('background-color', '');


}
</script>
</div>
{{ footer }}