Рекомендуемые

This commit is contained in:
Konstantin
2026-05-30 14:59:49 +03:00
parent 0e8a0f3b0c
commit 6a847ab7b5
4 changed files with 80 additions and 0 deletions
@@ -47,6 +47,17 @@
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-random">{{ entry_random }}</label>
<div class="col-sm-10">
<div class="input-group">
<input type="number" name="random_count" value="5" placeholder="{{ entry_random }}" id="input-random" class="form-control" min="1" />
<span class="input-group-btn">
<button type="button" id="button-random" data-toggle="tooltip" title="{{ button_random }}" class="btn btn-primary"><i class="fa fa-random"></i> {{ button_random }}</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-limit">{{ entry_limit }}</label>
<div class="col-sm-10">
@@ -123,5 +134,35 @@ $('input[name=\'product_name\']').autocomplete({
$('#featured-product').delegate('.fa-minus-circle', 'click', function() {
$(this).parent().remove();
});
$('#button-random').on('click', function() {
var limit = parseInt($('#input-random').val()) || 5;
var exclude = [];
$('#featured-product input[name=\'product[]\']').each(function() {
exclude.push($(this).val());
});
$.ajax({
url: 'index.php?route=extension/module/featured/random&user_token={{ user_token }}&limit=' + limit,
type: 'GET',
dataType: 'json',
traditional: true,
data: { exclude: exclude },
beforeSend: function() {
$('#button-random').button('loading');
},
complete: function() {
$('#button-random').button('reset');
},
success: function(json) {
$.each(json, function(i, item) {
$('#featured-product' + item['product_id']).remove();
$('#featured-product').append('<div id="featured-product' + item['product_id'] + '"><i class="fa fa-minus-circle"></i> ' + item['name'] + '<input type="hidden" name="product[]" value="' + item['product_id'] + '" /></div>');
});
$('#featured-product div input').before(' <i class="fa fa-hand-grab-o handle"></i> ');
}
});
});
//--></script></div>
{{ footer }}