$(".input-buttons").each(function () {
// bplus = +
// bminus = -
var input = ($(this).is("[data-target]") ? $($(this).attr("data-target")) : ($(this).is(".bminus") ? $(this).next() : $(this).prev()));
$(this).click(function () {
var max = $(input).is("[data-max]") ? parseInt($(input).attr("data-max")) : 0;
var step = $(input).is("[data-step]") ? parseInt($(input).attr("data-step")) : 1;
var val = parseInt($(input).val()) + (step * ($(this).is(".bminus") ? -1 : 1));
if (max != 0 && max < val) {
val = max;
}
$(input).val(val).change();
});
$(input).change(function () {
var max = $(this).is("[data-max]") ? parseInt($(this).attr("data-max")) : 0;
var step = $(this).is("[data-step]") ? parseInt($(this).attr("data-step")) : 1;
var val = parseInt($(input).val());
var valChanged = false;
if (step > 1) {
if (val % step > 0) {
val = Math.ceil(val / step) * step;
valChanged = true;
}
}
if (val > max) {
val = max;
valChanged = true;
}
if (valChanged) {
$(input).val(val).change();
return false;
}
});
});
<?foreach($arItem["DISPLAY_PROPERTIES"] as $pid=>$arProperty):?>
<small>
<?=$arProperty["NAME"]?>:
<?if($arProperty["CODE"] == "SLIDE_IMAGE") {?>
<?foreach($arProperty["VALUE"] as $image) {?>
<img src="<?=CFile::GetPath($image)?>" />
<?}?>
<?} else {?>
<?if(is_array($arProperty["DISPLAY_VALUE"])):?>
<?=implode(" / ", $arProperty["DISPLAY_VALUE"]);?>
<?else:?>
<?=$arProperty["DISPLAY_VALUE"];?>
<?endif?>
<?}?>
</small><br />
<?endforeach;?>
<li{if ($group.default == $id_attribute)} class="active"{/if}>
<input onchange="$(this).parent().parent().find('li').removeClass('active').find('input:checked').parent().addClass('active')" type="radio" class="attribute_radio" name="{$groupName|escape:'html':'UTF-8'}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} />
<span>{$group_attribute|escape:'html':'UTF-8'}</span>
</li>
было #attributes .attribute_list ul li:hover
стало #attributes .attribute_list ul li:hover, #attributes .attribute_list ul li.active
// Начало и конец
var dates = [new Date(2016, 10, 29), new Date(2016, 11, 1)];
var pricesPerMonth = {
"10": 2000,
"11": 1500
};
// Расчет цены
var price = 0;
for (var i = dates[0].getTime(); i <= dates[1].getTime(); i += 86400 * 1000) {
var d = new Date(i);
var m = d.getMonth();
if (pricesPerMonth[m]) {
price += pricesPerMonth[m];
}
}
console.log(pricesPerMonth);
console.log(price);
var obj = [{
title: 'Дверь',
color: 'Белая'
}, {
title: 'Дверь',
color: 'Белая'
}, {
title: 'Дверь',
color: 'Черная'
}, {
title: 'Дверь',
color: 'Черная'
}, {
title: 'Дверь',
color: 'Серая'
}
];
var r_obj = [];
for (var key in obj) {
var find = false;
for (var key2 in r_obj) {
if (r_obj[key2].title == obj[key].title &&
r_obj[key2].color == obj[key].color) {
r_obj[key2].count++;
find = true;
}
}
if (!find) {
r_obj.push({
title: obj[key].title,
color: obj[key].color,
count: 1
});
}
}
console.log(r_obj);