Your IP : 3.149.253.216
<?
CModule::IncludeModule('iblock');
$menuAr = array();
$arSelect = Array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID","PROPERTY_*");
$arFilter = Array("IBLOCK_ID"=>IntVal(IB_MENU), "ACTIVE"=>"Y");
$res = CIBlockElement::GetList(Array("SORT"=>"asc"), $arFilter, false, Array(), $arSelect);
while($ob = $res->GetNextElement()){
$arFields = $ob->GetFields();
$arProps = $ob->GetProperties();
// $rsSections = CIBlockSection::GetList(
// array("SORT"=>"asc"),
// array(
// "IBLOCK_ID" => IB_MENU,
// "ID" => $arFields["IBLOCK_SECTION_ID"],
// ),
// false,
// array("ID","PICTURE", "NAME", "UF_*")
// );
//
// $arSection = $rsSections->GetNext();
// pre($arProps);
$menuAr [$arFields["IBLOCK_SECTION_ID"]]["ELEMENTS"][] = array(
"ID"=> $arFields["ID"],
"IMG"=> CFile::GetPath($arProps["IMG"]["VALUE"]),
"TEXTMAIN"=> $arProps["TEXTMAIN"]["VALUE"],
"TEXT"=> $arProps["TEXT"]["VALUE"],
"ISGREEN"=> $arProps["ISGREEN"]["VALUE_XML_ID"],
"TYPE"=> $arProps["TYPE"]["VALUE_XML_ID"],
"COS"=> $arProps["COS"]["VALUE"],
"LINK"=> $arProps["LINK"]["VALUE"],
"LINK_MAIN"=> $arProps["LINK_MAIN"]["VALUE"],
"LINK_TEXT"=> $arProps["LINK_TEXT"]["VALUE"],
);
$menuAr [$arFields["IBLOCK_SECTION_ID"]]["SECTION"] = array(
"NAME" => $arSection["NAME"],
"LINK" => $arSection["UF_LINK"],
"UF_ICON" => $arSection["UF_ICON"],
"IMG" => CFile::GetPath($arSection["UF_IMG"]),
"IMG_LINK" => $arSection["UF_IMG_LINK"],
"COLOR" => $arSection["UF_COLOR"]);
}
$rsSections = CIBlockSection::GetList(
array("SORT"=>"asc"),
array(
"IBLOCK_ID" => IB_MENU,
),
false,
array("ID","PICTURE", "NAME", "UF_*")
);
while($arSection = $rsSections->GetNext()) {
$menuAr [$arSection["ID"]]["SECTION"] = array(
"NAME" => $arSection["NAME"],
"LINK" => $arSection["UF_LINK"],
"UF_ICON" => $arSection["UF_ICON"],
"IMG" => CFile::GetPath($arSection["UF_IMG"]),
"IMG_LINK" => $arSection["UF_IMG_LINK"],
"COLOR" => $arSection["UF_COLOR"]);
}
$elI = 0;//red blue pin browngrey yellow brown dark-blue
?>
<div id="header-nav" class="skip-content">
<nav id="nav">
<ol class="nav-primary count-<?=count($menuAr);?>">
<?foreach ($menuAr as $el): $elI++?>
<li class="level0 nav-<?=$elI?> <?=$elI==1?"first":" "?> <?=count($el["ELEMENTS"])>=1?"parent":""?>"><a href="<?=$el["SECTION"]["LINK"]?>"
class="level0 <?=count($el["ELEMENTS"])>=1?"has-children":""?> color-<?=$el["SECTION"]["COLOR"]?> <?=$el["SECTION"]["UF_ICON"]?>"><?=$el["SECTION"]["NAME"]?></a>
</li>
<?endforeach;?>
</ol>
</nav>
</div>
<script>
var cfg = {
data: {
<?
$elI=0;
foreach ($menuAr as $el) {
$elI++;
echo '
'.$elI.': {
id: "'.$elI.'",
img: {
url: {
ru: "'.$el["SECTION"]["IMG_LINK"].'",
en: "'.$el["SECTION"]["IMG_LINK"].'"
},
src: {
ru: "'.$el["SECTION"]["IMG"].'",
en: "'.$el["SECTION"]["IMG"].'"
}
},
cssClass: "myClass submenu0",
cssStyle: "",';
if($el["ELEMENTS"]){
echo 'submenu: {';
//green allh halfh item-with-links DEFAULT MID LG
$subI = 0;
foreach ($el["ELEMENTS"] as $sub) {
$subI++;
$style = "";
$style.= $sub["TYPE"]=="LG"?" allh ":"";
$style.= $sub["TYPE"]=="MID"?" halfh ":"";
$style.= $sub["ISGREEN"]=="YES"?" green ":"";
$style.= $sub["COS"]=="YES"?"item-with-links":"";
echo $subI.': {
text: {
ru: "'.$sub["TEXT"].'",
en: ""
},
title: {
ru: "'.$sub["TEXTMAIN"].'",
en: ""
},
url: {
ru: "'.$sub["LINK"].'",
en: ""
},
cssClass: "'.$style.'",
cssStyle: "",
img: "'.$sub["IMG"].'",
';
if($sub["COS"]=="YES")
echo 'titleImg: "",
textImg: "",
titleUrl: {
ru: "'.$sub["LINK_MAIN"].'",
en: ""
},
textUrl: {
ru: "'.$sub["LINK_TEXT"].'",
en: ""
},
next: "true"';
echo '},
';
}
echo '}';
}
echo '},';
}
?>
}
};
var targetSegments = {
mega_menu: {
},
home_page: {
push_banner_2: {}
},
catalog_page: {
}
};
function replaceClassNav() {
// jQuery(".level0.nav-4:eq(0)").removeClass("nav-4").addClass("nav-5"), jQuery(".level0.nav-4").insertBefore(".level0.nav-5"), jQuery(".level0.nav-5").insertBefore(".level0.nav-7")
}
function megamenu() {
lang = jQuery("#languageSelect .current span").html().toLowerCase() || "ru", cfg && jQuery.each(cfg.data, function (e, l) {
var t = targetSegments.mega_menu[l.id];
if (void 0 !== t && !jQuery.isEmptyObject(t)) {
var a = Mage.Cookies.get("CUSTOMER_SEGMENT_IDS");
if (null != a) {
var s = a.split(","),
r = localStorage.getItem("customer_viewed_segments_" + l.id) || "[]",
n = JSON.parse(r);
s.every(function (e, a) {
return e in t && jQuery.inArray(e, n) < 0 ? (n.push(e), localStorage.setItem("customer_viewed_segments_" + l.id, JSON.stringify(n)), "" != t[e].href && (l.img.url[lang] = t[e].href), "" != t[e].src && (l.img.src[lang] = t[e].src), pushToDataLayer(t[e], e), !1) : (localStorage.setItem("customer_viewed_segments_" + l.id, "[]"), !0)
})
} else void 0 !== t.new && ("" != t.new.href && (l.img.url[lang] = t.new.href), "" != t.new.src && (l.img.src[lang] = t.new.src), pushToDataLayer(t.new, "new"))
}
html = "<div", l.cssClass ? html += ' class="megamenu ' + l.cssClass + '"' : html += ' class="megamenu"', html += ' style="left:-' + 100 * (e - 1) + "%;", l.cssStyle && (html += "" + l.cssStyle), html += '"', html += ' id="' + l.id + '">', html += "<ul>", jQuery.each(l.submenu, function (e, l) {
"true" == l.next ? (html += '<li class="' + l.cssClass + '">', html += '<a href="' + l.url[lang] + '" style="' + l.cssStyle + '"><img class="toCheck" src="' + cfg.media_prefix + l.img + '" /></a><div class="info"><a href="' + l.titleUrl[lang] + '"><div class="item-title" style="background:url(' + l.titleImg + ') left center no-repeat">' + l.title[lang] + '</div></a><a href="' + l.textUrl[lang] + '"><p style="background:url(' + l.textImg + ') left center no-repeat">' + l.text[lang] + "</p></a></div></li>") : (html += '<li class="' + l.cssClass + '">', html += '<a href="' + l.url[lang] + '" style="' + l.cssStyle + '"><img class="toCheck" src="' + cfg.media_prefix + l.img + '" /><div class="info"><div class="item-title">' + l.title[lang] + "</div><p>" + l.text[lang] + "</p></div></a></li>")
}), html += "</ul>", html += '<a href="' + l.img.url[lang] + '"><img class="mega-image toCheck" src="' + cfg.media_prefix + l.img.src[lang] + '" /></a>', l.footer && (html += '<div class="menu-bottom"><span>' + l.footer.text[lang] + "</span>", jQuery.each(l.footer.links, function (e, l) {
html += '<a href="' + l.url[lang] + '">' + l.title[lang] + "</a>"
}), html += "</div>"), html += "</div>", jQuery("#nav .nav-" + e + " ul.level0").remove(), jQuery(html).insertAfter(jQuery("#nav .nav-" + e + " a.level0"))
})
}
jQuery(document).ready(function () {
replaceClassNav(), megamenu()
});
</script>
<script>
$(function() {
$('.toCheck').each(function() {
var $img = $(this);
var imgsrc = $img.attr('src');
$img.attr('src',imgsrc.replace("undefined",""));
});
$('.submenu0').each(function () {
var parrent = $(this).parent();
if(!parrent.hasClass("parent")){
$(this).remove();
}
})
});
</script>