зарефакторил скрипт в шаблоне левого меню

parent 9553b57b
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<?if (!empty($arResult)):?>
<ul id="side_menu_multilevel">
<ul id="side_menu_multilevel">
<?
$previousLevel = 0;
foreach($arResult as $arItem):?>
<?
$previousLevel = 0;
foreach($arResult as $arItem):?>
<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?>
<?=str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"]));?>
......@@ -46,39 +46,30 @@ foreach($arResult as $arItem):?>
<?$previousLevel = $arItem["DEPTH_LEVEL"];?>
<?endforeach?>
<?endforeach?>
<?if ($previousLevel > 1)://close last item tags?>
<?if ($previousLevel > 1)://close last item tags?>
<?=str_repeat("</ul></li>", ($previousLevel-1) );?>
<?endif?>
<?endif?>
</ul>
</ul>
<?endif?>
<script>
$(document).ready(function() {
if ($("#side_menu_multilevel li").is(".item-selected")) {$("#side_menu_multilevel li.root-item-selected").addClass("hide_selection")}
//$("#side_menu_multilevel li.item-selected").parent('#side_menu_multilevel').find("li.root-item-selected").addClass("hide_selection");
//console.log("!!!!!!!!!!111234!!!!!!!!!!!!!"+$("#side_menu_multilevel li.item-selected").parent('#side_menu_multilevel'));
$('#side_menu_multilevel li.root-item a span.roll-out').click(
function(){
if($(this).parent('a').next('ul').is('.root-item'))
{
$(this).parent('a').parent().toggleClass("opened");
$(this).parent('a').next("ul.root-item").toggle(150);
return false;
}
}
);
$('#side_menu_multilevel li.root-item-selected a span.roll-out').click(
function(){
if($(this).parent('a').next('ul').is('.root-item'))
$(document).ready(function() {
const $menu = $("#side_menu_multilevel");
if ($("li", $menu).is(".item-selected")) {$("li.root-item-selected", $menu).addClass("hide_selection")}
const clickHandler = function(){
const $a = $(this).parent('a');
if($a.next('ul').is('.root-item'))
{
$(this).parent('a').parent().toggleClass("opened");
$(this).parent('a').next("ul.root-item").toggle(150);
$a.parent().toggleClass("opened");
$a.next("ul.root-item").toggle(150);
return false;
}
}
);
});
};
$('li.root-item a span.roll-out', $menu).click( clickHandler );
$('li.root-item-selected a span.roll-out', $menu).click( clickHandler );
});
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment