	<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown"><?php if ($text_cleaner_size) { ?><span id="size-all" class="label label-danger pull-left"><?php echo $text_cleaner_size['all']; ?></span><?php } ?><i class="fa fa-eraser fa-lg"></i></a>

	  <ul class="dropdown-menu dropdown-menu-right clear-dropdown">
	  <?php foreach ($menu as $key=>$actions) { ?>
		<?php if ($actions['child']) { ?>
		<li class="dropdown-header"><?php echo $actions['text']; ?></li>
		<?php foreach ($actions['child'] as $key_action =>$action) { ?>
       <li><a>
	   <span><?php echo $action['text']; ?> 
		<?php if ($action['size']) { ?>
		<span id="size-<?php echo $key_action; ?>" class="text-danger"><?php echo $action['size']; ?></span>
		<?php } ?>
			</span>
			<button onclick="goClear('<?php echo $key; ?>', '<?php echo $key_action; ?>');" type="button" data-loading-text="<i class='fa fa-spinner'></i>" class="btn btn-danger btn-xs pull-right" id="button-<?php echo $key; ?>-<?php echo $key_action; ?>"><i class="fa fa-trash-o"></i><?php echo $text_clear; ?></button>
			</a></li>		
		<?php } ?>
	    <?php } ?>
	  <?php } ?>
	  </ul>
	</li>
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.clear-dropdown li').on('click', function(e) {
		e.stopPropagation();
	});
	<?php if ($storage_cleaner_hidden_opencart) { ?>
	$('a[href*="opencart.com"]').closest('.dropdown').css('display','none');
	<?php } ?>
});
function goClear(type, key) {
	$.ajax({
		url: '<?php echo $clear_url; ?>',
		type: 'post',
		data: 'key=' + key + '&type=' + type,
		dataType: 'json',
		beforeSend: function() {
			$('#button-' + type + '-' + key).button('loading');
			$('.clear-dropdown').prev('a').children('span').html('<i class=\'fa fa-spinner\'></i>');
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		},
		success: function(json) {
			$('.clear-dropdown > .alert-success, .clear-dropdown > .alert-danger').remove();

			if (json['success']) {
				$('#button-' + type + '-' + key).closest('li').addClass('bg-success');
				$('.clear-dropdown').append('<div class="alert alert-success" style="margin: 15px 20px 15px 20px; padding: 5px; font-size: 11px;"><i class="fa fa-check-circle"></i> ' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
				if (json['size']) {
					for (var entity in json['size']){
						$('#size-' + entity).html(json['size'][entity]);
						
					}
				}
			}

			if (json['error']) {
				$('#button-' + type + '-' + key).closest('li').addClass('bg-danger');
				$('.clear-dropdown').append('<div class="alert alert-danger" style="margin: 15px 20px 15px 20px; padding: 5px; font-size: 11px;"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
			}
		},
		complete: function() {
			$('#button-' + type + '-' + key).button('reset');
		}
	});
}
//--></script>
<style>
.dropdown-header {
    display: block;
    padding: 3px 20px;
    font-size: 11px;
    line-height: 1.42857;
    color: #777;
    white-space: nowrap;
}
.dropdown-menu-right {
    left: auto;
    right: 0;
}
.clear-dropdown li {overflow:hidden;margin-bottom:5px;padding:0 5px;}
</style>

